Closed matheusads closed 11 months ago
Would you expect this to be a bare array of that type in the generated OpenAPI spec?
i.e:
{
"description": "Some response",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/PropertyModel"
}
}
}
}
}
If you want a quick way of doing this, I have done it elsewhere by creating a Pydantic compatible wrapper type:
class PropertyModels(BaseModel):
__root__: list[ProperyModel]
We could definitely look at how that might work though!
I use this solution with root too, but I think it's a good option to accept Python types directly like list[str] for example.
I made it work here
Its working for list[BaseModel]
Hello, I started using this library recently and notice that I can't use Python types in Response.
Example:
@api.validate(query=PropertyQueryModel, resp=Response(HTTP_200=list[PropertyModel]), tags=['properties'])
This raises an Assertion Error from Response init
assert issubclass(value, BaseModel), "invalid
pydantic.BaseModel"
I think could be a good improvement to accept Python types, makes sense? Quickly looking at the code I didn't find other points where it could affect.
Maybe I can help in this part. Best.