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
Go's net/http ServeMux requires wildcard segment names to be valid Go
identifiers. OpenAPI specs can use path parameter names containing
dashes (e.g. "addressing-identifier"), which causes a panic when
registering routes with ServeMux.
Fix by sanitizing parameter names in the stdhttp code path:
- SwaggerUriToStdHttpUri now sanitizes param names via SanitizeGoIdentity
so route patterns use valid Go identifiers (e.g. {addressing_identifier})
- stdhttp middleware template uses new SanitizedParamName for r.PathValue()
calls to match the sanitized route pattern, while keeping the original
ParamName for error messages
- Add SanitizedParamName() method to ParameterDefinition for use by
templates that need the sanitized form
Add server-specific test directory with per-router integration tests
exercising dashed path parameter names. Right now, only stdhttp has
a test in this directory, but we'll do router specific tests in there
in the future.
Fixes#2278
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
0 commit comments