Skip to content

Conversation

@illionillion
Copy link

@illionillion illionillion commented Nov 24, 2025

Describe the PR

Fixes the issue where accessing /swagger and /swagger/ returned 404. Now, both paths return the content of index.html directly, matching typical static web server behavior and improving UX.

Closes #323

Additional context:

  • Both /swagger and /swagger/ now return the Swagger UI directly instead of 404.
  • Added tests for both paths to ensure future compatibility, in case gin's routing behavior changes.
  • For local testing, please update example/basic/main.go as follows to ensure Swagger UI loads the API definition correctly:
- url := ginSwagger.URL("http://petstore.swagger.io:8080/swagger/doc.json") // The url pointing to API definition
+ url := ginSwagger.URL("/swagger/doc.json") // The url pointing to API definition
  • Please check the behavior by accessing both /swagger and /swagger/ after applying this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Is there way to automatically redirect to index.html?

1 participant