Skip to content

Commit e0cb018

Browse files
Update modelOneOf.mustache
Adds booleans to modelOneOf
1 parent d605afe commit e0cb018

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

modules/openapi-generator/src/main/resources/typescript-fetch/modelOneOf.mustache

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,13 @@ export function {{classname}}FromJSONTyped(json: any, ignoreDiscriminator: boole
8989
}
9090
}
9191
{{/isNumeric}}
92+
{{#isBoolean}}
93+
if (Array.isArray(json)) {
94+
if (json.every(item => typeof item === 'boolean'{{#isEnum}} && ({{#allowableValues}}{{#values}}item === {{.}}{{^-last}} || {{/-last}}{{/values}}{{/allowableValues}}){{/isEnum}})) {
95+
return json;
96+
}
97+
}
98+
{{/isBoolean}}
9299
{{#isString}}
93100
if (Array.isArray(json)) {
94101
if (json.every(item => typeof item === 'string'{{#isEnum}} && ({{#allowableValues}}{{#values}}item === '{{.}}'{{^-last}} || {{/-last}}{{/values}}{{/allowableValues}}){{/isEnum}})) {
@@ -116,6 +123,11 @@ export function {{classname}}FromJSONTyped(json: any, ignoreDiscriminator: boole
116123
return json;
117124
}
118125
{{/isNumeric}}
126+
{{#isBoolean}}
127+
if (typeof json === 'boolean'{{#isEnum}} && ({{#allowableValues}}{{#values}}json === {{.}}{{^-last}} || {{/-last}}{{/values}}{{/allowableValues}}){{/isEnum}}) {
128+
return json;
129+
}
130+
{{/isBoolean}}
119131
{{#isString}}
120132
if (typeof json === 'string'{{#isEnum}} && ({{#allowableValues}}{{#values}}json === '{{.}}'{{^-last}} || {{/-last}}{{/values}}{{/allowableValues}}){{/isEnum}}) {
121133
return json;
@@ -194,6 +206,13 @@ export function {{classname}}ToJSONTyped(value?: {{classname}} | null, ignoreDis
194206
}
195207
}
196208
{{/isNumeric}}
209+
{{#isBoolean}}
210+
if (Array.isArray(value)) {
211+
if (value.every(item => typeof item === 'boolean'{{#isEnum}} && ({{#allowableValues}}{{#values}}item === {{.}}{{^-last}} || {{/-last}}{{/values}}{{/allowableValues}}){{/isEnum}})) {
212+
return value;
213+
}
214+
}
215+
{{/isBoolean}}
197216
{{#isString}}
198217
if (Array.isArray(value)) {
199218
if (value.every(item => typeof item === 'string'{{#isEnum}} && ({{#allowableValues}}{{#values}}item === '{{.}}'{{^-last}} || {{/-last}}{{/values}}{{/allowableValues}}){{/isEnum}})) {
@@ -219,6 +238,11 @@ export function {{classname}}ToJSONTyped(value?: {{classname}} | null, ignoreDis
219238
return value;
220239
}
221240
{{/isNumeric}}
241+
{{#isBoolean}}
242+
if (typeof value === 'boolean'{{#isEnum}} && ({{#allowableValues}}{{#values}}value === {{.}}{{^-last}} || {{/-last}}{{/values}}{{/allowableValues}}){{/isEnum}}) {
243+
return value;
244+
}
245+
{{/isBoolean}}
222246
{{#isString}}
223247
if (typeof value === 'string'{{#isEnum}} && ({{#allowableValues}}{{#values}}value === '{{.}}'{{^-last}} || {{/-last}}{{/values}}{{/allowableValues}}){{/isEnum}}) {
224248
return value;

0 commit comments

Comments
 (0)