We have a SpringBoot (version 1.5.12) REST Api with springfox-swagger2 and springfox-swagger-ui (version 2.9.2)
Is it possible to have nullable properties in Swagger UI (using swagger.yaml configuration file or swagger annotations)?
The payload that we need to send is something like this:
{
id: 2
name: 'test'
surname: null
}
Surname should be a string or null (by default null).
If not possible, can we override some swagger classes to obtain this behavior?
Thanks
Yes it is possible to have nullable/optional properties. To do so set the required attribute in @ApiModelProperty (io.swagger.annotations) annotation to false (it is actually false by default).
@ApiModelProperty(required = false, value = "Surname")
private String surname;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With