Skip to content

Conversation

@illionillion
Copy link
Contributor

@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.

@illionillion
Copy link
Contributor Author

@easonlin404 @pei0804 @sdghchj

Hi, just a small ping in case this PR was missed 🙂
It’s a minor change, so no rush at all. Thanks!

@sdghchj
Copy link
Member

sdghchj commented Dec 19, 2025

test with go 1.21.x failed.

@illionillion
Copy link
Contributor Author

@sdghchj
I noticed that the CI was failing due to an outdated version of actions/setup-go, which does not support Go 1.21+.
I have updated the workflow to use actions/setup-go@v4 to resolve this issue.

Could you please approve and re-run the GitHub Actions for this PR?
Thank you!

@sdghchj sdghchj merged commit 1b6744c into swaggo:master Dec 20, 2025
7 checks passed
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?

2 participants