Skip to content
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

Discriminator support #242

Closed
stojsavljevic opened this issue Mar 28, 2018 · 0 comments
Closed

Discriminator support #242

stojsavljevic opened this issue Mar 28, 2018 · 0 comments
Labels
enhancement v2 Feature will be implemented in v2.0 only (master branch)

Comments

@stojsavljevic
Copy link
Contributor

I would like to add support for discriminator and discriminatorValue attributes of data types.
Having data types defined like this:

types:
  Person:
    type: object
    discriminator: kind # refers to the `kind` property of object `Person`
    properties:
      kind: string # contains name of the kind of a `Person` instance
      name: string
  Employee: # kind can equal `Employee`; default value for `discriminatorValue`
    type: Person
    discriminatorValue: emp
    properties:
      employeeId: integer
  User: # kind can equal `User`; default value for `discriminatorValue`
    type: Person
    discriminatorValue: usr
    properties:
      userId: integer

should generate Person object with following annotations:

@JsonTypeInfo(use = Id.NAME, include = As.EXISTING_PROPERTY, property = "kind", visible = true)
@JsonSubTypes({
	@JsonSubTypes.Type(value = User.class, name = "usr"), 
	@JsonSubTypes.Type(value = Employee.class, name = "emp") 
})
public class Person implements Serializable
@stojsavljevic stojsavljevic added enhancement v2 Feature will be implemented in v2.0 only (master branch) labels Mar 28, 2018
stojsavljevic pushed a commit that referenced this issue Mar 28, 2018
Discriminator support
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement v2 Feature will be implemented in v2.0 only (master branch)
Projects
None yet
Development

No branches or pull requests

1 participant