From 53f1094765408a1b6f12fb3f8570f5e61e876600 Mon Sep 17 00:00:00 2001 From: Cameron Koegel <53310569+ckoegel@users.noreply.github.com> Date: Fri, 28 Jun 2024 07:27:10 -0400 Subject: [PATCH] [Python] Allow Overriding Accept Header (#19025) * [Python] Allow Overriding Accept Header * generate samples * add tests --- .../src/main/resources/python/api.mustache | 11 +- .../openapi_client/api/auth_api.py | 22 +- .../openapi_client/api/body_api.py | 110 ++++----- .../openapi_client/api/form_api.py | 33 +-- .../openapi_client/api/header_api.py | 11 +- .../openapi_client/api/path_api.py | 11 +- .../openapi_client/api/query_api.py | 110 ++++----- .../python/openapi_client/api/auth_api.py | 22 +- .../python/openapi_client/api/body_api.py | 110 ++++----- .../python/openapi_client/api/form_api.py | 33 +-- .../python/openapi_client/api/header_api.py | 11 +- .../python/openapi_client/api/path_api.py | 11 +- .../python/openapi_client/api/query_api.py | 110 ++++----- .../petstore_api/api/another_fake_api.py | 11 +- .../petstore_api/api/default_api.py | 11 +- .../petstore_api/api/fake_api.py | 209 ++++++++++-------- .../api/fake_classname_tags123_api.py | 11 +- .../api/import_test_datetime_api.py | 11 +- .../petstore_api/api/pet_api.py | 61 ++--- .../petstore_api/api/store_api.py | 37 ++-- .../petstore_api/api/user_api.py | 26 ++- .../python-aiohttp/tests/test_pet_api.py | 20 ++ .../petstore_api/api/another_fake_api.py | 11 +- .../python/petstore_api/api/default_api.py | 11 +- .../python/petstore_api/api/fake_api.py | 209 ++++++++++-------- .../api/fake_classname_tags123_api.py | 11 +- .../api/import_test_datetime_api.py | 11 +- .../python/petstore_api/api/pet_api.py | 61 ++--- .../python/petstore_api/api/store_api.py | 37 ++-- .../python/petstore_api/api/user_api.py | 26 ++- .../petstore/python/tests/test_pet_api.py | 19 ++ 31 files changed, 779 insertions(+), 619 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/python/api.mustache b/modules/openapi-generator/src/main/resources/python/api.mustache index fe34567ac5a..2aa70299a17 100644 --- a/modules/openapi-generator/src/main/resources/python/api.mustache +++ b/modules/openapi-generator/src/main/resources/python/api.mustache @@ -186,11 +186,12 @@ class {{classname}}: {{#hasProduces}} # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [{{#produces}} - '{{{mediaType}}}'{{^-last}}, {{/-last}}{{/produces}} - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [{{#produces}} + '{{{mediaType}}}'{{^-last}}, {{/-last}}{{/produces}} + ] + ) {{/hasProduces}} {{#hasConsumes}} diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/api/auth_api.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/api/auth_api.py index dfd24668c5e..e9f324925ba 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/api/auth_api.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/api/auth_api.py @@ -250,11 +250,12 @@ class AuthApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'text/plain' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'text/plain' + ] + ) # authentication setting @@ -493,11 +494,12 @@ class AuthApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'text/plain' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'text/plain' + ] + ) # authentication setting diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/api/body_api.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/api/body_api.py index 4ff665930e1..5dde71e64e9 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/api/body_api.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/api/body_api.py @@ -255,11 +255,12 @@ class BodyApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'image/gif' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'image/gif' + ] + ) # authentication setting @@ -517,11 +518,12 @@ class BodyApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'text/plain' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'text/plain' + ] + ) # set the HTTP header `Content-Type` if _content_type: @@ -788,11 +790,12 @@ class BodyApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'text/plain' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'text/plain' + ] + ) # set the HTTP header `Content-Type` if _content_type: @@ -1058,11 +1061,12 @@ class BodyApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'text/plain' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'text/plain' + ] + ) # set the HTTP header `Content-Type` if _content_type: @@ -1328,11 +1332,12 @@ class BodyApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/json' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) # set the HTTP header `Content-Type` if _content_type: @@ -1598,11 +1603,12 @@ class BodyApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'text/plain' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'text/plain' + ] + ) # set the HTTP header `Content-Type` if _content_type: @@ -1868,11 +1874,12 @@ class BodyApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/json' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) # set the HTTP header `Content-Type` if _content_type: @@ -2138,11 +2145,12 @@ class BodyApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'text/plain' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'text/plain' + ] + ) # set the HTTP header `Content-Type` if _content_type: @@ -2408,11 +2416,12 @@ class BodyApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/json' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) # set the HTTP header `Content-Type` if _content_type: @@ -2678,11 +2687,12 @@ class BodyApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'text/plain' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'text/plain' + ] + ) # set the HTTP header `Content-Type` if _content_type: diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/api/form_api.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/api/form_api.py index 48f4dcf80b0..9b4c1f825e8 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/api/form_api.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/api/form_api.py @@ -297,11 +297,12 @@ class FormApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'text/plain' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'text/plain' + ] + ) # set the HTTP header `Content-Type` if _content_type: @@ -567,11 +568,12 @@ class FormApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'text/plain' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'text/plain' + ] + ) # set the HTTP header `Content-Type` if _content_type: @@ -912,11 +914,12 @@ class FormApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'text/plain' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'text/plain' + ] + ) # set the HTTP header `Content-Type` if _content_type: diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/api/header_api.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/api/header_api.py index 9cf33bb7eb9..f1d64cfa02f 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/api/header_api.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/api/header_api.py @@ -327,11 +327,12 @@ class HeaderApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'text/plain' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'text/plain' + ] + ) # authentication setting diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/api/path_api.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/api/path_api.py index 8164e9a174c..f28f7a1b784 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/api/path_api.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/api/path_api.py @@ -311,11 +311,12 @@ class PathApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'text/plain' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'text/plain' + ] + ) # authentication setting diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/api/query_api.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/api/query_api.py index 2a004b65ee8..7e9a393cb37 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/api/query_api.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/api/query_api.py @@ -289,11 +289,12 @@ class QueryApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'text/plain' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'text/plain' + ] + ) # authentication setting @@ -600,11 +601,12 @@ class QueryApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'text/plain' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'text/plain' + ] + ) # authentication setting @@ -893,11 +895,12 @@ class QueryApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'text/plain' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'text/plain' + ] + ) # authentication setting @@ -1152,11 +1155,12 @@ class QueryApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'text/plain' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'text/plain' + ] + ) # authentication setting @@ -1411,11 +1415,12 @@ class QueryApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'text/plain' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'text/plain' + ] + ) # authentication setting @@ -1671,11 +1676,12 @@ class QueryApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'text/plain' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'text/plain' + ] + ) # authentication setting @@ -1931,11 +1937,12 @@ class QueryApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'text/plain' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'text/plain' + ] + ) # authentication setting @@ -2190,11 +2197,12 @@ class QueryApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'text/plain' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'text/plain' + ] + ) # authentication setting @@ -2449,11 +2457,12 @@ class QueryApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'text/plain' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'text/plain' + ] + ) # authentication setting @@ -2708,11 +2717,12 @@ class QueryApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'text/plain' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'text/plain' + ] + ) # authentication setting diff --git a/samples/client/echo_api/python/openapi_client/api/auth_api.py b/samples/client/echo_api/python/openapi_client/api/auth_api.py index dfd24668c5e..e9f324925ba 100644 --- a/samples/client/echo_api/python/openapi_client/api/auth_api.py +++ b/samples/client/echo_api/python/openapi_client/api/auth_api.py @@ -250,11 +250,12 @@ class AuthApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'text/plain' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'text/plain' + ] + ) # authentication setting @@ -493,11 +494,12 @@ class AuthApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'text/plain' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'text/plain' + ] + ) # authentication setting diff --git a/samples/client/echo_api/python/openapi_client/api/body_api.py b/samples/client/echo_api/python/openapi_client/api/body_api.py index 4ff665930e1..5dde71e64e9 100644 --- a/samples/client/echo_api/python/openapi_client/api/body_api.py +++ b/samples/client/echo_api/python/openapi_client/api/body_api.py @@ -255,11 +255,12 @@ class BodyApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'image/gif' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'image/gif' + ] + ) # authentication setting @@ -517,11 +518,12 @@ class BodyApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'text/plain' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'text/plain' + ] + ) # set the HTTP header `Content-Type` if _content_type: @@ -788,11 +790,12 @@ class BodyApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'text/plain' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'text/plain' + ] + ) # set the HTTP header `Content-Type` if _content_type: @@ -1058,11 +1061,12 @@ class BodyApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'text/plain' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'text/plain' + ] + ) # set the HTTP header `Content-Type` if _content_type: @@ -1328,11 +1332,12 @@ class BodyApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/json' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) # set the HTTP header `Content-Type` if _content_type: @@ -1598,11 +1603,12 @@ class BodyApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'text/plain' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'text/plain' + ] + ) # set the HTTP header `Content-Type` if _content_type: @@ -1868,11 +1874,12 @@ class BodyApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/json' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) # set the HTTP header `Content-Type` if _content_type: @@ -2138,11 +2145,12 @@ class BodyApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'text/plain' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'text/plain' + ] + ) # set the HTTP header `Content-Type` if _content_type: @@ -2408,11 +2416,12 @@ class BodyApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/json' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) # set the HTTP header `Content-Type` if _content_type: @@ -2678,11 +2687,12 @@ class BodyApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'text/plain' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'text/plain' + ] + ) # set the HTTP header `Content-Type` if _content_type: diff --git a/samples/client/echo_api/python/openapi_client/api/form_api.py b/samples/client/echo_api/python/openapi_client/api/form_api.py index 48f4dcf80b0..9b4c1f825e8 100644 --- a/samples/client/echo_api/python/openapi_client/api/form_api.py +++ b/samples/client/echo_api/python/openapi_client/api/form_api.py @@ -297,11 +297,12 @@ class FormApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'text/plain' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'text/plain' + ] + ) # set the HTTP header `Content-Type` if _content_type: @@ -567,11 +568,12 @@ class FormApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'text/plain' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'text/plain' + ] + ) # set the HTTP header `Content-Type` if _content_type: @@ -912,11 +914,12 @@ class FormApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'text/plain' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'text/plain' + ] + ) # set the HTTP header `Content-Type` if _content_type: diff --git a/samples/client/echo_api/python/openapi_client/api/header_api.py b/samples/client/echo_api/python/openapi_client/api/header_api.py index 9cf33bb7eb9..f1d64cfa02f 100644 --- a/samples/client/echo_api/python/openapi_client/api/header_api.py +++ b/samples/client/echo_api/python/openapi_client/api/header_api.py @@ -327,11 +327,12 @@ class HeaderApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'text/plain' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'text/plain' + ] + ) # authentication setting diff --git a/samples/client/echo_api/python/openapi_client/api/path_api.py b/samples/client/echo_api/python/openapi_client/api/path_api.py index 8164e9a174c..f28f7a1b784 100644 --- a/samples/client/echo_api/python/openapi_client/api/path_api.py +++ b/samples/client/echo_api/python/openapi_client/api/path_api.py @@ -311,11 +311,12 @@ class PathApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'text/plain' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'text/plain' + ] + ) # authentication setting diff --git a/samples/client/echo_api/python/openapi_client/api/query_api.py b/samples/client/echo_api/python/openapi_client/api/query_api.py index 2a004b65ee8..7e9a393cb37 100644 --- a/samples/client/echo_api/python/openapi_client/api/query_api.py +++ b/samples/client/echo_api/python/openapi_client/api/query_api.py @@ -289,11 +289,12 @@ class QueryApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'text/plain' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'text/plain' + ] + ) # authentication setting @@ -600,11 +601,12 @@ class QueryApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'text/plain' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'text/plain' + ] + ) # authentication setting @@ -893,11 +895,12 @@ class QueryApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'text/plain' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'text/plain' + ] + ) # authentication setting @@ -1152,11 +1155,12 @@ class QueryApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'text/plain' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'text/plain' + ] + ) # authentication setting @@ -1411,11 +1415,12 @@ class QueryApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'text/plain' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'text/plain' + ] + ) # authentication setting @@ -1671,11 +1676,12 @@ class QueryApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'text/plain' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'text/plain' + ] + ) # authentication setting @@ -1931,11 +1937,12 @@ class QueryApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'text/plain' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'text/plain' + ] + ) # authentication setting @@ -2190,11 +2197,12 @@ class QueryApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'text/plain' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'text/plain' + ] + ) # authentication setting @@ -2449,11 +2457,12 @@ class QueryApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'text/plain' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'text/plain' + ] + ) # authentication setting @@ -2708,11 +2717,12 @@ class QueryApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'text/plain' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'text/plain' + ] + ) # authentication setting diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/another_fake_api.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/another_fake_api.py index ebfbeec9157..f4d58775ffc 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/another_fake_api.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/another_fake_api.py @@ -266,11 +266,12 @@ class AnotherFakeApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/json' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) # set the HTTP header `Content-Type` if _content_type: diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/default_api.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/default_api.py index d6e7bb55705..71cf62b03c2 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/default_api.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/default_api.py @@ -243,11 +243,12 @@ class DefaultApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/json' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) # authentication setting diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_api.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_api.py index 078561dd407..4fc62b6e196 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_api.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_api.py @@ -772,11 +772,12 @@ class FakeApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/json' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) # authentication setting @@ -1324,11 +1325,12 @@ class FakeApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - '*/*' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + '*/*' + ] + ) # set the HTTP header `Content-Type` if _content_type: @@ -1594,11 +1596,12 @@ class FakeApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - '*/*' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + '*/*' + ] + ) # set the HTTP header `Content-Type` if _content_type: @@ -1864,11 +1867,12 @@ class FakeApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - '*/*' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + '*/*' + ] + ) # set the HTTP header `Content-Type` if _content_type: @@ -2134,11 +2138,12 @@ class FakeApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - '*/*' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + '*/*' + ] + ) # set the HTTP header `Content-Type` if _content_type: @@ -2422,11 +2427,12 @@ class FakeApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - '*/*' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + '*/*' + ] + ) # set the HTTP header `Content-Type` if _content_type: @@ -2674,11 +2680,12 @@ class FakeApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'plain/text' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'plain/text' + ] + ) # authentication setting @@ -2913,11 +2920,12 @@ class FakeApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/json' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) # authentication setting @@ -3152,11 +3160,12 @@ class FakeApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'plain/text' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'plain/text' + ] + ) # authentication setting @@ -3391,11 +3400,12 @@ class FakeApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/json' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) # authentication setting @@ -3630,11 +3640,12 @@ class FakeApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'plain/text' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'plain/text' + ] + ) # authentication setting @@ -3869,11 +3880,12 @@ class FakeApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/json' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) # authentication setting @@ -4108,11 +4120,12 @@ class FakeApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/json' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) # authentication setting @@ -4347,11 +4360,12 @@ class FakeApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/json' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) # authentication setting @@ -4586,11 +4600,12 @@ class FakeApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'plain/text' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'plain/text' + ] + ) # authentication setting @@ -4825,11 +4840,12 @@ class FakeApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/json' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) # authentication setting @@ -6407,11 +6423,12 @@ class FakeApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/json' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) # set the HTTP header `Content-Type` if _content_type: @@ -6941,11 +6958,12 @@ class FakeApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'text/plain' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'text/plain' + ] + ) # authentication setting @@ -7664,11 +7682,12 @@ class FakeApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/json' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) # authentication setting diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_classname_tags123_api.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_classname_tags123_api.py index 03c87d93a4c..85fac2a1727 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_classname_tags123_api.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_classname_tags123_api.py @@ -266,11 +266,12 @@ class FakeClassnameTags123Api: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/json' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) # set the HTTP header `Content-Type` if _content_type: diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/import_test_datetime_api.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/import_test_datetime_api.py index 16a8ea0f323..bdcae214561 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/import_test_datetime_api.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/import_test_datetime_api.py @@ -246,11 +246,12 @@ class ImportTestDatetimeApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/json' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) # authentication setting diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/pet_api.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/pet_api.py index 0ae1b2addb4..e9dc088da1c 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/pet_api.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/pet_api.py @@ -814,12 +814,13 @@ class PetApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/xml', - 'application/json' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/xml', + 'application/json' + ] + ) # authentication setting @@ -1083,12 +1084,13 @@ class PetApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/xml', - 'application/json' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/xml', + 'application/json' + ] + ) # authentication setting @@ -1349,12 +1351,13 @@ class PetApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/xml', - 'application/json' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/xml', + 'application/json' + ] + ) # authentication setting @@ -2212,11 +2215,12 @@ class PetApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/json' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) # set the HTTP header `Content-Type` if _content_type: @@ -2513,11 +2517,12 @@ class PetApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/json' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) # set the HTTP header `Content-Type` if _content_type: diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/store_api.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/store_api.py index d4150f7f9b9..430dffa6d23 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/store_api.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/store_api.py @@ -506,11 +506,12 @@ class StoreApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/json' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) # authentication setting @@ -770,12 +771,13 @@ class StoreApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/xml', - 'application/json' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/xml', + 'application/json' + ] + ) # authentication setting @@ -1031,12 +1033,13 @@ class StoreApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/xml', - 'application/json' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/xml', + 'application/json' + ] + ) # set the HTTP header `Content-Type` if _content_type: diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/user_api.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/user_api.py index 20391c692cd..b1a7325ada5 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/user_api.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/user_api.py @@ -1317,12 +1317,13 @@ class UserApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/xml', - 'application/json' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/xml', + 'application/json' + ] + ) # authentication setting @@ -1597,12 +1598,13 @@ class UserApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/xml', - 'application/json' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/xml', + 'application/json' + ] + ) # authentication setting diff --git a/samples/openapi3/client/petstore/python-aiohttp/tests/test_pet_api.py b/samples/openapi3/client/petstore/python-aiohttp/tests/test_pet_api.py index 2746c923ffb..d6dcdebd146 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/tests/test_pet_api.py +++ b/samples/openapi3/client/petstore/python-aiohttp/tests/test_pet_api.py @@ -58,6 +58,26 @@ class TestPetApiTests(unittest.TestCase): self.test_file_dir = os.path.realpath(self.test_file_dir) self.foo = os.path.join(self.test_file_dir, "foo.png") + def test_accept_header_serialization(self): + (_, _, headers, *_) = self.pet_api._get_pet_by_id_serialize( + pet_id=self.pet.id, + _request_auth=None, + _content_type=None, + _headers=None, + _host_index=0 + ) + self.assertEqual(headers['Accept'], 'application/json') + + (_, _, headers_overwritten, *_) = self.pet_api._get_pet_by_id_serialize( + pet_id=self.pet.id, + _request_auth=None, + _content_type=None, + _headers={'Accept': 'text/plain'}, + _host_index=0 + ) + self.assertEqual(headers_overwritten['Accept'], 'text/plain') + + def test_separate_default_client_instances(self): pet_api = petstore_api.PetApi() pet_api2 = petstore_api.PetApi() diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/another_fake_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/another_fake_api.py index 466a18cc0a3..4778db8c82c 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/api/another_fake_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/another_fake_api.py @@ -266,11 +266,12 @@ class AnotherFakeApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/json' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) # set the HTTP header `Content-Type` if _content_type: diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/default_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/default_api.py index 61061624030..89d164b4592 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/api/default_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/default_api.py @@ -243,11 +243,12 @@ class DefaultApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/json' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) # authentication setting diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/fake_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/fake_api.py index 04e5e9cd15c..f5e0609ba88 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/api/fake_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/fake_api.py @@ -772,11 +772,12 @@ class FakeApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/json' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) # authentication setting @@ -1324,11 +1325,12 @@ class FakeApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - '*/*' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + '*/*' + ] + ) # set the HTTP header `Content-Type` if _content_type: @@ -1594,11 +1596,12 @@ class FakeApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - '*/*' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + '*/*' + ] + ) # set the HTTP header `Content-Type` if _content_type: @@ -1864,11 +1867,12 @@ class FakeApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - '*/*' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + '*/*' + ] + ) # set the HTTP header `Content-Type` if _content_type: @@ -2134,11 +2138,12 @@ class FakeApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - '*/*' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + '*/*' + ] + ) # set the HTTP header `Content-Type` if _content_type: @@ -2422,11 +2427,12 @@ class FakeApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - '*/*' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + '*/*' + ] + ) # set the HTTP header `Content-Type` if _content_type: @@ -2674,11 +2680,12 @@ class FakeApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'plain/text' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'plain/text' + ] + ) # authentication setting @@ -2913,11 +2920,12 @@ class FakeApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/json' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) # authentication setting @@ -3152,11 +3160,12 @@ class FakeApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'plain/text' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'plain/text' + ] + ) # authentication setting @@ -3391,11 +3400,12 @@ class FakeApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/json' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) # authentication setting @@ -3630,11 +3640,12 @@ class FakeApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'plain/text' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'plain/text' + ] + ) # authentication setting @@ -3869,11 +3880,12 @@ class FakeApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/json' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) # authentication setting @@ -4108,11 +4120,12 @@ class FakeApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/json' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) # authentication setting @@ -4347,11 +4360,12 @@ class FakeApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/json' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) # authentication setting @@ -4586,11 +4600,12 @@ class FakeApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'plain/text' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'plain/text' + ] + ) # authentication setting @@ -4825,11 +4840,12 @@ class FakeApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/json' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) # authentication setting @@ -6407,11 +6423,12 @@ class FakeApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/json' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) # set the HTTP header `Content-Type` if _content_type: @@ -6941,11 +6958,12 @@ class FakeApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'text/plain' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'text/plain' + ] + ) # authentication setting @@ -7664,11 +7682,12 @@ class FakeApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/json' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) # authentication setting diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/fake_classname_tags123_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/fake_classname_tags123_api.py index 4fb9a7e98d9..598fdc02338 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/api/fake_classname_tags123_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/fake_classname_tags123_api.py @@ -266,11 +266,12 @@ class FakeClassnameTags123Api: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/json' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) # set the HTTP header `Content-Type` if _content_type: diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/import_test_datetime_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/import_test_datetime_api.py index f2467c71f2a..28443a99f1c 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/api/import_test_datetime_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/import_test_datetime_api.py @@ -246,11 +246,12 @@ class ImportTestDatetimeApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/json' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) # authentication setting diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/pet_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/pet_api.py index 2b238b6f28d..729dff8efd8 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/api/pet_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/pet_api.py @@ -814,12 +814,13 @@ class PetApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/xml', - 'application/json' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/xml', + 'application/json' + ] + ) # authentication setting @@ -1083,12 +1084,13 @@ class PetApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/xml', - 'application/json' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/xml', + 'application/json' + ] + ) # authentication setting @@ -1349,12 +1351,13 @@ class PetApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/xml', - 'application/json' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/xml', + 'application/json' + ] + ) # authentication setting @@ -2212,11 +2215,12 @@ class PetApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/json' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) # set the HTTP header `Content-Type` if _content_type: @@ -2513,11 +2517,12 @@ class PetApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/json' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) # set the HTTP header `Content-Type` if _content_type: diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/store_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/store_api.py index c50d82d6a5b..7eb32d8769b 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/api/store_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/store_api.py @@ -506,11 +506,12 @@ class StoreApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/json' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) # authentication setting @@ -770,12 +771,13 @@ class StoreApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/xml', - 'application/json' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/xml', + 'application/json' + ] + ) # authentication setting @@ -1031,12 +1033,13 @@ class StoreApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/xml', - 'application/json' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/xml', + 'application/json' + ] + ) # set the HTTP header `Content-Type` if _content_type: diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/user_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/user_api.py index 5131bce7d29..ce6299b037b 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/api/user_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/user_api.py @@ -1317,12 +1317,13 @@ class UserApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/xml', - 'application/json' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/xml', + 'application/json' + ] + ) # authentication setting @@ -1597,12 +1598,13 @@ class UserApi: # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/xml', - 'application/json' - ] - ) + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/xml', + 'application/json' + ] + ) # authentication setting diff --git a/samples/openapi3/client/petstore/python/tests/test_pet_api.py b/samples/openapi3/client/petstore/python/tests/test_pet_api.py index 396bdf0ce48..addfa801821 100644 --- a/samples/openapi3/client/petstore/python/tests/test_pet_api.py +++ b/samples/openapi3/client/petstore/python/tests/test_pet_api.py @@ -107,6 +107,25 @@ class PetApiTests(unittest.TestCase): self.pet_api.add_pet(self.pet, _request_timeout=5.0) self.pet_api.add_pet(self.pet, _request_timeout=(1.0, 2.0)) + def test_accept_header_serialization(self): + (_, _, headers, *_) = self.pet_api._get_pet_by_id_serialize( + pet_id=self.pet.id, + _request_auth=None, + _content_type=None, + _headers=None, + _host_index=0 + ) + self.assertEqual(headers['Accept'], 'application/json') + + (_, _, headers_overwritten, *_) = self.pet_api._get_pet_by_id_serialize( + pet_id=self.pet.id, + _request_auth=None, + _content_type=None, + _headers={'Accept': 'text/plain'}, + _host_index=0 + ) + self.assertEqual(headers_overwritten['Accept'], 'text/plain') + def test_separate_default_config_instances(self): # ensure the default api client is used pet_api = petstore_api.PetApi()