From ce60dbbc585ca917abf0d0af8b9921215be8786d Mon Sep 17 00:00:00 2001 From: Esteban Marin Date: Wed, 13 Mar 2019 16:12:13 +0100 Subject: [PATCH] fix typescript fetch compile issue (#2383) * fix tyepscript fetch compile issue * generate samples * improve fix --- .../src/main/resources/typescript-fetch/runtime.mustache | 4 ++-- .../petstore/typescript-fetch/builds/default/runtime.ts | 4 ++-- .../petstore/typescript-fetch/builds/es6-target/runtime.ts | 4 ++-- .../typescript-fetch/builds/with-interfaces/runtime.ts | 4 ++-- .../typescript-fetch/builds/with-npm-version/runtime.ts | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) 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 741a1ba5545..4f10c8d1c7d 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache @@ -189,12 +189,12 @@ export function querystring(params: HTTPQuery, prefix: string = '') { const fullKey = prefix + (prefix.length ? `[${key}]` : key); const value = params[key]; if (value instanceof Array) { - const multiValue = value.map(singleValue => encodeURIComponent(singleValue)) + const multiValue = value.map(singleValue => encodeURIComponent(String(singleValue))) .join(`&${encodeURIComponent(fullKey)}=`); return `${encodeURIComponent(fullKey)}=${multiValue}`; } if (value instanceof Object) { - return querystring(value, fullKey); + return querystring(value as HTTPQuery, fullKey); } return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`; }) diff --git a/samples/client/petstore/typescript-fetch/builds/default/runtime.ts b/samples/client/petstore/typescript-fetch/builds/default/runtime.ts index 593648d3776..0ed72ba5352 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/runtime.ts @@ -200,12 +200,12 @@ export function querystring(params: HTTPQuery, prefix: string = '') { const fullKey = prefix + (prefix.length ? `[${key}]` : key); const value = params[key]; if (value instanceof Array) { - const multiValue = value.map(singleValue => encodeURIComponent(singleValue)) + const multiValue = value.map(singleValue => encodeURIComponent(String(singleValue))) .join(`&${encodeURIComponent(fullKey)}=`); return `${encodeURIComponent(fullKey)}=${multiValue}`; } if (value instanceof Object) { - return querystring(value, fullKey); + return querystring(value as HTTPQuery, fullKey); } return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`; }) diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/runtime.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/runtime.ts index 593648d3776..0ed72ba5352 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/runtime.ts @@ -200,12 +200,12 @@ export function querystring(params: HTTPQuery, prefix: string = '') { const fullKey = prefix + (prefix.length ? `[${key}]` : key); const value = params[key]; if (value instanceof Array) { - const multiValue = value.map(singleValue => encodeURIComponent(singleValue)) + const multiValue = value.map(singleValue => encodeURIComponent(String(singleValue))) .join(`&${encodeURIComponent(fullKey)}=`); return `${encodeURIComponent(fullKey)}=${multiValue}`; } if (value instanceof Object) { - return querystring(value, fullKey); + return querystring(value as HTTPQuery, fullKey); } return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`; }) diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/runtime.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/runtime.ts index 593648d3776..0ed72ba5352 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/runtime.ts @@ -200,12 +200,12 @@ export function querystring(params: HTTPQuery, prefix: string = '') { const fullKey = prefix + (prefix.length ? `[${key}]` : key); const value = params[key]; if (value instanceof Array) { - const multiValue = value.map(singleValue => encodeURIComponent(singleValue)) + const multiValue = value.map(singleValue => encodeURIComponent(String(singleValue))) .join(`&${encodeURIComponent(fullKey)}=`); return `${encodeURIComponent(fullKey)}=${multiValue}`; } if (value instanceof Object) { - return querystring(value, fullKey); + return querystring(value as HTTPQuery, fullKey); } return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`; }) diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/runtime.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/runtime.ts index 593648d3776..0ed72ba5352 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/runtime.ts @@ -200,12 +200,12 @@ export function querystring(params: HTTPQuery, prefix: string = '') { const fullKey = prefix + (prefix.length ? `[${key}]` : key); const value = params[key]; if (value instanceof Array) { - const multiValue = value.map(singleValue => encodeURIComponent(singleValue)) + const multiValue = value.map(singleValue => encodeURIComponent(String(singleValue))) .join(`&${encodeURIComponent(fullKey)}=`); return `${encodeURIComponent(fullKey)}=${multiValue}`; } if (value instanceof Object) { - return querystring(value, fullKey); + return querystring(value as HTTPQuery, fullKey); } return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`; })