OpenAPI Toolkit Maven Plugin
Lint, bundle, transform and document OpenAPI and AsyncAPI descriptions from Maven with Redocly. Redocly runs inside the JVM; no Node.js is required.
Requires JDK 21+ and Maven 3.9+.
Quick start
This is documentation for version 0.2.0.
<plugin>
<groupId>net.mwalser</groupId>
<artifactId>openapi-toolkit-maven-plugin</artifactId>
<version>0.2.0</version>
<executions>
<execution>
<id>lint</id>
<goals>
<goal>lint</goal> <!-- runs in the validate phase -->
</goals>
</execution>
<execution>
<id>bundle</id>
<goals>
<goal>bundle</goal> <!-- runs in the generate-resources phase -->
</goals>
<configuration>
<addResource>true</addResource> <!-- package the bundle in the JAR -->
</configuration>
</execution>
</executions>
</plugin>
Put the API description under src/main/openapi/ and add a redocly.yaml next to the POM:
extends:
- recommended
apis:
petstore:
root: src/main/openapi/openapi.yaml
rules:
security-defined: warn # downgrade a rule; `off` disables it
mvn package lints src/main/openapi/openapi.yaml, writes the bundle to target/generated-resources/openapi/petstore.yaml and packages it as petstore.yaml in the JAR. An execution of build-docs also renders an HTML reference page, target/generated-resources/redoc/petstore.html.
Problems with severity error fail the build (Lint failed with 2 errors.); warnings do not. Change severities under rules: or pick a smaller ruleset such as minimal (see Redocly's rules).
Once the plugin is declared in the POM, every goal also runs from the command line. Without a redocly.yaml, pass the files and the built-in recommended ruleset applies:
mvn openapi-toolkit:lint -Dopenapi.toolkit.apis=src/main/openapi/openapi.yaml
Goals
| Goal | What it does |
|---|---|
| lint | Lints API descriptions; fails the build on errors; writes checkstyle or JUnit reports for CI. |
| bundle | Resolves references to other files and applies decorators; packages or attaches the bundle. |
| build-docs | Renders an HTML reference page with Redoc; can package it in the JAR. |
| check-config | Lints redocly.yaml. |
| stats | Counts paths, operations, schemas and more. |
| score | Scores an OpenAPI 3 description; fails the build below minScore. |
| join | Joins OpenAPI 3 descriptions into one (experimental upstream). |
| split | Splits a description into a multi-file tree. |
Next: usage and examples for each scenario, the goal reference for every parameter, limitations, and performance for the optional native engine.
