Fix swagger path generation: remove trailing slash for root routes with prefix (#5212)

This commit is contained in:
Copilot
2025-10-05 12:12:03 +08:00
committed by GitHub
parent 875fec3e1a
commit 7a6c3c8129
2 changed files with 95 additions and 1 deletions

View File

@@ -19,7 +19,11 @@ func spec2Paths(ctx Context, srv apiSpec.Service) *spec.Paths {
for _, route := range group.Routes {
routPath := pathVariable2SwaggerVariable(ctx, route.Path)
if len(prefix) > 0 && prefix != "." {
routPath = "/" + path.Clean(prefix) + routPath
if routPath == "/" {
routPath = "/" + path.Clean(prefix)
} else {
routPath = "/" + path.Clean(prefix) + routPath
}
}
pathItem := spec2Path(ctx, group, route)
existPathItem, ok := paths.Paths[routPath]