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

Commit 88e9e95

Browse files
committed
Fixes broken python tests
1 parent 30641ea commit 88e9e95

214 files changed

Lines changed: 2256 additions & 994 deletions

File tree

Some content is hidden

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

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,24 @@ class {{jsonPathPiece.camelCase}}(api_client.{{#if noName}}Header{{/if}}{{#eq in
3434
{{#each content}}
3535

3636

37-
class __{{@key.camelCase}}MediaType(api_client.MediaType):
37+
class {{@key.camelCase}}MediaType(api_client.MediaType):
3838
{{#with this}}
3939
{{#with schema}}
4040
schema: typing.Type[{{../@key.snakeCase}}_{{jsonPathPiece.snakeCase}}.{{jsonPathPiece.camelCase}}] = {{../@key.snakeCase}}_{{jsonPathPiece.snakeCase}}.{{jsonPathPiece.camelCase}}
4141
{{/with}}
4242
{{/with}}
4343
{{/each}}
44-
__Content = typing_extensions.TypedDict(
45-
'__Content',
44+
Content = typing_extensions.TypedDict(
45+
'Content',
4646
{
4747
{{#each content}}
48-
'{{{@key.original}}}': typing.Type[__{{@key.camelCase}}MediaType],
48+
'{{{@key.original}}}': typing.Type[{{@key.camelCase}}MediaType],
4949
{{/each}}
5050
}
5151
)
52-
content: __Content = {
52+
content: Content = {
5353
{{#each content}}
54-
'{{{@key.original}}}': __{{@key.camelCase}}MediaType,
54+
'{{{@key.original}}}': {{@key.camelCase}}MediaType,
5555
{{/each}}
5656
}
5757
{{/if}}

modules/openapi-json-schema-generator/src/main/resources/python/components/request_bodies/request_body.hbs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,24 @@ class {{jsonPathPiece.camelCase}}(api_client.RequestBody):
2424
{{#each content}}
2525

2626

27-
class __{{@key.camelCase}}MediaType(api_client.MediaType):
27+
class {{@key.camelCase}}MediaType(api_client.MediaType):
2828
{{#with this}}
2929
{{#with schema}}
3030
schema: typing.Type[{{../@key.snakeCase}}_{{jsonPathPiece.snakeCase}}.{{jsonPathPiece.camelCase}}] = {{../@key.snakeCase}}_{{jsonPathPiece.snakeCase}}.{{jsonPathPiece.camelCase}}
3131
{{/with}}
3232
{{/with}}
3333
{{/each}}
34-
__Content = typing_extensions.TypedDict(
35-
'__Content',
34+
Content = typing_extensions.TypedDict(
35+
'Content',
3636
{
3737
{{#each content}}
38-
'{{{@key.original}}}': typing.Type[__{{@key.camelCase}}MediaType],
38+
'{{{@key.original}}}': typing.Type[{{@key.camelCase}}MediaType],
3939
{{/each}}
4040
}
4141
)
42-
content: __Content = {
42+
content: Content = {
4343
{{#each content}}
44-
'{{{@key.original}}}': __{{@key.camelCase}}MediaType,
44+
'{{{@key.original}}}': {{@key.camelCase}}MediaType,
4545
{{/each}}
4646
}
4747
{{#if required}}

modules/openapi-json-schema-generator/src/main/resources/python/components/responses/response.hbs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class {{jsonPathPiece.camelCase}}(api_client.OpenApiResponse[Api{{jsonPathPiece.
9696
{{#each content}}
9797

9898

99-
class __{{@key.camelCase}}MediaType(api_client.MediaType):
99+
class {{@key.camelCase}}MediaType(api_client.MediaType):
100100
{{#with this}}
101101
{{#with schema}}
102102
schema: typing.Type[{{../@key.snakeCase}}_{{jsonPathPiece.snakeCase}}.{{jsonPathPiece.camelCase}}] = {{../@key.snakeCase}}_{{jsonPathPiece.snakeCase}}.{{jsonPathPiece.camelCase}}
@@ -106,17 +106,17 @@ class {{jsonPathPiece.camelCase}}(api_client.OpenApiResponse[Api{{jsonPathPiece.
106106
{{/with}}
107107
{{/each}}
108108
{{#if content}}
109-
__Content = typing_extensions.TypedDict(
110-
'__Content',
109+
Content = typing_extensions.TypedDict(
110+
'Content',
111111
{
112112
{{#each content}}
113-
'{{{@key.original}}}': typing.Type[__{{@key.camelCase}}MediaType],
113+
'{{{@key.original}}}': typing.Type[{{@key.camelCase}}MediaType],
114114
{{/each}}
115115
}
116116
)
117-
content: __Content = {
117+
content: Content = {
118118
{{#each content}}
119-
'{{{@key.original}}}': __{{@key.camelCase}}MediaType,
119+
'{{{@key.original}}}': {{@key.camelCase}}MediaType,
120120
{{/each}}
121121
}
122122
{{/if}}

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

Lines changed: 0 additions & 24 deletions
This file was deleted.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{{#if types}}
2+
{{#eq types.size 1}}
3+
def __getitem__(self, name: {{#if literal}}typing_extensions.Literal["{{{key}}}"]{{else}}{{key}}{{/if}}) -> Schema_{{propertyClass}}.{{jsonPathPiece.camelCase}}[{{> components/schemas/_helper_schema_python_base_types }}]:{{#if overload}} ...{{/if}}
4+
{{else}}
5+
def __getitem__(self, name: {{#if literal}}typing_extensions.Literal["{{{key}}}"]{{else}}{{key}}{{/if}}) -> Schema_{{propertyClass}}.{{jsonPathPiece.camelCase}}[typing.Union[
6+
{{> components/schemas/_helper_schema_python_base_types_newline }}
7+
]]:{{#if overload}} ...{{/if}}
8+
{{/eq}}
9+
{{else}}
10+
def __getitem__(self, name: {{#if literal}}typing_extensions.Literal["{{{key}}}"]{{else}}{{key}}{{/if}}) -> Schema_{{propertyClass}}.{{jsonPathPiece.camelCase}}[typing.Union[
11+
{{> components/schemas/_helper_schema_python_base_types_newline }}
12+
]]:{{#if overload}} ...{{/if}}
13+
{{/if}}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{{#with getDeepestRef}}
2+
{{#if types}}
3+
{{#eq types.size 1}}
4+
def __getitem__(self, name: {{#if literal}}typing_extensions.Literal["{{{key}}}"]{{else}}{{key}}{{/if}}) -> {{#if ../refInfo.refModule}}{{../refInfo.refModule}}.{{/if}}{{../refInfo.refClass}}[{{> components/schemas/_helper_schema_python_base_types }}]:{{#if overload}} ...{{/if}}
5+
{{else}}
6+
def __getitem__(self, name: {{#if literal}}typing_extensions.Literal["{{{key}}}"]{{else}}{{key}}{{/if}}) -> {{#if ../refInfo.refModule}}{{../refInfo.refModule}}.{{/if}}{{../refInfo.refClass}}[typing.Union[
7+
{{> components/schemas/_helper_schema_python_base_types_newline }}
8+
]]:{{#if overload}} ...{{/if}}
9+
{{/eq}}
10+
{{else}}
11+
def __getitem__(self, name: {{#if literal}}typing_extensions.Literal["{{{key}}}"]{{else}}{{key}}{{/if}}) -> {{#if ../refInfo.refModule}}{{../refInfo.refModule}}.{{/if}}{{../refInfo.refClass}}[typing.Union[
12+
{{> components/schemas/_helper_schema_python_base_types_newline }}
13+
]]:{{#if overload}} ...{{/if}}
14+
{{/if}}
15+
{{/with}}

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

Lines changed: 57 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,51 +4,93 @@
44

55
@typing.overload
66
{{#if refInfo.refClass}}
7-
def __getitem__(self, name: typing_extensions.Literal["{{{@key.original}}}"]) -> '{{> components/schemas/_helper_refclass_with_module }}': ...
7+
{{> components/schemas/_helper_getitem_refclass literal=true key=@key.original overload=true }}
88
{{else}}
99
{{#if jsonPathPiece}}
1010
{{#if schemaIsFromAdditionalProperties}}
11-
def __getitem__(self, name: typing_extensions.Literal["{{{@key.original}}}"]) -> Schema_.{{jsonPathPiece.camelCase}}: ...
11+
{{> components/schemas/_helper_getitem_property propertyClass="" literal=true key=@key.original overload=true }}
1212
{{else}}
13-
def __getitem__(self, name: typing_extensions.Literal["{{{@key.original}}}"]) -> Schema_.Properties.{{jsonPathPiece.camelCase}}: ...
13+
{{> components/schemas/_helper_getitem_property propertyClass=".Properties" literal=true key=@key.original overload=true }}
1414
{{/if}}
1515
{{else}}
16-
def __getitem__(self, name: typing_extensions.Literal["{{{@key.original}}}"]) -> schemas.UnsetAnyTypeSchema: ...
16+
{{! for when additionalProperties is unset }}
17+
def __getitem__(self, name: typing_extensions.Literal["{{{@key.original}}}"]) -> schemas.UnsetAnyTypeSchema[typing.Union[
18+
{{> components/schemas/_helper_schema_python_base_types_newline }}
19+
]]: ...
1720
{{/if}}
1821
{{/if}}
1922
{{/with}}
2023
{{/each}}
2124
{{/if}}
2225
{{#if optionalProperties}}
23-
{{#each optionalProperties}}
26+
{{#each optionalProperties}}
2427

2528
@typing.overload
26-
{{#if refInfo.refClass}}
27-
def __getitem__(self, name: typing_extensions.Literal["{{{@key.original}}}"]) -> '{{> components/schemas/_helper_refclass_with_module }}': ...
28-
{{else}}
29-
def __getitem__(self, name: typing_extensions.Literal["{{{@key.original}}}"]) -> Schema_.Properties.{{jsonPathPiece.camelCase}}: ...
30-
{{/if}}
31-
{{/each}}
29+
{{#if refInfo.refClass}}
30+
{{> components/schemas/_helper_getitem_refclass literal=true key=@key.original overload=true }}
31+
{{else}}
32+
{{> components/schemas/_helper_getitem_property propertyClass=".Properties" literal=true key=@key.original overload=true }}
33+
{{/if}}
34+
{{/each}}
3235
{{/if}}
3336
{{#or properties requiredProperties}}
3437
{{#with additionalProperties}}
3538
{{#unless isBooleanSchemaFalse}}
3639

3740
@typing.overload
38-
def __getitem__(self, name: str) -> {{#if refInfo.refClass}}'{{> components/schemas/_helper_refclass_with_module }}'{{else}}Schema_.{{jsonPathPiece.camelCase}}{{/if}}: ...
41+
{{#if refInfo.refClass}}
42+
{{> components/schemas/_helper_getitem_refclass literal=false key="str" overload=true }}
43+
{{else}}
44+
{{> components/schemas/_helper_getitem_property propertyClass="" literal=false key="str" overload=true }}
45+
{{/if}}
3946
{{/unless}}
4047
{{else}}
4148

4249
@typing.overload
43-
def __getitem__(self, name: str) -> schemas.UnsetAnyTypeSchema: ...
50+
def __getitem__(self, name: str) -> schemas.UnsetAnyTypeSchema[typing.Union[
51+
frozendict.frozendict,
52+
str,
53+
decimal.Decimal,
54+
schemas.BoolClass,
55+
schemas.NoneClass,
56+
tuple,
57+
bytes,
58+
schemas.FileIO
59+
]]: ...
4460
{{/with}}
4561

46-
{{> components/schemas/_helper_getitem methodName="__getitem__" }}
62+
def __getitem__(
63+
self,
64+
name: typing.Union[
65+
{{#each requiredProperties}}
66+
{{#if this}}
67+
typing_extensions.Literal["{{{@key.original}}}"],
68+
{{/if}}
69+
{{/each}}
70+
{{#each optionalProperties}}
71+
typing_extensions.Literal["{{{@key.original}}}"],
72+
{{/each}}
73+
{{#with additionalProperties}}
74+
{{#unless isBooleanSchemaFalse}}
75+
str
76+
{{/unless}}
77+
{{else}}
78+
str
79+
{{/with}}
80+
]
81+
):
82+
# dict_instance[name] accessor
83+
return super().__getitem__(name)
4784
{{else}}
85+
{{! no properties or requiredProperties }}
4886
{{#with additionalProperties}}
4987
{{#unless isBooleanSchemaFalse}}
5088

51-
def __getitem__(self, name: str) -> {{#if refInfo.refClass}}'{{> components/schemas/_helper_refclass_with_module }}'{{else}}Schema_.{{jsonPathPiece.camelCase}}{{/if}}:
89+
{{#if refInfo.refClass}}
90+
{{> components/schemas/_helper_getitem_refclass literal=false key="str" overload=false }}
91+
{{else}}
92+
{{> components/schemas/_helper_getitem_property propertyClass="" literal=false key="str" overload=false }}
93+
{{/if}}
5294
# dict_instance[name] accessor
5395
return super().__getitem__(name)
5496
{{/unless}}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class {{jsonPathPiece.camelCase}}(
6767

6868
{{> components/schemas/_helper_property_type_hints }}
6969

70-
{{#if hasMultipleTypes}}
70+
{{#neq types null}}
7171
{{> components/schemas/_helper_new }}
7272

73-
{{/if}}
73+
{{/neq}}

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,11 @@ class {{jsonPathPiece.camelCase}}(
2727

2828
{{> components/schemas/_helper_new }}
2929

30-
def __getitem__(self, i: int) -> {{#with items}}{{#if refInfo.refClass}}'{{> components/schemas/_helper_refclass_with_module }}'{{else}}Schema_.{{jsonPathPiece.camelCase}}{{/if}}{{/with}}:
31-
return super().__getitem__(i)
30+
{{#with items}}
31+
{{#if refInfo.refClass}}
32+
{{> components/schemas/_helper_getitem_refclass literal=false key="int" overload=false }}
33+
{{else}}
34+
{{> components/schemas/_helper_getitem_property propertyClass="" literal=false key="int" overload=false }}
35+
{{/if}}
36+
return super().__getitem__(name)
37+
{{/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

0 commit comments

Comments
 (0)