diff --git a/modules/swagger-codegen/src/main/resources/TypeScript-Fetch/api.mustache b/modules/swagger-codegen/src/main/resources/TypeScript-Fetch/api.mustache index 5bf0ed7fb92..f1aa9e6c4bd 100644 --- a/modules/swagger-codegen/src/main/resources/TypeScript-Fetch/api.mustache +++ b/modules/swagger-codegen/src/main/resources/TypeScript-Fetch/api.mustache @@ -102,16 +102,16 @@ export const {{classname}}FetchParamCreactor = { fetchOptions.body = JSON.stringify(params["{{paramName}}"] || {}); }{{/bodyParam}} {{/hasBodyParam}} -{{#hasHeaderParam}} +{{#hasHeaderParams}} fetchOptions.headers = {{#supportsES6}}Object.{{/supportsES6}}assign({ {{#headerParams}} "{{baseName}}": params.{{paramName}},{{/headerParams}} }, contentTypeHeader); -{{/hasHeaderParam}} -{{^hasHeaderParam}} +{{/hasHeaderParams}} +{{^hasHeaderParams}} if (contentTypeHeader) { fetchOptions.headers = contentTypeHeader; } -{{/hasHeaderParam}} +{{/hasHeaderParams}} return { url: url.format(urlObj), options: fetchOptions, diff --git a/samples/client/petstore/typescript-fetch/builds/default/api.ts b/samples/client/petstore/typescript-fetch/builds/default/api.ts index a83e38286ac..f37307f7352 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/api.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/api.ts @@ -144,9 +144,9 @@ export const PetApiFetchParamCreactor = { let fetchOptions: RequestInit = { method: "DELETE" }; let contentTypeHeader: Dictionary; - if (contentTypeHeader) { - fetchOptions.headers = contentTypeHeader; - } + fetchOptions.headers = assign({ + "api_key": params.apiKey, + }, contentTypeHeader); return { url: url.format(urlObj), options: fetchOptions, diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/api.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/api.ts index bf3b7c9bab2..fa7d5153c10 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/api.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/api.ts @@ -143,9 +143,9 @@ export const PetApiFetchParamCreactor = { let fetchOptions: RequestInit = { method: "DELETE" }; let contentTypeHeader: Dictionary; - if (contentTypeHeader) { - fetchOptions.headers = contentTypeHeader; - } + fetchOptions.headers = Object.assign({ + "api_key": params.apiKey, + }, contentTypeHeader); return { url: url.format(urlObj), options: fetchOptions, diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/api.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/api.ts index a83e38286ac..f37307f7352 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/api.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/api.ts @@ -144,9 +144,9 @@ export const PetApiFetchParamCreactor = { let fetchOptions: RequestInit = { method: "DELETE" }; let contentTypeHeader: Dictionary; - if (contentTypeHeader) { - fetchOptions.headers = contentTypeHeader; - } + fetchOptions.headers = assign({ + "api_key": params.apiKey, + }, contentTypeHeader); return { url: url.format(urlObj), options: fetchOptions,