Is there a way to generate swagger.json from json-server file

我的未来我决定 提交于 2021-01-28 05:53:40

问题


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:

  1. Go to https://inspector.swagger.io. You should create an account to continue with the next steps.
  2. Make calls to your fake API.
  3. Select calls and choose CREATE API DEFINITION.
  4. Follow the prompts to name the API, etc.
  5. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!