[php-nextgen] Discriminator class detection uses wrong namespace#22811
Closed
lukascernydis wants to merge 2 commits intoOpenAPITools:masterfrom
Closed
[php-nextgen] Discriminator class detection uses wrong namespace#22811lukascernydis wants to merge 2 commits intoOpenAPITools:masterfrom
lukascernydis wants to merge 2 commits intoOpenAPITools:masterfrom
Conversation
wing328
reviewed
Jan 26, 2026
| $discriminator = $class::DISCRIMINATOR; | ||
| if (!empty($discriminator) && isset($data->{$discriminator}) && is_string($data->{$discriminator})) { | ||
| $subclass = '\{{invokerPackage}}\Model\\' . $data->{$discriminator}; | ||
| $subclass = '\{{modelPackage}}\\' . $data->{$discriminator}; |
Member
There was a problem hiding this comment.
thanks for the PR
what about adding a test schema in modules/openapi-generator/src/test/resources/3_0/php-nextgen/petstore-with-fake-endpoints-models-for-testing.yaml to cover this change?
Contributor
Author
There was a problem hiding this comment.
Hi, sorry for the late reply. My poor brain forgot about it completly. Tests commited.
Contributor
There was a problem hiding this comment.
No issues found across 4 files
Since this is your first cubic review, here's how it works:
- cubic automatically reviews your code and comments on bugs and improvements
- Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
- Add one-off context when rerunning by tagging
@cubic-dev-aiwith guidance or docs links (includingllms.txt) - Ask questions if you need clarification on any suggestion
6 tasks
Member
|
update: merged via #23287 |
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.
When using discriminator - for example:
then the object serializer is trying to find matching class ChangeNewVO.
ObjectSerializerclass inside generated package was using hard-coded namespace{{invokerPackage}}\Modelinstead of proper{{modelPackage}}.Error is happening only when non-standard
modelPackageconfig option is set.@jebentier @dkarlovi @mandrean @jfastnacht @ybelenko @renepardon
Summary by cubic
Fix discriminator subclass resolution in PHP NextGen to use the configured
{{modelPackage}}, so polymorphic models resolve correctly with custom model packages. Adds tests to lock this behavior and refactors a TypeScript sample to build request options without sending the request.Bug Fixes
{{modelPackage}}for discriminator-based subclass detection inObjectSerializer(not{{invokerPackage}}\Model).Refactors
TestApi.ts, addtestRequestOpts()returningruntime.RequestOpts.testRaw()to use the request options builder before sending the request.Written for commit 99783e5. Summary will update on new commits.