Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/codegen/templates/chi/chi-handler.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ ErrorHandlerFunc: options.ErrorHandlerFunc,
}
{{end}}
{{range .}}r.Group(func(r chi.Router) {
r.{{.Method | lower | title }}(options.BaseURL+"{{.Path | swaggerUriToChiUri}}", wrapper.{{.HandlerName}})
r.{{.Method | lower | title }}(options.BaseURL+{{.Path | swaggerUriToChiUri | toGoString}}, wrapper.{{.HandlerName}})
})
{{end}}
return r
Expand Down
2 changes: 1 addition & 1 deletion pkg/codegen/templates/constants.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const (
// Defines values for {{$Enum.TypeName}}.
const (
{{range $name, $value := $Enum.GetValues}}
{{$name}} {{$Enum.TypeName}} = {{$Enum.ValueWrapper}}{{$value}}{{$Enum.ValueWrapper -}}
{{$name}} {{$Enum.TypeName}} = {{if $Enum.ValueWrapper}}{{$value | toGoString}}{{else}}{{$value}}{{end -}}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Missing regression test for the injection fix

The project convention (as codified in the review rules and via internal/test/issues/) is that bug fixes include a regression test keyed to the issue number. This PR has no new entry under internal/test/issues/ covering a string enum value that contains a quote (e.g. fo"o) or a route path with a backslash or quote. Without such a fixture, CI's make generate guard cannot detect a future regression that re-introduces the unescaped interpolation, and there is no _test.go exercising the boundary condition.

Prompt To Fix With AI
This is a comment left during a code review.
Path: pkg/codegen/templates/constants.tmpl
Line: 12

Comment:
**Missing regression test for the injection fix**

The project convention (as codified in the review rules and via `internal/test/issues/`) is that bug fixes include a regression test keyed to the issue number. This PR has no new entry under `internal/test/issues/` covering a string enum value that contains a quote (e.g. `fo"o`) or a route path with a backslash or quote. Without such a fixture, CI's `make generate` guard cannot detect a future regression that re-introduces the unescaped interpolation, and there is no `_test.go` exercising the boundary condition.

How can I resolve this? If you propose a fix, please make it concise.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

{{end}}
)
{{if not $.SkipEnumValidate}}
Expand Down
2 changes: 1 addition & 1 deletion pkg/codegen/templates/echo/echo-register.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ func RegisterHandlersWithOptions(router EchoRouter, si ServerInterface, options
Handler: si,
}
{{end}}
{{range .}}router.{{.Method}}(options.BaseURL + "{{.Path | swaggerUriToEchoUri}}", wrapper.{{.HandlerName}}, options.OperationMiddlewares["{{.MiddlewareKey}}"]...)
{{range .}}router.{{.Method}}(options.BaseURL + {{.Path | swaggerUriToEchoUri | toGoString}}, wrapper.{{.HandlerName}}, options.OperationMiddlewares["{{.MiddlewareKey}}"]...)
{{end}}
}
2 changes: 1 addition & 1 deletion pkg/codegen/templates/echo/v5/echo-register.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ func RegisterHandlersWithOptions(router EchoRouter, si ServerInterface, options
Handler: si,
}
{{end}}
{{range .}}router.{{.Method}}(options.BaseURL + "{{.Path | swaggerUriToEchoUri}}", wrapper.{{.HandlerName}}, options.OperationMiddlewares["{{.MiddlewareKey}}"]...)
{{range .}}router.{{.Method}}(options.BaseURL + {{.Path | swaggerUriToEchoUri | toGoString}}, wrapper.{{.HandlerName}}, options.OperationMiddlewares["{{.MiddlewareKey}}"]...)
{{end}}
}
2 changes: 1 addition & 1 deletion pkg/codegen/templates/fiber/fiber-handler.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ for _, m := range options.Middlewares {
}
{{end}}
{{range .}}
router.{{.Method | lower | title }}(options.BaseURL+"{{.Path | swaggerUriToFiberUri}}", wrapper.{{.HandlerName}})
router.{{.Method | lower | title }}(options.BaseURL+{{.Path | swaggerUriToFiberUri | toGoString}}, wrapper.{{.HandlerName}})
{{end}}
}
2 changes: 1 addition & 1 deletion pkg/codegen/templates/gin/gin-register.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ func RegisterHandlersWithOptions(router gin.IRouter, si ServerInterface, options
{{end}}

{{range . -}}
router.{{.Method }}(options.BaseURL+"{{.Path | swaggerUriToGinUri }}", wrapper.{{.HandlerName}})
router.{{.Method }}(options.BaseURL+{{.Path | swaggerUriToGinUri | toGoString}}, wrapper.{{.HandlerName}})
{{end -}}
}
2 changes: 1 addition & 1 deletion pkg/codegen/templates/gorilla/gorilla-register.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ ErrorHandlerFunc: options.ErrorHandlerFunc,
}
{{end}}
{{range .}}
r.HandleFunc(options.BaseURL+"{{.Path | swaggerUriToGorillaUri }}", wrapper.{{.HandlerName}}).Methods({{.Method | httpMethodConstant}})
r.HandleFunc(options.BaseURL+{{.Path | swaggerUriToGorillaUri | toGoString}}, wrapper.{{.HandlerName}}).Methods({{.Method | httpMethodConstant}})
{{end}}
return r
}
2 changes: 1 addition & 1 deletion pkg/codegen/templates/iris/iris-handler.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func RegisterHandlersWithOptions(router *iris.Application, si ServerInterface, o
Handler: si,
}
{{end}}
{{range .}}router.{{.Method | lower | title}}(options.BaseURL + "{{.Path | swaggerUriToIrisUri}}", wrapper.{{.HandlerName}})
{{range .}}router.{{.Method | lower | title}}(options.BaseURL + {{.Path | swaggerUriToIrisUri | toGoString}}, wrapper.{{.HandlerName}})
{{end}}
router.Build()
}
2 changes: 1 addition & 1 deletion pkg/codegen/templates/stdhttp/std-http-handler.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func HandlerWithOptions(si ServerInterface, options StdHTTPServerOptions) http.H
ErrorHandlerFunc: options.ErrorHandlerFunc,
}
{{end}}
{{range .}}m.HandleFunc({{.Method | httpMethodConstant}}+" "+options.BaseURL+"{{.Path | swaggerUriToStdHttpUri}}", wrapper.{{.HandlerName}})
{{range .}}m.HandleFunc({{.Method | httpMethodConstant}}+" "+options.BaseURL+{{.Path | swaggerUriToStdHttpUri | toGoString}}, wrapper.{{.HandlerName}})
{{end}}
return m
}
Loading