Open sakari opened 5 years ago
@sakari thanks for offering help. Sure we can work together on that. Do you mind pinging me via https://gitter.im (ID: wing328) so that we can come up with a plan to add the support of oneOf (and potentially anyOf)?
I'm running in to this problem also. For now the only way around it is for me to manually update the generated code (not a long term solution). In my situation if the generator could do this for me that would be great, not sure if this is the correct approach globally though.
Here is the work around that I put in place in my generated SDK: https://github.com/shotstack/shotstack-sdk-php/pull/2/commits/37770909704f162c359d4b241deceff33604091e
I added a parent type (Asset) and then have 3 classes (my oneOf types) extend the parent type (TitleAsset, ImageAsset and VideoAsset). In the Clip type I replaced the OneOfTitleAssetImageAssetVideoAsset
type with my new class \Shotstack\Client\Model\Asset
.
Hi everyone We have the same issue generator version is 5.1.0
Ditto, running into this here. v5.4.0
any news on the subject ? bug still present in v7.4.0
Any news on this ?
After a change in nelmio/api-doc-bundle
all allOf
changed to oneOf
( nelmio/NelmioApiDocBundle#2156 ) and this messed up our typeHinting because of class name changes (with the same json expect for the allOf
changed tooneOf
of course)
For example, a class TwoDto
used in property two
in another OneDto
class
class OneDto
{
private ?TwoDto $two = null;
}
Generated with allOf
will be : \App\My\Client\TwoDto
and the same class generated with oneOf
will be \App\My\Client\OneDtoTwo
Bug Report Checklist
Description
PHP model is generated with
OneOfModelAModelB
as type for$openAPITypes
foropenapi-generator version
master at 046db19a8590f3557ae1e04be75792bbeb39cb69
Suggest a fix
I think that it would be possible to create a type string like
oneOf[ModeA, ModelB]
in AbstractPhpCodegen.getTypeDeclaration and then deal with that in deserialiser like is done withmap[K, V]
types. Ie match the type string tooneOf[
there and try to deserialize all the enclosed options until a valid deserialization is found.If this seems like a legit approach I might be willing to do it as I need some reasonable way to handle this. Or if this has been considered before but the plan lacks implementation that would be something I could do also.