I wish to perform strict validation on a boolean parameter, seen below as "withDetails."
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "Success")})
@GetMapping(value = "/order", produces = "application/json")
public ResponseEntity<ResponseClass> getOrders( String id,
@RequestParam(value = "withDetails", defaultValue = "true")
Boolean withDetails){
ResponseClass responseClass = this.service.getResponse(id, withDetails);
return ResponseEntity.ok(responseClass);
}
Spring accepts non-boolean substitutions for this value, such as 0/1. This is apparently by design, as described here: https://stackoverflow.com/a/25123000/11994829
However, I want to strictly only allow "true/false" in requests. Can I do that while still defining the parameter as Boolean?