@@ -4,11 +4,20 @@ import {
4
4
{{#imports} }
5
5
{ {{.} }},
6
6
{ {.} }FromJSON,
7
+ { {.} }FromJSONTyped,
7
8
{ {.} }ToJSON,
8
9
{ {/imports} }
9
10
} from './';
10
11
11
12
{ {/hasImports} }
13
+ { {#discriminator} }
14
+ import {
15
+ {{#discriminator.mappedModels} }
16
+ { {modelName} }FromJSONTyped
17
+ { {/discriminator.mappedModels} }
18
+ } from './';
19
+
20
+ { {/discriminator} }
12
21
/**
13
22
* { {{description} }}
14
23
* @export
@@ -29,8 +38,25 @@ export interface {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{
29
38
}
30
39
31
40
export function { {classname} }FromJSON(json: any): { {classname} } {
41
+ return {{classname} }FromJSONTyped(json, false);
42
+ }
43
+
44
+ export function { {classname} }FromJSONTyped(json: any, ignoreDiscriminator: boolean): { {classname} } {
32
45
{{#hasVars} }
46
+ if ((json === undefined) || (json === null)) {
47
+ return json;
48
+ }
49
+ { {#discriminator} }
50
+ if (!ignoreDiscriminator) {
51
+ {{#discriminator.mappedModels} }
52
+ if (json['{ {discriminator.propertyName} }'] === '{ {modelName} }') {
53
+ return {{modelName} }FromJSONTyped(json, true);
54
+ }
55
+ { {/discriminator.mappedModels} }
56
+ }
57
+ { {/discriminator} }
33
58
return {
59
+ {{#parent} }...{ {{parent} }}FromJSONTyped(json, ignoreDiscriminator),{ {/parent} }
34
60
{ {#additionalPropertiesType} }
35
61
...json,
36
62
{ {/additionalPropertiesType} }
@@ -79,7 +105,11 @@ export function {{classname}}ToJSON(value?: {{classname}}): any {
79
105
if (value === undefined) {
80
106
return undefined;
81
107
}
108
+ if (value === null) {
109
+ return null;
110
+ }
82
111
return {
112
+ {{#parent} }...{ {{parent} }}ToJSON(value),{ {/parent} }
83
113
{ {#additionalPropertiesType} }
84
114
...value,
85
115
{ {/additionalPropertiesType} }
0 commit comments