-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PHP] Missing model inheritance in generated client when schema has both oneOf and properties #1206
Comments
Actually, this happens also when there is an |
#1360 has been merged into master. Please give it another try and let us know if it's still an issue with Closing this issue for the time being. |
I am having this problem with version 4.0.1 of openapi-generator on mac OS 10.14.5.
Generates the following PHP:
It's attempting to deserialize the response into the single class |
Hi everyone |
Hi everyone |
Description
When a schema contains both
properties
andoneOf
, I expect openapi-generator to create multiple PHP classes with inheritance. In the example schema below, I expectFruit
, which has a protected membercolor
with getters and setters.Apple
, which inherits fromFruit
and extends it with protected memberkind
, and, crucially, whose serialisation contains both fieldscolor
andkind
.Banana
, which also inherits fromFruit
but extends it with protected membercount
instead.This does not happen – instead the
Fruit
superclass is generated without any protected members at all (i.e. theproperties
are ignored as soon asoneOf
is part of the schema) and the "child" classes do not inherit from the superclass.openapi-generator version
3.3.0
OpenAPI declaration file content or url
Reasonably minimal example to reproduce the problem. The interesting bits are under #/components/schemas, so you can ignore the rest.
Command line used for generation
openapi-generator generate -g php -i testschema.json -o out
Related issues/PRs
I couldn't find any related specifically to using the closed
oneOf
way to model inheritance. The common way to model inheritance with OpenAPI seems to be to useallOf
in the child classes instead.Suggest a fix/enhancement
The actual fixes to the generated code are really small, but I don't really know where to put them!
The text was updated successfully, but these errors were encountered: