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

Commit f99e312

Browse files
committed
Shortens operation body type hint template
1 parent 658854b commit f99e312

22 files changed

Lines changed: 17 additions & 487 deletions

File tree

modules/openapi-json-schema-generator/src/main/resources/python/paths/path/verb/_helper_operation_args_ref_body.hbs renamed to modules/openapi-json-schema-generator/src/main/resources/python/paths/path/verb/_helper_operation_args_body.hbs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,29 @@
11
{{#if refInfo}}
22
{{#with refInfo.ref}}
33
{{#eq fullRefModule "" }}
4-
{{> paths/path/verb/_helper_operation_args_ref_body fullRefModule=../refInfo.refModule }}
4+
{{> paths/path/verb/_helper_operation_args_body fullRefModule=../refInfo.refModule }}
55
{{else}}
6-
{{> paths/path/verb/_helper_operation_args_ref_body fullRefModule=(join fullRefModule ../refInfo.refModule ".") }}
6+
{{> paths/path/verb/_helper_operation_args_body fullRefModule=(join fullRefModule ../refInfo.refModule ".") }}
77
{{/eq}}
88
{{/with}}
99
{{else}}
1010
{{#eq required requiredValue}}
1111
body: typing.Union[
1212
{{#each content}}
1313
{{#with schema}}
14-
{{#if refInfo.refClass}}
15-
{{> components/schemas/_helper_schema_output_ref_type mode="unprefixed" fullRefModule=(join "request_body" fullRefModule "content" ../@key.snakeCase "schema" ".") endChar="," }}
14+
{{#eq fullRefModule null}}
15+
{{#if refInfo.refClass}}
16+
{{> components/schemas/_helper_schema_output_ref_type mode="unprefixed" fullRefModule=(join "request_body" "content" ../@key.snakeCase "schema" ".") endChar="," }}
17+
{{else}}
18+
{{> components/schemas/_helper_schema_output_type mode="unprefixed" fullRefModule=(join "request_body" "content" ../@key.snakeCase "schema" ".") endChar="," }}
19+
{{/if}}
1620
{{else}}
21+
{{#if refInfo.refClass}}
22+
{{> components/schemas/_helper_schema_output_ref_type mode="unprefixed" fullRefModule=(join "request_body" fullRefModule "content" ../@key.snakeCase "schema" ".") endChar="," }}
23+
{{else}}
1724
{{> components/schemas/_helper_schema_output_type mode="unprefixed" fullRefModule=(join "request_body" fullRefModule "content" ../@key.snakeCase "schema" ".") endChar="," }}
18-
{{/if}}
25+
{{/if}}
26+
{{/eq}}
1927
{{/with}}
2028
{{/each}}
2129
{{#unless required}}

modules/openapi-json-schema-generator/src/main/resources/python/paths/path/verb/_helper_operation_args_optional.hbs

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,9 @@
11
{{#if requestBody}}
22
{{#with requestBody}}
33
{{#if refInfo}}
4-
{{> paths/path/verb/_helper_operation_args_ref_body fullRefModule="" requiredValue=true }}
4+
{{> paths/path/verb/_helper_operation_args_body fullRefModule="" requiredValue=false }}
55
{{else}}
6-
{{#unless required}}
7-
body: typing.Union[
8-
{{#each content}}
9-
{{#with schema}}
10-
{{#if refInfo.refClass}}
11-
{{> components/schemas/_helper_schema_output_ref_type mode="unprefixed" fullRefModule=(join "request_body" "content" ../@key.snakeCase "schema" ".") endChar="," }}
12-
{{else}}
13-
{{> components/schemas/_helper_schema_output_type mode="unprefixed" fullRefModule=(join "request_body" "content" ../@key.snakeCase "schema" ".") endChar="," }}
14-
{{/if}}
15-
{{/with}}
16-
{{/each}}
17-
schemas.Unset,
18-
{{#each getContentSchemas}}
19-
{{> _helper_schema_python_types_newline }}
20-
{{/each}}
21-
] = schemas.unset,
22-
{{/unless}}
6+
{{> paths/path/verb/_helper_operation_args_body fullRefModule=null requiredValue=false }}
237
{{/if}}
248
{{/with}}
259
{{/if}}

modules/openapi-json-schema-generator/src/main/resources/python/paths/path/verb/_helper_operation_args_required.hbs

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,9 @@
11
{{#if requestBody}}
22
{{#with requestBody}}
33
{{#if refInfo}}
4-
{{> paths/path/verb/_helper_operation_args_ref_body fullRefModule="" requiredValue=true }}
4+
{{> paths/path/verb/_helper_operation_args_body fullRefModule="" requiredValue=true }}
55
{{else}}
6-
{{#if required}}
7-
body: typing.Union[
8-
{{#each content}}
9-
{{#with schema}}
10-
{{#if refInfo.refClass}}
11-
{{> components/schemas/_helper_schema_output_ref_type mode="unprefixed" fullRefModule=(join "request_body" "content" ../@key.snakeCase "schema" ".") endChar="," }}
12-
{{else}}
13-
{{> components/schemas/_helper_schema_output_type mode="unprefixed" fullRefModule=(join "request_body" "content" ../@key.snakeCase "schema" ".") endChar="," }}
14-
{{/if}}
15-
{{/with}}
16-
{{/each}}
17-
{{#each getContentSchemas}}
18-
{{> _helper_schema_python_types_newline }}
19-
{{/each}}
20-
],
21-
{{/if}}
6+
{{> paths/path/verb/_helper_operation_args_body fullRefModule=null requiredValue=true }}
227
{{/if}}
238
{{/with}}
249
{{/if}}

samples/openapi3/client/petstore/python/src/petstore_api/paths/another_fake_dummy/patch/operation.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,6 @@ def _call_123_test__special_tags(
3737
dict,
3838
immutabledict.immutabledict
3939
],
40-
body: typing.Union[
41-
request_body.request_body_client.content.application_json.schema.client.ClientDict,
42-
dict,
43-
immutabledict.immutabledict
44-
],
4540
content_type: typing_extensions.Literal["application/json"] = "application/json",
4641
accept_content_types: typing.Tuple[str, ...] = _all_accept_content_types,
4742
server_index: typing.Optional[int] = None,
@@ -58,11 +53,6 @@ def _call_123_test__special_tags(
5853
dict,
5954
immutabledict.immutabledict
6055
],
61-
body: typing.Union[
62-
request_body.request_body_client.content.application_json.schema.client.ClientDict,
63-
dict,
64-
immutabledict.immutabledict
65-
],
6656
content_type: typing_extensions.Literal["application/json"] = "application/json",
6757
accept_content_types: typing.Tuple[str, ...] = _all_accept_content_types,
6858
server_index: typing.Optional[int] = None,
@@ -78,11 +68,6 @@ def _call_123_test__special_tags(
7868
dict,
7969
immutabledict.immutabledict
8070
],
81-
body: typing.Union[
82-
request_body.request_body_client.content.application_json.schema.client.ClientDict,
83-
dict,
84-
immutabledict.immutabledict
85-
],
8671
content_type: typing_extensions.Literal["application/json"] = "application/json",
8772
accept_content_types: typing.Tuple[str, ...] = _all_accept_content_types,
8873
server_index: typing.Optional[int] = None,

samples/openapi3/client/petstore/python/src/petstore_api/paths/fake/get/operation.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,6 @@ class BaseApi(api_client.Api):
9999
@typing.overload
100100
def _enum_parameters(
101101
self,
102-
body: typing.Union[
103-
request_body.content.application_x_www_form_urlencoded.schema.SchemaDict,
104-
schemas.Unset,
105-
dict,
106-
immutabledict.immutabledict
107-
] = schemas.unset,
108102
query_params: typing.Optional[RequestQueryParameters.Params] = None,
109103
header_params: typing.Optional[RequestHeaderParameters.Params] = None,
110104
content_type: typing_extensions.Literal["application/x-www-form-urlencoded"] = "application/x-www-form-urlencoded",
@@ -118,12 +112,6 @@ def _enum_parameters(
118112
@typing.overload
119113
def _enum_parameters(
120114
self,
121-
body: typing.Union[
122-
request_body.content.application_x_www_form_urlencoded.schema.SchemaDict,
123-
schemas.Unset,
124-
dict,
125-
immutabledict.immutabledict
126-
] = schemas.unset,
127115
query_params: typing.Optional[RequestQueryParameters.Params] = None,
128116
header_params: typing.Optional[RequestHeaderParameters.Params] = None,
129117
content_type: typing_extensions.Literal["application/x-www-form-urlencoded"] = "application/x-www-form-urlencoded",
@@ -136,12 +124,6 @@ def _enum_parameters(
136124

137125
def _enum_parameters(
138126
self,
139-
body: typing.Union[
140-
request_body.content.application_x_www_form_urlencoded.schema.SchemaDict,
141-
schemas.Unset,
142-
dict,
143-
immutabledict.immutabledict
144-
] = schemas.unset,
145127
query_params: typing.Optional[RequestQueryParameters.Params] = None,
146128
header_params: typing.Optional[RequestHeaderParameters.Params] = None,
147129
content_type: typing_extensions.Literal["application/x-www-form-urlencoded"] = "application/x-www-form-urlencoded",

samples/openapi3/client/petstore/python/src/petstore_api/paths/fake/patch/operation.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,6 @@ def _client_model(
3737
dict,
3838
immutabledict.immutabledict
3939
],
40-
body: typing.Union[
41-
request_body.request_body_client.content.application_json.schema.client.ClientDict,
42-
dict,
43-
immutabledict.immutabledict
44-
],
4540
content_type: typing_extensions.Literal["application/json"] = "application/json",
4641
accept_content_types: typing.Tuple[str, ...] = _all_accept_content_types,
4742
server_index: typing.Optional[int] = None,
@@ -58,11 +53,6 @@ def _client_model(
5853
dict,
5954
immutabledict.immutabledict
6055
],
61-
body: typing.Union[
62-
request_body.request_body_client.content.application_json.schema.client.ClientDict,
63-
dict,
64-
immutabledict.immutabledict
65-
],
6656
content_type: typing_extensions.Literal["application/json"] = "application/json",
6757
accept_content_types: typing.Tuple[str, ...] = _all_accept_content_types,
6858
server_index: typing.Optional[int] = None,
@@ -78,11 +68,6 @@ def _client_model(
7868
dict,
7969
immutabledict.immutabledict
8070
],
81-
body: typing.Union[
82-
request_body.request_body_client.content.application_json.schema.client.ClientDict,
83-
dict,
84-
immutabledict.immutabledict
85-
],
8671
content_type: typing_extensions.Literal["application/json"] = "application/json",
8772
accept_content_types: typing.Tuple[str, ...] = _all_accept_content_types,
8873
server_index: typing.Optional[int] = None,

samples/openapi3/client/petstore/python/src/petstore_api/paths/fake/post/operation.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,6 @@ class BaseApi(api_client.Api):
3838
@typing.overload
3939
def _endpoint_parameters(
4040
self,
41-
body: typing.Union[
42-
request_body.content.application_x_www_form_urlencoded.schema.SchemaDict,
43-
schemas.Unset,
44-
dict,
45-
immutabledict.immutabledict
46-
] = schemas.unset,
4741
content_type: typing_extensions.Literal["application/x-www-form-urlencoded"] = "application/x-www-form-urlencoded",
4842
security_index: typing.Optional[int] = None,
4943
server_index: typing.Optional[int] = None,
@@ -55,12 +49,6 @@ def _endpoint_parameters(
5549
@typing.overload
5650
def _endpoint_parameters(
5751
self,
58-
body: typing.Union[
59-
request_body.content.application_x_www_form_urlencoded.schema.SchemaDict,
60-
schemas.Unset,
61-
dict,
62-
immutabledict.immutabledict
63-
] = schemas.unset,
6452
content_type: typing_extensions.Literal["application/x-www-form-urlencoded"] = "application/x-www-form-urlencoded",
6553
security_index: typing.Optional[int] = None,
6654
server_index: typing.Optional[int] = None,
@@ -71,12 +59,6 @@ def _endpoint_parameters(
7159

7260
def _endpoint_parameters(
7361
self,
74-
body: typing.Union[
75-
request_body.content.application_x_www_form_urlencoded.schema.SchemaDict,
76-
schemas.Unset,
77-
dict,
78-
immutabledict.immutabledict
79-
] = schemas.unset,
8062
content_type: typing_extensions.Literal["application/x-www-form-urlencoded"] = "application/x-www-form-urlencoded",
8163
security_index: typing.Optional[int] = None,
8264
server_index: typing.Optional[int] = None,

samples/openapi3/client/petstore/python/src/petstore_api/paths/fake_classname_test/patch/operation.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,6 @@ def _classname(
4242
dict,
4343
immutabledict.immutabledict
4444
],
45-
body: typing.Union[
46-
request_body.request_body_client.content.application_json.schema.client.ClientDict,
47-
dict,
48-
immutabledict.immutabledict
49-
],
5045
content_type: typing_extensions.Literal["application/json"] = "application/json",
5146
accept_content_types: typing.Tuple[str, ...] = _all_accept_content_types,
5247
security_index: typing.Optional[int] = None,
@@ -64,11 +59,6 @@ def _classname(
6459
dict,
6560
immutabledict.immutabledict
6661
],
67-
body: typing.Union[
68-
request_body.request_body_client.content.application_json.schema.client.ClientDict,
69-
dict,
70-
immutabledict.immutabledict
71-
],
7262
content_type: typing_extensions.Literal["application/json"] = "application/json",
7363
accept_content_types: typing.Tuple[str, ...] = _all_accept_content_types,
7464
security_index: typing.Optional[int] = None,
@@ -85,11 +75,6 @@ def _classname(
8575
dict,
8676
immutabledict.immutabledict
8777
],
88-
body: typing.Union[
89-
request_body.request_body_client.content.application_json.schema.client.ClientDict,
90-
dict,
91-
immutabledict.immutabledict
92-
],
9378
content_type: typing_extensions.Literal["application/json"] = "application/json",
9479
accept_content_types: typing.Tuple[str, ...] = _all_accept_content_types,
9580
security_index: typing.Optional[int] = None,

samples/openapi3/client/petstore/python/src/petstore_api/paths/fake_inline_composition/post/operation.py

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -62,26 +62,6 @@ class BaseApi(api_client.Api):
6262
@typing.overload
6363
def _inline_composition(
6464
self,
65-
body: typing.Union[
66-
schemas.OUTPUT_BASE_TYPES,
67-
request_body.content.multipart_form_data.schema.SchemaDict,
68-
schemas.Unset,
69-
dict,
70-
immutabledict.immutabledict,
71-
str,
72-
datetime.date,
73-
datetime.datetime,
74-
uuid.UUID,
75-
int,
76-
float,
77-
bool,
78-
None,
79-
list,
80-
tuple,
81-
bytes,
82-
io.FileIO,
83-
io.BufferedReader
84-
] = schemas.unset,
8565
query_params: typing.Optional[RequestQueryParameters.Params] = None,
8666
content_type: typing_extensions.Literal[
8767
"application/json",
@@ -97,26 +77,6 @@ def _inline_composition(
9777
@typing.overload
9878
def _inline_composition(
9979
self,
100-
body: typing.Union[
101-
schemas.OUTPUT_BASE_TYPES,
102-
request_body.content.multipart_form_data.schema.SchemaDict,
103-
schemas.Unset,
104-
dict,
105-
immutabledict.immutabledict,
106-
str,
107-
datetime.date,
108-
datetime.datetime,
109-
uuid.UUID,
110-
int,
111-
float,
112-
bool,
113-
None,
114-
list,
115-
tuple,
116-
bytes,
117-
io.FileIO,
118-
io.BufferedReader
119-
] = schemas.unset,
12080
query_params: typing.Optional[RequestQueryParameters.Params] = None,
12181
content_type: typing_extensions.Literal[
12282
"application/json",
@@ -131,26 +91,6 @@ def _inline_composition(
13191

13292
def _inline_composition(
13393
self,
134-
body: typing.Union[
135-
schemas.OUTPUT_BASE_TYPES,
136-
request_body.content.multipart_form_data.schema.SchemaDict,
137-
schemas.Unset,
138-
dict,
139-
immutabledict.immutabledict,
140-
str,
141-
datetime.date,
142-
datetime.datetime,
143-
uuid.UUID,
144-
int,
145-
float,
146-
bool,
147-
None,
148-
list,
149-
tuple,
150-
bytes,
151-
io.FileIO,
152-
io.BufferedReader
153-
] = schemas.unset,
15494
query_params: typing.Optional[RequestQueryParameters.Params] = None,
15595
content_type: typing_extensions.Literal[
15696
"application/json",

samples/openapi3/client/petstore/python/src/petstore_api/paths/fake_json_form_data/get/operation.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,6 @@ class BaseApi(api_client.Api):
2828
@typing.overload
2929
def _json_form_data(
3030
self,
31-
body: typing.Union[
32-
request_body.content.application_x_www_form_urlencoded.schema.SchemaDict,
33-
schemas.Unset,
34-
dict,
35-
immutabledict.immutabledict
36-
] = schemas.unset,
3731
content_type: typing_extensions.Literal["application/x-www-form-urlencoded"] = "application/x-www-form-urlencoded",
3832
server_index: typing.Optional[int] = None,
3933
stream: bool = False,
@@ -44,12 +38,6 @@ def _json_form_data(
4438
@typing.overload
4539
def _json_form_data(
4640
self,
47-
body: typing.Union[
48-
request_body.content.application_x_www_form_urlencoded.schema.SchemaDict,
49-
schemas.Unset,
50-
dict,
51-
immutabledict.immutabledict
52-
] = schemas.unset,
5341
content_type: typing_extensions.Literal["application/x-www-form-urlencoded"] = "application/x-www-form-urlencoded",
5442
server_index: typing.Optional[int] = None,
5543
stream: bool = False,
@@ -59,12 +47,6 @@ def _json_form_data(
5947

6048
def _json_form_data(
6149
self,
62-
body: typing.Union[
63-
request_body.content.application_x_www_form_urlencoded.schema.SchemaDict,
64-
schemas.Unset,
65-
dict,
66-
immutabledict.immutabledict
67-
] = schemas.unset,
6850
content_type: typing_extensions.Literal["application/x-www-form-urlencoded"] = "application/x-www-form-urlencoded",
6951
server_index: typing.Optional[int] = None,
7052
stream: bool = False,

0 commit comments

Comments
 (0)