diff --git a/modules/openapi-generator/src/main/resources/Javascript/ApiClient.mustache b/modules/openapi-generator/src/main/resources/Javascript/ApiClient.mustache index b6bbc47374..c0c692fc5b 100644 --- a/modules/openapi-generator/src/main/resources/Javascript/ApiClient.mustache +++ b/modules/openapi-generator/src/main/resources/Javascript/ApiClient.mustache @@ -546,8 +546,8 @@ if (type === Object) { // generic object, return directly return data; - } else if (typeof type === 'function') { - // for model type like: User + } else if (typeof type.constructFromObject === 'function') { + // for model type like User or enum class return type.constructFromObject(data); } else if (Array.isArray(type)) { // for array type like: ['String'] diff --git a/modules/openapi-generator/src/main/resources/Javascript/es6/ApiClient.mustache b/modules/openapi-generator/src/main/resources/Javascript/es6/ApiClient.mustache index 49b92e21ca..694013f142 100644 --- a/modules/openapi-generator/src/main/resources/Javascript/es6/ApiClient.mustache +++ b/modules/openapi-generator/src/main/resources/Javascript/es6/ApiClient.mustache @@ -502,8 +502,8 @@ class ApiClient { if (type === Object) { // generic object, return directly return data; - } else if (typeof type === 'function') { - // for model type like: User + } else if (typeof type.constructFromObject === 'function') { + // for model type like User and enum class return type.constructFromObject(data); } else if (Array.isArray(type)) { // for array type like: ['String'] diff --git a/samples/client/petstore/javascript-es6/src/ApiClient.js b/samples/client/petstore/javascript-es6/src/ApiClient.js index 369632309d..50bdc61113 100644 --- a/samples/client/petstore/javascript-es6/src/ApiClient.js +++ b/samples/client/petstore/javascript-es6/src/ApiClient.js @@ -486,8 +486,8 @@ class ApiClient { if (type === Object) { // generic object, return directly return data; - } else if (typeof type === 'function') { - // for model type like: User + } else if (typeof type.constructFromObject === 'function') { + // for model type like User and enum class return type.constructFromObject(data); } else if (Array.isArray(type)) { // for array type like: ['String'] diff --git a/samples/client/petstore/javascript-promise-es6/src/ApiClient.js b/samples/client/petstore/javascript-promise-es6/src/ApiClient.js index 2b2d43810c..50ef10e264 100644 --- a/samples/client/petstore/javascript-promise-es6/src/ApiClient.js +++ b/samples/client/petstore/javascript-promise-es6/src/ApiClient.js @@ -478,8 +478,8 @@ class ApiClient { if (type === Object) { // generic object, return directly return data; - } else if (typeof type === 'function') { - // for model type like: User + } else if (typeof type.constructFromObject === 'function') { + // for model type like User and enum class return type.constructFromObject(data); } else if (Array.isArray(type)) { // for array type like: ['String'] diff --git a/samples/client/petstore/javascript-promise/src/ApiClient.js b/samples/client/petstore/javascript-promise/src/ApiClient.js index 0415153dac..883b148d5a 100644 --- a/samples/client/petstore/javascript-promise/src/ApiClient.js +++ b/samples/client/petstore/javascript-promise/src/ApiClient.js @@ -525,8 +525,8 @@ if (type === Object) { // generic object, return directly return data; - } else if (typeof type === 'function') { - // for model type like: User + } else if (typeof type.constructFromObject === 'function') { + // for model type like User or enum class return type.constructFromObject(data); } else if (Array.isArray(type)) { // for array type like: ['String'] diff --git a/samples/client/petstore/javascript/src/ApiClient.js b/samples/client/petstore/javascript/src/ApiClient.js index 07b9ab030e..4e33f192e4 100644 --- a/samples/client/petstore/javascript/src/ApiClient.js +++ b/samples/client/petstore/javascript/src/ApiClient.js @@ -536,8 +536,8 @@ if (type === Object) { // generic object, return directly return data; - } else if (typeof type === 'function') { - // for model type like: User + } else if (typeof type.constructFromObject === 'function') { + // for model type like User or enum class return type.constructFromObject(data); } else if (Array.isArray(type)) { // for array type like: ['String']