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

Can the swagger editor online take a YAML url as input through the address bar?

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

因此,如果我想查看 https://github.com/OAI/OpenAPI-Specification/blob/master/examples/v3.0/petstore.yaml,我应该能够将其作为输入提供给可通过 Internet 访问的 swagger 编辑器。

这可能吗?

是的,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 文件,您需要指定“原始”文件 link.

此外,要使其正常工作,托管 YAML/JSON 文件的服务器必须使用 HTTPS 和 support CORS(即允许来自 editor.swagger.io 的跨域调用)。