You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When specifying a subclass of pydantic.BaseModel in spectree.Response, an AssertionError: invalid pydantic.BaseModel is raised. This issue seems to be caused by the assertion at line 87 in spectree/response.py, which checks the model using issubclass(model, BaseModel). Despite importing BaseModel from spectree._pydantic, the assertion does not use the is_base_model() function from spectree._pydantic, which would correctly identify pydantic.BaseModel subclasses.
To Reproduce
Create a Flask application with pydantic and spectree.
Define a response model using pydantic.BaseModel.
Use the response model in spectree.Response.
Run the Flask application and make a request to the endpoint.
The response model should be validated correctly without raising an AssertionError.
The spectree version
SpecTree: 1.2.11
Flask: 3.0.2
pydantic: 2.9.2
Additional context
The issue seems to be caused by the assertion at line 87 in spectree/response.py, which checks the model using issubclass(model, BaseModel). A potential fix could be to adjust the assertion to use the is_base_model() function from spectree._pydantic to correctly identify pydantic.BaseModel subclasses.
The text was updated successfully, but these errors were encountered:
Describe the bug
When specifying a subclass of pydantic.BaseModel in spectree.Response, an
AssertionError: invalid pydantic.BaseModel
is raised. This issue seems to be caused by the assertion at line 87 in spectree/response.py, which checks the model usingissubclass(model, BaseModel)
. Despite importing BaseModel from spectree._pydantic, the assertion does not use theis_base_model()
function from spectree._pydantic, which would correctly identify pydantic.BaseModel subclasses.To Reproduce
Example code:
Expected behavior
The response model should be validated correctly without raising an
AssertionError
.The spectree version
Additional context
The issue seems to be caused by the assertion at line 87 in spectree/response.py, which checks the model using
issubclass(model, BaseModel)
. A potential fix could be to adjust the assertion to use theis_base_model()
function from spectree._pydantic to correctly identify pydantic.BaseModel subclasses.The text was updated successfully, but these errors were encountered: