Skip to content
This repository was archived by the owner on Dec 25, 2024. It is now read-only.

Commit 9a73df4

Browse files
authored
Fixes Python schema class order, Issue 276 (#277)
* Adds new components, adds possible java fix * Fixes schema writing order * Fixes python test * Samples regen
1 parent 06c63dd commit 9a73df4

File tree

50 files changed

+753
-206
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+753
-206
lines changed

samples/client/3_0_3_unit_test/python/src/unit_test_api/components/schema/ref_in_allof.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
from unit_test_api.shared_imports.schema_imports import * # pyright: ignore [reportWildcardImportFromLibrary]
1212

1313

14+
from unit_test_api.components.schema import property_named_ref_that_is_not_a_reference
15+
AllOf = typing.Tuple[
16+
typing.Type[property_named_ref_that_is_not_a_reference.PropertyNamedRefThatIsNotAReference],
17+
]
18+
1419

1520
@dataclasses.dataclass(frozen=True)
1621
class RefInAllof(
@@ -24,8 +29,3 @@ class RefInAllof(
2429
# any type
2530
all_of: AllOf = dataclasses.field(default_factory=lambda: schemas.tuple_to_instance(AllOf)) # type: ignore
2631

27-
28-
from unit_test_api.components.schema import property_named_ref_that_is_not_a_reference
29-
AllOf = typing.Tuple[
30-
typing.Type[property_named_ref_that_is_not_a_reference.PropertyNamedRefThatIsNotAReference],
31-
]

samples/client/3_0_3_unit_test/python/src/unit_test_api/components/schema/ref_in_anyof.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
from unit_test_api.shared_imports.schema_imports import * # pyright: ignore [reportWildcardImportFromLibrary]
1212

1313

14+
from unit_test_api.components.schema import property_named_ref_that_is_not_a_reference
15+
AnyOf = typing.Tuple[
16+
typing.Type[property_named_ref_that_is_not_a_reference.PropertyNamedRefThatIsNotAReference],
17+
]
18+
1419

1520
@dataclasses.dataclass(frozen=True)
1621
class RefInAnyof(
@@ -24,8 +29,3 @@ class RefInAnyof(
2429
# any type
2530
any_of: AnyOf = dataclasses.field(default_factory=lambda: schemas.tuple_to_instance(AnyOf)) # type: ignore
2631

27-
28-
from unit_test_api.components.schema import property_named_ref_that_is_not_a_reference
29-
AnyOf = typing.Tuple[
30-
typing.Type[property_named_ref_that_is_not_a_reference.PropertyNamedRefThatIsNotAReference],
31-
]

samples/client/3_0_3_unit_test/python/src/unit_test_api/components/schema/ref_in_oneof.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
from unit_test_api.shared_imports.schema_imports import * # pyright: ignore [reportWildcardImportFromLibrary]
1212

1313

14+
from unit_test_api.components.schema import property_named_ref_that_is_not_a_reference
15+
OneOf = typing.Tuple[
16+
typing.Type[property_named_ref_that_is_not_a_reference.PropertyNamedRefThatIsNotAReference],
17+
]
18+
1419

1520
@dataclasses.dataclass(frozen=True)
1621
class RefInOneof(
@@ -24,8 +29,3 @@ class RefInOneof(
2429
# any type
2530
one_of: OneOf = dataclasses.field(default_factory=lambda: schemas.tuple_to_instance(OneOf)) # type: ignore
2631

27-
28-
from unit_test_api.components.schema import property_named_ref_that_is_not_a_reference
29-
OneOf = typing.Tuple[
30-
typing.Type[property_named_ref_that_is_not_a_reference.PropertyNamedRefThatIsNotAReference],
31-
]

samples/client/3_0_3_unit_test/python/src/unit_test_api/schemas/validation.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -840,8 +840,9 @@ def validate_any_of(
840840
) -> PathToSchemasType:
841841
anyof_classes = []
842842
path_to_schemas: PathToSchemasType = collections.defaultdict(dict)
843+
module_namespace = vars(sys.modules[cls.__module__])
843844
for schema in classes:
844-
schema = _get_class(schema)
845+
schema = _get_class(schema, module_namespace)
845846
if schema is cls:
846847
"""
847848
optimistically assume that cls schema will pass validation

samples/client/3_1_0_unit_test/python/src/unit_test_api/schemas/validation.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -840,8 +840,9 @@ def validate_any_of(
840840
) -> PathToSchemasType:
841841
anyof_classes = []
842842
path_to_schemas: PathToSchemasType = collections.defaultdict(dict)
843+
module_namespace = vars(sys.modules[cls.__module__])
843844
for schema in classes:
844-
schema = _get_class(schema)
845+
schema = _get_class(schema, module_namespace)
845846
if schema is cls:
846847
"""
847848
optimistically assume that cls schema will pass validation

samples/client/openapi_features/nonCompliantUseDiscriminatorIfCompositionFails/python/src/this_package/components/schema/operator.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@
1111
from this_package.shared_imports.schema_imports import * # pyright: ignore [reportWildcardImportFromLibrary]
1212

1313

14+
from this_package.components.schema import addition_operator
15+
from this_package.components.schema import subtraction_operator
16+
OneOf = typing.Tuple[
17+
typing.Type[addition_operator.AdditionOperator],
18+
typing.Type[subtraction_operator.SubtractionOperator],
19+
]
20+
1421

1522
@dataclasses.dataclass(frozen=True)
1623
class Operator(
@@ -34,10 +41,3 @@ class Operator(
3441
)
3542
one_of: OneOf = dataclasses.field(default_factory=lambda: schemas.tuple_to_instance(OneOf)) # type: ignore
3643

37-
38-
from this_package.components.schema import addition_operator
39-
from this_package.components.schema import subtraction_operator
40-
OneOf = typing.Tuple[
41-
typing.Type[addition_operator.AdditionOperator],
42-
typing.Type[subtraction_operator.SubtractionOperator],
43-
]

samples/client/openapi_features/nonCompliantUseDiscriminatorIfCompositionFails/python/src/this_package/schemas/validation.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -888,8 +888,9 @@ def validate_any_of(
888888
) -> PathToSchemasType:
889889
anyof_classes = []
890890
path_to_schemas: PathToSchemasType = collections.defaultdict(dict)
891+
module_namespace = vars(sys.modules[cls.__module__])
891892
for schema in classes:
892-
schema = _get_class(schema)
893+
schema = _get_class(schema, module_namespace)
893894
if schema is cls:
894895
"""
895896
optimistically assume that cls schema will pass validation

samples/client/openapi_features/security/python/src/this_package/schemas/validation.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -840,8 +840,9 @@ def validate_any_of(
840840
) -> PathToSchemasType:
841841
anyof_classes = []
842842
path_to_schemas: PathToSchemasType = collections.defaultdict(dict)
843+
module_namespace = vars(sys.modules[cls.__module__])
843844
for schema in classes:
844-
schema = _get_class(schema)
845+
schema = _get_class(schema, module_namespace)
845846
if schema is cls:
846847
"""
847848
optimistically assume that cls schema will pass validation

samples/client/petstore/java/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -810,6 +810,10 @@ Class | Description
810810

811811

812812

813+
[MyObjectDto](docs/MyObjectDto.md) |
814+
815+
816+
813817
[Name](docs/Name.md) | Model for testing model name same as property name
814818

815819

@@ -906,6 +910,10 @@ Class | Description
906910

907911

908912

913+
[PaginatedResultMyObjectDto](docs/PaginatedResultMyObjectDto.md) |
914+
915+
916+
909917
[ParentPet](docs/ParentPet.md) |
910918

911919

samples/client/petstore/python/.openapi-generator/FILES

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ docs/components/schema/mammal.md
128128
docs/components/schema/map_test.md
129129
docs/components/schema/mixed_properties_and_additional_properties_class.md
130130
docs/components/schema/money.md
131+
docs/components/schema/my_object_dto.md
131132
docs/components/schema/name.md
132133
docs/components/schema/no_additional_properties.md
133134
docs/components/schema/nullable_class.md
@@ -152,6 +153,7 @@ docs/components/schema/object_with_only_optional_props.md
152153
docs/components/schema/object_with_optional_test_prop.md
153154
docs/components/schema/object_with_validations.md
154155
docs/components/schema/order.md
156+
docs/components/schema/paginated_result_my_object_dto.md
155157
docs/components/schema/parent_pet.md
156158
docs/components/schema/pet.md
157159
docs/components/schema/pig.md
@@ -636,6 +638,7 @@ src/petstore_api/components/schema/mammal.py
636638
src/petstore_api/components/schema/map_test.py
637639
src/petstore_api/components/schema/mixed_properties_and_additional_properties_class.py
638640
src/petstore_api/components/schema/money.py
641+
src/petstore_api/components/schema/my_object_dto.py
639642
src/petstore_api/components/schema/name.py
640643
src/petstore_api/components/schema/no_additional_properties.py
641644
src/petstore_api/components/schema/nullable_class.py
@@ -660,6 +663,7 @@ src/petstore_api/components/schema/object_with_only_optional_props.py
660663
src/petstore_api/components/schema/object_with_optional_test_prop.py
661664
src/petstore_api/components/schema/object_with_validations.py
662665
src/petstore_api/components/schema/order.py
666+
src/petstore_api/components/schema/paginated_result_my_object_dto.py
663667
src/petstore_api/components/schema/parent_pet.py
664668
src/petstore_api/components/schema/pet.py
665669
src/petstore_api/components/schema/pig.py

0 commit comments

Comments
 (0)