diff --git a/modules/openapi-generator/src/main/resources/Javascript/partial_model_generic.mustache b/modules/openapi-generator/src/main/resources/Javascript/partial_model_generic.mustache index 2203cc43150..facd6bf222e 100644 --- a/modules/openapi-generator/src/main/resources/Javascript/partial_model_generic.mustache +++ b/modules/openapi-generator/src/main/resources/Javascript/partial_model_generic.mustache @@ -64,7 +64,7 @@ class {{classname}} {{#parent}}{{^parentModel}}{{#vendorExtensions.x-is-array}}e {{#-first}} // check to make sure all required properties are present in the JSON string for (const property of {{classname}}.RequiredProperties) { - if (!data[property]) { + if (!data.hasOwnProperty(property)) { throw new Error("The required field `" + property + "` is not found in the JSON data: " + JSON.stringify(data)); } }