Please note: I am using Spring Boot here, not Spring MVC.
Java 8 and Spring Boot/Jackson here. I have the following enum:
public enum OrderType {
PARTIAL("partialOrder"),
FULL("fullOrder");
private String label;
OrderType(String label) { this.label = label; }
}
I would like to expose a POST
endpoint where the client can place the OrderType#label
as a request parameter, and Spring will know to convert the provided label into an OrderType
like so:
@PostMapping("/v1/myapp/orders")
public ResponseEntity<?> acceptOrder(@RequestParam(value = "orderType") OrderType orderType) {
// ...
}
And hence the client could make a call such as POST /v1/myapp/orders?orderType=fullOrder
and on the server, the controller would receive an OrderType
instance.
How can I accomplish this?