有没有办法从 json-server 文件生成 swagger.json [英] Is there a way to generate swagger.json from json-server file

查看:108
本文介绍了有没有办法从 json-server 文件生成 swagger.json的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于原型设计,我们使用 json-server 库,该库基于我们的 db.json 文件创建假 REST api.现在我们想使用 swagger.

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.

所以我的问题是,有没有办法从我们的 db.json 文件中生成 swagger.json?

So my question is, is there a way to generate swagger.json from our db.json file?

如果没有,你们知道一些轻松生成swagger.json文件的工具吗?

If not, do you guys know some tool to generate swagger.json file easily?

谢谢!

推荐答案

如果您可以对假"API 进行 API 调用,则可以使用 Swagger Inspector 创建 API 定义 (swagger.json)!步骤:

If you can make API calls to your 'fake' API, you can use Swagger Inspector to create an API Definition (swagger.json)! Steps:

  1. 转到 https://inspector.swagger.io.您应该创建一个帐户以继续执行后续步骤.
  2. 调用您的虚假 API.
  3. 选择调用并选择创建 API 定义.
  4. 按照提示命名 API 等.
  5. 您最终将进入一个包含 swagger.json 文件的文本编辑器(您可以复制文本或下载文件).
  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).

瞧!

别担心,如果您不想公开您的 API,您可以立即从 SwaggerHub 中删除您的 API 文件(公开是免费帐户的唯一选项).

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).

这篇关于有没有办法从 json-server 文件生成 swagger.json的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆