diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache index 0f80666ff9ae..942f65369c88 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache @@ -52,10 +52,13 @@ export class BaseAPI { const body = (context.body instanceof FormData || isBlob(context.body)) ? context.body : JSON.stringify(context.body); + + const headers = Object.assign({}, this.configuration.headers, context.headers); const init = { method: context.method, - headers: context.headers, + headers: headers, body, + credentials: this.configuration.credentials }; return { url, init }; } @@ -121,6 +124,8 @@ export interface ConfigurationParameters { password?: string; // parameter for basic security apiKey?: string | ((name: string) => string); // parameter for apiKey security accessToken?: string | ((name?: string, scopes?: string[]) => string); // parameter for oauth2 security + headers?: HTTPHeaders; //header params we want to use on every request + credentials?: RequestCredentials; //value for the credentials param we want to use on each request } export class Configuration { @@ -165,6 +170,14 @@ export class Configuration { } return undefined; } + + get headers(): HTTPHeaders { + return this.configuration.headers; + } + + get credentials(): RequestCredentials { + return this.configuration.credentials; + } } export type Json = any; diff --git a/samples/client/petstore/typescript-fetch/builds/default/src/runtime.ts b/samples/client/petstore/typescript-fetch/builds/default/src/runtime.ts index 6feeddff5d41..48e54ca6eb21 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/src/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/src/runtime.ts @@ -63,10 +63,13 @@ export class BaseAPI { const body = (context.body instanceof FormData || isBlob(context.body)) ? context.body : JSON.stringify(context.body); + + const headers = Object.assign({}, this.configuration.headers, context.headers); const init = { method: context.method, - headers: context.headers, + headers: headers, body, + credentials: this.configuration.credentials }; return { url, init }; } @@ -132,6 +135,8 @@ export interface ConfigurationParameters { password?: string; // parameter for basic security apiKey?: string | ((name: string) => string); // parameter for apiKey security accessToken?: string | ((name?: string, scopes?: string[]) => string); // parameter for oauth2 security + headers?: HTTPHeaders; //header params we want to use on every request + credentials?: RequestCredentials; //value for the credentials param we want to use on each request } export class Configuration { @@ -176,6 +181,14 @@ export class Configuration { } return undefined; } + + get headers(): HTTPHeaders { + return this.configuration.headers; + } + + get credentials(): RequestCredentials { + return this.configuration.credentials; + } } export type Json = any; diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/src/runtime.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/src/runtime.ts index 6feeddff5d41..48e54ca6eb21 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/src/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/src/runtime.ts @@ -63,10 +63,13 @@ export class BaseAPI { const body = (context.body instanceof FormData || isBlob(context.body)) ? context.body : JSON.stringify(context.body); + + const headers = Object.assign({}, this.configuration.headers, context.headers); const init = { method: context.method, - headers: context.headers, + headers: headers, body, + credentials: this.configuration.credentials }; return { url, init }; } @@ -132,6 +135,8 @@ export interface ConfigurationParameters { password?: string; // parameter for basic security apiKey?: string | ((name: string) => string); // parameter for apiKey security accessToken?: string | ((name?: string, scopes?: string[]) => string); // parameter for oauth2 security + headers?: HTTPHeaders; //header params we want to use on every request + credentials?: RequestCredentials; //value for the credentials param we want to use on each request } export class Configuration { @@ -176,6 +181,14 @@ export class Configuration { } return undefined; } + + get headers(): HTTPHeaders { + return this.configuration.headers; + } + + get credentials(): RequestCredentials { + return this.configuration.credentials; + } } export type Json = any; diff --git a/samples/client/petstore/typescript-fetch/builds/multiple-parameters/src/runtime.ts b/samples/client/petstore/typescript-fetch/builds/multiple-parameters/src/runtime.ts index 6feeddff5d41..48e54ca6eb21 100644 --- a/samples/client/petstore/typescript-fetch/builds/multiple-parameters/src/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/multiple-parameters/src/runtime.ts @@ -63,10 +63,13 @@ export class BaseAPI { const body = (context.body instanceof FormData || isBlob(context.body)) ? context.body : JSON.stringify(context.body); + + const headers = Object.assign({}, this.configuration.headers, context.headers); const init = { method: context.method, - headers: context.headers, + headers: headers, body, + credentials: this.configuration.credentials }; return { url, init }; } @@ -132,6 +135,8 @@ export interface ConfigurationParameters { password?: string; // parameter for basic security apiKey?: string | ((name: string) => string); // parameter for apiKey security accessToken?: string | ((name?: string, scopes?: string[]) => string); // parameter for oauth2 security + headers?: HTTPHeaders; //header params we want to use on every request + credentials?: RequestCredentials; //value for the credentials param we want to use on each request } export class Configuration { @@ -176,6 +181,14 @@ export class Configuration { } return undefined; } + + get headers(): HTTPHeaders { + return this.configuration.headers; + } + + get credentials(): RequestCredentials { + return this.configuration.credentials; + } } export type Json = any; diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/src/runtime.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/src/runtime.ts index 6feeddff5d41..48e54ca6eb21 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/src/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/src/runtime.ts @@ -63,10 +63,13 @@ export class BaseAPI { const body = (context.body instanceof FormData || isBlob(context.body)) ? context.body : JSON.stringify(context.body); + + const headers = Object.assign({}, this.configuration.headers, context.headers); const init = { method: context.method, - headers: context.headers, + headers: headers, body, + credentials: this.configuration.credentials }; return { url, init }; } @@ -132,6 +135,8 @@ export interface ConfigurationParameters { password?: string; // parameter for basic security apiKey?: string | ((name: string) => string); // parameter for apiKey security accessToken?: string | ((name?: string, scopes?: string[]) => string); // parameter for oauth2 security + headers?: HTTPHeaders; //header params we want to use on every request + credentials?: RequestCredentials; //value for the credentials param we want to use on each request } export class Configuration { @@ -176,6 +181,14 @@ export class Configuration { } return undefined; } + + get headers(): HTTPHeaders { + return this.configuration.headers; + } + + get credentials(): RequestCredentials { + return this.configuration.credentials; + } } export type Json = any; diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/runtime.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/runtime.ts index 6feeddff5d41..48e54ca6eb21 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/runtime.ts @@ -63,10 +63,13 @@ export class BaseAPI { const body = (context.body instanceof FormData || isBlob(context.body)) ? context.body : JSON.stringify(context.body); + + const headers = Object.assign({}, this.configuration.headers, context.headers); const init = { method: context.method, - headers: context.headers, + headers: headers, body, + credentials: this.configuration.credentials }; return { url, init }; } @@ -132,6 +135,8 @@ export interface ConfigurationParameters { password?: string; // parameter for basic security apiKey?: string | ((name: string) => string); // parameter for apiKey security accessToken?: string | ((name?: string, scopes?: string[]) => string); // parameter for oauth2 security + headers?: HTTPHeaders; //header params we want to use on every request + credentials?: RequestCredentials; //value for the credentials param we want to use on each request } export class Configuration { @@ -176,6 +181,14 @@ export class Configuration { } return undefined; } + + get headers(): HTTPHeaders { + return this.configuration.headers; + } + + get credentials(): RequestCredentials { + return this.configuration.credentials; + } } export type Json = any;