How to generate OpenApi 3.0 spec from existing Spring Boot App?

I decided to implement my own generator maybe you can check it out too. It's based on reflection and supports javax and spring annotations. It also generates inheritance model (with discriminators) based on Jackson annotations. Besides you can define your own interceptors if you want to alter generation process (e.g. when you have your own annotations and need to adjust generated sections of schema). You can use it in runtime mode or as a maven plugin. There is also OpenAPI3 to java client generator, which generates the model from openapi3 spec. Again it generates also Javax annotations and Jackson annotations for correct inheritance.

We have used springdoc-openapi library in our kotlin project, and it meets our need for automating the generation of API documentation using spring boot projects.

It automatically deploys swagger-ui to a spring-boot application

The Swagger UI page should then be available at: - http://server:port/context-path/swagger-ui.html The OpenAPI description will be available at the following url for json format: - http://server:port/context-path/v3/api-docs

Add the library to the list of your project dependencies (No additional configuration is needed)


You could look at spring-restdocs and restdocs-api-spec.

spring-restdocs takes a test-driven approach to API documentation which has many advantages over the introspection-driven approach spring-fox uses. restdocs-api-spec is an extension for spring-restdocs that adds API specification support. Currently it supports OpenAPI2 OpenAPI3 and Postman.