-
Notifications
You must be signed in to change notification settings - Fork 26
Open
Description
Hey guys,
Very good project for swagger 3.x, really appreciated your work.
I'd like to create a server with v1 and v2 server url, so was trying to follow https://github.com/swaggest/rest/blob/master/_examples/mount/main.go example to mount endpoints under api/v1, but has following error with service.Mount("/api/v1", apiV1):
panic: reflect API schema for GET /api/v1/sum: operation already exists: get /api/v1/sum
goroutine 1 [running]:
github.com/swaggest/rest/nethttp.OpenAPIMiddleware.func1({0x1012d9600?, 0x14000373920?})
/Users/267121010/go/pkg/mod/github.com/swaggest/[email protected]/nethttp/openapi.go:35 +0x1a8
I also tried to use
r := openapi31.NewReflector()
r.Spec.WithServers(
openapi31.Server{
URL: "/api/v1",
})
s := web.NewService(r)
s.Route("/data", func(r chi.Router) {
r.Group(func(r chi.Router) {
r.Use(serviceTokenAuth, serviceTokenDoc, checkSize)
r.Method(http.MethodPost, "/", nethttp.NewHandler(handler.GenericPost()))
r.Method(http.MethodPost, "/file-upload", nethttp.NewHandler(handler.FileUploader()))
})
})
s.Docs(“/docs”, swgui.New)
with this code I can see server url options in the swagger gui, but the actual endpoint logic is not correctly mapped to server selection. I'd expect to be able to call endpoint <url>/api/v1/data, but the server is actually only listening on <url>/data, the swagger GUI call test does show correct curl example <url>/api/v1/data though.
vearutop
Metadata
Metadata
Assignees
Labels
No labels