Skip to content

Commit f3b132f

Browse files
committed
address comments
1 parent 97041c3 commit f3b132f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

api/api/openapi.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ class _GenerateJsonSchema(GenerateJsonSchema):
1111
def nullable_schema(self, schema: core_schema.NullableSchema) -> JsonSchemaValue:
1212
"""Generates an OpenAPI 2.0-compatible JSON schema that matches a schema that allows null values.
1313
14+
(The catch is OpenAPI 2.0 does not allow them, but some clients are capable
15+
to consume the `x-nullable` annotation.)
16+
1417
Args:
1518
schema: The core schema.
1619
@@ -36,6 +39,8 @@ def get_response_schemas(
3639
) -> dict[str, Response]:
3740
result = {}
3841

42+
definitions = self.components.with_scope(SCHEMA_DEFINITIONS)
43+
3944
for status_code in list(response_serializers):
4045
if isinstance(response_serializers[status_code], type) and issubclass(
4146
model_cls := response_serializers[status_code], BaseModel
@@ -46,7 +51,6 @@ def get_response_schemas(
4651
ref_template=f"#/{SCHEMA_DEFINITIONS}/{{model}}",
4752
)
4853

49-
definitions = self.components.with_scope(SCHEMA_DEFINITIONS)
5054
for ref_name, schema_kwargs in model_json_schema.pop("$defs").items():
5155
definitions.setdefault(
5256
ref_name,

0 commit comments

Comments
 (0)