Skip to content

Commit

Permalink
openapi - missing initialization of v20 response models
Browse files Browse the repository at this point in the history
  • Loading branch information
commonism committed Sep 15, 2023
1 parent 586995c commit 7461375
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions aiopenapi3/openapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,21 @@ def is_schema(v: Tuple[str, "SchemaType"]) -> bool:
assert byid is not None and isinstance(byid, dict)
for name, schema in filter(is_schema, byid.items()):
byname[schema._get_identity(name=name)] = schema
# Request

# PathItems
for path, obj in (self.paths or dict()).items():
for m in obj.model_fields_set & HTTP_METHODS:
op = getattr(obj, m)

for r, response in op.responses.items():
if isinstance(response, ReferenceBase):
response = response._target
if isinstance(response, (v20.paths.Response)):
if isinstance(response.schema_, (v20.Schema, v31.Schema)):
name = response.schema_._get_identity("PI", f"{path}.{m}.{r}")
byname[name] = response.schema_
else:
raise TypeError(f"{type(response)} at {path}")

# Response
for byid in map(lambda x: x.responses, documents):
Expand All @@ -490,7 +504,7 @@ def is_schema(v: Tuple[str, "SchemaType"]) -> bool:
for name, schema in filter(is_schema, byid.items()):
byname[schema._get_identity(name=name)] = schema

# Request
# PathItems
for path, obj in (self.paths or dict()).items():
for m in obj.model_fields_set & HTTP_METHODS:
op = getattr(obj, m)
Expand Down

0 comments on commit 7461375

Please sign in to comment.