Besides using java command line to generate microservice API based on the OpenAPI 3.0 specification, light-codegen also can be integrated with the project maven build process.
Sometimes the specification could be changed by different team members frequently. In this case, it could be challenging to re-generate the API project from the Java command line for every specification change.
To serve this purpose a new way is introduced here which could integrate the light-codegen into the maven build process. You can find the reference example at petstore maven codegen example.
Initiate the microservice API project. Define one module for the service and another module for specification
create or copy the specification and the config JSON file to the specification module, for example, /petstore-spec/config
Run maven install to build the project, and the maven build will trigger the light-codegen to generate the initial service into the service module
mvn clean install
After the service project generated, developers start to work on the service; then change config value “specChangeCodeReGenOnly” to true:
The light-codegen will be triggered every time maven install be executed; but since the “specChangeCodeReGenOnly” set as true, only specification change related code will be generated to the service project.