fix: support non-indexed deepObject array unmarshaling (#22)#96
Open
mromaszewicz wants to merge 1 commit intooapi-codegen:mainfrom
Open
fix: support non-indexed deepObject array unmarshaling (#22)#96mromaszewicz wants to merge 1 commit intooapi-codegen:mainfrom
mromaszewicz wants to merge 1 commit intooapi-codegen:mainfrom
Conversation
OpenAPI 3.0's deepObject style has undefined behavior for arrays. Two conventions exist in the wild: - Indexed: p[vals][0]=a&p[vals][1]=b (oapi-codegen's current format) - Non-indexed: p[vals]=a&p[vals]=b (Swagger UI / Rails convention) Swagger UI generates the non-indexed format, which previously failed with "[field] has multiple values". This change makes UnmarshalDeepObject accept both formats by detecting repeated query parameter keys and expanding them into synthetic indexed entries (e.g. [vals][0], [vals][1]) before feeding them into the existing tree-construction and assignment logic. Marshaling (MarshalDeepObject) intentionally remains unchanged and continues to emit the indexed format. The indexed format is unambiguous, already consumed correctly by all known implementations, and is what oapi-codegen's own generated clients expect. Changing it to the non-indexed format would be a breaking change for consumers that rely on the current wire format, with no practical benefit since both formats are now accepted on the unmarshaling side. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
OpenAPI 3.0's deepObject style has undefined behavior for arrays. Two conventions exist in the wild:
Swagger UI generates the non-indexed format, which previously failed with "[field] has multiple values". This change makes UnmarshalDeepObject accept both formats by detecting repeated query parameter keys and expanding them into synthetic indexed entries (e.g. [vals][0], [vals][1]) before feeding them into the existing tree-construction and assignment logic.
Marshaling (MarshalDeepObject) intentionally remains unchanged and continues to emit the indexed format. The indexed format is unambiguous, already consumed correctly by all known implementations, and is what oapi-codegen's own generated clients expect. Changing it to the non-indexed format would be a breaking change for consumers that rely on the current wire format, with no practical benefit since both formats are now accepted on the unmarshaling side.