swagger-ui icon indicating copy to clipboard operation
swagger-ui copied to clipboard

Loading new URL does not reset schemes value if schemes unset

Open chewi opened this issue 6 years ago • 0 comments

Q&A (please complete the following information)

  • OS: CentOS 7
  • Browser: Vivaldi
  • Version: 2.3.1440.60
  • Method of installation: git clone, using dist directory
  • Swagger-UI version: 604c7b420f069b132a3d8b4636afe91a4f473fe2
  • Swagger/OpenAPI version: Swagger 2.0

Content & configuration

I'm just loading dist/index.html directly in my browser and pointing UI at my server.

Example Swagger/OpenAPI definition: Sorry, proprietary, but all you need to know is no host, basePath, or schemes value is defined.

Swagger-UI configuration options: git repository is completely unmodified and clean.

Describe the bug you're encountering

When I first open dist/index.html, it shows the Petstore API. If I point UI at my HTTP (not HTTPS) server then it successfully loads but any attempt to "Try It Out" does the request over HTTPS.

Through trial and error, I have found that this is caused by the schemes value in the Petstore API. If I modify index.html to point directly to my HTTP URL, it works fine. If I add a schemes entry to my swagger.json, it works fine. If I remove the UI url field so that nothing is loaded initially, it works fine. If I load the Petstore API over HTTP instead, it doesn't work, which indicates that the schemes value takes precedence, as you would expect.

To reproduce...

Steps to reproduce the behavior:

  1. Fire up UI with it pointing at the Petstore API.
  2. Point UI to a HTTP URL with no schemes value defined.
  3. Try It Out.

Expected behavior

The request should be made with HTTP, not HTTPS.

chewi avatar Mar 08 '19 16:03 chewi