-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
validate request body against openapi schema #104
Conversation
@Provider | ||
public class InvalidInputExceptionMapper implements ExceptionMapper<JsonMappingException> { | ||
public class InvalidInputExceptionMapper implements ExceptionMapper<ConstraintViolationException> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
essentially i took the original class of this name and moved it to InvalidJsonInputExceptionMapper.java. the original class is handling exceptions that arise in the jackson json parsing layers.
this new class is handling errors for when the request body does not match the described open api spec.
.put("message", "The received object did not pass validation") | ||
.put("details", e.getOriginalMessage()) | ||
.toString()) | ||
.put("message", "Invalid JSON") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I this the right message?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shoudln't it be "The received object did not pass validation"?
.entity( | ||
new ObjectMapper() | ||
.createObjectNode() | ||
.put("message", "The received object did not pass validation") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't it be Invalid JSON
What
The API was not actually validating that the incoming request body matched the schema described in our open api config.
How
jersey-bean-validation
.