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

Commit b405635

Browse files
committed
Updates sample, type hints close to wrking i think
1 parent eb26ffe commit b405635

File tree

74 files changed

+3725
-691
lines changed

Some content is hidden

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

74 files changed

+3725
-691
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,10 @@ class BaseApi(api_client.Api):
376376
{{#if bodyParam}}
377377
{{#each getContentTypeToOperation}}
378378
{{> endpoint_args_baseapi_wrapper contentType=@key this=this}}
379+
379380
{{/each}}
381+
{{> endpoint_args_baseapi_wrapper contentType="null" this=this}}
382+
380383
{{else}}
381384
@typing.overload
382385
def _{{operationId}}_oapg(
@@ -541,7 +544,10 @@ class {{operationIdCamelCase}}(BaseApi):
541544
{{#if bodyParam}}
542545
{{#each getContentTypeToOperation}}
543546
{{> endpoint_args_operationid_wrapper contentType=@key this=this}}
547+
544548
{{/each}}
549+
{{> endpoint_args_operationid_wrapper contentType="null" this=this}}
550+
545551
{{else}}
546552
@typing.overload
547553
def {{operationId}}(
@@ -569,7 +575,10 @@ class ApiFor{{httpMethod}}(BaseApi):
569575
{{#if bodyParam}}
570576
{{#each getContentTypeToOperation}}
571577
{{> endpoint_args_httpmethod_wrapper contentType=@key this=this}}
578+
572579
{{/each}}
580+
{{> endpoint_args_httpmethod_wrapper contentType="null" this=this}}
581+
573582
{{else}}
574583
@typing.overload
575584
def {{httpMethod}}(

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

Lines changed: 56 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,75 @@
22
{{#if bodyParam}}
33
{{#if bodyParam.required}}
44
{{#with bodyParam}}
5-
body: typing.Union[{{#each content}}{{#eq key contentType }}{{#with this.schema}}{{baseName}},{{> model_templates/schema_python_types }}{{/with}}{{/eq}}{{/each}}],
5+
{{#eq ../contentType "null"}}
6+
body: typing.Union[{{#each getContent}}{{#with this.schema}}{{baseName}},{{> model_templates/schema_python_types }}{{/with}}{{/each}}],
7+
{{else}}
8+
body: typing.Union[{{#each getContent}}{{#eq @key ../../contentType }}{{#with this.schema}}{{baseName}},{{> model_templates/schema_python_types }}{{/with}}{{/eq}}{{/each}}],
9+
{{/eq}}
610
{{/with}}
711
{{#if isOverload}}
812
{{#eq skipDeserialization "True"}}
913
skip_deserialization: typing_extensions.Literal[True],
1014
{{/eq}}
15+
{{#neq contentType "null"}}
16+
{{#with bodyParam}}
17+
{{#each content}}
18+
{{#eq @key ../../contentType}}
19+
{{#if @first}}
20+
content_type: typing_extensions.Literal["{{{@key}}}"] = ...,
21+
{{else}}
22+
content_type: typing_extensions.Literal["{{{@key}}}"],
23+
{{/if}}
24+
{{/eq}}
25+
{{/each}}
26+
{{/with}}
27+
{{else}}
28+
content_type: str = ...,
29+
{{/neq}}
30+
{{else}}
31+
{{#with bodyParam}}
32+
{{#each getContent}}
33+
{{#if @first}}
34+
content_type: str = '{{{@key}}}',
35+
{{/if}}
36+
{{/each}}
37+
{{/with}}
1138
{{/if}}
1239
{{else}}
1340
{{#if isOverload}}
1441
{{#eq skipDeserialization "True"}}
1542
skip_deserialization: typing_extensions.Literal[True],
1643
{{/eq}}
44+
{{#neq contentType "null"}}
45+
{{#with bodyParam}}
46+
{{#each getContent}}
47+
{{#eq @key ../../contentType}}
48+
{{#if @first}}
49+
content_type: typing_extensions.Literal["{{{@key}}}"] = ...,
50+
{{else}}
51+
content_type: typing_extensions.Literal["{{{@key}}}"],
52+
{{/if}}
53+
{{/eq}}
54+
{{/each}}
55+
{{/with}}
56+
{{else}}
57+
content_type: str = ...,
58+
{{/neq}}
59+
{{else}}
60+
{{#with bodyParam}}
61+
{{#each getContent}}
62+
{{#if @first}}
63+
content_type: str = '{{{@key}}}',
64+
{{/if}}
65+
{{/each}}
66+
{{/with}}
1767
{{/if}}
1868
{{#with bodyParam}}
19-
body: typing.Union[{{#each content}}{{#eq key contentType }}{{#with this.schema}}{{baseName}}, {{> model_templates/schema_python_types }}{{/with}}{{/eq}}{{/each}}schemas.Unset] = schemas.unset,
69+
{{#eq ../contentType "null"}}
70+
body: typing.Union[{{#each getContent}}{{#with this.schema}}{{baseName}}, {{> model_templates/schema_python_types }}{{/with}}{{/each}}schemas.Unset] = schemas.unset,
71+
{{else}}
72+
body: typing.Union[{{#each getContent}}{{#eq @key ../../contentType }}{{#with this.schema}}{{baseName}}, {{> model_templates/schema_python_types }}{{/with}}{{/eq}}{{/each}}schemas.Unset] = schemas.unset,
73+
{{/eq}}
2074
{{/with}}
2175
{{/if}}
2276
{{/if}}
@@ -32,23 +86,6 @@
3286
{{#if cookieParams}}
3387
cookie_params: RequestCookieParams = frozendict.frozendict(),
3488
{{/if}}
35-
{{#if bodyParam}}
36-
{{#if isOverload}}
37-
{{#eq contentType "null"}}
38-
content_type: str = ...,
39-
{{else}}
40-
content_type: typing_extensions.Literal["{{{contentType}}}"] = "{{{contentType}}}",
41-
{{/eq}}
42-
{{else}}
43-
{{#with bodyParam}}
44-
{{#each content}}
45-
{{#if @first}}
46-
content_type: str = '{{{@key}}}',
47-
{{/if}}
48-
{{/each}}
49-
{{/with}}
50-
{{/if}}
51-
{{/if}}
5289
{{#if produces}}
5390
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
5491
{{/if}}

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

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class BaseApi(api_client.Api):
7272
def _call_123_test_special_tags_oapg(
7373
self,
7474
body: typing.Union[SchemaForRequestBodyApplicationJson,],
75-
content_type: typing_extensions.Literal["application/json"] = "application/json",
75+
content_type: typing_extensions.Literal["application/json"] = ...,
7676
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
7777
stream: bool = False,
7878
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
@@ -81,6 +81,20 @@ def _call_123_test_special_tags_oapg(
8181
ApiResponseFor200,
8282
]: ...
8383

84+
@typing.overload
85+
def _call_123_test_special_tags_oapg(
86+
self,
87+
body: typing.Union[SchemaForRequestBodyApplicationJson,],
88+
content_type: str = ...,
89+
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
90+
stream: bool = False,
91+
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
92+
skip_deserialization: typing_extensions.Literal[False] = ...,
93+
) -> typing.Union[
94+
ApiResponseFor200,
95+
]: ...
96+
97+
8498
@typing.overload
8599
def _call_123_test_special_tags_oapg(
86100
self,
@@ -172,7 +186,20 @@ class Call123TestSpecialTags(BaseApi):
172186
def call_123_test_special_tags(
173187
self,
174188
body: typing.Union[SchemaForRequestBodyApplicationJson,],
175-
content_type: typing_extensions.Literal["application/json"] = "application/json",
189+
content_type: typing_extensions.Literal["application/json"] = ...,
190+
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
191+
stream: bool = False,
192+
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
193+
skip_deserialization: typing_extensions.Literal[False] = ...,
194+
) -> typing.Union[
195+
ApiResponseFor200,
196+
]: ...
197+
198+
@typing.overload
199+
def call_123_test_special_tags(
200+
self,
201+
body: typing.Union[SchemaForRequestBodyApplicationJson,],
202+
content_type: str = ...,
176203
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
177204
stream: bool = False,
178205
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
@@ -181,6 +208,7 @@ def call_123_test_special_tags(
181208
ApiResponseFor200,
182209
]: ...
183210

211+
184212
@typing.overload
185213
def call_123_test_special_tags(
186214
self,
@@ -232,7 +260,7 @@ class ApiForpatch(BaseApi):
232260
def patch(
233261
self,
234262
body: typing.Union[SchemaForRequestBodyApplicationJson,],
235-
content_type: typing_extensions.Literal["application/json"] = "application/json",
263+
content_type: typing_extensions.Literal["application/json"] = ...,
236264
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
237265
stream: bool = False,
238266
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
@@ -241,6 +269,20 @@ def patch(
241269
ApiResponseFor200,
242270
]: ...
243271

272+
@typing.overload
273+
def patch(
274+
self,
275+
body: typing.Union[SchemaForRequestBodyApplicationJson,],
276+
content_type: str = ...,
277+
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
278+
stream: bool = False,
279+
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
280+
skip_deserialization: typing_extensions.Literal[False] = ...,
281+
) -> typing.Union[
282+
ApiResponseFor200,
283+
]: ...
284+
285+
244286
@typing.overload
245287
def patch(
246288
self,

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

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class BaseApi(api_client.Api):
6767
def _call_123_test_special_tags_oapg(
6868
self,
6969
body: typing.Union[SchemaForRequestBodyApplicationJson,],
70-
content_type: typing_extensions.Literal["application/json"] = "application/json",
70+
content_type: typing_extensions.Literal["application/json"] = ...,
7171
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
7272
stream: bool = False,
7373
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
@@ -76,6 +76,20 @@ class BaseApi(api_client.Api):
7676
ApiResponseFor200,
7777
]: ...
7878

79+
@typing.overload
80+
def _call_123_test_special_tags_oapg(
81+
self,
82+
body: typing.Union[SchemaForRequestBodyApplicationJson,],
83+
content_type: str = ...,
84+
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
85+
stream: bool = False,
86+
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
87+
skip_deserialization: typing_extensions.Literal[False] = ...,
88+
) -> typing.Union[
89+
ApiResponseFor200,
90+
]: ...
91+
92+
7993
@typing.overload
8094
def _call_123_test_special_tags_oapg(
8195
self,
@@ -167,7 +181,20 @@ class Call123TestSpecialTags(BaseApi):
167181
def call_123_test_special_tags(
168182
self,
169183
body: typing.Union[SchemaForRequestBodyApplicationJson,],
170-
content_type: typing_extensions.Literal["application/json"] = "application/json",
184+
content_type: typing_extensions.Literal["application/json"] = ...,
185+
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
186+
stream: bool = False,
187+
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
188+
skip_deserialization: typing_extensions.Literal[False] = ...,
189+
) -> typing.Union[
190+
ApiResponseFor200,
191+
]: ...
192+
193+
@typing.overload
194+
def call_123_test_special_tags(
195+
self,
196+
body: typing.Union[SchemaForRequestBodyApplicationJson,],
197+
content_type: str = ...,
171198
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
172199
stream: bool = False,
173200
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
@@ -176,6 +203,7 @@ class Call123TestSpecialTags(BaseApi):
176203
ApiResponseFor200,
177204
]: ...
178205

206+
179207
@typing.overload
180208
def call_123_test_special_tags(
181209
self,
@@ -227,7 +255,7 @@ class ApiForpatch(BaseApi):
227255
def patch(
228256
self,
229257
body: typing.Union[SchemaForRequestBodyApplicationJson,],
230-
content_type: typing_extensions.Literal["application/json"] = "application/json",
258+
content_type: typing_extensions.Literal["application/json"] = ...,
231259
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
232260
stream: bool = False,
233261
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
@@ -236,6 +264,20 @@ class ApiForpatch(BaseApi):
236264
ApiResponseFor200,
237265
]: ...
238266

267+
@typing.overload
268+
def patch(
269+
self,
270+
body: typing.Union[SchemaForRequestBodyApplicationJson,],
271+
content_type: str = ...,
272+
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
273+
stream: bool = False,
274+
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
275+
skip_deserialization: typing_extensions.Literal[False] = ...,
276+
) -> typing.Union[
277+
ApiResponseFor200,
278+
]: ...
279+
280+
239281
@typing.overload
240282
def patch(
241283
self,

0 commit comments

Comments
 (0)