Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
khvn26 committed Apr 22, 2024
1 parent 63b244f commit 1c06394
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion api/api/openapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ class _GenerateJsonSchema(GenerateJsonSchema):
def nullable_schema(self, schema: core_schema.NullableSchema) -> JsonSchemaValue:
"""Generates an OpenAPI 2.0-compatible JSON schema that matches a schema that allows null values.
(The catch is OpenAPI 2.0 does not allow them, but some clients are capable
to consume the `x-nullable` annotation.)
Args:
schema: The core schema.
Expand All @@ -36,6 +39,8 @@ def get_response_schemas(
) -> dict[str, Response]:
result = {}

definitions = self.components.with_scope(SCHEMA_DEFINITIONS)

for status_code in list(response_serializers):
if isinstance(response_serializers[status_code], type) and issubclass(
model_cls := response_serializers[status_code], BaseModel
Expand All @@ -46,7 +51,6 @@ def get_response_schemas(
ref_template=f"#/{SCHEMA_DEFINITIONS}/{{model}}",
)

definitions = self.components.with_scope(SCHEMA_DEFINITIONS)
for ref_name, schema_kwargs in model_json_schema.pop("$defs").items():
definitions.setdefault(
ref_name,
Expand Down

0 comments on commit 1c06394

Please sign in to comment.