@@ -25,10 +25,14 @@ import type { CancelablePromise } from '../core/CancelablePromise';
25
25
import { BaseHttpRequest } from '../core/BaseHttpRequest';
26
26
{{ else }}
27
27
import type { BaseHttpRequest } from '../core/BaseHttpRequest';
28
+ import { Left, Right, Either } from '../core/ApiResult';
29
+ import { ApiError } from '../core/ApiError';
28
30
{{ /equals }}
29
31
{{ else }}
30
32
import { OpenAPI } from '../core/OpenAPI';
31
33
import { request as __request } from '../core/request';
34
+ import { Left, Right, Either } from '../core/ApiResult';
35
+ import { ApiError } from '../core/ApiError';
32
36
{{ /if }}
33
37
34
38
{{ #equals @root.httpClient ' angular' }}
@@ -146,5 +150,128 @@ export class {{{name}}}{{{@root.postfix}}} {
146
150
});
147
151
}
148
152
153
+ {{ #equals @root.httpClient ' angular' }}
154
+ {{ else }}
155
+ /**
156
+ {{ #if deprecated }}
157
+ * @deprecated
158
+ {{ /if }}
159
+ {{ #if summary }}
160
+ * {{{ escapeComment summary }}}
161
+ {{ /if }}
162
+ {{ #if description }}
163
+ * {{{ escapeComment description }}}
164
+ {{ /if }}
165
+ {{ #unless @root.useOptions }}
166
+ {{ #if parameters }}
167
+ {{ #each parameters }}
168
+ * @param {{{ name }}} {{ #if description }} {{{ escapeComment description }}} {{ /if }}
169
+ {{ /each }}
170
+ {{ /if }}
171
+ {{ /unless }}
172
+ {{ #each results }}
173
+ * @returns {{{ type }}} {{ #if description }} {{{ escapeComment description }}} {{ /if }}
174
+ {{ /each }}
175
+ * @throws ApiError
176
+ */
177
+ {{ #if @root.exportClient }}
178
+ {{ #equals @root.httpClient ' angular' }}
179
+ public async {{{ name }}} Either({{> parameters }} ): Observable<{{ >result}}> {
180
+ try {
181
+ const result: ({{> result }} ) = await this.httpRequest.request({
182
+ {{ else }}
183
+ public async {{{ name }}} Either({{> parameters }} ): Promise<Either <ApiError, {{> result }} >> {
184
+ try {
185
+ const result: ({{> result }} ) = await this.httpRequest.request({
186
+ {{ /equals }}
187
+ {{ else }}
188
+ {{ #equals @root.httpClient ' angular' }}
189
+ public async {{{ name }}} Either({{> parameters }} ): Observable<{{ >result}}> {
190
+ try {
191
+ const result: ({{> result }} ) = await __request(OpenAPI, this.http, {
192
+ {{ else }}
193
+ public static async {{{ name }}} Either({{> parameters }} ): Promise<Either <ApiError, {{> result }} >> {
194
+ try {
195
+ const result: ({{> result }} ) = await __request(OpenAPI, {
196
+ {{ /equals }}
197
+ {{ /if }}
198
+ method: '{{{ method }}} ',
199
+ url: '{{{ path }}} ',
200
+ {{ #if parametersPath }}
201
+ path: {
202
+ {{ #each parametersPath }}
203
+ '{{{ prop }}} ': {{{ name }}} ,
204
+ {{ /each }}
205
+ },
206
+ {{ /if }}
207
+ {{ #if parametersCookie }}
208
+ cookies: {
209
+ {{ #each parametersCookie }}
210
+ '{{{ prop }}} ': {{{ name }}} ,
211
+ {{ /each }}
212
+ },
213
+ {{ /if }}
214
+ {{ #if parametersHeader }}
215
+ headers: {
216
+ {{ #each parametersHeader }}
217
+ '{{{ prop }}} ': {{{ name }}} ,
218
+ {{ /each }}
219
+ },
220
+ {{ /if }}
221
+ {{ #if parametersQuery }}
222
+ query: {
223
+ {{ #each parametersQuery }}
224
+ '{{{ prop }}} ': {{{ name }}} ,
225
+ {{ /each }}
226
+ },
227
+ {{ /if }}
228
+ {{ #if parametersForm }}
229
+ formData: {
230
+ {{ #each parametersForm }}
231
+ '{{{ prop }}} ': {{{ name }}} ,
232
+ {{ /each }}
233
+ },
234
+ {{ /if }}
235
+ {{ #if parametersBody }}
236
+ {{ #equals parametersBody.in ' formData' }}
237
+ formData: {{{ parametersBody.name }}} ,
238
+ {{ /equals }}
239
+ {{ #equals parametersBody.in ' body' }}
240
+ body: {{{ parametersBody.name }}} ,
241
+ {{ /equals }}
242
+ {{ #if parametersBody.mediaType }}
243
+ mediaType: '{{{ parametersBody.mediaType }}} ',
244
+ {{ /if }}
245
+ {{ /if }}
246
+ {{ #if responseHeader }}
247
+ responseHeader: '{{{ responseHeader }}} ',
248
+ {{ /if }}
249
+ {{ #if errors }}
250
+ errors: {
251
+ {{ #each errors }}
252
+ {{{ code }}} : `{{{ escapeDescription description }}} `,
253
+ {{ /each }}
254
+ },
255
+ {{ /if }}
256
+ });
257
+
258
+ const right: Right<{{ >result}}> = {
259
+ _tag: 'Right',
260
+ right: result,
261
+ };
262
+
263
+ return right;
264
+ } catch (e) {
265
+ const left: Left<ApiError > = {
266
+ _tag: 'Left',
267
+ left: e as ApiError,
268
+ };
269
+
270
+ return left;
271
+ }
272
+ }
273
+ {{ /equals }}
274
+
275
+
149
276
{{ /each }}
150
277
}
0 commit comments