Enhancing the controller with a service and HATEOAS
In Chapter 3, API Specifications and Implementation, we created the Controller
class for the Cart API – CartController
– which just implements the OpenAPI Codegen-generated API specification interface – CartApi
. It was just a mere block of code without any business logic or data persistence calls.
Now, since we have written the repositories, services, and HATEOAS assemblers, we can enhance the API controller class, as shown here:
@RestControllerpublic class CartsController implements CartApi { private CartService service; private final CartRepresentationModelAssembler assembler; public CartsController(CartService service, CartRepresentationModelAssembler assembler) { this.service = service; this.assembler = assembler; }
https://github.com/PacktPublishing/Modern-API-Development...