Skip to content

Commit d2b8a1e

Browse files
authored
[typescript] add abort signal to requestcontext (#21323)
* add abort signal to requestcontext * regenerate * rebuild and regenerate * abort signal import * refresh samples * clean csharp samples * csharp sample cleanup * add missing cs samples from master * abort testing
1 parent dbc5d09 commit d2b8a1e

File tree

34 files changed

+366
-104
lines changed

34 files changed

+366
-104
lines changed

modules/openapi-generator/src/main/resources/typescript/http/http.mustache

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {{^supportsES6}}* as{{/supportsES6}} FormData from "form-data";
55
import { URL, URLSearchParams } from 'url';
66
import * as http from 'http';
77
import * as https from 'https';
8+
import { AbortSignal } from "node-fetch/externals";
89
{{/node}}
910
{{/platforms}}
1011
import { Observable, from } from {{#useRxJS}}'rxjs'{{/useRxJS}}{{^useRxJS}}'../rxjsStub{{importFileExtension}}'{{/useRxJS}};
@@ -86,6 +87,7 @@ export class RequestContext {
8687
private headers: Headers = {};
8788
private body: RequestBody = undefined;
8889
private url: URL;
90+
private signal: AbortSignal | undefined = undefined;
8991
{{#platforms}}
9092
{{#node}}
9193
private agent: http.Agent | https.Agent | undefined = undefined;
@@ -167,6 +169,15 @@ export class RequestContext {
167169
public setHeaderParam(key: string, value: string): void {
168170
this.headers[key] = value;
169171
}
172+
173+
public setSignal(signal: AbortSignal): void {
174+
this.signal = signal;
175+
}
176+
177+
public getSignal(): AbortSignal | undefined {
178+
return this.signal;
179+
}
180+
170181
{{#platforms}}
171182
{{#node}}
172183

modules/openapi-generator/src/main/resources/typescript/http/isomorphic-fetch.mustache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export class IsomorphicFetchHttpLibrary implements HttpLibrary {
1919
method: method,
2020
body: body as any,
2121
headers: request.getHeaders(),
22+
signal: request.getSignal(),
2223
{{#platforms}}
2324
{{#node}}
2425
agent: request.getAgent(),

samples/client/echo_api/typescript/build/http/http.ts

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

samples/client/echo_api/typescript/build/http/isomorphic-fetch.ts

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

samples/client/others/typescript/builds/array-of-lists/http/http.ts

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

samples/client/others/typescript/builds/array-of-lists/http/isomorphic-fetch.ts

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

samples/client/others/typescript/builds/enum-single-value/http/http.ts

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

samples/client/others/typescript/builds/enum-single-value/http/isomorphic-fetch.ts

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

samples/client/others/typescript/builds/null-types-simple/http/http.ts

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

samples/client/others/typescript/builds/null-types-simple/http/isomorphic-fetch.ts

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)