[BUG] [typescript-fetch] serialize/deserialze not working with inheritence
Created by: stephanpelikan
Description
Properties of super-classes are not serialized/deserialized.
openapi-generator version
4.1.0
OpenAPI declaration file content or url
components:
schemas:
Type:
type: string
enum:
- B
A:
type: object
discriminator:
propertyName: type
required:
- type
properties:
whatever-a:
type: string
type:
$ref: "#/components/schemas/Type"
B:
allOf:
- $ref: "#/components/schemas/A"
- type: object
discriminator:
propertyName: type
properties:
whatever-b:
type: string
Suggest a fix
in modelGeneric.mustache add the lines with comment:
export function {{classname}}FromJSON(json: any): {{classname}} {
{{#hasVars}}
return {
{{#parent}}...{{{parent}}}FromJSON(json),{{/parent}} // deserialize inherited properties as well
{{#additionalPropertiesType}}
...json,
{{/additionalPropertiesType}}
and
export function {{classname}}ToJSON(value?: {{classname}}): any {
{{#hasVars}}
if (value === undefined) {
return undefined;
}
return {
{{#parent}}...{{{parent}}}ToJSON(value),{{/parent}} // serialize inherited properties as well
{{#additionalPropertiesType}}
...value,
{{/additionalPropertiesType}}