Skip to content

polymorphism for entity's filed #2591

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

Closed
kaijiezhang0319 opened this issue May 24, 2021 · 2 comments
Closed

polymorphism for entity's filed #2591

kaijiezhang0319 opened this issue May 24, 2021 · 2 comments

Comments

@kaijiezhang0319
Copy link

kaijiezhang0319 commented May 24, 2021

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.

@MikeRalphson
Copy link
Member

What does pet.yaml contain?

As to the codegen/compiler errors, please raise tooling-related issues on the relevant repository. This repository is for the OpenAPI specification itself. You may also receive more answers on a general support forum such as StackOverflow. Thanks.

@MikeRalphson
Copy link
Member

Closing due to inactivity - but please feel free to reopen the issue if necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants