-
Notifications
You must be signed in to change notification settings - Fork 83
Open
Description
$ swag --version
Swag version: v2.0.0
swag version v2.0.0
go.mod
go 1.24.2
require (
github.com/go-chi/chi/v5 v5.2.2
github.com/swaggo/http-swagger/v2 v2.0.2
github.com/swaggo/swag/v2 v2.0.0-rc4
)
Generating the spec with swag/v2
:
$ swag init --dir ./internal/handlers --v3.1
We get the following output:
docs/docs.go
// Code generated by swaggo/swag. DO NOT EDIT.
package docs
import "github.com/swaggo/swag/v2"
// ...
Then use http-swagger/v2
to render the page
routes.go
package server
import _ "app/docs"
import httpSwagger "github.com/swaggo/http-swagger/v2"
// ...
func registerRoutes(r *chi.Mux) {
r.Get("/docs", func(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, "/docs/", http.StatusFound)
})
r.Get("/docs/*", httpSwagger.Handler(
httpSwagger.URL("/docs/doc.json"),
httpSwagger.Layout(httpSwagger.BaseLayout),
))
}
And then we get the following error:
But if we manually go to docs/docs.go
and update the import to import "github.com/swaggo/swag"
(removing the v2
), everything works as expected.
derevnjuk and arcinston
Metadata
Metadata
Assignees
Labels
No labels