Skip to content

[php-nextgen] Fix Nested oneOf/anyOf Behavior#24318

Draft
ckoegel wants to merge 19 commits into
OpenAPITools:masterfrom
ckoegel:php-nextgen-nested-composed
Draft

[php-nextgen] Fix Nested oneOf/anyOf Behavior#24318
ckoegel wants to merge 19 commits into
OpenAPITools:masterfrom
ckoegel:php-nextgen-nested-composed

Conversation

@ckoegel

@ckoegel ckoegel commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

This PR builds off of work done in #24306. It flattens composed union type-hints transitively so a nested composed property resolves to its leaf members. Previously, composed property type-hints only listed their direct members, so when a composed type nested another composed type, the deserializer returned a leaf instance the property's union rejected and threw a TypeError.

Once #24306 is merged, I'll update this and mark as ready for review.

PR checklist

  • Read the contribution guidelines.
  • Run the following to build the project and update samples:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    (For Windows users, please run the script in WSL)
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

@jebentier (2017/07), @dkarlovi (2017/07), @mandrean (2017/08), @jfastnacht (2017/09), @ybelenko (2018/07), @renepardon (2018/12)


Summary by cubic

Fixes deserialization and typing for nested oneOf/anyOf in php-nextgen by flattening composed unions to their leaf types. Unifies handling via ComposedInterface and adds anyOf support to prevent TypeErrors with nested composed schemas.

  • Bug Fixes

    • Flatten nested oneOf/anyOf unions so properties accept leaf member types during deserialization.
    • Add anyOf support to models and docs with a new model_anyof.mustache.
    • Unify composed handling with ComposedInterface; ObjectSerializer now dispatches via deserializeComposed before array-to-object casting.
    • Update tests and samples to cover nested and discriminator scenarios.
  • Migration

    • OneOfInterface is replaced by ComposedInterface. Update any custom references and regenerate clients.

Written for commit 9d1ce0b. Summary will update on new commits.

Review in cubic

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