Skip to content

fix(json-schema): handle union object types in iterable properties#7726

Open
JakovKnezovicc wants to merge 1 commit intoapi-platform:mainfrom
JakovKnezovicc:fix/json-schema-union-collection
Open

fix(json-schema): handle union object types in iterable properties#7726
JakovKnezovicc wants to merge 1 commit intoapi-platform:mainfrom
JakovKnezovicc:fix/json-schema-union-collection

Conversation

@JakovKnezovicc
Copy link
Contributor

Q A
Branch? main
Tickets .
License MIT
Doc PR .

Description

Fix JSON Schema generation for properties that are collections with PHP union types.

Motivation

When a property is iterable and typed as a union of object or generic types,
the generated schema did not properly expose item references, resulting in
incomplete items definitions.

Changes

  • Detect UnionType on collection properties
  • Build sub-schemas per object/generic subtype
  • Use items.anyOf when multiple refs are present

This behavior was previously discussed in issue #2817.

Test coverage is intentionally omitted in this initial PR to validate the proposed approach. Once confirmed, I will add or adjust tests accordingly.

@JakovKnezovicc JakovKnezovicc force-pushed the fix/json-schema-union-collection branch 3 times, most recently from 3cf1c9d to 0d56929 Compare February 5, 2026 12:11
@JakovKnezovicc JakovKnezovicc force-pushed the fix/json-schema-union-collection branch from 0d56929 to bf5c89f Compare February 5, 2026 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant