Description
If you choose not to use inheritance in your model and instead simply use composition using the allOf properties, does it make sense to generate interfaces for these models so that the server implementation can have code reuse for specific types?
Use case for not relying upon inheritance:
Inheritance makes the API more confusing for consumers in untyped languages. In our use case, our consumers primarily use untyped languages but our server is written in strongly typed java.
Swagger-codegen version
A version just a few commits after the 2.2.2 release.
Swagger declaration file content or url
For example:
definitions:
ModelOne:
type: object
properties:
modelOneProp:
type: string
ModelTwo:
type: object
properties:
modelTwoProp:
type: string
ModelThree:
type: object
properties:
modelThreeProp:
type: string
SimpleComposition:
allOf:
- $ref: '#/definitions/ModelOne'
- $ref: '#/definitions/ModelTwo'
- type: object
properties:
simpleCompositionProp:
type: string
CompositionOfSimpleComposition:
allOf:
- $ref: '#/definitions/SimpleComposition'
- $ref: '#/definitions/ModelThree'
- type: object
properties:
compositionOfSimpleCompositionProp:
type: string
Suggest a Fix
In the above example additional interfaces would be generated (names are up for debate):
IModelOne, IModelTwo, IModelThree ISimpleComposition, ICompositionOfSimpleComposition.
The class ModelOne would implement IModelOne as would SimpleComposition and ISimpleComposition.
Ect...
What are the maintainers thoughts on this? Would this be a feature worth implementing in the mainline branch?
Description
If you choose not to use inheritance in your model and instead simply use composition using the
allOfproperties, does it make sense to generate interfaces for these models so that the server implementation can have code reuse for specific types?Use case for not relying upon inheritance:
Inheritance makes the API more confusing for consumers in untyped languages. In our use case, our consumers primarily use untyped languages but our server is written in strongly typed java.
Swagger-codegen version
A version just a few commits after the 2.2.2 release.
Swagger declaration file content or url
For example:
Suggest a Fix
In the above example additional interfaces would be generated (names are up for debate):
IModelOne,IModelTwo,IModelThreeISimpleComposition,ICompositionOfSimpleComposition.The class
ModelOnewould implementIModelOneas wouldSimpleCompositionandISimpleComposition.Ect...
What are the maintainers thoughts on this? Would this be a feature worth implementing in the mainline branch?