Skip to content

Commit f22e6d9

Browse files
committed
update ts fetch samples
1 parent d20682e commit f22e6d9

3 files changed

Lines changed: 33 additions & 11 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7.19.0-SNAPSHOT
1+
7.23.0-SNAPSHOT

samples/client/others/typescript-fetch/additional-properties-in-multipart-issue/apis/FileApi.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,12 @@
1212
* Do not edit the class manually.
1313
*/
1414

15-
1615
import * as runtime from '../runtime';
17-
import type {
18-
StructuredType,
19-
} from '../models/index';
2016
import {
17+
type StructuredType,
2118
StructuredTypeFromJSON,
2219
StructuredTypeToJSON,
23-
} from '../models/index';
20+
} from '../models/StructuredType';
2421

2522
export interface CreateFileRequest {
2623
documentBytes: Blob;
@@ -35,8 +32,9 @@ export interface CreateFileRequest {
3532
export class FileApi extends runtime.BaseAPI {
3633

3734
/**
35+
* Creates request options for createFile without sending the request
3836
*/
39-
async createFileRaw(requestParameters: CreateFileRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
37+
async createFileRequestOpts(requestParameters: CreateFileRequest): Promise<runtime.RequestOpts> {
4038
if (requestParameters['documentBytes'] == null) {
4139
throw new runtime.RequiredError(
4240
'documentBytes',
@@ -97,13 +95,20 @@ export class FileApi extends runtime.BaseAPI {
9795

9896
let urlPath = `/api/v1/file`;
9997

100-
const response = await this.request({
98+
return {
10199
path: urlPath,
102100
method: 'POST',
103101
headers: headerParameters,
104102
query: queryParameters,
105103
body: formParams,
106-
}, initOverrides);
104+
};
105+
}
106+
107+
/**
108+
*/
109+
async createFileRaw(requestParameters: CreateFileRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
110+
const requestOptions = await this.createFileRequestOpts(requestParameters);
111+
const response = await this.request(requestOptions, initOverrides);
107112

108113
return new runtime.VoidApiResponse(response);
109114
}

samples/client/others/typescript-fetch/additional-properties-in-multipart-issue/runtime.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
* Do not edit the class manually.
1313
*/
1414

15-
1615
export const BASE_PATH = "http://localhost:8080".replace(/\/+$/, "");
1716

1817
export interface ConfigurationParameters {
@@ -91,7 +90,7 @@ export const DefaultConfig = new Configuration();
9190
*/
9291
export class BaseAPI {
9392

94-
private static readonly jsonRegex = new RegExp('^(:?application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i');
93+
private static readonly jsonRegex = /^(:?application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$/i;
9594
private middleware: Middleware[];
9695

9796
constructor(protected configuration = DefaultConfig) {
@@ -261,20 +260,38 @@ export class ResponseError extends Error {
261260
override name: "ResponseError" = "ResponseError";
262261
constructor(public response: Response, msg?: string) {
263262
super(msg);
263+
264+
// restore prototype chain
265+
const actualProto = new.target.prototype;
266+
if (Object.setPrototypeOf) {
267+
Object.setPrototypeOf(this, actualProto);
268+
}
264269
}
265270
}
266271

267272
export class FetchError extends Error {
268273
override name: "FetchError" = "FetchError";
269274
constructor(public cause: Error, msg?: string) {
270275
super(msg);
276+
277+
// restore prototype chain
278+
const actualProto = new.target.prototype;
279+
if (Object.setPrototypeOf) {
280+
Object.setPrototypeOf(this, actualProto);
281+
}
271282
}
272283
}
273284

274285
export class RequiredError extends Error {
275286
override name: "RequiredError" = "RequiredError";
276287
constructor(public field: string, msg?: string) {
277288
super(msg);
289+
290+
// restore prototype chain
291+
const actualProto = new.target.prototype;
292+
if (Object.setPrototypeOf) {
293+
Object.setPrototypeOf(this, actualProto);
294+
}
278295
}
279296
}
280297

0 commit comments

Comments
 (0)