fix(v3): build swaggertype array overrides with items, not additional…#2200
Open
kklem0 wants to merge 1 commit into
Open
fix(v3): build swaggertype array overrides with items, not additional…#2200kklem0 wants to merge 1 commit into
kklem0 wants to merge 1 commit into
Conversation
…Properties BuildCustomSchemaV3's ARRAY case stored the element schema in additionalProperties (a map keyword) and left Items nil, so any field using a `swaggertype:"array,<type>"` override produced an invalid array schema and complementSchema panicked dereferencing schema.Items.Schema.Spec (field_parserv3.go). Mirror parseTypeExprV3's handling of ordinary slices and put the element schema in Items. Resolves the TODO that marked this line. Co-Authored-By: Claude Fable 5 <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.
Fixes the v3 half of the
swaggertype:"array,..."override (see umbrella issue).BuildCustomSchemaV3'sARRAYcase stored the element schema inadditionalProperties(a map keyword) and leftItemsnil — the line was marked// TODO: check if this is correct. Any field using an array swaggertype override then panicked incomplementSchemadereferencingschema.Items.Schema.Spec:This mirrors how
parseTypeExprV3builds schemas for ordinary Go slices (Items = spec.NewBoolOrSchema(false, itemSchema)).After the fix the override renders as expected:
{"type": "array", "items": {"type": "integer"}}Adds
TestBuildCustomSchemaV3covering array/object/primitive/error cases. Validated on a production codebase (126 operations): generation completes and array overrides render correctly.