Open xfh opened 3 months ago
The following worked for me:
@POST
public Response create(@Nonnull @NotNull @Valid @RequestBody Payload payload) {
return Response.ok().build();
}
I'm sorry, I was wrong (probably issues with dependencies). It doesn't work the way I wrote, the request body is not generated as required.
@xfh , @cristalp - this should no longer be an issue as of version 4.0. Request bodies are marked as required: true
by default (not due to the not-null constraint).
Thanks, works as described.
BeanValidation's @NotNull annotation integrates seamlessly into openapi schema generation - I much appreciated feature.
Unfortunately, there is an inconsistency regarding @NotNull and method parameters.
The following endpoint doesn't mark the input parameter
Payload
as required:generated schema:
Manually adding
@RequestBody(required = true)
the the create method yields in the desired output:It would be really nice, if a
@NotNull
annotation on a body parameter automatically added therequired: true
flag.