Skip to content

Commit d0b5fff

Browse files
author
Silas Boyd-Wickizer
committed
[TypeScript][Node] support for overriding HTTP request headers
This approach is inspired by the typescript-fetch implementation. Fixes #9035
1 parent 377174f commit d0b5fff

File tree

5 files changed

+125
-43
lines changed

5 files changed

+125
-43
lines changed

modules/swagger-codegen/src/main/resources/typescript-node/api.mustache

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,8 +371,9 @@ export class {{classname}} {
371371
{{#allParams}}
372372
* @param {{paramName}} {{description}}
373373
{{/allParams}}
374+
* @param {*} [options] Override http request options.
374375
*/
375-
public {{nickname}} ({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) : Promise<{ response: http.{{#supportsES6}}IncomingMessage{{/supportsES6}}{{^supportsES6}}ClientResponse{{/supportsES6}}; {{#returnType}}body: {{{returnType}}}; {{/returnType}}{{^returnType}}body?: any; {{/returnType}} }> {
376+
public {{nickname}} ({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options: any = {}) : Promise<{ response: http.{{#supportsES6}}IncomingMessage{{/supportsES6}}{{^supportsES6}}ClientResponse{{/supportsES6}}; {{#returnType}}body: {{{returnType}}}; {{/returnType}}{{^returnType}}body?: any; {{/returnType}} }> {
376377
const localVarPath = this.basePath + '{{{path}}}'{{#pathParams}}
377378
.replace('{' + '{{baseName}}' + '}', encodeURIComponent(String({{paramName}}))){{/pathParams}};
378379
let localVarQueryParameters: any = {};
@@ -397,6 +398,7 @@ export class {{classname}} {
397398
{{#headerParams}}
398399
localVarHeaderParams['{{baseName}}'] = ObjectSerializer.serialize({{paramName}}, "{{{dataType}}}");
399400
{{/headerParams}}
401+
(<any>Object).assign(localVarHeaderParams, options.headers);
400402
401403
let localVarUseFormData = false;
402404
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.4.0-SNAPSHOT
1+
2.4.1-SNAPSHOT

0 commit comments

Comments
 (0)