diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache index 9ad18a9ccc7..12b09f34402 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache @@ -126,7 +126,7 @@ export function {{classname}}ToJSONTyped(value?: {{#hasReadOnly}}Omit<{{classnam return {{modelName}}ToJSONTyped(value as {{modelName}}, ignoreDiscriminator); {{/discriminator.mappedModels}} default: - throw new Error(`No variant of {{classname}} exists with '{{discriminator.propertyName}}=${value['{{discriminator.propertyName}}']}'`); + return value; } } {{/discriminator}} 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 c02a0df9da7..b516da670e1 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/modelOneOf.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/modelOneOf.mustache @@ -27,7 +27,7 @@ export function {{classname}}FromJSONTyped(json: any, ignoreDiscriminator: boole return Object.assign({}, {{modelName}}FromJSONTyped(json, true), { {{discriminator.propertyName}}: '{{mappingName}}' } as const); {{/discriminator.mappedModels}} default: - throw new Error(`No variant of {{classname}} exists with '{{discriminator.propertyName}}=${json['{{discriminator.propertyName}}']}'`); + return json; } {{/discriminator}} {{^discriminator}} @@ -56,7 +56,7 @@ export function {{classname}}ToJSONTyped(value?: {{classname}} | null, ignoreDis return Object.assign({}, {{modelName}}ToJSON(value), { {{discriminator.propertyName}}: '{{mappingName}}' } as const); {{/discriminator.mappedModels}} default: - throw new Error(`No variant of {{classname}} exists with '{{discriminator.propertyName}}=${value['{{discriminator.propertyName}}']}'`); + return json; } {{/discriminator}} diff --git a/samples/client/others/typescript-fetch/self-import-issue/models/AbstractUserDto.ts b/samples/client/others/typescript-fetch/self-import-issue/models/AbstractUserDto.ts index 29e0d20f36f..ad4ece85fb3 100644 --- a/samples/client/others/typescript-fetch/self-import-issue/models/AbstractUserDto.ts +++ b/samples/client/others/typescript-fetch/self-import-issue/models/AbstractUserDto.ts @@ -96,7 +96,7 @@ export function AbstractUserDtoToJSONTyped(value?: AbstractUserDto | null, ignor case 'remote-authenticated': return RemoteAuthenticatedUserDtoToJSONTyped(value as RemoteAuthenticatedUserDto, ignoreDiscriminator); default: - throw new Error(`No variant of AbstractUserDto exists with 'type=${value['type']}'`); + return value; } } diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Animal.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Animal.ts index f1289f027f1..a6fed19c73b 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Animal.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Animal.ts @@ -82,7 +82,7 @@ export function AnimalToJSONTyped(value?: Animal | null, ignoreDiscriminator: bo case 'DOG': return DogToJSONTyped(value as Dog, ignoreDiscriminator); default: - throw new Error(`No variant of Animal exists with 'className=${value['className']}'`); + return value; } } diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ParentWithNullable.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ParentWithNullable.ts index 8b64d83d50f..410f2d732cc 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ParentWithNullable.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ParentWithNullable.ts @@ -85,7 +85,7 @@ export function ParentWithNullableToJSONTyped(value?: ParentWithNullable | null, case 'ChildWithNullable': return ChildWithNullableToJSONTyped(value as ChildWithNullable, ignoreDiscriminator); default: - throw new Error(`No variant of ParentWithNullable exists with 'type=${value['type']}'`); + return value; } } diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/Animal.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/Animal.ts index fb532ffbeff..6edfcf07925 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/Animal.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/Animal.ts @@ -82,7 +82,7 @@ export function AnimalToJSONTyped(value?: Animal | null, ignoreDiscriminator: bo case 'DOG': return DogToJSONTyped(value as Dog, ignoreDiscriminator); default: - throw new Error(`No variant of Animal exists with 'className=${value['className']}'`); + return value; } }