Description
Description
I've tried doing inheritance without discriminator and I think something changed in the latest version as I find "example" online which work the way I wanted it, but it's not what I'm generating with the 2.2.3 SNAPSHOT.
From reading #2096 it feels like it is now impossible to generate inheritence without a discriminator.
MyParent:
type: object
properties:
code:
type: string
MyChild:
type: object
allOf:
- $ref: '#/definitions/MyParent'
- properties:
label:
type: string
public class MyParentApiBean {
@JsonProperty("code")
private String code = null;
}
public class MyChildApiBean {
@JsonProperty("code")
private String code = null;
@JsonProperty("label")
private String label = null;
}
If I add a discriminator I do get inheritance but also an extra field (the discriminator field)
In my use case I do not want discriminator as the 2 objects will be used on different API path so there is never the need to know which type it at de-serialization.
And I do not want to force people to add an extra attribut in their json.
The use case I've is I want to be able to define a method taking a MyParentApiBean and working with the code field be it MyParentApiBean or MyChildApiBean.
Right now I've to declare the attribut as an Object and do instanceof or duplicate code.
Swagger-codegen version
2.2.3-SNAPSHOT
Suggest a fix/enhancement
I understand the issue with multiple allOf inheritance, but that could be fixed with interface as suggested #5275
Or if there is a single allOf inheritance could be done still with inheritance.
Again thanks for your work.
Hope to have the time to give a hand soon.