x-oapi-codegen-extra-tags on path parameters not generated in strict-server RequestObject structs
Description
When using strict-server: true, x-oapi-codegen-extra-tags on path parameters are not propagated to the generated RequestObject struct fields. This means validation tags (e.g., validate:"required,alphanum") declared on path parameters in the OpenAPI spec have no effect in the generated strict-server code.
Query parameter tags work correctly — they appear on the generated *Params struct fields. This issue is specific to path parameters in strict-server mode.
Steps to Reproduce
Given this OpenAPI spec:
paths: /node/{hostname}/status: get: operationId: GetNodeStatus parameters: - name: hostname in: path required: true x-oapi-codegen-extra-tags: validate: "required,hostname_rfc1123" schema: type: string
With config:
output: gen.go package: gen generate: strict-server: true models: true
Expected Behavior
The generated GetNodeStatusRequestObject struct should include the validate tag:
type GetNodeStatusRequestObject struct { Hostname string `validate:"required,hostname_rfc1123"` }
This would allow using a single validation.Struct(request) call in the handler.
Actual Behavior
The generated struct has no extra tags:
type GetNodeStatusRequestObject struct { Hostname string }
The x-oapi-codegen-extra-tags is silently ignored for path parameters in strict-server mode.
Workaround
Manually validate path parameters in each handler using a temporary struct or direct validation calls:
func (n *Node) GetNodeStatus( _ context.Context, request gen.GetNodeStatusRequestObject, ) (gen.GetNodeStatusResponseObject, error) { if errMsg, ok := validation.Var(request.Hostname, "required,hostname_rfc1123"); !ok { return gen.GetNodeStatus400JSONResponse{Error: &errMsg}, nil } // ... }
Context
This becomes particularly noticeable with resource-oriented APIs where path parameters are common (e.g., /node/{hostname}/network/dns/{interfaceName}). Each handler needs manual validation boilerplate for path params, while query params and request body fields get automatic tag generation.