I'm using swagger-codgen to generate java model classes for my spring boot application and serialize them as json. By default these models would all include optional properties with null values.
I would like to configure the swagger-codgen for spring to include this annotation on top of all classes: @JsonInclude(Include.NON_NULL)
so that null valued properties are not included in the serialized json.
How can i achieve this? Is there a configuration option or do i have to extend the spring codegen manually?
You can configure that in your application.yaml
:
spring:
jackson:
default-property-inclusion: NON_NULL