Skip to content

Commit 3a4c632

Browse files
committed
improved doc, added default-cli info
1 parent b7fb321 commit 3a4c632

1 file changed

Lines changed: 53 additions & 27 deletions

File tree

docs/modules/ROOT/pages/index.adoc

Lines changed: 53 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,6 @@ a maven plugin based on the link:{oap-api}[openapi-processor-api] to handle any
2222

2323
NOTE: unfortunately it is necessary to configure a few xref:oap::jdk.adoc[additional jvm parameter] to run the processor with JDK 16+
2424

25-
== compatibility
26-
27-
[cols="3*",options="header"]
28-
|===
29-
| plugin version
30-
| minimum maven version
31-
| description
32-
33-
| 2021.1
34-
| 3.6
35-
a| supports processors with new `io.openapiprocessor` group id
36-
37-
3+| ↓ old (deprecated)
38-
39-
| 1.0.0.M2
40-
| 3.6
41-
a| supports processors with new `io.openapiprocessor` and old `com.github.hauner.openapi` group id
42-
|===
43-
44-
4525
== plugin configuration
4626

4727
The first step of the configuration is to add the plugin, and the processor(s) to an existing project `pom.xml` into the `<plugins/>` block.
@@ -55,8 +35,8 @@ The first step of the configuration is to add the plugin, and the processor(s) t
5535
<plugin>
5636
<groupId>io.openapiprocessor</groupId>
5737
<artifactId>openapi-processor-maven-plugin</artifactId>
58-
<!-- update to latest version, see maven central badge at top -->
59-
<version>2021.1</version>
38+
<!-- update to the latest version, see maven central badge at top -->
39+
<version>2022.1</version>
6040
6141
<!-- ... next step ... -->
6242
</plugin>
@@ -74,7 +54,7 @@ The processors are dependencies of the plugin, and they are expected in the `<pl
7454
<dependency>
7555
<groupId>io.openapiprocessor</groupId>
7656
<artifactId>openapi-processor-spring</artifactId>
77-
<version>2021.2</version>
57+
<version>2022.1</version>
7858
</dependency>
7959
<dependency>
8060
<groupId>io.openapiprocessor</groupId>
@@ -93,13 +73,15 @@ Then it should know where the processors will find the input OpenAPI yaml files
9373
----
9474
<plugin>
9575
<configuration>
76+
<id>processor-api</id>
9677
<apiPath>${project.basedir}/src/api/openapi.yaml</apiPath>
9778
</configuration>
9879
9980
<!-- ... next step ... -->
10081
</plugin>
10182
----
10283

84+
* `<id/>`, maven wants this. It is not used by the processor.
10385
* `*<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.
10486

10587
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.
@@ -113,7 +95,7 @@ Here is an example to run `openapi-processor-spring` that explains the configura
11395
<plugin>
11496
<executions>
11597
<execution>
116-
<id>spring</id> <!--1-->
98+
<id>spring-interfaces</id> <!--1-->
11799
<phase>generate-sources</phase> <!--2-->
118100
119101
<configuration>
@@ -153,7 +135,7 @@ Here is an example to run `openapi-processor-spring` that explains the configura
153135

154136
<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.
155137

156-
<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 processors artifact name is the processor id.
138+
<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.
157139
+
158140
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`.
159141

@@ -191,7 +173,7 @@ To run a second processor add another `<execution>` element. Here is an example
191173
<plugin>
192174
<executions>
193175
<execution>
194-
<id>spring</id>
176+
<id>spring-interfaces</id>
195177
<phase>generate-sources</phase>
196178
197179
<configuration>
@@ -201,7 +183,7 @@ To run a second processor add another `<execution>` element. Here is an example
201183
</execution>
202184
203185
<execution>
204-
<id>json</id>
186+
<id>json-resource</id>
205187
<phase>generate-resources</phase> <!--1-->
206188
207189
<configuration>
@@ -215,6 +197,50 @@ To run a second processor add another `<execution>` element. Here is an example
215197

216198
<1> uses `generate-resources` phase for the json output, to consider it as a resource.
217199

200+
== executing the goal
201+
202+
The `<execution>` s created in the previous chapter will automatically run the processor in the given `<phase>` s with commands like `./mvnw compile`.
203+
204+
Running the goal directly with `./mvnw openapi-processor:process` to check the source code generation will not work because there is no configuration without `<phase>`.
205+
206+
=== selecting an execution
207+
208+
This can be solved in two ways:
209+
210+
First, it is possible to the run the goal with an explicit `<execution>` like this:
211+
212+
[source,shell script]
213+
----
214+
./mvnw openapi-processor:process@spring-interfaces
215+
----
216+
217+
where `spring-interfaces` is the `<id>` of the execution.
218+
219+
== adding a default execution
220+
221+
The other solution is to change the `execution` that should run by default to a default `<execution>`. When running `./mvnw openapi-processor:process` from the shell, maven will look for an `<execution>` with the id `<id>default-cli</id>` and if available run it.
222+
223+
[source,xml]
224+
----
225+
<plugin>
226+
<executions>
227+
<execution>
228+
<id>default-cli</id> <!--1-->
229+
<phase>generate-sources</phase>
230+
231+
<configuration>
232+
<id>spring</id>
233+
<!-- ... -->
234+
</configuration>
235+
</execution>
236+
</executions>
237+
</plugin>
238+
----
239+
240+
<1> using maven's default execution id instead of a user selected id.
241+
242+
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.
243+
218244

219245
== using the processor output
220246

0 commit comments

Comments
 (0)