fix: treat array without items as list of Any per OpenAPI 3.1 (#1435) - #1484
Open
rifkir23 wants to merge 2 commits into
Open
fix: treat array without items as list of Any per OpenAPI 3.1 (#1435)#1484rifkir23 wants to merge 2 commits into
rifkir23 wants to merge 2 commits into
Conversation
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.
Problem
When a schema has
"type": "array"with noitems(and noprefixItems), the generator fails to produce a property, silently skipping the schema or theanyOfbranch. In JSON Schema 2020-12 (used by OpenAPI 3.1), omittingitemsis valid and means "array of any type", so this should generate alist[Any]rather than failing.Reported cases include a bare
{"type": "array"}and ananyOfbranch{"type": "array", "maxItems": 0}.Fixes #1435
Fix
In
ListProperty.build, when neitheritemsnorprefixItemsis present, use an empty schema (oai.Schema()) as the inner schema, which resolves to anAnyProperty. The property is generated aslist[Any], equivalent toitems: {}. Arrays that do declareitems/prefixItemsare unaffected.Tests
Added
TestArrayWithoutItems::test_array_without_items_becomes_list_of_any: a{"type": "array"}schema with no items now builds aListPropertywhose inner property is anAnyPropertyand whose base type islist[Any]. Verified the test FAILS without the fix (returns aPropertyError) and PASSES with it. Fulltests/suite passes (322 passed, 4 skipped);ruffandmypyclean. Added a changeset per CONTRIBUTING.