From a4ba1c590b523a3ff7691cdffca7696301b77feb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20G=C3=BCrtler?= Date: Tue, 21 Oct 2025 15:03:14 +0200 Subject: [PATCH] [typescript-fetch] Check against the typed JSON in oneOf serialization --- .../src/main/resources/typescript-fetch/modelOneOf.mustache | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/modelOneOf.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/modelOneOf.mustache index 7d5c01878949..03a69ce29344 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/modelOneOf.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/modelOneOf.mustache @@ -47,7 +47,7 @@ export function {{classname}}FromJSONTyped(json: any, ignoreDiscriminator: boole return json; } {{/-first}} - if (instanceOf{{{.}}}(json)) { + if (instanceOf{{{.}}}({{{.}}}FromJSONTyped(json, true))) { return {{{.}}}FromJSONTyped(json, true); } {{/oneOfModels}} @@ -56,7 +56,7 @@ export function {{classname}}FromJSONTyped(json: any, ignoreDiscriminator: boole if (Array.isArray(json)) { if (json.every(item => typeof item === 'object')) { {{/-first}} - if (json.every(item => instanceOf{{{.}}}(item))) { + if (json.every(item => instanceOf{{{.}}}({{{.}}}FromJSONTyped(item, true)))) { return json.map(value => {{{.}}}FromJSONTyped(value, true)); } {{#-last}}