diff --git a/modules/openapi-generator/src/main/resources/Javascript/ApiClient.mustache b/modules/openapi-generator/src/main/resources/Javascript/ApiClient.mustache index b6bbc4737493..c0c692fc5b0a 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 49b92e21cae8..694013f1425c 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 369632309dc9..50bdc6111313 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 2b2d43810cf0..50ef10e264e9 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 0415153dac19..883b148d5ab3 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 07b9ab030ec4..4e33f192e4a0 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']