Comments (5)
I wonder if a hybrid approach might make sense - leveraging x-codesamples/x-code-samples (why do I see both used 🤣 in different example specs) and generating some kind of config like:
😄 Yeah, the x-*
is just a convention for extensions so it's not uncommon to find variations. One thing to factor in is that the generated code samples change depending on the inputs/form values, whereas x-code-samples
would ostensibly be static.
could you point at where the various "allowed" languages are controlled
They're externally limited in the PaloAltoNetworks/postman-code-generators panw-develop
branch under the codegens
directory. It's possible they could be added back, without (much) impact to bundle size. Also, I was proposing that the languages should be a Plugin Configuration option, so it can be configured per API.
it looks like the fork of the code generators still includes the languages like PowerShell etc.
It's published from the panw-develop
branch. See the link referenced above. In theory, we would just need to add the missing languages back to the codegens
directory coupled with adding them to the languageTabs
object mentioned above.
from docusaurus-openapi-docs.
Will revisit in the future with goal of allowing users to select which languages they want to support.
from docusaurus-openapi-docs.
Hi @homotechsual, you're correct: the code examples are being generated using a forked instance of postman-code-generators. For now, we intentionally limit support to Python, Javascript, Golang, and cURL, to help reduce the overall webpack bundle size. Although we could potentially support more languages we want to be careful about how we introduce them. Ideally, I think it should be a user defined configuration but we would want to pay close attention to how it might impact the overall bundle size. A PR would be most welcome if you're up for it, otherwise, out team will revisit this in the near future.
from docusaurus-openapi-docs.
Yeah it's already user-configurable to a degree - as the plugin can read from themeConfig.languageTabs
but as you say the actual generator is missing from PowerShell.
I wonder if a hybrid approach might make sense - leveraging x-codesamples
/x-code-samples
(why do I see both used 🤣 in different example specs) and generating some kind of config like:
languageTabs: [
{
tabName: "cURL",
tabType: "generated",
highlight: "bash",
language: "curl",
codeLanguage: "bash",
variant: "curl",
options: {
longFormat: false,
followRedirect: true,
trimRequestBody: true,
},
},
{
tabName: "Python",
tabType: "generated",
highlight: "python",
language: "python",
codeLanguage: "python",
variant: "requests",
options: {
followRedirect: true,
trimRequestBody: true,
},
},
{
tabName: "Go",
tabType: "generated",
highlight: "go",
language: "go",
codeLanguage: "go",
variant: "native",
options: {
followRedirect: true,
trimRequestBody: true,
},
},
{
tabName: "Node",
tabType: "generated",
highlight: "javascript",
language: "nodejs",
codeLanguage: "javascript",
variant: "axios",
options: {
ES6_enabled: true,
followRedirect: true,
trimRequestBody: true,
},
},
{
tabName: "PowerShell",
tabType: "codesample",
highlight: "powershell",
language: "powershell",
codeLanguage: "powershell",
variant: "restmethod",
options: {
followRedirect: true,
trimRequestBody: true,
},
},
]
In any event I'll dig into what it would look like to add PowerShell since the user-configurable part already works.
from docusaurus-openapi-docs.
@sserrata could you point at where the various "allowed" languages are controlled, from what I see here:
themeConfig.languageTabs
and I do but the new tab loads the first code example (Linux) and then eventually if I switch tabs it just goes blank and crashes the tab section.
What I can't see is where the allowable languages or loaded language plugins (if that's the right term) are defined - it looks like the fork of the code generators still includes the languages like PowerShell etc.
from docusaurus-openapi-docs.
Related Issues (20)
- Support for Docusauros 3.2.1 HOT 1
- Uncaught Runtime Errors HOT 7
- Missing selector dropdown menu HOT 2
- Download URL on versions is referring to the main version HOT 2
- Add classes to sidebar items when certain API specification criteria are met. HOT 1
- CodeSnippets can't display if `languageTabs` isn't present in docusaurus theme config HOT 2
- [Bug] Setup of Docusaurus from scratch on Windows HOT 1
- Change endpoints ServerUrl location to be table
- Missing information in 'Authorization: <API_KEY_VALUE>'
- Missing information in the API key value in the Authorization header in all the sample codes HOT 2
- Response example summary is broken in v3 HOT 4
- Fenced code blocks started with `~~~` are incorrectly cleaned in v3 HOT 2
- Huge swagger.json file is not being processed HOT 4
- Example & externalDocs attributes not displaying
- Custom item naming and path generation HOT 1
- Show description of 'oneOf' schema items HOT 4
- oneOf creates strange-looking schema
- Ignore unknown vendor extensions HOT 5
- oneOf at root of schema generates empty <SchemaTabs> resulting in <Tabs> error HOT 3
- Autogenerated docs sidebar shows the api spec item when it shouldn't HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from docusaurus-openapi-docs.