oas-path-generator
If you are as lazy as me, you would have often wondered if there was an easier way to draft your OpenApi specs using just the schemas or at least get a starting boiler plate code for the paths definitions based on some template.
If so then today is your lucky day. Here is a tool that lets you do just that. Use this tool to generate Open API v3.0 paths using the schema objects with vendor extensions defined in the usage section.
Getting Started
Pre-requisites
- Install Node JS
- download oas-repo and build or use npm
- download this source code or use npm
Usage
npm install oas-path-generator --save
In your schema models add the following:
x-path-gen:
operations:
- list
- create
//all actions you want your path to have
pluralName: models //optionally specify the name for the path.
//If not present the plural form of the model name is generated automatically
run the following script to generate
npm start [modelFileName]
you can also use the realtime editor by running
npm run editor
Then open http://localhost:8080/swagger-editor/ in Chrome and you will get a Swagger Editor that you can use to define your models
Once edited , refresh the editor browser and voila your paths have been created for you to further modify.
Notes
- Once path is created, changes in model does not reflect till the path is deleted from the editor.
- If you delete all the paths in the editor, then you will need to clear the browser cache for the changes to take effect.
- Tip! Instead of deleting all paths leave one and refresh and then delete the one that was left out and refresh again
OpenAPI Specification for the vendor extension created here
see spec_backup.yaml
or do
npm run editor
Tests
Run the tests by
npm test
Github Pages
Deploys docs to GitHub Pages. You don't need to run it manually if you have Travis CI configured.
npm run gh-pages