|
29 | 29 |
|
30 | 30 | from ..util import remove_none
|
31 | 31 |
|
| 32 | +from ..swagger import ApiClient |
| 33 | + |
32 | 34 | class PetApi(object):
|
33 | 35 |
|
34 | 36 | def __init__(self, api_client):
|
@@ -63,11 +65,13 @@ def update_pet(self, **kwargs):
|
63 | 65 | files = remove_none(dict())
|
64 | 66 | body_params = params.get('body')
|
65 | 67 |
|
66 |
| - accepts = ['application/json', 'application/xml'] |
67 |
| - header_params['Accept'] = ', '.join(accepts) |
| 68 | + # HTTP header `Accept` |
| 69 | + header_params['Accept'] = ApiClient.select_header_accept(['application/json', 'application/xml']) |
| 70 | + if not header_params['Accept']: |
| 71 | + del header_params['Accept'] |
68 | 72 |
|
69 |
| - content_types = ['application/json', 'application/xml'] |
70 |
| - header_params['Content-Type'] = content_types[0] if len(content_types) > 0 else 'application/json' |
| 73 | + # HTTP header `Content-Type` |
| 74 | + header_params['Content-Type'] = ApiClient.select_header_content_type(['application/json', 'application/xml']) |
71 | 75 |
|
72 | 76 | response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
73 | 77 | body=body_params, post_params=form_params, files=files,
|
@@ -102,11 +106,13 @@ def add_pet(self, **kwargs):
|
102 | 106 | files = remove_none(dict())
|
103 | 107 | body_params = params.get('body')
|
104 | 108 |
|
105 |
| - accepts = ['application/json', 'application/xml'] |
106 |
| - header_params['Accept'] = ', '.join(accepts) |
| 109 | + # HTTP header `Accept` |
| 110 | + header_params['Accept'] = ApiClient.select_header_accept(['application/json', 'application/xml']) |
| 111 | + if not header_params['Accept']: |
| 112 | + del header_params['Accept'] |
107 | 113 |
|
108 |
| - content_types = ['application/json', 'application/xml'] |
109 |
| - header_params['Content-Type'] = content_types[0] if len(content_types) > 0 else 'application/json' |
| 114 | + # HTTP header `Content-Type` |
| 115 | + header_params['Content-Type'] = ApiClient.select_header_content_type(['application/json', 'application/xml']) |
110 | 116 |
|
111 | 117 | response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
112 | 118 | body=body_params, post_params=form_params, files=files,
|
@@ -141,11 +147,13 @@ def find_pets_by_status(self, **kwargs):
|
141 | 147 | files = remove_none(dict())
|
142 | 148 | body_params = None
|
143 | 149 |
|
144 |
| - accepts = ['application/json', 'application/xml'] |
145 |
| - header_params['Accept'] = ', '.join(accepts) |
| 150 | + # HTTP header `Accept` |
| 151 | + header_params['Accept'] = ApiClient.select_header_accept(['application/json', 'application/xml']) |
| 152 | + if not header_params['Accept']: |
| 153 | + del header_params['Accept'] |
146 | 154 |
|
147 |
| - content_types = [] |
148 |
| - header_params['Content-Type'] = content_types[0] if len(content_types) > 0 else 'application/json' |
| 155 | + # HTTP header `Content-Type` |
| 156 | + header_params['Content-Type'] = ApiClient.select_header_content_type([]) |
149 | 157 |
|
150 | 158 | response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
151 | 159 | body=body_params, post_params=form_params, files=files,
|
@@ -182,11 +190,13 @@ def find_pets_by_tags(self, **kwargs):
|
182 | 190 | files = remove_none(dict())
|
183 | 191 | body_params = None
|
184 | 192 |
|
185 |
| - accepts = ['application/json', 'application/xml'] |
186 |
| - header_params['Accept'] = ', '.join(accepts) |
| 193 | + # HTTP header `Accept` |
| 194 | + header_params['Accept'] = ApiClient.select_header_accept(['application/json', 'application/xml']) |
| 195 | + if not header_params['Accept']: |
| 196 | + del header_params['Accept'] |
187 | 197 |
|
188 |
| - content_types = [] |
189 |
| - header_params['Content-Type'] = content_types[0] if len(content_types) > 0 else 'application/json' |
| 198 | + # HTTP header `Content-Type` |
| 199 | + header_params['Content-Type'] = ApiClient.select_header_content_type([]) |
190 | 200 |
|
191 | 201 | response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
192 | 202 | body=body_params, post_params=form_params, files=files,
|
@@ -227,11 +237,13 @@ def get_pet_by_id(self, pet_id, **kwargs):
|
227 | 237 | files = remove_none(dict())
|
228 | 238 | body_params = None
|
229 | 239 |
|
230 |
| - accepts = ['application/json', 'application/xml'] |
231 |
| - header_params['Accept'] = ', '.join(accepts) |
| 240 | + # HTTP header `Accept` |
| 241 | + header_params['Accept'] = ApiClient.select_header_accept(['application/json', 'application/xml']) |
| 242 | + if not header_params['Accept']: |
| 243 | + del header_params['Accept'] |
232 | 244 |
|
233 |
| - content_types = [] |
234 |
| - header_params['Content-Type'] = content_types[0] if len(content_types) > 0 else 'application/json' |
| 245 | + # HTTP header `Content-Type` |
| 246 | + header_params['Content-Type'] = ApiClient.select_header_content_type([]) |
235 | 247 |
|
236 | 248 | response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
237 | 249 | body=body_params, post_params=form_params, files=files,
|
@@ -274,11 +286,13 @@ def update_pet_with_form(self, pet_id, **kwargs):
|
274 | 286 | files = remove_none(dict())
|
275 | 287 | body_params = None
|
276 | 288 |
|
277 |
| - accepts = ['application/json', 'application/xml'] |
278 |
| - header_params['Accept'] = ', '.join(accepts) |
| 289 | + # HTTP header `Accept` |
| 290 | + header_params['Accept'] = ApiClient.select_header_accept(['application/json', 'application/xml']) |
| 291 | + if not header_params['Accept']: |
| 292 | + del header_params['Accept'] |
279 | 293 |
|
280 |
| - content_types = ['application/x-www-form-urlencoded'] |
281 |
| - header_params['Content-Type'] = content_types[0] if len(content_types) > 0 else 'application/json' |
| 294 | + # HTTP header `Content-Type` |
| 295 | + header_params['Content-Type'] = ApiClient.select_header_content_type(['application/x-www-form-urlencoded']) |
282 | 296 |
|
283 | 297 | response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
284 | 298 | body=body_params, post_params=form_params, files=files,
|
@@ -318,11 +332,13 @@ def delete_pet(self, pet_id, **kwargs):
|
318 | 332 | files = remove_none(dict())
|
319 | 333 | body_params = None
|
320 | 334 |
|
321 |
| - accepts = ['application/json', 'application/xml'] |
322 |
| - header_params['Accept'] = ', '.join(accepts) |
| 335 | + # HTTP header `Accept` |
| 336 | + header_params['Accept'] = ApiClient.select_header_accept(['application/json', 'application/xml']) |
| 337 | + if not header_params['Accept']: |
| 338 | + del header_params['Accept'] |
323 | 339 |
|
324 |
| - content_types = [] |
325 |
| - header_params['Content-Type'] = content_types[0] if len(content_types) > 0 else 'application/json' |
| 340 | + # HTTP header `Content-Type` |
| 341 | + header_params['Content-Type'] = ApiClient.select_header_content_type([]) |
326 | 342 |
|
327 | 343 | response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
328 | 344 | body=body_params, post_params=form_params, files=files,
|
@@ -363,11 +379,13 @@ def upload_file(self, pet_id, **kwargs):
|
363 | 379 | files = remove_none(dict(file=params.get('file')))
|
364 | 380 | body_params = None
|
365 | 381 |
|
366 |
| - accepts = ['application/json', 'application/xml'] |
367 |
| - header_params['Accept'] = ', '.join(accepts) |
| 382 | + # HTTP header `Accept` |
| 383 | + header_params['Accept'] = ApiClient.select_header_accept(['application/json', 'application/xml']) |
| 384 | + if not header_params['Accept']: |
| 385 | + del header_params['Accept'] |
368 | 386 |
|
369 |
| - content_types = ['multipart/form-data'] |
370 |
| - header_params['Content-Type'] = content_types[0] if len(content_types) > 0 else 'application/json' |
| 387 | + # HTTP header `Content-Type` |
| 388 | + header_params['Content-Type'] = ApiClient.select_header_content_type(['multipart/form-data']) |
371 | 389 |
|
372 | 390 | response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
373 | 391 | body=body_params, post_params=form_params, files=files,
|
|
0 commit comments