Skip to content

Wrong URL used when executing the request from swagger ui when a server url starts with a variable #10111

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

Open
brampouwelse-luminis opened this issue Aug 29, 2024 · 0 comments

Comments

@brampouwelse-luminis
Copy link

Q&A (please complete the following information)

  • OS: macOS
  • Browser: chrome
  • Version: 128
  • Method of installation: npm
  • Swagger-UI version: 5.17.14
  • Swagger/OpenAPI version: OpenAPI 3.0

Content & configuration

Example Swagger/OpenAPI definition:

---
openapi: "3.0.1"
info:
  title: "Random Yes/No"
  version: "1.0.0"
servers:
- url: "{server}/api"
  variables:
    server:
      default: "https://yesno.wtf"
paths:
  /:
    get:
      description: "Yes or no"
      responses:
        "200": 
          description: "OK"
          content:
            "application/json":
              schema:
                properties:
                  answer:
                    type: string
                  forced: 
                    type: boolean
                  image: 
                    type: string
                    format: uri

Describe the bug you're encountering

The wrong URL used when executing the request from swagger ui when a server url starts with a variable.

I feel this should work as the spec not having any validation issues and there is a similar example in the exaples section on this page https://swagger.io/docs/specification/api-host-and-base-path/ (see SaaS and On-Premise).

To reproduce...

Steps to reproduce the behavior:

  1. Go to https://editor.swagger.io/
  2. Paste the spec from the issue in the editor
  3. Click "Try it out"
  4. Click "Execute"

A request is now performed but it failed due to the request url getting prefixed with https://editor.swagger.io/

Expected behavior

A get request to https://yesno.wtf/api/

When manually replacing the {server} variable in the url with with the default value the hostname is not prefixed and the correct server url is used.

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

No branches or pull requests

1 participant