Repository navigation
[php-nextgen] Use unknown default case when deserializing unknown enum values - #25266
Merged
wing328 merged 1 commit intoOct 15, 2026
Merged
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.
With
enumUnknownDefaultCaseenabled, the php-nextgen generator adds anUNKNOWN_DEFAULT_OPEN_APIcase to every enum, butObjectSerializer::deserialize()never used it. Deserializing a response with an unknown enum value still threw:InvalidArgumentException: Invalid value for enum \Example\Model\FileStatusโ must be one of: ...This PR falls back to the unknown default case in
ObjectSerializer::deserialize(), using the same check as thephpgenerator. Serialization is unchanged, so unknown values are still rejected when sending requests.The existing
enumUnknownDefaultCasetests now also check the generatedObjectSerializer. The php-nextgen samples don't change, as none of them enables the option.I also verified the fix with clients generated from real specs, for integer and string backed enums.
PR checklist
PHP: @jebentier @dkarlovi @mandrean @jfastnacht @ybelenko @renepardon
Summary by cubic
Fixes php-nextgen deserialization so that unknown enum values fall back to the
UNKNOWN_DEFAULT_OPEN_APIcase whenenumUnknownDefaultCaseis enabled, instead of throwing anInvalidArgumentException. Serialization is unchanged, and unknown values are still rejected when sending requests.ObjectSerializer::deserialize(), matching the existingphpgenerator behavior.enumUnknownDefaultCasetests to verify the generatedObjectSerializercode for both enabled and disabled states.Written for commit 3cf8f57. Summary will update on new commits.