openapi-python-client icon indicating copy to clipboard operation
openapi-python-client copied to clipboard

Generate also models that are children of models used in endpoints

Open filipkral opened this issue 4 years ago • 1 comments

Is your feature request related to a problem? Please describe. Yes, my problem is that some of my endpoints use contract (component) that is of type QueryCondition. But QueryCondition has subclasses like AttributeQueryCondition, SpatialQueryCondition, and others. The openapi-python-client does not generate the subclasses in the models folder.

Describe the solution you'd like I think this happens because parser/openapi.py walks around all endpoints and generates a model when it finds one. But this way it skips the subclasses of models used in endpoints. I would like all models present in the openapi document to be generated. Alternatively, which classes to include or exclude could be controlled by the the --config file. I would also like the inheritance of models to be preserved in the generated models.

Describe alternatives you've considered I've considered writing my own generator but I would much rather use one that exists and openapi-python-client seems most promising.

Additional context Here is one of the openapi document I am working with: https://develop.mike-cloud.com/core-gis-prod/v2

filipkral avatar Nov 29 '21 16:11 filipkral

To be clear, QueryCondtion would be "allOf": ["/#/components/schemas/AttributeQueryCondition", "/#/components/schemas/SpatialQueryCondition"]? All of the models in components/schemas should be generated regardless of whether or not they're used, so if it's skipping some without warning that's a bug.

I won't be adding inheritence because it creates too many weird issues with interactions between classes, ends up being a big headache to support for arbitrary combinations of things. Could be useful to add a note about composition in a generated docstring though 🤔

dbanty avatar Jan 29 '22 23:01 dbanty

I think this issue was requesting inheritance, which will not be added.

dbanty avatar Jul 08 '23 17:07 dbanty