From e17890d526d0f8b29b4758bdba4d00207e1dd01d Mon Sep 17 00:00:00 2001 From: Lukas S <9408779+Dijky@users.noreply.github.com> Date: Thu, 18 Apr 2019 05:04:35 +0200 Subject: [PATCH] [typescript-fetch] Double ampersand in query string with empty nested object (#2679) * [typescript-fetch] Filter empty parts from querystring before joining with '&' * [typescript-fetch] Update samples --- .../src/main/resources/typescript-fetch/runtime.mustache | 1 + .../client/petstore/typescript-fetch/builds/default/runtime.ts | 1 + .../petstore/typescript-fetch/builds/es6-target/runtime.ts | 1 + .../petstore/typescript-fetch/builds/with-interfaces/runtime.ts | 1 + .../petstore/typescript-fetch/builds/with-npm-version/runtime.ts | 1 + 5 files changed, 5 insertions(+) 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 a8d7af2354c..624feac809f 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache @@ -198,6 +198,7 @@ export function querystring(params: HTTPQuery, prefix: string = ''): string { } return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`; }) + .filter(part => part.length > 0) .join('&'); } diff --git a/samples/client/petstore/typescript-fetch/builds/default/runtime.ts b/samples/client/petstore/typescript-fetch/builds/default/runtime.ts index 0afb0ba14c0..be61a90a51f 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/runtime.ts @@ -209,6 +209,7 @@ export function querystring(params: HTTPQuery, prefix: string = ''): string { } return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`; }) + .filter(part => part.length > 0) .join('&'); } 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 0afb0ba14c0..be61a90a51f 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/runtime.ts @@ -209,6 +209,7 @@ export function querystring(params: HTTPQuery, prefix: string = ''): string { } return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`; }) + .filter(part => part.length > 0) .join('&'); } 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 0afb0ba14c0..be61a90a51f 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/runtime.ts @@ -209,6 +209,7 @@ export function querystring(params: HTTPQuery, prefix: string = ''): string { } return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`; }) + .filter(part => part.length > 0) .join('&'); } 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 0afb0ba14c0..be61a90a51f 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 @@ -209,6 +209,7 @@ export function querystring(params: HTTPQuery, prefix: string = ''): string { } return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`; }) + .filter(part => part.length > 0) .join('&'); }