From 373a34c78ccd35a9550c0ece26dabf9e52a7e843 Mon Sep 17 00:00:00 2001 From: Al Scott Date: Fri, 9 May 2025 13:24:54 -0600 Subject: [PATCH] Updated param checking --- .../main/resources/typescript-fetch/apis.mustache | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache index 47d4d90335a..dfe4f97471e 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache @@ -281,11 +281,19 @@ export class {{classname}} extends runtime.BaseAPI { let urlPath = `{{{path}}}`; {{#pathParams}} {{#isDateTimeType}} - urlPath = urlPath.replace(`{${"{{baseName}}"}}`, encodeURIComponent((requestParameters['{{paramName}}'] as any).toISOString())); + if (requestParameters['{{paramName}}'] instanceof Date) { + urlPath = urlPath.replace(`{${"{{baseName}}"}}`, encodeURIComponent(requestParameters['{{paramName}}'].toISOString())); + } else { + urlPath = urlPath.replace(`{${"{{baseName}}"}}`, encodeURIComponent(String(requestParameters['{{paramName}}']))); + } {{/isDateTimeType}} {{^isDateTimeType}} {{#isDateType}} - urlPath = urlPath.replace(`{${"{{baseName}}"}}`, encodeURIComponent((requestParameters['{{paramName}}'] as any).toISOString().substring(0,10))); + if (requestParameters['{{paramName}}'] instanceof Date) { + urlPath = urlPath.replace(`{${"{{baseName}}"}}`, encodeURIComponent(requestParameters['{{paramName}}'].toISOString().substring(0,10)); + } else { + urlPath = urlPath.replace(`{${"{{baseName}}"}}`, encodeURIComponent(String(requestParameters['{{paramName}}']))); + } {{/isDateType}} {{^isDateType}} urlPath = urlPath.replace(`{${"{{baseName}}"}}`, encodeURIComponent(String(requestParameters['{{paramName}}'])));