Search code examples
swaggerswagger-uiswagger-editor

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


I want to access https://editor.swagger.io/ but need the YAML file to be preloaded based on a URL parameter.

So if I want to view https://github.com/OAI/OpenAPI-Specification/blob/master/examples/v3.0/petstore.yaml, I should be able to provide this as an input to swagger editor accessible over the internet.

Is this possible?


Solution

  • Yes, Swagger Editor supports the url parameter:

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

    Note that to load OpenAPI files from GitHub/GitLab/Bitbucket/etc., you need to specify the "raw" file link.

    Also, for this to work, the server where the YAML/JSON file is hosted must use HTTPS and support CORS (i.e. allow cross-domain calls from editor.swagger.io).