How to generate Swagger's "api-docs" during build process?

Viewed 52

I think this is a trivial use case, but can't find anywhere about it.

Our build should have 2 parts that are related to Swagger:

  1. Run regular swagger and create the JSON (available in \api-docs url) and other Swagger-related items.
  2. Create DTOs from the JSON.

I want to run step 1 as a part of the build process.

Details:

Currently, our project has springfox-boot-starter (3.0.0) that includes Swagger-UI. This allows the api-docs to be available when the server is online (I believe this is created on runtime, and doesn't display an existing JSON file). So I can fetch that JSON from the browser.

I added to Maven's pom.xml file the awesome openapi-codegen (openapi-generator-maven-plugin), and so when I set the plugin to point on the JSON file (created when the server was online) and run mvn clean install it does what I need in step 2: generates DTOs.

However, I can't find anywhere how to do step 1 (create the JSON) during the build process, when the server is offline. I believe this is very common use case so this is surprising, since generating DTOs is needed on the build process and shouldn't be dependent on a running server.

I know there is a project called Swagger2Markup in GitHub but it is un-maintained. Thanks!

0 Answers
Related