Comments (9)
@corvinusy there is a new option --environment
or -e
which allows you to load an options object from a file in yaml or json format at runtime without requiring a wrapper script. This should make it easier to override the language_tabs
or any other options.
I've just released v2.2.0 including this enhancement.
Please feel free to re-open this issue if you encounter the output corruption bug again.
from widdershins.
Hi @corvinusy yes there's a couple of existing ways of doing this.
If you have x-code-samples
specification extensions in your OpenAPI definition, you can use the --lang
switch to enable automatic detection of the necessary language tab entries.
If you are using the programmatic API, you can specify in your options
object that you want to override the default language-tabs.
E.g.
var converter = require('widdershins');
var options = {};
options.language_tabs = [{ 'http': 'HTTP' }, { 'javascript': 'JavaScript' }, { 'javascript--nodejs': 'Node.JS' }, { 'python': 'Python' }, { 'ruby': 'Ruby' }];
converter.convert(swaggerObj,options,function(err,str){
//
});
This would only output the language-tabs specified (omitting shell
and java
). I have updated the README file to make this clearer.
If you need to do this from the command-line, I can see a potential way to do it, by allowing a config-file to be read to set the default options. Would this be of help?
Can I also ask whether you are using the npm package, or direct from git?
from widdershins.
I use npm package and run it in terminal as CLI-command.
I have generated openapi.json from other source language tool and want to create static *.md for project documentation.
I always tried to modify source code by removing items from language_tabs directly, but this lead to corrupted output.
Now I see how to do it with JS-wrapper script.
Thank you for fast reaction.
The issue can be closed if you don't want to see it as a reminder to update README or to provide some wrapper.
from widdershins.
Great. I'll leave the issue open for a while, in case you hit any snags (like corrupted output) when trying to override the language_tabs
option. I've updated the README now, but the ability to read the options in from a config file might still be useful...
from widdershins.
If you need details about corrupted output: I removed all languages except shell, nodejs and python. And got not a properly closed sample tag (```) and end-braces. Seems nodejs sample generation has a dependency on pure javascript one.
Anyway, thank you for this good tool.
from widdershins.
Thanks for letting me know, I'll try it out a couple of ways and see if I can reproduce it.
from widdershins.
I've just realised the example above and in the README was wrong, you now need to pass a callback to the convert
function, which takes an err
and str
parameters:
var converter = require('widdershins');
var options = {};
options.language_tabs = [{ 'http': 'HTTP' }, { 'javascript': 'JavaScript' }, { 'javascript--nodejs': 'Node.JS' }, { 'python': 'Python' }, { 'ruby': 'Ruby' }];
converter.convert(swaggerObj,options,function(err,str){
// str contains the output markdown
});
from widdershins.
Hi. Is there a way I can get C# code through widdershins in my langugage tab?
from widdershins.
Hi, @areebaasad77 there's a number of ways to do it!
- Create a code_csharp.dot template and specify a
--user_templates
option - Include
x-code-samples
extensions in your API definition and use the--lang
option - Use the
--httpsnippet
and--language-tabs
options
All as per the help / README. If you did option 1 then you could contribute it back as a pull request.
Let me know if you need anything further.
from widdershins.
Related Issues (20)
- Support custom media type HOT 6
- Add option "--header-offset"
- Add support for OpenRPC
- Support for AsyncAPI version 2.2
- headingLevel is getting overriden to default value i.e 2.
- Vulnerability for package [email protected] in widdershins
- Upgrade to [email protected] to fix yargs-parser vulnerability
- CODE SAMPLES ERROR WIDDERSHINS + SLATE
- node can't find widdershins module after npm install is run HOT 2
- Any programmable API? HOT 1
- shins dependency is including vulnerable jquery version 3.2.1
- Missing body parameter code for API languages other than JavaScript HOT 2
- User defined data fields to be used in templates
- user_template is not well defined HOT 1
- Could not get ToC to generate
- Generate Markdown with no html headers
- Bump version of httpsnippet
- Error picking up user templates HOT 1
- Multiline markdown in response examples breaks table in Markdown
- Resolving external refs and showing as links
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 widdershins.