Null values on swagger JSON file

I've spent a week on that and I found the solution only few hours after I posted my question, sorry for that.

It seems that in web.xml was missing the io.swagger.jaxrs.listing.SwaggerSerializers class in the ServletContainer, the full portion is:

<servlet>
    <servlet-name>jersey</servlet-name>
    <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
    <init-param>
    <param-name>jersey.config.server.provider.classnames</param-name>
    <param-value>
        io.swagger.jersey.listing.ApiListingResourceJSON,
        io.swagger.jaxrs.listing.SwaggerSerializers,
        org.something.DatasetApi
    </param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

With the io.swagger.jaxrs.listing.SwaggerSerializers bit everything is now working as expected.


If using spring-boot, you can set in application.yml:

spring.jackson.default-property-inclusion: non_null