swagger-api / swagger-ui

Swagger UI is a collection of HTML, JavaScript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API.
https://swagger.io
Apache License 2.0
26.54k stars 8.96k forks source link

operation level server override option always appears for OAS 3.1 specification #9947

Open aharin opened 5 months ago

aharin commented 5 months ago

This option seem to appear for OAS 3.1 documents when servers are not specified globally. Although servers are not specified on operation level either, swagger-ui defaults to '/' and always displays the override.

hxem3

char0n commented 5 months ago

Hi @aharin,

It's related to the fact that OpenAPI 3.1.0 resolution is facilitated by ApiDOM which utilizes (currently) full duplication and normalization algorithms. I can imagine this is not warranted for the SwaggerUI usecase. SO we'll review the normalization for OpenAPI 3.1.0 in foreseeable future.

dzanot commented 5 months ago

@aharin my team just saw this when navigating directly to the url of an expanded endpoint. It was preventing us from sending requests via the doc. A workaround that worked for me: navigate to the root (delete stuff after #) and hard refresh your browser, the dropdown should be absent after expanding the endpoint and clicking “Try it out”

djdutcher commented 3 months ago

I'm seeing this issue too, and the main problem is that global server option is always overridden by the local. I have a spec with multiple environments, and when loaded in swagger-ui, the multiple servers are shown in the global list. However picking something there has no effect, because each operation has it's own server list. People using swagger-ui to try my API have reported being frustrated by having to remember to set the server for each operation they try. I'd love an option to turn off the local server options or something similar. Thanks.

atwinand commented 1 month ago

I am also experiencing this. It is quite annoying having to refill the server URL for every endpoint I want to try in the documentation.