问题
For prototyping we are using json-server library that creates fake REST api based on our db.json file. Now we would like to use swagger.
So my question is, is there a way to generate swagger.json from our db.json file?
If not, do you guys know some tool to generate swagger.json file easily?
Thanks!
回答1:
If you can make API calls to your 'fake' API, you can use Swagger Inspector to create an API Definition (swagger.json)! Steps:
- Go to https://inspector.swagger.io. You should create an account to continue with the next steps.
- Make calls to your fake API.
- Select calls and choose CREATE API DEFINITION.
- Follow the prompts to name the API, etc.
- You'll eventually get to a text editor that has your swagger.json file (you can copy the text or download the file).
Voila!
Don't worry, you can delete your API file immediately from SwaggerHub if you don't want your API exposed publicly (public is the only option for a free account).
来源:https://stackoverflow.com/questions/48764682/is-there-a-way-to-generate-swagger-json-from-json-server-file