在线的swagger编辑器可以通过地址栏输入一个YAML url吗?

use*_*445 4 swagger swagger-ui swagger-editor

我想访问https://editor.swagger.io/但需要根据 URL 参数预加载 YAML 文件。

因此,如果我想查看 https://github.com/OAI/OpenAPI-Specification/blob/master/examples/v3.0/petstore.yaml,我应该能够将其作为输入提供给可通过互联网。

这可能吗?

Hel*_*len 6

是的,Swagger Editor 支持以下url参数:

https://editor.swagger.io/?url=https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore.yaml

请注意,要从 GitHub/GitLab/Bitbucket/etc. 加载 OpenAPI 文件,您需要指定“原始”文件链接。

此外,为了使其工作,托管 YAML/JSON 文件的服务器必须使用 HTTPS 并支持 CORS(即允许来自 的跨域调用editor.swagger.io)。

  • @BenMares我认为Swagger Editor使用与Swagger UI相同的配置参数https://github.com/swagger-api/swagger-ui/blob/master/docs/usage/configuration.md (2认同)