@@ -389,7 +389,7 @@ class TypedDictGeneric(TypedDict, Generic[T]):
389
389
@pytest .mark .parametrize ("cls" , annotations )
390
390
def test_schema_generation_with_generic_classes (cls : Any ) -> None :
391
391
expected_foo_schema = Schema (type = OpenAPIType .INTEGER )
392
- expected_optional_foo_schema = Schema (one_of = [Schema (type = OpenAPIType .NULL ), Schema (type = OpenAPIType .INTEGER )])
392
+ expected_optional_foo_schema = Schema (one_of = [Schema (type = OpenAPIType .INTEGER ), Schema (type = OpenAPIType .NULL )])
393
393
394
394
properties = get_schema_for_field_definition (
395
395
FieldDefinition .from_kwarg (name = get_name (cls ), annotation = cls )
@@ -443,7 +443,7 @@ def test_schema_generation_with_generic_classes_constrained() -> None:
443
443
)
444
444
def test_schema_generation_with_pagination (annotation : Any ) -> None :
445
445
expected_foo_schema = Schema (type = OpenAPIType .INTEGER )
446
- expected_optional_foo_schema = Schema (one_of = [Schema (type = OpenAPIType .NULL ), Schema (type = OpenAPIType .INTEGER )])
446
+ expected_optional_foo_schema = Schema (one_of = [Schema (type = OpenAPIType .INTEGER ), Schema (type = OpenAPIType .NULL )])
447
447
448
448
properties = get_schema_for_field_definition (FieldDefinition .from_annotation (annotation ).inner_types [- 1 ]).properties
449
449
@@ -478,11 +478,11 @@ class Foo(Enum):
478
478
assert isinstance (schema , Schema )
479
479
assert schema .type is None
480
480
assert schema .one_of is not None
481
- null_schema = schema .one_of [0 ]
481
+ null_schema = schema .one_of [1 ]
482
482
assert isinstance (null_schema , Schema )
483
483
assert null_schema .type is not None
484
484
assert null_schema .type is OpenAPIType .NULL
485
- enum_ref = schema .one_of [1 ]
485
+ enum_ref = schema .one_of [0 ]
486
486
assert isinstance (enum_ref , Reference )
487
487
assert enum_ref .ref == "#/components/schemas/tests_unit_test_openapi_test_schema_test_optional_enum.Foo"
488
488
enum_schema = creator .schema_registry .from_reference (enum_ref ).schema
@@ -569,9 +569,9 @@ class ModelB(base_type): # type: ignore[no-redef, misc]
569
569
FieldDefinition .from_kwarg (name = "Lookup" , annotation = Union [ModelA , ModelB , None ])
570
570
)
571
571
assert schema .one_of == [
572
- Schema (type = OpenAPIType .NULL ),
573
572
Reference (ref = "#/components/schemas/tests_unit_test_openapi_test_schema_test_type_union_with_none.ModelA" ),
574
573
Reference ("#/components/schemas/tests_unit_test_openapi_test_schema_test_type_union_with_none.ModelB" ),
574
+ Schema (type = OpenAPIType .NULL ),
575
575
]
576
576
577
577
0 commit comments