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

OpenAPI 3.1.0 support: Path servers is getting incorrectly rendered even though there's no "servers" prop defined for that path #9221

Open
acelaya opened this issue Sep 17, 2023 · 7 comments

Comments

@acelaya
Copy link

acelaya commented Sep 17, 2023

Q&A (please complete the following information)

  • OS: Linux
  • Browser: chrome
  • Version: 4.7.1 (but all versions supporting OAS 3.1 are affected)
  • Method of installation: swaggerapi/swagger-ui docker image
  • Swagger-UI version: 4.7.1 (but all versions supporting OAS 3.1 are affected)
  • Swagger/OpenAPI version: OpenAPI 3.1

Content & configuration

Example Swagger/OpenAPI definition: https://drive.google.com/file/d/1ysjjWAy-1_Xxhf4LBN4nLasMZSCm0EUa/view?usp=drive_link

Swagger-UI configuration options: Whatever is set in swaggerapi/swagger-ui docker image

Describe the bug you're encountering

After updating my OAS spec from v3.0 to v3.1 I have noticed swagger-ui renders a "servers" block for every endpoint, when clicking "Try it out", but only if an Authorization has been set before.

This wouldn't bother me if it wasn't because it does not inherit the value set on the global "Servers", meaning you have to set the value for every endpoint you want to test, instead of just once globally.

image

I could not reproduce this in https://editor-next.swagger.io/ though.

To reproduce...

Steps to reproduce the behavior:

  1. Download the oas spec provided avobe and call it swagger.json
  2. Spin up a docker container using swaggerapi/swagger-ui and mounting the swagger.json file
    docker run --rm -p 8888:8080 -v ${PWD}/swagger.json:/app/swagger.json swaggerapi/swagger-ui:v5.9.4
  3. Visit http://localhost:8888
  4. Fill in server details with any value.
  5. Set an Authorization value (also anything should work).
  6. Click on any endpoint to uncollapse it, then click on "Try it out".
  7. You'll notice the Servers block is rendered as shown in the screenshot, even though no servers is defined for the endpoints in the spec.

Expected behavior

Servers block is not rendered, and the endpoint uses the value set in the global servers.

@acelaya acelaya changed the title Rendering path servers even though there's no "servers" prop defined for that path Path servers is getting incorrectly rendered even though there's no "servers" prop defined for that path Oct 26, 2023
@acelaya
Copy link
Author

acelaya commented Nov 5, 2023

Still reproducible with v5.9.1

@char0n char0n changed the title Path servers is getting incorrectly rendered even though there's no "servers" prop defined for that path OpenAPI 3.1.0 support: Path servers is getting incorrectly rendered even though there's no "servers" prop defined for that path Nov 13, 2023
@char0n
Copy link
Member

char0n commented Nov 14, 2023

@acelaya I couldn't reproduce on v5.9.4. Can you please confirm?

Context: how the servers field normalization is being done for OpenAPI 3.1.0 changed in swagger-api/apidom#3355 and was incorporated into SwaggerUI in [email protected].

@acelaya
Copy link
Author

acelaya commented Nov 14, 2023

@acelaya I couldn't reproduce on v5.9.4. Can you please confirm?

Yes, I'm afraid I can still reproduce this in v5.9.4

@char0n
Copy link
Member

char0n commented Nov 14, 2023

@acelaya unfortunately you're Steps Of Reproduction don't work for me. Can you delete all swagger-ui containers and images and recreate your setup using your steps of reproduction with v5.9.4?

@acelaya
Copy link
Author

acelaya commented Nov 14, 2023

@acelaya unfortunately you're Steps Of Reproduction don't work for me. Can you delete all swagger-ui containers and images and recreate your setup using your steps of reproduction with v5.9.4?

You are right, I cannot reproduce it using those steps, but I can still reproduce it with my real swagger. Let me try to find the difference and I will come back to you.

I also updated the steps to use v5.9.4, and fixed a typo in the port referenced in step 3

@acelaya
Copy link
Author

acelaya commented Nov 14, 2023

I think the problem is that it is not consistent. I thought the problem was the swagger.json sample I originally provided, so I ended up uploading the full swagger spec from my project, where I was able to reproduce it. It is attached to the issue because it's too big to embed in the issue body.

However, while trying to reproduce it again, I realized it doesn't always happen. You can see a screen recording here where, using the instructions above, I couldn't reproduce it on the first attempt, but then I refreshed the page, repeated the steps, and then I was able to reproduce it.

I believe the same would have happened with the originally provided swagger sample.

swagger-ui-servers.webm

@jux61
Copy link
Contributor

jux61 commented Dec 15, 2023

hello @char0n, i encounter the same issue after the cache fix in swagger-js (for parameters defined at path level)

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

3 participants