Open luis199230 opened 1 year ago
There may have been a breaking change in Pydantic that has caused this issue. I'll see if I can investigate at some point! Thanks!
I have this issue as well and can't figure out what exactly needs to change. The problem happens when you use nested Pydantic models. The nested model gets defined inside the parent model and Swagger isn't happy with that:
class NestedModel(BaseModel):
name: str
class ParentModel(BaseModel):
message: str
data: NestedModel
Generates this when used as the response model in Operation
:
"components": {
"schemas": {
"ParentModel": {
"$defs": { <----- Swagger doesn't seem to accept
"NestedModel": {
"properties": {
"name": {
"title": "Name",
"type": "string"
},
},
"required": [
"name",
],
"title": "NestedModel",
"type": "object"
}
},
"properties": {
"message": {
"title": "Message",
"type": "string"
},
"data": {
"$ref": "#/components/schemas/NestedModel", <----- Invalid
"default": null
}
},
"required": [
"message"
],
"title": "ParentModel",
"type": "object"
},
}
Did you come up with any workarounds by any chance @luis199230 ?
Here's a fix: https://github.com/TestBoxLab/chalice-spec/pull/22
I installed the following libraries
chalice==1.28.0 apispec==6.3.0 chalice_spec==0.6.0 pydantic==2.0.3
My initialization code is this:
my CodeSchema:
my CodesResponse:
When I validate in https://validator.swagger.io/validator/debug my url I find this error:
I was researching and I realized in OpenAPI v3 not support that reference and I would like to know if possible to solve from your side or apisec side?