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

Commit 8f28b8b

Browse files
committed
Adds annotation
1 parent 0fcf3c3 commit 8f28b8b

236 files changed

Lines changed: 1308 additions & 233 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.
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
def __new__(
2+
cls,
3+
{{#if types}}
4+
{{#eq types.size 1}}
5+
{{#contains types "array"}}
6+
arg_: typing.Union[
7+
typing.Tuple[
8+
{{#with ../items}}{{#if refInfo.refClass}}typing.Union['{{> components/schemas/_helper_refclass_with_module }}', {{#with getDeepestRef}}{{> _helper_schema_python_types }}{{/with}}]{{else}}typing.Union[Schema_.{{jsonPathPiece.camelCase}}, {{> _helper_schema_python_types }}]{{/if}}{{/with}}, ...
9+
],
10+
typing.List[
11+
{{#with ../items}}{{#if refInfo.refClass}}typing.Union['{{> components/schemas/_helper_refclass_with_module }}', {{#with getDeepestRef}}{{> _helper_schema_python_types }}{{/with}}]{{else}}typing.Union[Schema_.{{jsonPathPiece.camelCase}}, {{> _helper_schema_python_types }}]{{/if}}{{/with}}
12+
],
13+
],
14+
{{/contains}}
15+
{{#contains types "object"}}
16+
*args_: typing.Union[{{> _helper_schema_python_types }}],
17+
{{/contains}}
18+
{{#contains types "string"}}
19+
arg_: {{> _helper_schema_python_types }},
20+
{{/contains}}
21+
{{#contains types "number"}}
22+
arg_: typing.Union[{{> _helper_schema_python_types }}],
23+
{{/contains}}
24+
{{#contains types "integer"}}
25+
arg_: {{> _helper_schema_python_types }},
26+
{{/contains}}
27+
{{#contains types "boolean"}}
28+
arg_: {{> _helper_schema_python_types }},
29+
{{/contains}}
30+
{{#contains types "null"}}
31+
arg_: {{> _helper_schema_python_types }},
32+
{{/contains}}
33+
{{else}}
34+
{{#contains types "object"}}
35+
*args_: typing.Union[{{> _helper_schema_python_types }}],
36+
{{else}}
37+
arg_: typing.Union[{{> _helper_schema_python_types }}],
38+
{{/contains}}
39+
{{/eq}}
40+
{{else}}
41+
*args_: typing.Union[{{> _helper_schema_python_types }}],
42+
{{/if}}
43+
{{#if types}}
44+
{{#eq types.size 1}}
45+
{{#contains types "object"}}
46+
{{#each requiredProperties}}
47+
{{#if @key.isValid}}
48+
{{#with this}}
49+
{{#if refInfo.refClass}}
50+
{{@key.original}}: typing.Union['{{> components/schemas/_helper_refclass_with_module }}', {{#with getDeepestRef}}{{> _helper_schema_python_types }}{{/with}}],
51+
{{else}}
52+
{{#if jsonPathPiece}}
53+
{{#if schemaIsFromAdditionalProperties}}
54+
{{@key.original}}: typing.Union[Schema_.{{jsonPathPiece.camelCase}}, {{> _helper_schema_python_types }}],
55+
{{else}}
56+
{{@key.original}}: typing.Union[Schema_.Properties.{{jsonPathPiece.camelCase}}, {{> _helper_schema_python_types }}],
57+
{{/if}}
58+
{{else}}
59+
{{@key.original}}: typing.Union[schemas.AnyTypeSchema, {{> _helper_schema_python_types }}],
60+
{{/if}}
61+
{{/if}}
62+
{{/with}}
63+
{{/if}}
64+
{{/each}}
65+
{{/contains}}
66+
{{/eq}}
67+
{{/if}}
68+
{{#each optionalProperties}}
69+
{{#if @key.isValid}}
70+
{{#if refInfo.refClass}}
71+
{{@key.original}}: typing.Union['{{> components/schemas/_helper_refclass_with_module }}', {{#with getDeepestRef}}{{> _helper_schema_python_types }}{{/with}}, schemas.Unset] = schemas.unset,
72+
{{else}}
73+
{{@key.original}}: typing.Union[Schema_.Properties.{{jsonPathPiece.camelCase}}, {{> _helper_schema_python_types }}, schemas.Unset] = schemas.unset,
74+
{{/if}}
75+
{{/if}}
76+
{{/each}}
77+
configuration_: typing.Optional[schemas.schema_configuration.SchemaConfiguration] = None,
78+
{{#with additionalProperties}}
79+
{{#unless isBooleanSchemaFalse}}
80+
{{#if refInfo.refClass}}
81+
**kwargs: typing.Union['{{> components/schemas/_helper_refclass_with_module }}', {{#with getDeepestRef}}{{> _helper_schema_python_types }}{{/with}}],
82+
{{else}}
83+
**kwargs: typing.Union[Schema_.{{jsonPathPiece.camelCase}}, {{> _helper_schema_python_types }}],
84+
{{/if}}
85+
{{/unless}}
86+
{{else}}
87+
{{#eq types null}}
88+
**kwargs: typing.Union[{{> components/schemas/_helper_types_all_incl_schema_oneline }}],
89+
{{else}}
90+
{{#contains types "object"}}
91+
**kwargs: typing.Union[{{> components/schemas/_helper_types_all_incl_schema_oneline }}],
92+
{{/contains}}
93+
{{/eq}}
94+
{{/with}}
95+
) -> {{#each identifierPieces}}{{#if this.camelCase}}{{this.camelCase}}{{else}}{{this}}{{/if}}{{#unless @last}}.{{else}}Typed.Dict.{{jsonPathPiece.camelCase}}[frozendict.frozendict]{{/unless}}{{/each}}:
96+
return super().__new__(
97+
cls,
98+
{{#eq types null}}
99+
*args_,
100+
{{else}}
101+
{{#contains types "object"}}
102+
*args_,
103+
{{else}}
104+
arg_,
105+
{{/contains}}
106+
{{/eq}}
107+
{{#if types}}
108+
{{#eq types.size 1}}
109+
{{#contains types "object"}}
110+
{{#each requiredProperties}}
111+
{{#if @key.isValid}}
112+
{{#with this}}
113+
{{@key.original}}={{@key.original}},
114+
{{/with}}
115+
{{/if}}
116+
{{/each}}
117+
{{/contains}}
118+
{{/eq}}
119+
{{/if}}
120+
{{#each optionalProperties}}
121+
{{#if @key.isValid}}
122+
{{@key.original}}={{@key.original}},
123+
{{/if}}
124+
{{/each}}
125+
configuration_=configuration_,
126+
{{#with additionalProperties}}
127+
{{#unless isBooleanSchemaFalse}}
128+
**kwargs,
129+
{{/unless}}
130+
{{else}}
131+
{{#eq types null}}
132+
**kwargs,
133+
{{else}}
134+
{{#contains types "object"}}
135+
**kwargs,
136+
{{/contains}}
137+
{{/eq}}
138+
{{/with}}
139+
)

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22

33
class {{jsonPathPiece.camelCase}}(
4-
schemas.DictSchema
4+
schemas.DictSchema[schemas.T]
55
):
66
{{#if componentModule}}
77
"""NOTE: This class is auto generated by OpenAPI JSON Schema Generator.
@@ -24,4 +24,11 @@ class {{jsonPathPiece.camelCase}}(
2424
{{/or}}
2525
{{> components/schemas/_helper_property_type_hints }}
2626

27-
{{> components/schemas/_helper_new }}
27+
{{> components/schemas/_helper_new_dict }}
28+
29+
_{{jsonPathPiece.camelCase}} = {{jsonPathPiece.camelCase}}
30+
31+
class {{jsonPathPiece.camelCase}}Typed:
32+
class Dict:
33+
class {{jsonPathPiece.camelCase}}(_{{jsonPathPiece.camelCase}}[schemas.T], frozendict.frozendict):
34+
pass

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
{{> _helper_imports }}
1111
{{> components/schemas/_helper_schema_switch_case identifierPieces=(append identifierPieces jsonPathPiece) }}
1212
{{else}}
13+
from __future__ import annotations
1314
from {{packageName}}.shared_imports.schema_imports import *
1415
{{> components/schemas/_helper_schema_switch_case identifierPieces=(append identifierPieces jsonPathPiece) }}
1516
{{#if imports}}

modules/openapi-json-schema-generator/src/test/resources/3_0/python/petstore_customized.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3243,8 +3243,6 @@ components:
32433243
description: Abstract Step
32443244
discriminator:
32453245
propertyName: discriminator
3246-
anyOf:
3247-
- $ref: '#/components/schemas/AbstractStepMessage'
32483246
ReqPropsFromUnsetAddProps:
32493247
required:
32503248
- validName

samples/openapi3/client/petstore/python/docs/components/schema/abstract_step_message.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,4 @@ Key | Input Type | Accessed Type | Description | Notes
1717
**sequenceNumber** | dict, frozendict.frozendict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, decimal.Decimal, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader | frozendict.frozendict, str, decimal.Decimal, BoolClass, NoneClass, tuple, bytes, io.FileIO | |
1818
**any_string_name** | dict, frozendict.frozendict, list, tuple, decimal.Decimal, float, int, str, datetime.date, datetime.datetime, uuid.UUID, bool, None, bytes, io.FileIO, io.BufferedReader, schemas.Schema | frozendict.frozendict, tuple, decimal.Decimal, str, bytes, BoolClass, NoneClass, FileIO | any string name can be used but the value must be the correct type | [optional]
1919

20-
## Composed Schemas (allOf/anyOf/oneOf/not)
21-
## anyOf
22-
Class Name | Input Type | Accessed Type | Description | Notes
23-
------------- | ------------- | ------------- | ------------- | -------------
24-
[**AbstractStepMessage**](#top) | [**AbstractStepMessage**](#top) | [**AbstractStepMessage**](#top) | |
25-
2620
[[Back to top]](#top) [[Back to Component Schemas]](../../../README.md#Component-Schemas) [[Back to README]](../../../README.md)

samples/openapi3/client/petstore/python/src/petstore_api/components/headers/header_int32_json_content_type_header/content/application_json/schema.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
Generated by: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator
88
"""
99

10+
from __future__ import annotations
1011
from petstore_api.shared_imports.schema_imports import *
1112
Schema = schemas.Int32Schema

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
Generated by: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator
88
"""
99

10+
from __future__ import annotations
1011
from petstore_api.shared_imports.schema_imports import *
1112
Schema = schemas.DecimalSchema

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
Generated by: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator
88
"""
99

10+
from __future__ import annotations
1011
from petstore_api.shared_imports.schema_imports import *
1112
Schema = schemas.StrSchema

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
Generated by: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator
88
"""
99

10+
from __future__ import annotations
1011
from petstore_api.shared_imports.schema_imports import *
1112
Schema = schemas.StrSchema

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
Generated by: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator
88
"""
99

10+
from __future__ import annotations
1011
from petstore_api.shared_imports.schema_imports import *
1112

1213

0 commit comments

Comments
 (0)