Skip to content

Commit

Permalink
Fix openapi >=3 versions compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
cgaunet committed Dec 10, 2020
1 parent 6226af2 commit 7a1d15f
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions spectree/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,12 @@ async def async_validate(*args, **kwargs):
):
if model is not None:
assert issubclass(model, BaseModel)
self.models[model.__name__] = model.schema()
self.models[model.__name__] = model.schema(ref_template="#/components/schemas/{model}")
setattr(validation, name, model.__name__)

if resp:
for model in resp.models:
self.models[model.__name__] = model.schema()
self.models[model.__name__] = model.schema(ref_template="#/components/schemas/{model}")
validation.resp = resp

if tags:
Expand Down Expand Up @@ -214,8 +214,7 @@ def _generate_spec(self):
},
"tags": list(tags.values()),
"paths": {**routes},
"components": {"schemas": {**self.models}},
"definitions": self._get_model_definitions(),
"components": {"schemas": {**self.models, **self._get_model_definitions()}},
}
return spec

Expand Down

0 comments on commit 7a1d15f

Please sign in to comment.