Commit f3b132f 1 parent 97041c3 commit f3b132f Copy full SHA for f3b132f
File tree 1 file changed +5
-1
lines changed
1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,9 @@ class _GenerateJsonSchema(GenerateJsonSchema):
11
11
def nullable_schema (self , schema : core_schema .NullableSchema ) -> JsonSchemaValue :
12
12
"""Generates an OpenAPI 2.0-compatible JSON schema that matches a schema that allows null values.
13
13
14
+ (The catch is OpenAPI 2.0 does not allow them, but some clients are capable
15
+ to consume the `x-nullable` annotation.)
16
+
14
17
Args:
15
18
schema: The core schema.
16
19
@@ -36,6 +39,8 @@ def get_response_schemas(
36
39
) -> dict [str , Response ]:
37
40
result = {}
38
41
42
+ definitions = self .components .with_scope (SCHEMA_DEFINITIONS )
43
+
39
44
for status_code in list (response_serializers ):
40
45
if isinstance (response_serializers [status_code ], type ) and issubclass (
41
46
model_cls := response_serializers [status_code ], BaseModel
@@ -46,7 +51,6 @@ def get_response_schemas(
46
51
ref_template = f"#/{ SCHEMA_DEFINITIONS } /{{model}}" ,
47
52
)
48
53
49
- definitions = self .components .with_scope (SCHEMA_DEFINITIONS )
50
54
for ref_name , schema_kwargs in model_json_schema .pop ("$defs" ).items ():
51
55
definitions .setdefault (
52
56
ref_name ,
You can’t perform that action at this time.
0 commit comments