Skip to content

polymorphism for entity's filed #2591

Closed
@kaijiezhang0319

Description

@kaijiezhang0319

Hello open api experts, i meet some issue and want some help from you.

It is about polymorphism. i find some example here : #2116. want to reuse the pet scenario as example.

I define Pet, Cat, Dog. 3 yaml files.
Also, I have a entity Person , the yaml file like below.

description: Structure of person.
type: object
properties:
  name:
    type: string
  pet:
    $ref: 'pet.yaml'
required:
  - name
  - pet

what i find is, if i use above yaml, Pet.java can be generated, but there is no cat.java and dog.java generated.

Then i update the Person.yaml file like blew :

description: Structure of person.
type: object
properties:
  name:
    type: string
  pet:
    oneOf:
        - $ref: '#/components/schemas/Dog'
        - $ref: '#/components/schemas/Cat'
required:
  - name
  - pet

The generated Person.java file has some error, the filed "pet" 's. type is "OneOfDogCat", and then it complain the "OneOfDogCat" class with complier error.

I think 1st approach seems better, but not sure why client not generate the Dog.java and Cat.java file. Do you have any ideas on this problem, any suggestion is appreciate.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions