1
1
# coding: utf-8
2
2
3
3
{ {> partial_header} }
4
-
5
- import io
6
4
import warnings
7
-
8
5
from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt
9
- from typing import Dict, List, Optional, Tuple, Union, Any
10
-
11
- try:
12
- from typing import Annotated
13
- except ImportError:
14
- from typing_extensions import Annotated
6
+ from typing import Any, Dict, List, Optional, Tuple, Union
7
+ from typing_extensions import Annotated
15
8
16
9
{ {#imports} }
17
10
{ {import} }
18
11
{ {/imports} }
19
12
20
- from { {packageName} }.api_client import ApiClient
13
+ from { {packageName} }.api_client import ApiClient, RequestSerialized
21
14
from { {packageName} }.api_response import ApiResponse
22
15
from { {packageName} }.rest import RESTResponseType
23
16
@@ -84,7 +77,7 @@ class {{classname}}:
84
77
_content_type,
85
78
_headers,
86
79
_host_index,
87
- ) -> Tuple :
80
+ ) -> RequestSerialized :
88
81
89
82
{ {#servers.0} }
90
83
_hosts = [{ {#servers} }
@@ -108,7 +101,7 @@ class {{classname}}:
108
101
_query_params: List[Tuple[str, str]] = []
109
102
_header_params: Dict[str, Optional[str]] = _headers or { }
110
103
_form_params: List[Tuple[str, str]] = []
111
- _files: Dict[str, str] = { }
104
+ _files: Dict[str, Union[ str, bytes] ] = { }
112
105
_body_params: Optional[bytes] = None
113
106
114
107
# process the path parameters
@@ -170,7 +163,7 @@ class {{classname}}:
170
163
{ {#isBinary} }
171
164
# convert to byte array if the input is a file name (str)
172
165
if isinstance({ {paramName} }, str):
173
- with io. open({ {paramName} }, "rb") as _fp:
166
+ with open({ {paramName} }, "rb") as _fp:
174
167
_body_params = _fp.read()
175
168
else:
176
169
_body_params = { {paramName} }
@@ -183,7 +176,7 @@ class {{classname}}:
183
176
{ {#constantParams} }
184
177
{ {#isQueryParam} }
185
178
# Set client side default value of Query Param "{ {baseName} }".
186
- _query_params[ '{ {baseName} }'] = { {#_enum} }'{ {{.} }}'{ {/_enum} }
179
+ _query_params.append(( '{ {baseName} }', { {#_enum} }'{ {{.} }}'{ {/_enum} }))
187
180
{ {/isQueryParam} }
188
181
{ {#isHeaderParam} }
189
182
# Set client side default value of Header Param "{ {baseName} }".
@@ -193,11 +186,12 @@ class {{classname}}:
193
186
194
187
{ {#hasProduces} }
195
188
# set the HTTP header `Accept`
196
- _header_params['Accept'] = self.api_client.select_header_accept(
197
- [{ {#produces} }
198
- '{ {{mediaType} }}'{ {^-last} }, { {/-last} }{ {/produces} }
199
- ]
200
- )
189
+ if 'Accept' not in _header_params:
190
+ _header_params['Accept'] = self.api_client.select_header_accept(
191
+ [{ {#produces} }
192
+ '{ {{mediaType} }}'{ {^-last} }, { {/-last} }{ {/produces} }
193
+ ]
194
+ )
201
195
{ {/hasProduces} }
202
196
203
197
{ {#hasConsumes} }
0 commit comments