Skip to content

[php-nextgen] Fix for enum allowed values, fixes #23813#23814

Open
coffeemakr wants to merge 4 commits into
OpenAPITools:masterfrom
coffeemakr:issues-23813
Open

[php-nextgen] Fix for enum allowed values, fixes #23813#23814
coffeemakr wants to merge 4 commits into
OpenAPITools:masterfrom
coffeemakr:issues-23813

Conversation

@coffeemakr
Copy link
Copy Markdown
Contributor

@coffeemakr coffeemakr commented May 18, 2026

I added

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • 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.
  • File the PR against the correct branch: master (upcoming 7.x.0 minor release - breaking changes with fallbacks), 8.0.x (breaking changes without fallbacks)
  • If your PR solves a reported issue, reference it using GitHub's linking syntax (e.g., having "fixes #123" present in the PR description)
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

Summary by cubic

Fixes incorrect enum allowed values in php-nextgen models and restores missing discriminator constants. Prevents mixing discriminator values into unrelated enums. Fixes #23813.

  • Bug Fixes
    • Update model_generic.mustache to handle enums separately for discriminator vs non-discriminator fields and preserve discriminator constants.
    • Add tests for oneOf discriminator enum generation and constant preservation; include repro spec src/test/resources/bugs/issue_23813.yaml.

Written for commit 14e75a6. Summary will update on new commits. Review in cubic

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 3 files

Re-trigger cubic

@wing328
Copy link
Copy Markdown
Member

wing328 commented May 18, 2026

thanks for the PR

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

cc @JulianVennen (top contributor to php-nextgen)

Copy link
Copy Markdown
Contributor

@JulianVennen JulianVennen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the entire discriminator stuff in nextgen has to be overhauled at some point as it doesn't really work the way it should.

The object serializer always returns a PetAnimal, because:

  1. The mapping key is not implemented. Discriminator values have to be the literal class name of the model
  2. The generated classes are not children of the PetAnimal class.

In other generators (e.g. typescript) those work correctly.

That being said, this PR does seem to be an improvement for now until someone has time and motivation to implement the discriminator stuff properly.

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.

[BUG][php-nextgen] Discriminator values used for allowed enum values

3 participants