I have model with field i want to make not required:
import io.swagger.v3.oas.annotations.media.Schema;
import javax.validation.constraints.NotNull;
public class Model {
@NotNull
@Schema(required = false)
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
but springdoc automaticaly marks it as required(i know that it's cause of @NotNull annotation)
"schemas": {
"Model": {
"required": [
"name"
],
"type": "object",
"properties": {
"name": {
"type": "string"
}
}
},
So how i can make field not required in generated documentation and leave both annotations i mean @NotNull and @Schema?
Used dependencies:
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.6.7</version>
</dependency>