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

Commit a4507c0

Browse files
committed
Add overload for endpoint
1 parent 94745a3 commit a4507c0

File tree

115 files changed

+8946
-252
lines changed

Some content is hidden

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

115 files changed

+8946
-252
lines changed

modules/openapi-json-schema-generator/src/main/resources/python/endpoint.handlebars

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,14 @@ _all_accept_content_types = (
386386

387387
class BaseApi(api_client.Api):
388388

389+
@typing.overload
390+
def _{{operationId}}_oapg(
391+
{{> endpoint_args_overload selfType="api_client.Api" isSkip=false}}
392+
393+
@typing.overload
394+
def _{{operationId}}_oapg(
395+
{{> endpoint_args_overload selfType="api_client.Api" isSkip=true}}
396+
389397
def _{{operationId}}_oapg(
390398
{{> endpoint_args selfType="api_client.Api" }}
391399
"""
@@ -533,6 +541,14 @@ class BaseApi(api_client.Api):
533541
class {{operationIdCamelCase}}(BaseApi):
534542
# this class is used by api classes that refer to endpoints with operationId fn names
535543

544+
@typing.overload
545+
def {{operationId}}(
546+
{{> endpoint_args_overload selfType="api_client.Api" isSkip=false}}
547+
548+
@typing.overload
549+
def {{operationId}}(
550+
{{> endpoint_args_overload selfType="api_client.Api" isSkip=true}}
551+
536552
def {{operationId}}(
537553
{{> endpoint_args selfType="BaseApi" }}
538554
return self._{{operationId}}_oapg(
@@ -543,6 +559,14 @@ class {{operationIdCamelCase}}(BaseApi):
543559
class ApiFor{{httpMethod}}(BaseApi):
544560
# this class is used by api classes that refer to endpoints by path and http method names
545561

562+
@typing.overload
563+
def {{httpMethod}}(
564+
{{> endpoint_args_overload selfType="api_client.Api" isSkip=false}}
565+
566+
@typing.overload
567+
def {{httpMethod}}(
568+
{{> endpoint_args_overload selfType="api_client.Api" isSkip=true}}
569+
546570
def {{httpMethod}}(
547571
{{> endpoint_args selfType="BaseApi" }}
548572
return self._{{operationId}}_oapg(

modules/openapi-json-schema-generator/src/main/resources/python/endpoint_args.handlebars

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
{{#if is2xx}}
4141
ApiResponseFor{{code}},
4242
{{/if}}
43+
{{else}}
44+
api_client.ApiResponse,
4345
{{/if}}
4446
{{/each}}
4547
api_client.ApiResponseWithoutDeserialization
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
self: {{selfType}},
2+
{{#if bodyParam}}
3+
{{#with bodyParam}}
4+
body: typing.Union[{{#each content}}{{#with this.schema}}{{baseName}}, {{> model_templates/schema_python_types }}{{/with}}{{/each}}{{#unless required}}schemas.Unset] = schemas.unset{{else}}]{{/unless}},
5+
{{/with}}
6+
{{/if}}
7+
{{#if queryParams}}
8+
query_params: RequestQueryParams = frozendict.frozendict(),
9+
{{/if}}
10+
{{#if headerParams}}
11+
header_params: RequestHeaderParams = frozendict.frozendict(),
12+
{{/if}}
13+
{{#if pathParams}}
14+
path_params: RequestPathParams = frozendict.frozendict(),
15+
{{/if}}
16+
{{#if cookieParams}}
17+
cookie_params: RequestCookieParams = frozendict.frozendict(),
18+
{{/if}}
19+
{{#with bodyParam}}
20+
{{#each content}}
21+
{{#if @first}}
22+
content_type: str = '{{{@key}}}',
23+
{{/if}}
24+
{{/each}}
25+
{{/with}}
26+
{{#if produces}}
27+
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
28+
{{/if}}
29+
{{#if servers}}
30+
host_index: typing.Optional[int] = None,
31+
{{/if}}
32+
stream: bool = False,
33+
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
34+
skip_deserialization: typing_extensions.Literal[{{#if isSkip}}True{{else}}False{{/if}}] = {{#if isSkip}}True{{else}}False{{/if}},
35+
{{#if isSkip}}
36+
) -> api_client.ApiResponseWithoutDeserialization:
37+
{{else}}
38+
) -> typing.Union[
39+
{{#each responses}}
40+
{{#if isDefault}}
41+
ApiResponseForDefault,
42+
{{else}}
43+
{{#if is2xx}}
44+
ApiResponseFor{{code}},
45+
{{/if}}
46+
{{else}}
47+
api_client.ApiResponse,
48+
{{/if}}
49+
{{/each}}
50+
]:
51+
{{/if}}
52+
...

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

Lines changed: 81 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,32 @@ class ApiResponseFor200(api_client.ApiResponse):
6969

7070
class BaseApi(api_client.Api):
7171

72+
@typing.overload
73+
def _call_123_test_special_tags_oapg(
74+
self: api_client.Api,
75+
body: typing.Union[SchemaForRequestBodyApplicationJson, ],
76+
content_type: str = 'application/json',
77+
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
78+
stream: bool = False,
79+
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
80+
skip_deserialization: typing_extensions.Literal[False] = False,
81+
) -> typing.Union[
82+
api_client.ApiResponse,
83+
]:
84+
...
85+
86+
@typing.overload
87+
def _call_123_test_special_tags_oapg(
88+
self: api_client.Api,
89+
body: typing.Union[SchemaForRequestBodyApplicationJson, ],
90+
content_type: str = 'application/json',
91+
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
92+
stream: bool = False,
93+
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
94+
skip_deserialization: typing_extensions.Literal[True] = True,
95+
) -> api_client.ApiResponseWithoutDeserialization:
96+
...
97+
7298
def _call_123_test_special_tags_oapg(
7399
self: api_client.Api,
74100
body: typing.Union[SchemaForRequestBodyApplicationJson, ],
@@ -78,7 +104,7 @@ def _call_123_test_special_tags_oapg(
78104
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
79105
skip_deserialization: bool = False,
80106
) -> typing.Union[
81-
ApiResponseFor200,
107+
api_client.ApiResponse,
82108
api_client.ApiResponseWithoutDeserialization
83109
]:
84110
"""
@@ -134,6 +160,32 @@ class instances
134160
class Call123TestSpecialTags(BaseApi):
135161
# this class is used by api classes that refer to endpoints with operationId fn names
136162

163+
@typing.overload
164+
def call_123_test_special_tags(
165+
self: api_client.Api,
166+
body: typing.Union[SchemaForRequestBodyApplicationJson, ],
167+
content_type: str = 'application/json',
168+
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
169+
stream: bool = False,
170+
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
171+
skip_deserialization: typing_extensions.Literal[False] = False,
172+
) -> typing.Union[
173+
api_client.ApiResponse,
174+
]:
175+
...
176+
177+
@typing.overload
178+
def call_123_test_special_tags(
179+
self: api_client.Api,
180+
body: typing.Union[SchemaForRequestBodyApplicationJson, ],
181+
content_type: str = 'application/json',
182+
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
183+
stream: bool = False,
184+
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
185+
skip_deserialization: typing_extensions.Literal[True] = True,
186+
) -> api_client.ApiResponseWithoutDeserialization:
187+
...
188+
137189
def call_123_test_special_tags(
138190
self: BaseApi,
139191
body: typing.Union[SchemaForRequestBodyApplicationJson, ],
@@ -143,7 +195,7 @@ def call_123_test_special_tags(
143195
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
144196
skip_deserialization: bool = False,
145197
) -> typing.Union[
146-
ApiResponseFor200,
198+
api_client.ApiResponse,
147199
api_client.ApiResponseWithoutDeserialization
148200
]:
149201
return self._call_123_test_special_tags_oapg(
@@ -159,6 +211,32 @@ def call_123_test_special_tags(
159211
class ApiForpatch(BaseApi):
160212
# this class is used by api classes that refer to endpoints by path and http method names
161213

214+
@typing.overload
215+
def patch(
216+
self: api_client.Api,
217+
body: typing.Union[SchemaForRequestBodyApplicationJson, ],
218+
content_type: str = 'application/json',
219+
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
220+
stream: bool = False,
221+
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
222+
skip_deserialization: typing_extensions.Literal[False] = False,
223+
) -> typing.Union[
224+
api_client.ApiResponse,
225+
]:
226+
...
227+
228+
@typing.overload
229+
def patch(
230+
self: api_client.Api,
231+
body: typing.Union[SchemaForRequestBodyApplicationJson, ],
232+
content_type: str = 'application/json',
233+
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
234+
stream: bool = False,
235+
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
236+
skip_deserialization: typing_extensions.Literal[True] = True,
237+
) -> api_client.ApiResponseWithoutDeserialization:
238+
...
239+
162240
def patch(
163241
self: BaseApi,
164242
body: typing.Union[SchemaForRequestBodyApplicationJson, ],
@@ -168,7 +246,7 @@ def patch(
168246
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
169247
skip_deserialization: bool = False,
170248
) -> typing.Union[
171-
ApiResponseFor200,
249+
api_client.ApiResponse,
172250
api_client.ApiResponseWithoutDeserialization
173251
]:
174252
return self._call_123_test_special_tags_oapg(

samples/openapi3/client/petstore/python/petstore_api/paths/another_fake_dummy/patch.pyi

Lines changed: 81 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,32 @@ _all_accept_content_types = (
3737

3838
class BaseApi(api_client.Api):
3939

40+
@typing.overload
41+
def _call_123_test_special_tags_oapg(
42+
self: api_client.Api,
43+
body: typing.Union[SchemaForRequestBodyApplicationJson, ],
44+
content_type: str = 'application/json',
45+
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
46+
stream: bool = False,
47+
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
48+
skip_deserialization: typing_extensions.Literal[False] = False,
49+
) -> typing.Union[
50+
api_client.ApiResponse,
51+
]:
52+
...
53+
54+
@typing.overload
55+
def _call_123_test_special_tags_oapg(
56+
self: api_client.Api,
57+
body: typing.Union[SchemaForRequestBodyApplicationJson, ],
58+
content_type: str = 'application/json',
59+
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
60+
stream: bool = False,
61+
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
62+
skip_deserialization: typing_extensions.Literal[True] = True,
63+
) -> api_client.ApiResponseWithoutDeserialization:
64+
...
65+
4066
def _call_123_test_special_tags_oapg(
4167
self: api_client.Api,
4268
body: typing.Union[SchemaForRequestBodyApplicationJson, ],
@@ -46,7 +72,7 @@ class BaseApi(api_client.Api):
4672
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
4773
skip_deserialization: bool = False,
4874
) -> typing.Union[
49-
ApiResponseFor200,
75+
api_client.ApiResponse,
5076
api_client.ApiResponseWithoutDeserialization
5177
]:
5278
"""
@@ -102,6 +128,32 @@ class BaseApi(api_client.Api):
102128
class Call123TestSpecialTags(BaseApi):
103129
# this class is used by api classes that refer to endpoints with operationId fn names
104130

131+
@typing.overload
132+
def call_123_test_special_tags(
133+
self: api_client.Api,
134+
body: typing.Union[SchemaForRequestBodyApplicationJson, ],
135+
content_type: str = 'application/json',
136+
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
137+
stream: bool = False,
138+
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
139+
skip_deserialization: typing_extensions.Literal[False] = False,
140+
) -> typing.Union[
141+
api_client.ApiResponse,
142+
]:
143+
...
144+
145+
@typing.overload
146+
def call_123_test_special_tags(
147+
self: api_client.Api,
148+
body: typing.Union[SchemaForRequestBodyApplicationJson, ],
149+
content_type: str = 'application/json',
150+
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
151+
stream: bool = False,
152+
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
153+
skip_deserialization: typing_extensions.Literal[True] = True,
154+
) -> api_client.ApiResponseWithoutDeserialization:
155+
...
156+
105157
def call_123_test_special_tags(
106158
self: BaseApi,
107159
body: typing.Union[SchemaForRequestBodyApplicationJson, ],
@@ -111,7 +163,7 @@ class Call123TestSpecialTags(BaseApi):
111163
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
112164
skip_deserialization: bool = False,
113165
) -> typing.Union[
114-
ApiResponseFor200,
166+
api_client.ApiResponse,
115167
api_client.ApiResponseWithoutDeserialization
116168
]:
117169
return self._call_123_test_special_tags_oapg(
@@ -127,6 +179,32 @@ class Call123TestSpecialTags(BaseApi):
127179
class ApiForpatch(BaseApi):
128180
# this class is used by api classes that refer to endpoints by path and http method names
129181

182+
@typing.overload
183+
def patch(
184+
self: api_client.Api,
185+
body: typing.Union[SchemaForRequestBodyApplicationJson, ],
186+
content_type: str = 'application/json',
187+
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
188+
stream: bool = False,
189+
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
190+
skip_deserialization: typing_extensions.Literal[False] = False,
191+
) -> typing.Union[
192+
api_client.ApiResponse,
193+
]:
194+
...
195+
196+
@typing.overload
197+
def patch(
198+
self: api_client.Api,
199+
body: typing.Union[SchemaForRequestBodyApplicationJson, ],
200+
content_type: str = 'application/json',
201+
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
202+
stream: bool = False,
203+
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
204+
skip_deserialization: typing_extensions.Literal[True] = True,
205+
) -> api_client.ApiResponseWithoutDeserialization:
206+
...
207+
130208
def patch(
131209
self: BaseApi,
132210
body: typing.Union[SchemaForRequestBodyApplicationJson, ],
@@ -136,7 +214,7 @@ class ApiForpatch(BaseApi):
136214
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
137215
skip_deserialization: bool = False,
138216
) -> typing.Union[
139-
ApiResponseFor200,
217+
api_client.ApiResponse,
140218
api_client.ApiResponseWithoutDeserialization
141219
]:
142220
return self._call_123_test_special_tags_oapg(

0 commit comments

Comments
 (0)