Repository navigation
fix: explain nested arrays in styled parameters - #192
Merged
mromaszewicz merged 1 commit intoNov 22, 2026
Merged
Conversation
An array nested inside a styled object, map, or array has no wire format defined by OpenAPI, the same as a nested object. It failed with a bare "unsupported type []T", which gave no hint about the cause. Return an error naming the limitation and the alternatives (a `content` parameter or `style: deepObject`), matching the existing nested-object error. Closes oapi-codegen#191 Refs oapi-codegen/oapi-codegen#2109 Co-Authored-By: Claude Fable 5.2 <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.
Closes #191
Refs oapi-codegen/oapi-codegen#2109
Problem
Styling an object that has an array property fails with
unsupported type []T, which gives no hint about the cause. OpenAPI only defines style-based serialization for primitives, arrays of primitives, and flat objects, so an array nested inside a styled object has no wire format, the same as a nested object (#52). Nested objects already get an explicit error; nested arrays fell through to the generic branch.Change
primitiveToStringnow returns an explicit error for a slice or array nested in a struct field, map value, or another array:[]bytekeeps the previous message, since it is a string in OpenAPI terms and not an array.Nothing that serialized before changes; this only replaces the error text for a case that already failed.
Testing
TestStyleParamNestedArrayErrorcovers a struct field across theform,simple,label, andmatrixstyles in both explode modes, a map value, an array of arrays, and confirmsdeepObjectstill serializes the same struct.🤖 Generated with Claude Code