Skip to content

[BUG][PHP] oneOf produces type OneOfModelAModelB in Model $openAPITypes #2011

@sakari

Description

@sakari

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What's the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?script-client-produces-a-wrong-object-for-a-string-enum-type-that-is-used-with-ref))
Description

PHP model is generated with OneOfModelAModelB as type for $openAPITypes for

foo: 
  oneOf:
    - $ref: 'modelA'
    - $ref: 'modelB'
openapi-generator version

master at 046db19

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 with map[K, V] types. Ie match the type string to oneOf[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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions