forked from loafle/openapi-generator-original
fix: support backwards compatible changes in discriminators (#20983)
Closes https://github.com/OpenAPITools/openapi-generator/issues/20982
This commit is contained in:
parent
701b6bd576
commit
045a9c16b1
@ -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}}
|
||||
|
@ -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}}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user