Repository navigation
fix: marshal a reusable form response's envelope, not its wrapper - #2587
Merged
mromaszewicz merged 1 commit intoSep 27, 2026
Merged
Conversation
An operation that reaches a components/responses entry through $ref, with a fixed status code and no headers, embeds the reusable envelope in its own response struct. For JSON the visitor encodes the embedded envelope, but for application/x-www-form-urlencoded it passed the wrapper to runtime.MarshalForm. The embedded field has no tag, so its fields went on the wire under an empty name: "%5Bvalue%5D=x" instead of "value=x". Cross-package $refs had the same problem. Marshal the embedded envelope, as the JSON path does, in the standard, Fiber and Iris strict templates. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Contributor
|
mromaszewicz
added a commit
to mromaszewicz/oapi-codegen
that referenced
this pull request
Sep 27, 2026
Brings in oapi-codegen#2587 (a reusable form response's envelope is marshalled, not its wrapper) and oapi-codegen#2589 (types from an imported document qualify only their model names). Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was wrong. A strict-server operation that reaches a
components/responsesentry through$ref, with a fixed status code and no headers, embeds the reusable envelope in its response struct (type Op200FormdataResponse struct{ ThingFormdataResponse }). The JSON visitor encodes the embedded envelope, but the form visitor passed the wrapper toruntime.MarshalForm. The embedded field has no tag, so its fields went on the wire under an empty name:%5Bvalue%5D=xinstead ofvalue=x. This happened in every strict flavor, and for cross-package$refs as well.What changed. The form branch in
strict-interface.tmpl,strict-fiber-interface.tmplandstrict-iris-interface.tmplmarshalsresponse.<Envelope>for a$refresponse, exactly as the JSON branch encodes it. The external case uses the envelope's unqualified name, which is the embedded field's name. Only the body of a form$refvisitor changes, and that output has never produced a correct body.How it's tested.
internal/test/servers/strict) gains aReusableURLEncodedResponseoperation that answers with a reusable form response. A wire test asserts the body isvalue=zxcvfor chi, echo, echo5, gin, iris, fiber-v3 (strict_test.go), fiber and std-http. Onmainevery one of them sends%5Bvalue%5D=zxcv.TestStrictReusableFormResponseMarshalsEnvelopepins the visitor for local and cross-package$refs, with an inline control, across the standard, Fiber and Iris templates. It fails onmain.value=xon this branch and the empty-name body onmain.mainand this branch across 71 specs × 15 configs (every strict flavor plusnullable-type,old-aliasing,old-allof-sibling-merging, schema-merging v1/v3, custom content-type tags). Of 1065 outputs, the only differences are theMarshalFormline of form$refvisitors, and no output's compile status changes.make generatechanges no other committed file.make testandmake lintpass, and the strict fixtures pass under Go 1.25.Fixes #2586
🤖 Generated with Claude Code