javaspring-bootopenapiopenapi-generator

Swagger / Openapi with openapi-generator where do we add the business logic code?


I have to create a rest api from scratch. I have already some experience with Jersey by doing mostly everything manualy.

I wanted to do it right now as this project is new. So I am currently trying the pet store sample that is available every time I am trying an openapi 3.0 online editor.

Using openapi-generator, I have generated the spring boot server for the pet store.

There are a lot of tutorial that will stop there. I don't understand where or how do I have to add my business logic code (database access, ....).

And after that I have a question, how is the specification update is done ?


Solution

  • With Spring Framework, you use Repository and Entity classes to handle data layer. And then add Service classes for business logic.

    https://www.baeldung.com/spring-component-repository-service

    Database (example in MySql): https://spring.io/guides/gs/accessing-data-mysql/