swagger-api / swagger-api/swagger-ui

Default schemes is based on order in the spec instead of the current context

Open
#3,704 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

P2 type: feature version: 3.x
Dominant language
JavaScript
Stars
29k
Forks
9.3k
Avg merge
2d 23h
Merged PRs (30d)
25

Description

Q A
Bug or feature request? Bug
Which Swagger/OpenAPI version? 2.0
Which Swagger-UI version? Master
How did you install Swagger-UI? Clone from github
Which browser & version? Chrome (latest)
Which operating system? Windows 10 / Linux
Expected Behavior

If a spec is having http and https in the schemes section, swagger-ui should default to the one that it was loaded on. For example, in dev over http, it should have http selected in the dropdown by default and do http request by default. In prod over https, it should have https selected in the dropdown by default and do https request by default.

This seems related to this bug: https://github.com/swagger-api/swagger-ui/issues/1382

Current Behavior

The default selected scheme and the one that is used for the query is always the first one in the list in the spec

Possible Solution

I didn't check the code at all, I'm not very good in javascript. But this related bug seems to had a solution: https://github.com/swagger-api/swagger-ui/issues/1382

Context

Different environment use the same spec. The order in which we declare the possible schemes should not decide which one is used by default.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files or tests are named. Reproduce the issue in Swagger UI with a Swagger 2.0 spec listing both http and https schemes, then trace the default dropdown selection and request behavior. Done means the current page protocol is selected and used by default instead of the first scheme in the spec.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.