[Python] Allow Overriding Accept Header (#19025)

* [Python] Allow Overriding Accept Header

* generate samples

* add tests
This commit is contained in:
Cameron Koegel
2024-06-28 07:27:10 -04:00
committed by GitHub
parent 44e9ff58bd
commit 53f1094765
31 changed files with 779 additions and 619 deletions

View File

@@ -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:

View File

@@ -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

View File

@@ -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

View File

@@ -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:

View File

@@ -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

View File

@@ -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:

View File

@@ -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:

View File

@@ -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

View File

@@ -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()