Chapter 4: Writing Business Logic for APIs
We discussed APIs using OpenAPI in the previous chapter. API interfaces and models were generated by the Swagger Codegen. In this chapter, you will implement the API's code in terms of both business logic and data persistence. You will write services and repositories for implementation and also add hypermedia and ETags to API responses. It is worth noting that the code provided only consists of the important lines and not the whole file in the interest of brevity. You can always access the links given below the code to view the complete file.
This chapter includes the following topics:
- Overview of the service design
- Adding repository components
- Adding service components
- Implementing hypermedia
- Enhancing the controller with a service and HATEOAS
- Adding ETags to API responses