From 7651a85b55e6029141d6af01a90ce20183bf3b4f Mon Sep 17 00:00:00 2001 From: Inf1mum Date: Sun, 15 Nov 2026 15:18:49 +0300 Subject: [PATCH 1/2] docs: document Maven and Gradle plugin usage in README The README only described the CLI and the library, but the project also publishes a Maven plugin and a Gradle plugin to Maven Central. Add usage sections for both plugins, verified against the mojo and task sources, and link the sbt plugin maintained outside this project. Fixes #339 Signed-off-by: Inf1mum --- README.md | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 65 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5c7194d8..d936e2f4 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ times. I did not validate lately if they still have this feature. ## How to use the style validator -For now, the project is a simple command line interface (CLI) and a library. The easiest way to use it right now +The project is available as a command line interface (CLI), a library, and Maven and Gradle plugins. The easiest way to use it right now is to use the CLI and check the output. It will list all errors found based on the options you provided. ### To build @@ -173,6 +173,70 @@ Example 2: } ``` +### Using the Maven plugin + +A Maven plugin is released on Maven Central as `openapi-style-validator-maven-plugin`. Its `validate` goal (bound to the `validate` phase of the build lifecycle by default) fails the build if the specification does not meet the requirements: + +```xml + + org.openapitools.openapistylevalidator + openapi-style-validator-maven-plugin + ${validatorVersion} + + + + validate + + + path/to/spec.yaml + + + + +``` + +It can also be invoked directly from the command line (replace `` with the current version): + +`mvn org.openapitools.openapistylevalidator:openapi-style-validator-maven-plugin::validate -DinputFile=path/to/spec.yaml` + +The validation options and naming conventions listed in the Options File table above can be set in the same `` element, using the same names (for example `false`). + +### Using the Gradle plugin + +A Gradle plugin is released on Maven Central as `openapi-style-validator-gradle-plugin` (the plugin is not published to the Gradle Plugin Portal). It adds an `openAPIStyleValidator` task, in the `Verification` group, that fails the build if the specification does not meet the requirements: + +```groovy +buildscript { + repositories { + mavenCentral() + } + dependencies { + classpath 'org.openapitools.openapistylevalidator:openapi-style-validator-gradle-plugin:${validatorVersion}' + } +} + +apply plugin: 'org.openapitools.openapistylevalidator' + +openAPIStyleValidator { + // set the input file option: + inputFile = file('path/to/spec.yaml') + + // customize the validation options: + validateInfoLicense = false + validateInfoDescription = false +} +``` + +The task can then be run with: + +`gradlew openAPIStyleValidator` + +The validation options and naming conventions listed in the Options File table above can be set on the task the same way, using the same names. + +### Using sbt + +There is also an sbt plugin, maintained outside this project: [sbt-openapi-style-validator](https://github.com/jrouly/sbt-openapi-style-validator). + ## Supported Extensions We sometimes have some paths in our API that are there for legacy reasons. To support this scenario, there is now the possibility to add an extension property in your spec named `x-style-validator-ignored`. Here is an example: From 31f623de16576a90c4bcb10b7aaec8f16e6e7716 Mon Sep 17 00:00:00 2001 From: Inf1mum Date: Tue, 17 Nov 2026 23:02:32 +0300 Subject: [PATCH 2/2] docs: clarify plugin option coverage and Gradle classpath snippet The Maven goal and the Gradle task do not expose the allowedModelProperties option (it is only available through the options file of the CLI), so the README now states that explicitly instead of implying every table option is wired. The Gradle classpath snippet switches to a double-quoted string so the version placeholder is interpolated once defined, with a note on how to provide it. Signed-off-by: Inf1mum --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d936e2f4..6e3ab905 100644 --- a/README.md +++ b/README.md @@ -199,7 +199,7 @@ It can also be invoked directly from the command line (replace `` with `mvn org.openapitools.openapistylevalidator:openapi-style-validator-maven-plugin::validate -DinputFile=path/to/spec.yaml` -The validation options and naming conventions listed in the Options File table above can be set in the same `` element, using the same names (for example `false`). +The validation options and naming conventions listed in the Options File table above can be set in the same `` element, using the same names (for example `false`). The `allowedModelProperties` option is not currently exposed by this plugin. ### Using the Gradle plugin @@ -211,7 +211,8 @@ buildscript { mavenCentral() } dependencies { - classpath 'org.openapitools.openapistylevalidator:openapi-style-validator-gradle-plugin:${validatorVersion}' + // replace validatorVersion with the current version, or define it as a property first + classpath "org.openapitools.openapistylevalidator:openapi-style-validator-gradle-plugin:${validatorVersion}" } } @@ -231,7 +232,7 @@ The task can then be run with: `gradlew openAPIStyleValidator` -The validation options and naming conventions listed in the Options File table above can be set on the task the same way, using the same names. +The validation options and naming conventions listed in the Options File table above can be set on the task the same way, using the same names. The `allowedModelProperties` option is not currently exposed by this task. ### Using sbt