Skip to content

Commit 833749c

Browse files
authored
fix array of enum class in JS (OpenAPITools#1484)
1 parent a4c9dfd commit 833749c

File tree

6 files changed

+12
-12
lines changed

6 files changed

+12
-12
lines changed

modules/openapi-generator/src/main/resources/Javascript/ApiClient.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -546,8 +546,8 @@
546546
if (type === Object) {
547547
// generic object, return directly
548548
return data;
549-
} else if (typeof type === 'function') {
550-
// for model type like: User
549+
} else if (typeof type.constructFromObject === 'function') {
550+
// for model type like User or enum class
551551
return type.constructFromObject(data);
552552
} else if (Array.isArray(type)) {
553553
// for array type like: ['String']

modules/openapi-generator/src/main/resources/Javascript/es6/ApiClient.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -502,8 +502,8 @@ class ApiClient {
502502
if (type === Object) {
503503
// generic object, return directly
504504
return data;
505-
} else if (typeof type === 'function') {
506-
// for model type like: User
505+
} else if (typeof type.constructFromObject === 'function') {
506+
// for model type like User and enum class
507507
return type.constructFromObject(data);
508508
} else if (Array.isArray(type)) {
509509
// for array type like: ['String']

samples/client/petstore/javascript-es6/src/ApiClient.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -486,8 +486,8 @@ class ApiClient {
486486
if (type === Object) {
487487
// generic object, return directly
488488
return data;
489-
} else if (typeof type === 'function') {
490-
// for model type like: User
489+
} else if (typeof type.constructFromObject === 'function') {
490+
// for model type like User and enum class
491491
return type.constructFromObject(data);
492492
} else if (Array.isArray(type)) {
493493
// for array type like: ['String']

samples/client/petstore/javascript-promise-es6/src/ApiClient.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,8 +478,8 @@ class ApiClient {
478478
if (type === Object) {
479479
// generic object, return directly
480480
return data;
481-
} else if (typeof type === 'function') {
482-
// for model type like: User
481+
} else if (typeof type.constructFromObject === 'function') {
482+
// for model type like User and enum class
483483
return type.constructFromObject(data);
484484
} else if (Array.isArray(type)) {
485485
// for array type like: ['String']

samples/client/petstore/javascript-promise/src/ApiClient.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -525,8 +525,8 @@
525525
if (type === Object) {
526526
// generic object, return directly
527527
return data;
528-
} else if (typeof type === 'function') {
529-
// for model type like: User
528+
} else if (typeof type.constructFromObject === 'function') {
529+
// for model type like User or enum class
530530
return type.constructFromObject(data);
531531
} else if (Array.isArray(type)) {
532532
// for array type like: ['String']

samples/client/petstore/javascript/src/ApiClient.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -536,8 +536,8 @@
536536
if (type === Object) {
537537
// generic object, return directly
538538
return data;
539-
} else if (typeof type === 'function') {
540-
// for model type like: User
539+
} else if (typeof type.constructFromObject === 'function') {
540+
// for model type like User or enum class
541541
return type.constructFromObject(data);
542542
} else if (Array.isArray(type)) {
543543
// for array type like: ['String']

0 commit comments

Comments
 (0)