Closed bopi- closed 1 year ago
@bopi-,
Fields in Schema are not considered as required by default.
If you add @Schema
annotation, they would be marked as required.
Hi @bnasslahsen,
thank you for your fast response.
Exactly. That is why I created this feature request. From my point of view it would be great if springdoc would consider fields in response schemas as required by default. Jackson serializes all fields by default so in fact they are required by default.
Describe the solution you'd like
Spring uses Jackson to serialize the java objects to json. Since Jackson serializes all fields by default the generated OpenApi documentation would match that behavior.
Optional fields could be marked by
@Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED)
or even better by@JsonInclude(JsonInclude.Include.NON_NULL)
and be generated by springdoc as not requiredDescribe alternatives you've considered
Annotate every field with
@Schema(requiredMode = Schema.RequiredMode.REQUIRED)