Skip to content

Commit

Permalink
fix json validation for fields that are required but nullable (#781)
Browse files Browse the repository at this point in the history
  • Loading branch information
eddiechayes authored Aug 28, 2024
1 parent f5659ea commit 812712a
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,14 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
{{^isNestedPrimitive}}
{{#required}}
// validate the required field `{{{baseName}}}`
{{#isNullable}}
if (!jsonObj.get("{{{baseName}}}").isJsonNull()) {
{{{dataType}}}.validateJsonObject(jsonObj.getAsJsonObject("{{{baseName}}}"));
}
{{/isNullable}}
{{^isNullable}}
{{{dataType}}}.validateJsonObject(jsonObj.getAsJsonObject("{{{baseName}}}"));
{{/isNullable}}
{{/required}}
{{^required}}
// validate the optional field `{{{baseName}}}`
Expand Down

0 comments on commit 812712a

Please sign in to comment.