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

Path swaggerui does not serve openapi.yml #10

Open
fabiante opened this issue Sep 20, 2023 · 2 comments
Open

Path swaggerui does not serve openapi.yml #10

fabiante opened this issue Sep 20, 2023 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@fabiante
Copy link
Member

fabiante commented Sep 20, 2023

Oops, the change in #3 wasn't properly tested. While the swagger ui correctly loads all assets under the new swaggerui path, it does not properly load the openAPI spec:

grafik

  • Visting swagger-ui will try to load http://localhost:8044/openapi.yml
  • Visting swaggerui will try to load http://localhost:8044/swaggerui/openapi.yml

The issue is with

var openApiUrl = document.URL.substr(0,document.URL.indexOf("swagger-ui/")) + "openapi.yml";

Swagger UI expects to run under the swagger-ui path.

@fabiante fabiante added the bug Something isn't working label Sep 20, 2023
@fabiante fabiante self-assigned this Sep 20, 2023
@fabiante
Copy link
Member Author

One fix would be to support both path, which requires changing swagger-initializer.js:

  let basePrefixIndex = document.URL.indexOf("swagger-ui/");
  if (basePrefixIndex == -1) {
    basePrefixIndex = document.URL.indexOf("swaggerui/");
  }

  var openApiUrl = document.URL.substr(0, basePrefixIndex) + "openapi.yml";

@fabiante
Copy link
Member Author

The other option is to use an HTTP redirect from swaggerui to swagger-ui. That has the benefit of not having to modify the dist directory which is better for maintenance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant