From d3ac87408067391746a3a5faf6f3cf80bced3968 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bernhard=20=C3=96hlinger?= Date: Tue, 2 Jul 2024 16:55:44 +0200 Subject: [PATCH] Enable selection of annotation scanners (#1370) via maven plugin config. --- tools/maven-plugin/README.adoc | 1 + .../smallrye/openapi/mavenplugin/GenerateSchemaMojo.java | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/tools/maven-plugin/README.adoc b/tools/maven-plugin/README.adoc index 9ef3ee4a3..fdcc76e9d 100644 --- a/tools/maven-plugin/README.adoc +++ b/tools/maven-plugin/README.adoc @@ -66,6 +66,7 @@ E.g. for includeDependenciesScopes could be configured as: - `skip` (boolean, default: false) - Skip execution of the plugin. - `encoding` (String) - Encoding of output OpenAPI files. - `outputFileTypeFilter` (String, default: ALL) - Set this to `YAML` in order to let the generation process produce just *.yaml output, `JSON` to obtain *.json files only. The default is `ALL`, which will generate both file types. +- `scanners` (List) - To set the names of the AnnotationScanner implementations that should be executed. == MicroProfile OpenAPI Properties diff --git a/tools/maven-plugin/src/main/java/io/smallrye/openapi/mavenplugin/GenerateSchemaMojo.java b/tools/maven-plugin/src/main/java/io/smallrye/openapi/mavenplugin/GenerateSchemaMojo.java index 1c11873ca..9f42a81c7 100644 --- a/tools/maven-plugin/src/main/java/io/smallrye/openapi/mavenplugin/GenerateSchemaMojo.java +++ b/tools/maven-plugin/src/main/java/io/smallrye/openapi/mavenplugin/GenerateSchemaMojo.java @@ -100,6 +100,12 @@ public class GenerateSchemaMojo extends AbstractMojo { @Parameter(property = "configProperties") private File configProperties; + /** + * Configuration property to specify the list of scanners to use. If the list is empty the default scanners are used. + */ + @Parameter(property = "scanners") + private List scanners; + // Properies as per OpenAPI Config. /** @@ -295,6 +301,7 @@ private SmallRyeOpenAPI generateOpenAPI(IndexView index) throws IOException, Dep .withConfig(config) .withApplicationClassLoader(getClassLoader()) .withIndex(index) + .withScannerFilter(scanners != null && !scanners.isEmpty() ? x -> scanners.contains(x) : x -> true) .build(); }