-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Closed
Labels
Description
Due to the removal of nullable: true from schema in 3.1.0, it appears that the nullable = true property on the @Schema annotation no longer works. That isn't obvious in the documentation for the annotation, and it's inconvenient to boot ;-)
I think it will be quite easy to continue to support the nullable attribute under 3.1.0, I suggest a little change to Schema.getTypes:
@OpenAPI31
public Set<String> getTypes() {
if (types != null) {
if (nullable != null && nullable.booleanValue()) {
Set<String> ss = new LinkedHashSet<>(types);
ss.add("null");
return ss;
} else {
return types;
}
} else {
return null;
}
}We simply add "null" to the list of types if the schema is nullable... which ends up nicely in the schema output.
I'm happy to make a PR of this, or a better suggestion, or I'd love to know if this is more like the wrong approach!
Reactions are currently unavailable