ardielle / ardielle-tools

Apache License 2.0
18 stars 19 forks source link

Use of JsonSerialize.Inclusion.NON_DEFAULT in java model classes ends up generating "empty" output #71

Closed havetisyan closed 7 years ago

havetisyan commented 7 years ago

When generating java model classes, the generator uses the following annotation:

@JsonSerialize(include = JsonSerialize.Inclusion.NON_DEFAULT)

In Athenz, we have a class called Access which has a single boolean field granted which returns whether the authorization check is successful or failed: {"granted":true} or {"granted":false"}

However, with the use of @JsonSerialize(include = JsonSerialize.Inclusion.NON_DEFAULT) annotation, Jackson library skips the default value of false for the granted attribute and generates the json object as {} which is invalid. The client was expecting to see the "granted" attribute in response with the false value.

The model generator must provide the option to use different annotations which generate the expected output: e.g.:

@JsonSerialize(include = JsonSerialize.Inclusion.ALWAYS)