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
When an OpenAPI spec defines a path parameter whose name starts with a digit (e.g. {1param}), the generated stdhttp server code panics during route registration because Go's http.ServeMux requires wildcard names to be valid Go identifiers.
The middleware also extracts the value using the raw name:
n1param=r.PathValue("1param")
Root cause
SwaggerUriToStdHttpUri in pkg/codegen/utils.go strips OpenAPI style prefixes (., ;, ?, *) but passes through the raw parameter name without sanitizing it for stdlib mux compatibility. The stdhttp middleware template similarly uses {{.ParamName}} directly in r.PathValue() calls.
Other routers (Echo, Chi, Gin, Gorilla, Iris, Fiber) don't have this restriction — their routing libraries accept arbitrary parameter names.
Proposed fix
Both SwaggerUriToStdHttpUri and the stdhttp middleware template need to apply the same name sanitization that the Go type generator uses (prefixing digit-leading names with a character like N). They must agree on the sanitized name so route registration and PathValue extraction match.
Affected files:
pkg/codegen/utils.go — SwaggerUriToStdHttpUri function (line ~652)
Activity
fix: parameter binding consistency across all server templates and ro…
fix: clean up and test parameter binding
fix: clean up and test parameter binding
fix: clean up and test parameter binding
mromaszewicz commentedon Mar 27, 2026
This is actually a dup of #2278
fix: clean up and test parameter binding (#2307)
Tell the runtime whether routers deliver escaped path parameter values
Tell the runtime whether routers deliver escaped path parameter values (