You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have an use case where we use /api/v{n} as a basepath for the API and the middleware isn't able to handle it, this PR would fix it, any way I can help?
Hey, that's awesome! I guess any additional test cases we can put into #40 - and once we get round to finishing off that PR doing a test with your own workload, that'd be awesome 🤞🏽
// path is the mount point i.e. `/api/v1`funcwithSwaggerValidate(pathstring) func(http.Handler) http.Handler {
swagger, err:=oapigen.GetSwagger()
iferr!=nil {
// This should never errorpanic("there was an error getting the swagger")
}
// The openapi spec does not do prefixes yet (e.g. looking at `/templates` instead of `/api/v1/templates`)// To validate spec, need to update paths to match the prefix passed inupdatedPaths:= openapi3.Paths{}
forkey, value:=rangeswagger.Paths.Map() {
updatedPaths.Set(path+key, value)
}
// Clear out the servers array in the swagger spec. It is recommended to do this so that it skips validating// that server names match.swagger.Servers=nilf:=middleware.OapiRequestValidator(swagger)
returnfunc(next http.Handler) http.Handler {
returnf(next)
}
}
Hello,
I have prepared a PR (#54) with a straightforward implementation of this feature. All tests are passing, and I am already using this implementation in my production system.
Could you please review it and provide feedback if necessary?
It would be great to have this feature included in the upcoming release.
Activity
ChepChaf commentedon May 29, 2025
I have an use case where we use /api/v{n} as a basepath for the API and the middleware isn't able to handle it, this PR would fix it, any way I can help?
jamietanna commentedon May 30, 2025
Hey, that's awesome! I guess any additional test cases we can put into #40 - and once we get round to finishing off that PR doing a test with your own workload, that'd be awesome 🤞🏽
jarangutan commentedon Aug 27, 2025
I did get around it for now by doing
rakhmanov commentedon Sep 3, 2025
Alternative workaround that worked for me:
Fedott commentedon Sep 16, 2025
Hello,
I have prepared a PR (#54) with a straightforward implementation of this feature. All tests are passing, and I am already using this implementation in my production system.
Could you please review it and provide feedback if necessary?
It would be great to have this feature included in the upcoming release.