Implementing the OAS code interfaces
So far, we have generated code that consists of e-commerce app models and API Java interfaces. These generated interfaces contain all the annotations as per the YAML description provided by us. For example, in CartApi.java
, @RequestMapping
, @PathVariable
, and @RequestBody
contain the endpoint path (/api/v1/carts/{customerId}/items
), the value of the path
variable (such as {customerId}
in path
), and the request payload (such as Item
), respectively. Similarly, generated models contain all the mapping required to support the JSON and XML content types.
Swagger Codegen writes the Spring code for us. We just need to implement the interface and write the business logic inside it. Swagger Codegen generates the API Java interfaces for each of the provided tags. For example, it generates the CartApi
and PaymentAPI
Java interfaces for the cart
and payment
tags, respectively. All the paths are clubbed together into a single Java interface based on the given...