You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
a maven plugin based on the link:{oap-api}[openapi-processor-api] to handle any openapi-processor without an explicit dependency on the processor.
22
22
23
-
NOTE: unfortunately it is necessary to configure a few xref:oap::jdk.adoc[additional jvm parameter] to run the processor with JDK 16+
23
+
NOTE: unfortunately, it may be necessary to configure a few xref:oap::jdk.adoc[additional jvm parameters] to run the processor with *enabled* code formatter on JDK 16+.
24
24
25
25
== plugin configuration
26
26
@@ -35,8 +35,8 @@ The first step of the configuration is to add the plugin, and the processor(s) t
<!-- update to the latest version, see maven central badge at top -->
39
-
<version>2024.1</version>
38
+
<!-- to update to the latest version, see maven central badge at top -->
39
+
<version>2026.1</version>
40
40
41
41
<!-- ... next step ... -->
42
42
</plugin>
@@ -54,12 +54,12 @@ The processors are dependencies of the plugin, and they are expected in the `<pl
54
54
<dependency>
55
55
<groupId>io.openapiprocessor</groupId>
56
56
<artifactId>openapi-processor-spring</artifactId>
57
-
<version>2023.6.1</version>
57
+
<version>2026.1</version>
58
58
</dependency>
59
59
<dependency>
60
60
<groupId>io.openapiprocessor</groupId>
61
61
<artifactId>openapi-processor-json</artifactId>
62
-
<version>2023.6.1</version>
62
+
<version>2026.1</version>
63
63
</dependency>
64
64
</dependencies>
65
65
@@ -84,7 +84,7 @@ Then it should know where the processors will find the input OpenAPI yaml files
84
84
* `<id/>`, maven wants this. It is not used by the processor.
85
85
* `*<apiPath/>*`, defines the path to the openapi yaml file. This is usually the same for all processors and adding it directly into the plugin `<configuration/>` block sets it for all processors.
86
86
87
-
Next step is to configure the goals for processing. The plugin has only a single goal `process` that can run any processor. It is configured by an `<execution/>` element to run a specific processor.
87
+
The next step is to configure the goals for processing. The plugin has only a single goal `process` that can run any processor. It is configured by an `<execution/>` element to run a specific processor.
88
88
89
89
If maven should run multiple processors, multiple `<execution/>` s are needed.
90
90
@@ -100,6 +100,7 @@ Here is an example to run `openapi-processor-spring` that explains the configura
100
100
101
101
<configuration>
102
102
<id>spring</id> <!--3-->
103
+
<processor>spring</processor> <!--3-->
103
104
104
105
<!-- true is default -->
105
106
<addSourceRoot>true</addSourceRoot> <!--9-->
@@ -112,7 +113,7 @@ Here is an example to run `openapi-processor-spring` that explains the configura
@@ -136,17 +137,19 @@ Here is an example to run `openapi-processor-spring` that explains the configura
136
137
137
138
<1> `*<id/>*`: **execution id** of the goal (choose your id). It is necessary to configure multiple executions.
138
139
139
-
<2> `*<phase/>*` **phase** (mandatory): openapi-processor-spring generates java code, so the `<phase/>` should be `generate-source`. This tells maven to run the goal before compiling anything.
140
+
<2> `*<phase/>*` **phase** (mandatory): openapi-processor-spring generates Java code, so the `<phase/>` should be `generate-source`. This tells maven to run the goal before compiling anything.
140
141
141
-
<3> `*<id/>*` **processor id** (mandatory): this configures the openapi-processor the goal should run. The processor id must match exactly with the name of the processor. The convention is, that the last part of the processor artifact name is the processor id.
142
+
<3> `*<id/>*` **processor id** (mandatory): this configures the openapi-processor the goal should run. The processor id must match exactly with the name of the processor unless the `<processor/>` is used. In this case `<id/>` is used as a subfolder of an automatically created `<targetDir/>`.
142
143
+
143
-
If the artifact of a processor is called `openapi-processor-x`, the last part `x` is the id of the processor. For example for `openapi-processor-spring` the id is `spring`, for `openapi-processor-json` the id is `json`.
144
+
`*<processor/>*` **processor id** (optional): this is an alternative configuration of the openapi-processor a goal should run. It is necessary to process multiple OpenAPI files with the same processor. See below for more on this.
145
+
+
146
+
The convention is that the last part of the processor artifact name is the processor id. If the artifact of a processor is called `openapi-processor-x`, the last part `x` is the id of the processor. For example, for `openapi-processor-spring` the id is `spring`, for `openapi-processor-json` the id is `json`.
144
147
145
-
<4> `*<apiPath/>*` (optional): the path to the open api yaml file. If set inside an `<execution>` `<configuration/>` it overrides the parent `apiPath` set in the `<plugin>` `<configuration/>`.
148
+
<4> `*<apiPath/>*` (optional): the path to the open api YAML file. If set inside an `<execution>` `<configuration/>` it overrides the parent `apiPath` set in the `<plugin>` `<configuration/>`.
146
149
147
-
<5> `*<options/>*` (mandatory): **processorspecific options**, the configuration of a single processor can have any number of additional parameters defined by the processor (all options will be passed as a map to the processor with the option name as the key). The nested `*<values/>*` element defines that map.
150
+
<5> `*<options/>*` (mandatory): **processor-specific options**, the configuration of a single processor can have any number of additional parameters defined by the processor (all options will be passed as a map to the processor with the option name as the key). The nested `*<values/>*` element defines that map.
148
151
+
149
-
To allow any level of nesting it is possible to create `*<nested/>*` option maps, i.e. `*<nested/>*` can contain another `*<nested/>*` element and so on. In the configuration above the plugin would pass the following map to the processor:
152
+
To allow any level of nesting, it is possible to create `*<nested/>*` option maps, i.e. `*<nested/>*` can contain another `*<nested/>*` element and so on. In the configuration above, the plugin would pass the following map to the processor:
150
153
+
151
154
[source,json,title=json notation]
152
155
----
@@ -161,17 +164,26 @@ To allow any level of nesting it is possible to create `*<nested/>*` option maps
161
164
}
162
165
----
163
166
164
-
<6> `*<targetDir/>*` **target directory** (mandatory): the directory the processor should use for its output. By convention a processor should use this key to as the output directory.
167
+
<6> `*<targetDir/>*` **target directory** (optional): the directory the processor should use for its output. By convention, a processor uses this key as the output directory.
168
+
+
169
+
If this is not given, the plugin will automatically select the target dir as:
where `{processor id}` is `<processor/>` if given, or `<id/>` if `<processor/>` is not given.
165
177
166
-
<7> the rest of the options are processorspecific. See xref:spring::index.adoc[openapi-processor-spring].
178
+
<7> the rest of the options are processor-specific. See xref:spring::index.adoc[openapi-processor-spring].
167
179
168
180
<8> `*<goal/>*` **goal** (mandatory): this is the goal maven should run. Since the plugin does only have a single goal the value is always `process`.
169
181
170
-
<9> `*<addSourceRoot/>*` **addSourceRoot* (optional): this defaults to `true` and automatically adds the `targetDir` as compile source root folder. It can be disabled by setting it to `false`.
182
+
<9> `*<addSourceRoot/>*` **addSourceRoot** (optional): this defaults to `true` and automatically adds the `targetDir` as compile source root folder. It can be disabled by setting it to `false`.
171
183
172
-
=== multiple processors
184
+
=== multiple different processors
173
185
174
-
To run a second processor add another `<execution>` element. Here is an example that configures xref:spring:ROOT:index.adoc[openapi-processor-spring] and xref:json:ROOT:index.adoc[openapi-processor-json]:
186
+
To run a second processor, add another `<execution>` element. Here is an example that configures xref:spring:ROOT:index.adoc[openapi-processor-spring] and xref:json:ROOT:index.adoc[openapi-processor-json]:
175
187
176
188
177
189
[source,xml]
@@ -203,6 +215,59 @@ To run a second processor add another `<execution>` element. Here is an example
203
215
204
216
<1> uses `generate-resources` phase for the json output, to consider it as a resource.
205
217
218
+
=== multiple identical processors
219
+
220
+
To run the same processor on different inputs, add another `<execution>` element. Here is an example that configures two xref:spring:ROOT:index.adoc[openapi-processor-spring] processors:
<1> the configuration id, used to automatically select the `<targetDir/>` if it is not explicitly set. Otherwise, it is not used.
269
+
<2> the processor id that should be used for this configuration.
270
+
206
271
== executing the goal
207
272
208
273
The `<execution>` s created in the previous chapter will automatically run the processor in the given `<phase>` s with commands like `./mvnw compile`.
@@ -213,7 +278,7 @@ Running the goal directly with `./mvnw openapi-processor:process` to check the s
213
278
214
279
This can be solved in two ways:
215
280
216
-
First, it is possible to the run the goal with an explicit `<execution>` like this:
281
+
First, it is possible to run the goal with an explicit `<execution>` like this:
217
282
218
283
[source,shell script]
219
284
----
@@ -243,7 +308,7 @@ The other solution is to change the `execution` that should run by default to a
243
308
</plugin>
244
309
----
245
310
246
-
<1> using maven's default execution id instead of a userselected id.
311
+
<1> using maven's default execution id instead of a user-selected id.
247
312
248
313
With this configuration maven will use it when directly running the `process` goal from the shell, and it will also run it when the given phase is active.
249
314
@@ -252,13 +317,13 @@ With this configuration maven will use it when directly running the `process` go
252
317
253
318
=== source files
254
319
255
-
Starting with the release 2024.1 it is no longer necessary to manually add the generated sources to the build. The plugin will automatically add the `targetDir` as compile source root.
320
+
Starting with the release 2024.1, it is no longer necessary to manually add the generated sources to the build. The plugin will automatically add the `targetDir` as compile source root.
256
321
257
322
It can be disabled by setting the plugin configuration `<addSourceRoot>` to `false`.
258
323
259
324
=== resource files
260
325
261
-
If the output of the processor (e.g. generated by openapi-processor-json) should be used as resource add a resource directory.
326
+
If the output of the processor, (e.g., generated by openapi-processor-json) should be used as a resource, add a resource directory.
262
327
263
328
[source,xml]
264
329
----
@@ -276,4 +341,4 @@ If the output of the processor (e.g. generated by openapi-processor-json) should
276
341
277
342
== Samples
278
343
279
-
See the maven sample in the xref:samples::index.adoc[samples] for a working spring boot example.
344
+
See the maven samples in the xref:samples::index.adoc[samples] for a working example using Spring Boot. Look into the parent `pom.xml` in the root folder to find the samples which have a maven configuration.
0 commit comments