connexion icon indicating copy to clipboard operation
connexion copied to clipboard

[Question] Is there a prescribed way to generate response model from openapi spec?

Open arajkumar opened this issue 4 years ago • 2 comments

Description

Thanks for this great framework. I would like to know the connexion prescribed way to generate response models. It is really hard to work with arbitrary python dictionary when preparing a huge response with multiple fields. I would love to use pydantic, but there is no proper tool to generate pydantic models from swagger spec.

arajkumar avatar Apr 15 '20 05:04 arajkumar

https://github.com/koxudaxi/datamodel-code-generator is not perfect but quite usable now for this task. However, using pydantic objects directly for responses is not easily possible right now.

languitar avatar Sep 16 '20 12:09 languitar

Related to this question, is it possible to hook the request model validation to supply the Pydantic model as an input?

The ideal workflow for me would be to use the datamodel-code-generator to produce models, which are then typed as the actual models so my IDE can codehint/guide their use in the handler functions appropriately.

wrouesnel avatar Sep 02 '22 01:09 wrouesnel