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

Commit 376a650

Browse files
committed
Fixes array get_item singature
1 parent 6cc5fc5 commit 376a650

37 files changed

Lines changed: 146 additions & 85 deletions

File tree

modules/openapi-json-schema-generator/src/main/resources/python/components/schemas/_helper_schema_list.hbs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ class {{jsonPathPiece.camelCase}}(
2929

3030
{{#with items}}
3131
{{#if refInfo.refClass}}
32-
def __getitem__(self, i: int) -> '{{> components/schemas/_helper_refclass_with_module }}':
32+
{{> components/schemas/_helper_getitem_refclass literal=false key="int" overload=false }}
3333
{{else}}
34-
def __getitem__(self, i: int) -> Schema_.{{jsonPathPiece.camelCase}}:
34+
{{> components/schemas/_helper_getitem_property propertyClass="" literal=false key="int" overload=false }}
3535
{{/if}}
36-
return super().__getitem__(i)
36+
return super().__getitem__(name)
3737
{{/with}}

modules/openapi-json-schema-generator/src/main/resources/python/schemas.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2160,7 +2160,7 @@ class ListSchema(
21602160
def from_openapi_data_(cls, arg: typing.List[typing.Any], configuration_: typing.Optional[schema_configuration.SchemaConfiguration] = None):
21612161
return super().from_openapi_data_(arg, configuration_=configuration_)
21622162

2163-
def __new__(cls, arg_: typing.Union[typing.List[typing.Any], typing.Tuple[typing.Any]], **kwargs: schema_configuration.SchemaConfiguration) -> ListSchema[tuple]:
2163+
def __new__(cls, arg_: typing.Union[typing.List[typing.Any], typing.Tuple[typing.Any]], **kwargs: typing.Optional[schema_configuration.SchemaConfiguration]) -> ListSchema[tuple]:
21642164
return super().__new__(cls, arg_, **kwargs)
21652165

21662166

samples/openapi3/client/petstore/python/src/petstore_api/components/request_bodies/request_body_user_array/content/application_json/schema.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def __new__(
4141
configuration_=configuration_,
4242
)
4343

44-
def __getitem__(self, i: int) -> 'user.User':
45-
return super().__getitem__(i)
44+
def __getitem__(self, name: int) -> user.User[frozendict.frozendict]:
45+
return super().__getitem__(name)
4646

4747
from petstore_api.components.schema import user

samples/openapi3/client/petstore/python/src/petstore_api/components/responses/response_successful_xml_and_json_array_of_pet/content/application_json/schema.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def __new__(
4141
configuration_=configuration_,
4242
)
4343

44-
def __getitem__(self, i: int) -> 'ref_pet.RefPet':
45-
return super().__getitem__(i)
44+
def __getitem__(self, name: int) -> ref_pet.RefPet[frozendict.frozendict]:
45+
return super().__getitem__(name)
4646

4747
from petstore_api.components.schema import ref_pet

samples/openapi3/client/petstore/python/src/petstore_api/components/responses/response_successful_xml_and_json_array_of_pet/content/application_xml/schema.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def __new__(
4141
configuration_=configuration_,
4242
)
4343

44-
def __getitem__(self, i: int) -> 'pet.Pet':
45-
return super().__getitem__(i)
44+
def __getitem__(self, name: int) -> pet.Pet[frozendict.frozendict]:
45+
return super().__getitem__(name)
4646

4747
from petstore_api.components.schema import pet

samples/openapi3/client/petstore/python/src/petstore_api/components/schema/additional_properties_with_array_of_enums.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ def __new__(
5555
configuration_=configuration_,
5656
)
5757

58-
def __getitem__(self, i: int) -> 'enum_class.EnumClass':
59-
return super().__getitem__(i)
58+
def __getitem__(self, name: int) -> enum_class.EnumClass[str]:
59+
return super().__getitem__(name)
6060

6161
def __getitem__(self, name: str) -> Schema_.AdditionalProperties[tuple]:
6262
# dict_instance[name] accessor

samples/openapi3/client/petstore/python/src/petstore_api/components/schema/animal_farm.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def __new__(
4646
configuration_=configuration_,
4747
)
4848

49-
def __getitem__(self, i: int) -> 'animal.Animal':
50-
return super().__getitem__(i)
49+
def __getitem__(self, name: int) -> animal.Animal[frozendict.frozendict]:
50+
return super().__getitem__(name)
5151

5252
from petstore_api.components.schema import animal

samples/openapi3/client/petstore/python/src/petstore_api/components/schema/array_holding_any_type.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,14 @@ def __new__(
4343
configuration_=configuration_,
4444
)
4545

46-
def __getitem__(self, i: int) -> Schema_.Items:
47-
return super().__getitem__(i)
46+
def __getitem__(self, name: int) -> Schema_.Items[typing.Union[
47+
frozendict.frozendict,
48+
str,
49+
decimal.Decimal,
50+
schemas.BoolClass,
51+
schemas.NoneClass,
52+
tuple,
53+
bytes,
54+
schemas.FileIO
55+
]]:
56+
return super().__getitem__(name)

samples/openapi3/client/petstore/python/src/petstore_api/components/schema/array_of_array_of_number_only.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ def __new__(
6363
configuration_=configuration_,
6464
)
6565

66-
def __getitem__(self, i: int) -> Schema_.Items:
67-
return super().__getitem__(i)
66+
def __getitem__(self, name: int) -> Schema_.Items[decimal.Decimal]:
67+
return super().__getitem__(name)
6868

6969
def __new__(
7070
cls,
@@ -84,8 +84,8 @@ def __new__(
8484
configuration_=configuration_,
8585
)
8686

87-
def __getitem__(self, i: int) -> Schema_.Items:
88-
return super().__getitem__(i)
87+
def __getitem__(self, name: int) -> Schema_.Items[tuple]:
88+
return super().__getitem__(name)
8989
__annotations__ = {
9090
"ArrayArrayNumber": ArrayArrayNumber,
9191
}

samples/openapi3/client/petstore/python/src/petstore_api/components/schema/array_of_enums.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ def __new__(
4646
configuration_=configuration_,
4747
)
4848

49-
def __getitem__(self, i: int) -> 'string_enum.StringEnum':
50-
return super().__getitem__(i)
49+
def __getitem__(self, name: int) -> string_enum.StringEnum[typing.Union[
50+
schemas.NoneClass,
51+
str
52+
]]:
53+
return super().__getitem__(name)
5154

5255
from petstore_api.components.schema import string_enum

0 commit comments

Comments
 (0)