OpenAPI V3 specs generation at compile/build time from Spring code

Viewed 331

I have a Spring boot application. I am trying to switch to OpenAPI v3 from Swagger 2. Earlier I was relying on https://github.com/kongchen/swagger-maven-plugin which was wonderful and used to support the compile/build time generation of artifacts like yaml/json. Now, for the openAPI v3 support not being available in the kongchen repo, I am forced to move to https://github.com/springdoc/springdoc-openapi-maven-plugin. But, this "springdocs-openapi" plugin has a dependency on the Server to be running as it uses integration phase. This is really not feasible in a number of CI/CD environments to have the server up and running during build phase. Is there a limitation, why there is no reflection based options available to build the openAPI specs during compile phase? Can anyone help me to find an alternate option to get through this?

1 Answers

It might be late but I am answering so it could be helpful to others as I also came across this question when I was stuck and it took me sometime to reach to right tools.

As we know openapi specs are available at runtime and we can get complete and correct openapi specs by running the application locally and we can easily integrate this step in CI/CD pipeline.

With the help of maven openapi plugin you can integrate openapi generation at integration phase and save autogenerated openapi specs as per your requirements.

Related