We need to update the sortOrder field in the SearchQuerySortRequest from a string type to an enum with possible values asc and desc in our OpenAPI specification. The default value should be asc. Additionally, we need to ensure that the API validation correctly returns a 400 Bad Request with an appropriate ProblemDetail object when an invalid value is provided.
Acceptance Criteria
The sortOrder field in the SearchQuerySortRequest is an enum with values asc and desc, and the default is asc.
The API returns a 400 Bad Request with a ProblemDetail object when an invalid sort order value is provided.
Unit tests (ProcessInstanceControllerTest) are passing/updated with the new validation logic.
Implementation proposal
We can use an ExceptionHandler on MethodArgumentNotValidException to identify the invalid input field
@RestControllerAdvice
public class GlobalExceptionHandler {
@ExceptionHandler(MethodArgumentNotValidException.class)
public ResponseEntity<ProblemDetail> handleValidationExceptions(MethodArgumentNotValidException ex) {
for (FieldError error : ex.getBindingResult().getFieldErrors()) {
if ("sortOrder".equals(error.getField())) {
// return the problem Detail with the invalid sortOrder
}
...
}
Description
We need to update the
sortOrder
field in theSearchQuerySortRequest
from a string type to an enum with possible valuesasc
anddesc
in our OpenAPI specification. The default value should beasc
. Additionally, we need to ensure that the API validation correctly returns a 400 Bad Request with an appropriateProblemDetail
object when an invalid value is provided.Acceptance Criteria
asc
anddesc
, and the default isasc
.ProcessInstanceControllerTest
) are passing/updated with the new validation logic.Implementation proposal
We can use an ExceptionHandler on
MethodArgumentNotValidException
to identify the invalid input field