Skip to content

Commit 2b6b3b0

Browse files
[python] Do not pydantic-validate function args twice (#16776)
* refactor: Use newlines in _with_http_info call This prevents too-long lines and matches the style that black would enforce. * fix: Do not pydantic-validate function args twice Closes #15757
1 parent bbf9ccd commit 2b6b3b0

27 files changed

Lines changed: 769 additions & 133 deletions

File tree

modules/openapi-generator/src/main/resources/python/api.mustache

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,13 @@ class {{classname}}:
8888
if '_preload_content' in kwargs:
8989
message = "Error! Please call the {{operationId}}_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501
9090
raise ValueError(message)
91-
return {{#asyncio}}await {{/asyncio}}self.{{operationId}}_with_http_info({{#allParams}}{{paramName}}, {{/allParams}}**kwargs) # noqa: E501
91+
92+
return {{#asyncio}}await {{/asyncio}}self.{{operationId}}_with_http_info.raw_function(
93+
{{#allParams}}
94+
{{paramName}},
95+
{{/allParams}}
96+
**kwargs,
97+
)
9298

9399
@validate_call
94100
{{#asyncio}}

samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/auth_api.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ def test_auth_http_basic(
7070
if '_preload_content' in kwargs:
7171
message = "Error! Please call the test_auth_http_basic_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501
7272
raise ValueError(message)
73-
return self.test_auth_http_basic_with_http_info(**kwargs) # noqa: E501
73+
74+
return self.test_auth_http_basic_with_http_info.raw_function(
75+
**kwargs,
76+
)
7477

7578
@validate_call
7679
def test_auth_http_basic_with_http_info(

samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/body_api.py

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,10 @@ def test_binary_gif(
7878
if '_preload_content' in kwargs:
7979
message = "Error! Please call the test_binary_gif_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501
8080
raise ValueError(message)
81-
return self.test_binary_gif_with_http_info(**kwargs) # noqa: E501
81+
82+
return self.test_binary_gif_with_http_info.raw_function(
83+
**kwargs,
84+
)
8285

8386
@validate_call
8487
def test_binary_gif_with_http_info(
@@ -219,7 +222,11 @@ def test_body_application_octetstream_binary(
219222
if '_preload_content' in kwargs:
220223
message = "Error! Please call the test_body_application_octetstream_binary_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501
221224
raise ValueError(message)
222-
return self.test_body_application_octetstream_binary_with_http_info(body, **kwargs) # noqa: E501
225+
226+
return self.test_body_application_octetstream_binary_with_http_info.raw_function(
227+
body,
228+
**kwargs,
229+
)
223230

224231
@validate_call
225232
def test_body_application_octetstream_binary_with_http_info(
@@ -379,7 +386,11 @@ def test_body_multipart_formdata_array_of_binary(
379386
if '_preload_content' in kwargs:
380387
message = "Error! Please call the test_body_multipart_formdata_array_of_binary_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501
381388
raise ValueError(message)
382-
return self.test_body_multipart_formdata_array_of_binary_with_http_info(files, **kwargs) # noqa: E501
389+
390+
return self.test_body_multipart_formdata_array_of_binary_with_http_info.raw_function(
391+
files,
392+
**kwargs,
393+
)
383394

384395
@validate_call
385396
def test_body_multipart_formdata_array_of_binary_with_http_info(
@@ -535,7 +546,11 @@ def test_echo_body_free_form_object_response_string(
535546
if '_preload_content' in kwargs:
536547
message = "Error! Please call the test_echo_body_free_form_object_response_string_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501
537548
raise ValueError(message)
538-
return self.test_echo_body_free_form_object_response_string_with_http_info(body, **kwargs) # noqa: E501
549+
550+
return self.test_echo_body_free_form_object_response_string_with_http_info.raw_function(
551+
body,
552+
**kwargs,
553+
)
539554

540555
@validate_call
541556
def test_echo_body_free_form_object_response_string_with_http_info(
@@ -690,7 +705,11 @@ def test_echo_body_pet(
690705
if '_preload_content' in kwargs:
691706
message = "Error! Please call the test_echo_body_pet_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501
692707
raise ValueError(message)
693-
return self.test_echo_body_pet_with_http_info(pet, **kwargs) # noqa: E501
708+
709+
return self.test_echo_body_pet_with_http_info.raw_function(
710+
pet,
711+
**kwargs,
712+
)
694713

695714
@validate_call
696715
def test_echo_body_pet_with_http_info(
@@ -845,7 +864,11 @@ def test_echo_body_pet_response_string(
845864
if '_preload_content' in kwargs:
846865
message = "Error! Please call the test_echo_body_pet_response_string_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501
847866
raise ValueError(message)
848-
return self.test_echo_body_pet_response_string_with_http_info(pet, **kwargs) # noqa: E501
867+
868+
return self.test_echo_body_pet_response_string_with_http_info.raw_function(
869+
pet,
870+
**kwargs,
871+
)
849872

850873
@validate_call
851874
def test_echo_body_pet_response_string_with_http_info(
@@ -1000,7 +1023,11 @@ def test_echo_body_tag_response_string(
10001023
if '_preload_content' in kwargs:
10011024
message = "Error! Please call the test_echo_body_tag_response_string_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501
10021025
raise ValueError(message)
1003-
return self.test_echo_body_tag_response_string_with_http_info(tag, **kwargs) # noqa: E501
1026+
1027+
return self.test_echo_body_tag_response_string_with_http_info.raw_function(
1028+
tag,
1029+
**kwargs,
1030+
)
10041031

10051032
@validate_call
10061033
def test_echo_body_tag_response_string_with_http_info(

samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/form_api.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,13 @@ def test_form_integer_boolean_string(
8383
if '_preload_content' in kwargs:
8484
message = "Error! Please call the test_form_integer_boolean_string_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501
8585
raise ValueError(message)
86-
return self.test_form_integer_boolean_string_with_http_info(integer_form, boolean_form, string_form, **kwargs) # noqa: E501
86+
87+
return self.test_form_integer_boolean_string_with_http_info.raw_function(
88+
integer_form,
89+
boolean_form,
90+
string_form,
91+
**kwargs,
92+
)
8793

8894
@validate_call
8995
def test_form_integer_boolean_string_with_http_info(
@@ -267,7 +273,16 @@ def test_form_oneof(
267273
if '_preload_content' in kwargs:
268274
message = "Error! Please call the test_form_oneof_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501
269275
raise ValueError(message)
270-
return self.test_form_oneof_with_http_info(form1, form2, form3, form4, id, name, **kwargs) # noqa: E501
276+
277+
return self.test_form_oneof_with_http_info.raw_function(
278+
form1,
279+
form2,
280+
form3,
281+
form4,
282+
id,
283+
name,
284+
**kwargs,
285+
)
271286

272287
@validate_call
273288
def test_form_oneof_with_http_info(

samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/header_api.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,15 @@ def test_header_integer_boolean_string_enums(
9090
if '_preload_content' in kwargs:
9191
message = "Error! Please call the test_header_integer_boolean_string_enums_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501
9292
raise ValueError(message)
93-
return self.test_header_integer_boolean_string_enums_with_http_info(integer_header, boolean_header, string_header, enum_nonref_string_header, enum_ref_string_header, **kwargs) # noqa: E501
93+
94+
return self.test_header_integer_boolean_string_enums_with_http_info.raw_function(
95+
integer_header,
96+
boolean_header,
97+
string_header,
98+
enum_nonref_string_header,
99+
enum_ref_string_header,
100+
**kwargs,
101+
)
94102

95103
@validate_call
96104
def test_header_integer_boolean_string_enums_with_http_info(

samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/path_api.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,14 @@ def tests_path_string_path_string_integer_path_integer_enum_nonref_string_path_e
8585
if '_preload_content' in kwargs:
8686
message = "Error! Please call the tests_path_string_path_string_integer_path_integer_enum_nonref_string_path_enum_ref_string_path_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501
8787
raise ValueError(message)
88-
return self.tests_path_string_path_string_integer_path_integer_enum_nonref_string_path_enum_ref_string_path_with_http_info(path_string, path_integer, enum_nonref_string_path, enum_ref_string_path, **kwargs) # noqa: E501
88+
89+
return self.tests_path_string_path_string_integer_path_integer_enum_nonref_string_path_enum_ref_string_path_with_http_info.raw_function(
90+
path_string,
91+
path_integer,
92+
enum_nonref_string_path,
93+
enum_ref_string_path,
94+
**kwargs,
95+
)
8996

9097
@validate_call
9198
def tests_path_string_path_string_integer_path_integer_enum_nonref_string_path_enum_ref_string_path_with_http_info(

samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/query_api.py

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,12 @@ def test_enum_ref_string(
8585
if '_preload_content' in kwargs:
8686
message = "Error! Please call the test_enum_ref_string_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501
8787
raise ValueError(message)
88-
return self.test_enum_ref_string_with_http_info(enum_nonref_string_query, enum_ref_string_query, **kwargs) # noqa: E501
88+
89+
return self.test_enum_ref_string_with_http_info.raw_function(
90+
enum_nonref_string_query,
91+
enum_ref_string_query,
92+
**kwargs,
93+
)
8994

9095
@validate_call
9196
def test_enum_ref_string_with_http_info(
@@ -246,7 +251,13 @@ def test_query_datetime_date_string(
246251
if '_preload_content' in kwargs:
247252
message = "Error! Please call the test_query_datetime_date_string_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501
248253
raise ValueError(message)
249-
return self.test_query_datetime_date_string_with_http_info(datetime_query, date_query, string_query, **kwargs) # noqa: E501
254+
255+
return self.test_query_datetime_date_string_with_http_info.raw_function(
256+
datetime_query,
257+
date_query,
258+
string_query,
259+
**kwargs,
260+
)
250261

251262
@validate_call
252263
def test_query_datetime_date_string_with_http_info(
@@ -420,7 +431,13 @@ def test_query_integer_boolean_string(
420431
if '_preload_content' in kwargs:
421432
message = "Error! Please call the test_query_integer_boolean_string_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501
422433
raise ValueError(message)
423-
return self.test_query_integer_boolean_string_with_http_info(integer_query, boolean_query, string_query, **kwargs) # noqa: E501
434+
435+
return self.test_query_integer_boolean_string_with_http_info.raw_function(
436+
integer_query,
437+
boolean_query,
438+
string_query,
439+
**kwargs,
440+
)
424441

425442
@validate_call
426443
def test_query_integer_boolean_string_with_http_info(
@@ -582,7 +599,11 @@ def test_query_style_deep_object_explode_true_object(
582599
if '_preload_content' in kwargs:
583600
message = "Error! Please call the test_query_style_deep_object_explode_true_object_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501
584601
raise ValueError(message)
585-
return self.test_query_style_deep_object_explode_true_object_with_http_info(query_object, **kwargs) # noqa: E501
602+
603+
return self.test_query_style_deep_object_explode_true_object_with_http_info.raw_function(
604+
query_object,
605+
**kwargs,
606+
)
586607

587608
@validate_call
588609
def test_query_style_deep_object_explode_true_object_with_http_info(
@@ -730,7 +751,11 @@ def test_query_style_deep_object_explode_true_object_all_of(
730751
if '_preload_content' in kwargs:
731752
message = "Error! Please call the test_query_style_deep_object_explode_true_object_all_of_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501
732753
raise ValueError(message)
733-
return self.test_query_style_deep_object_explode_true_object_all_of_with_http_info(query_object, **kwargs) # noqa: E501
754+
755+
return self.test_query_style_deep_object_explode_true_object_all_of_with_http_info.raw_function(
756+
query_object,
757+
**kwargs,
758+
)
734759

735760
@validate_call
736761
def test_query_style_deep_object_explode_true_object_all_of_with_http_info(
@@ -878,7 +903,11 @@ def test_query_style_form_explode_true_array_string(
878903
if '_preload_content' in kwargs:
879904
message = "Error! Please call the test_query_style_form_explode_true_array_string_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501
880905
raise ValueError(message)
881-
return self.test_query_style_form_explode_true_array_string_with_http_info(query_object, **kwargs) # noqa: E501
906+
907+
return self.test_query_style_form_explode_true_array_string_with_http_info.raw_function(
908+
query_object,
909+
**kwargs,
910+
)
882911

883912
@validate_call
884913
def test_query_style_form_explode_true_array_string_with_http_info(
@@ -1026,7 +1055,11 @@ def test_query_style_form_explode_true_object(
10261055
if '_preload_content' in kwargs:
10271056
message = "Error! Please call the test_query_style_form_explode_true_object_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501
10281057
raise ValueError(message)
1029-
return self.test_query_style_form_explode_true_object_with_http_info(query_object, **kwargs) # noqa: E501
1058+
1059+
return self.test_query_style_form_explode_true_object_with_http_info.raw_function(
1060+
query_object,
1061+
**kwargs,
1062+
)
10301063

10311064
@validate_call
10321065
def test_query_style_form_explode_true_object_with_http_info(
@@ -1174,7 +1207,11 @@ def test_query_style_form_explode_true_object_all_of(
11741207
if '_preload_content' in kwargs:
11751208
message = "Error! Please call the test_query_style_form_explode_true_object_all_of_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501
11761209
raise ValueError(message)
1177-
return self.test_query_style_form_explode_true_object_all_of_with_http_info(query_object, **kwargs) # noqa: E501
1210+
1211+
return self.test_query_style_form_explode_true_object_all_of_with_http_info.raw_function(
1212+
query_object,
1213+
**kwargs,
1214+
)
11781215

11791216
@validate_call
11801217
def test_query_style_form_explode_true_object_all_of_with_http_info(

samples/client/echo_api/python/openapi_client/api/auth_api.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ def test_auth_http_basic(
7070
if '_preload_content' in kwargs:
7171
message = "Error! Please call the test_auth_http_basic_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501
7272
raise ValueError(message)
73-
return self.test_auth_http_basic_with_http_info(**kwargs) # noqa: E501
73+
74+
return self.test_auth_http_basic_with_http_info.raw_function(
75+
**kwargs,
76+
)
7477

7578
@validate_call
7679
def test_auth_http_basic_with_http_info(

samples/client/echo_api/python/openapi_client/api/body_api.py

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,10 @@ def test_binary_gif(
7878
if '_preload_content' in kwargs:
7979
message = "Error! Please call the test_binary_gif_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501
8080
raise ValueError(message)
81-
return self.test_binary_gif_with_http_info(**kwargs) # noqa: E501
81+
82+
return self.test_binary_gif_with_http_info.raw_function(
83+
**kwargs,
84+
)
8285

8386
@validate_call
8487
def test_binary_gif_with_http_info(
@@ -219,7 +222,11 @@ def test_body_application_octetstream_binary(
219222
if '_preload_content' in kwargs:
220223
message = "Error! Please call the test_body_application_octetstream_binary_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501
221224
raise ValueError(message)
222-
return self.test_body_application_octetstream_binary_with_http_info(body, **kwargs) # noqa: E501
225+
226+
return self.test_body_application_octetstream_binary_with_http_info.raw_function(
227+
body,
228+
**kwargs,
229+
)
223230

224231
@validate_call
225232
def test_body_application_octetstream_binary_with_http_info(
@@ -379,7 +386,11 @@ def test_body_multipart_formdata_array_of_binary(
379386
if '_preload_content' in kwargs:
380387
message = "Error! Please call the test_body_multipart_formdata_array_of_binary_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501
381388
raise ValueError(message)
382-
return self.test_body_multipart_formdata_array_of_binary_with_http_info(files, **kwargs) # noqa: E501
389+
390+
return self.test_body_multipart_formdata_array_of_binary_with_http_info.raw_function(
391+
files,
392+
**kwargs,
393+
)
383394

384395
@validate_call
385396
def test_body_multipart_formdata_array_of_binary_with_http_info(
@@ -535,7 +546,11 @@ def test_echo_body_free_form_object_response_string(
535546
if '_preload_content' in kwargs:
536547
message = "Error! Please call the test_echo_body_free_form_object_response_string_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501
537548
raise ValueError(message)
538-
return self.test_echo_body_free_form_object_response_string_with_http_info(body, **kwargs) # noqa: E501
549+
550+
return self.test_echo_body_free_form_object_response_string_with_http_info.raw_function(
551+
body,
552+
**kwargs,
553+
)
539554

540555
@validate_call
541556
def test_echo_body_free_form_object_response_string_with_http_info(
@@ -690,7 +705,11 @@ def test_echo_body_pet(
690705
if '_preload_content' in kwargs:
691706
message = "Error! Please call the test_echo_body_pet_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501
692707
raise ValueError(message)
693-
return self.test_echo_body_pet_with_http_info(pet, **kwargs) # noqa: E501
708+
709+
return self.test_echo_body_pet_with_http_info.raw_function(
710+
pet,
711+
**kwargs,
712+
)
694713

695714
@validate_call
696715
def test_echo_body_pet_with_http_info(
@@ -845,7 +864,11 @@ def test_echo_body_pet_response_string(
845864
if '_preload_content' in kwargs:
846865
message = "Error! Please call the test_echo_body_pet_response_string_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501
847866
raise ValueError(message)
848-
return self.test_echo_body_pet_response_string_with_http_info(pet, **kwargs) # noqa: E501
867+
868+
return self.test_echo_body_pet_response_string_with_http_info.raw_function(
869+
pet,
870+
**kwargs,
871+
)
849872

850873
@validate_call
851874
def test_echo_body_pet_response_string_with_http_info(
@@ -1000,7 +1023,11 @@ def test_echo_body_tag_response_string(
10001023
if '_preload_content' in kwargs:
10011024
message = "Error! Please call the test_echo_body_tag_response_string_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501
10021025
raise ValueError(message)
1003-
return self.test_echo_body_tag_response_string_with_http_info(tag, **kwargs) # noqa: E501
1026+
1027+
return self.test_echo_body_tag_response_string_with_http_info.raw_function(
1028+
tag,
1029+
**kwargs,
1030+
)
10041031

10051032
@validate_call
10061033
def test_echo_body_tag_response_string_with_http_info(

0 commit comments

Comments
 (0)