@@ -55,7 +55,64 @@ export function {{classname}}FromJSONTyped(json: any, ignoreDiscriminator: boole
5555 }
5656 { {/-last} }
5757 { {/oneOfArrays} }
58-
58+ { {#oneOfPrimitives} }
59+ { {#isArray} }
60+ { {#items} }
61+ { {#isDateType} }
62+ if (Array.isArray(json)) {
63+ if (json.every(item => ! (isNaN(new Date(json).getTime()))) {
64+ return json.map(value => new Date(json);
65+ }
66+ }
67+ { {/isDateType} }
68+ { {#isDateTimeType} }
69+ if (Array.isArray(json)) {
70+ if (json.every(item => ! (isNaN(new Date(json).getTime()))) {
71+ return json.map(value => new Date(json);
72+ }
73+ }
74+ { {/isDateTimeType} }
75+ { {#isNumeric} }
76+ if (Array.isArray(json)) {
77+ if (json.every(item => typeof item === ' number' {{#isEnum} } && ({ {#allowableValues} }{ {#values} }item === { {.} }{ {^-last} } || { {/-last} }{ {/values} }{ {/allowableValues} }){ {/isEnum} })) {
78+ return json;
79+ }
80+ }
81+ { {/isNumeric} }
82+ { {#isString} }
83+ if (Array.isArray(json)) {
84+ if (json.every(item => typeof item === ' string' {{#isEnum} } && ({ {#allowableValues} }{ {#values} }item === '{ {.} }'{ {^-last} } || { {/-last} }{ {/values} }{ {/allowableValues} }){ {/isEnum} })) {
85+ return json;
86+ }
87+ }
88+ { {/isString} }
89+ { {/items} }
90+ { {/isArray} }
91+ { {^isArray} }
92+ { {#isDateType} }
93+ if(!(isNaN(new Date(json).getTime()))) {
94+ return {{^required} }json == null ? undefined : { {/required} }({ {#required} }{ {#isNullable} }json == null ? null : { {/isNullable} }{ {/required} }new Date(json));
95+ }
96+ { {/isDateType} }
97+ { {^isDateType} }
98+ { {#isDateTimeType} }
99+ if(!(isNaN(new Date(json).getTime()))) {
100+ return {{^required} }json == null ? undefined : { {/required} }({ {#required} }{ {#isNullable} }json == null ? null : { {/isNullable} }{ {/required} }new Date(json));
101+ }
102+ { {/isDateTimeType} }
103+ { {/isDateType} }
104+ { {#isNumeric} }
105+ if(typeof json === 'number'{ {#isEnum} } && ({ {#allowableValues} }{ {#values} }json === { {.} }{ {^-last} } || { {/-last} }{ {/values} }{ {/allowableValues} }){ {/isEnum} }) {
106+ return json;
107+ }
108+ { {/isNumeric} }
109+ { {#isString} }
110+ if(typeof json === 'string'{ {#isEnum} } && ({ {#allowableValues} }{ {#values} }json === '{ {.} }'{ {^-last} } || { {/-last} }{ {/values} }{ {/allowableValues} }){ {/isEnum} }) {
111+ return json;
112+ }
113+ { {/isString} }
114+ { {/isArray} }
115+ { {/oneOfPrimitives} }
59116 return { } as any;
60117{ {/discriminator} }
61118}
@@ -103,7 +160,62 @@ export function {{classname}}ToJSONTyped(value?: {{classname}} | null, ignoreDis
103160 }
104161 { {/-last} }
105162 { {/oneOfArrays} }
106-
163+ { {#oneOfPrimitives} }
164+ { {#isArray} }
165+ { {#items} }
166+ { {#isDateType} }
167+ if (Array.isArray(value)) {
168+ if (value.every(item => item instanceof Date) {
169+ return value.map(value => value.toISOString().substring(0,10)));
170+ }
171+ }
172+ { {/isDateType} }
173+ { {#isDateTimeType} }
174+ if (Array.isArray(value)) {
175+ if (value.every(item => item instanceof Date) {
176+ return value.map(value => value.toISOString();
177+ }
178+ }
179+ { {/isDateTimeType} }
180+ { {#isNumeric} }
181+ if (Array.isArray(value)) {
182+ if (value.every(item => typeof item === ' number' {{#isEnum} } && ({ {#allowableValues} }{ {#values} }item === { {.} }{ {^-last} } || { {/-last} }{ {/values} }{ {/allowableValues} }){ {/isEnum} }) {
183+ return value;
184+ }
185+ }
186+ { {/isNumeric} }
187+ { {#isString} }
188+ if (Array.isArray(value)) {
189+ if (value.every(item => typeof item === ' string' {{#isEnum} } && ({ {#allowableValues} }{ {#values} }item === '{ {.} }'{ {^-last} } || { {/-last} }{ {/values} }{ {/allowableValues} }){ {/isEnum} }) {
190+ return value;
191+ }
192+ }
193+ { {/isString} }
194+ { {/items} }
195+ { {/isArray} }
196+ { {^isArray} }
197+ { {#isDateType} }
198+ if(value instanceof Date) {
199+ return ((value{{#isNullable} } as any{ {/isNullable} }){ {^required} }{ {#isNullable} }?{ {/isNullable} }{ {/required} }.toISOString().substring(0,10));
200+ }
201+ { {/isDateType} }
202+ { {#isDateTimeType} }
203+ if(value instanceof Date) {
204+ return {{^required} }{ {#isNullable} }value === null ? null : { {/isNullable} }{ {^isNullable} }value == null ? undefined : { {/isNullable} }{ {/required} }((value{ {#isNullable} } as any{ {/isNullable} }){ {^required} }{ {#isNullable} }?{ {/isNullable} }{ {/required} }.toISOString());
205+ }
206+ { {/isDateTimeType} }
207+ { {#isNumeric} }
208+ if(typeof value === 'number'{ {#isEnum} } && ({ {#allowableValues} }{ {#values} }value === { {.} }{ {^-last} } || { {/-last} }{ {/values} }{ {/allowableValues} }){ {/isEnum} }) {
209+ return value;
210+ }
211+ { {/isNumeric} }
212+ { {#isString} }
213+ if(typeof value === 'string'{ {#isEnum} } && ({ {#allowableValues} }{ {#values} }value === '{ {.} }'{ {^-last} } || { {/-last} }{ {/values} }{ {/allowableValues} }){ {/isEnum} }) {
214+ return value;
215+ }
216+ { {/isString} }
217+ { {/isArray} }
218+ { {/oneOfPrimitives} }
107219 return { } ;
108220{ {/discriminator} }
109221}
0 commit comments