Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the spec url parameter of the swagger online editor #2196

Open
pask84 opened this issue Jul 30, 2020 · 2 comments
Open

Use the spec url parameter of the swagger online editor #2196

pask84 opened this issue Jul 30, 2020 · 2 comments

Comments

@pask84
Copy link

pask84 commented Jul 30, 2020

Q&A (please complete the following information)

  • OS: Windows 10
  • Browser: chrome
  • Version: 84.0.4147.105
  • Method of installation: online use
  • Swagger-Editor version: https://editor.swagger.io
  • Swagger/OpenAPI version: OpenAPI 3.0

Content & configuration

Example Swagger/OpenAPI definition:

{
  "openapi": "3.0.0",
  "info": {
    "version": "1.0.0",
    "title": "Swagger"
  },
  "paths": {
    "/mypath": {
      "get": {
        "operationId": "listPets",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A paged array of pets"
          }
        }
      }
    }
  }
}

Swagger-Editor configuration options:

https://editor.swagger.io/?spec={...}

Describe the bug you're encountering

I'm trying to pass the spec parameter in the url to the swagger editor to be able to open the API spec passed in the URL

https://editor.swagger.io/?spec={...}

as documented here:

https://swagger.io/docs/open-source-tools/swagger-ui/usage/configuration/

spec SPEC Object={}. A JavaScript object describing the OpenAPI definition. When used, the url parameter will not be parsed. This is useful for testing manually-generated definitions without hosting them.

but it seems that doesn't work, here the example

below the spec put in the link:

{
  "openapi": "3.0.0",
  "info": {
    "version": "1.0.0",
    "title": "Swagger"
  },
  "paths": {
    "/mypath": {
      "get": {
        "operationId": "listPets",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A paged array of pets"
          }
        }
      }
    }
  }
}

To reproduce...

Steps to reproduce the behavior:

  1. Click on the link

Expected behavior

the swagger online editor should open the specification passed in the spec query parameter

Screenshots

Additional context or thoughts

@maximehamm
Copy link

Hello
An idea when this will be fixed ?
Thanx !

@danielschilling-ml
Copy link

danielschilling-ml commented Dec 6, 2023

The documentation you referenced is for Swagger UI, but then you passed the spec parameter to Swagger Editor instead.

Swagger Editor does have a query string parameter for loading a spec from a url, documented here: https://github.com/swagger-api/swagger-editor/blob/master/docs/import.md. If you are able to specify a URL instead of a JSON object, this might work for you:

https://editor.swagger.io/?url=YOUR_URL_HERE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants