Request: Support List[pydantic.BaseModel] as response #57
-
Environment:
RequestAdd support of List[] in ExplanationI'm trying to migrate an existing Flask API to Flask-OpenAPI, and I'm hitting an issue.
Since this API is used in production:
Note that |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
I think class ResponseWithList(BaseModel):
__root__: List[Any] More information see https://docs.pydantic.dev/usage/models/#custom-root-types |
Beta Was this translation helpful? Give feedback.
-
Hi @luolingchun, That's exactly what I needed. Thanks for pointing it out. Thanks |
Beta Was this translation helpful? Give feedback.
-
It's worth it because developers can understand your API more easily. |
Beta Was this translation helpful? Give feedback.
I think
__root__
can solve your problem:More information see https://docs.pydantic.dev/usage/models/#custom-root-types