Skip to content

Commit 7fcb9f3

Browse files
committed
update docs
1 parent 80566a2 commit 7fcb9f3

File tree

1 file changed

+24
-55
lines changed

1 file changed

+24
-55
lines changed

docs/modules/ROOT/pages/index.adoc

Lines changed: 24 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ The first step of the configuration is to add the plugin, and the processor(s) t
3636
<groupId>io.openapiprocessor</groupId>
3737
<artifactId>openapi-processor-maven-plugin</artifactId>
3838
<!-- update to the latest version, see maven central badge at top -->
39-
<version>2022.1</version>
39+
<version>2024.1</version>
4040
4141
<!-- ... next step ... -->
4242
</plugin>
@@ -54,12 +54,12 @@ The processors are dependencies of the plugin, and they are expected in the `<pl
5454
<dependency>
5555
<groupId>io.openapiprocessor</groupId>
5656
<artifactId>openapi-processor-spring</artifactId>
57-
<version>2022.1</version>
57+
<version>2023.6.1</version>
5858
</dependency>
5959
<dependency>
6060
<groupId>io.openapiprocessor</groupId>
6161
<artifactId>openapi-processor-json</artifactId>
62-
<version>2021.2</version>
62+
<version>2023.6.1</version>
6363
</dependency>
6464
</dependencies>
6565
@@ -101,6 +101,9 @@ Here is an example to run `openapi-processor-spring` that explains the configura
101101
<configuration>
102102
<id>spring</id> <!--3-->
103103
104+
<!-- true is default -->
105+
<addSourceRoot>true</addSourceRoot> <!--9-->
106+
104107
<!--
105108
<apiPath>${project.basedir}/src/api/openapi.yaml</apiPath>
106109
--> <!--4-->
@@ -109,7 +112,7 @@ Here is an example to run `openapi-processor-spring` that explains the configura
109112
<values>
110113
<targetDir>${project.basedir}/target/generated-sources/openapi</targetDir> <!--6-->
111114
<mapping>${project.basedir}/src/api/mapping.yaml</mapping> <!--7-->
112-
<parser>OPENAPI4J</parser>
115+
<parser>INTERNAL</parser>
113116
<showWarnings>true</showWarnings>
114117
</values>
115118
@@ -150,7 +153,7 @@ To allow any level of nesting it is possible to create `*<nested/>*` option maps
150153
{
151154
"targetDir": "<basedir path>/target/generated-sources/openapi",
152155
"mapping": "<basedir path>/src/api/mapping.yaml",
153-
"parser": "OPENAPI4J",
156+
"parser": "INTERNAL",
154157
"showWarnings":true,
155158
"foo": {
156159
"bar": "foo-bar"
@@ -164,6 +167,9 @@ To allow any level of nesting it is possible to create `*<nested/>*` option maps
164167

165168
<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`.
166169

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`.
171+
172+
=== multiple processors
167173

168174
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]:
169175

@@ -244,67 +250,30 @@ With this configuration maven will use it when directly running the `process` go
244250

245251
== using the processor output
246252

247-
So far the plugin processes the given openapi yaml and writes the output to the given target directory but maven ignores the output.
248-
249-
It is necessary to tell maven to use the generated files. In case of generated java source files maven should compile them. The *build-helper-maven-plugin* is used to for this:
250-
251-
[source,xml]
252-
----
253-
<?xml version="1.0" encoding="UTF-8"?>
254-
<project xmlns="http://maven.apache.org/POM/4.0.0" ...>
255-
<build>
256-
<plugins>
257-
<plugin>
258-
<groupId>org.codehaus.mojo</groupId>
259-
<artifactId>build-helper-maven-plugin</artifactId>
260-
<executions>
261-
<execution>
262-
<id>oap-sources</id>
263-
<phase>generate-sources</phase>
264-
<goals>
265-
<goal>add-source</goal>
266-
</goals>
267-
<configuration>
268-
<sources>
269-
<source>${project.build.directory}/generated-sources/openapi</source>
270-
</sources>
271-
</configuration>
272-
</execution>
273-
274-
275-
</executions>
276-
</plugin>
253+
=== source files
277254

278-
</plugins>
279-
</build>
280-
</project>
281-
----
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.
282256

283-
This tells the *build-helper-maven-plugin* to add the processors `targetDir` as an additional source folder to the project.
257+
It can be disabled by setting the plugin configuration `<addSourceRoot>` to `false`.
284258

285-
Maven will now include the generated files when it compiles the project.
259+
=== resource files
286260

287-
If the output of the processor (e.g. generated by openapi-processor-json) should be used as resource the *build-helper-maven-plugin* has a goal for this too. Just add another `<excecution/>` using the `add-resource` goal:
261+
If the output of the processor (e.g. generated by openapi-processor-json) should be used as resource add a resource directory.
288262

289263
[source,xml]
290264
----
291-
<execution>
292-
<id>oap-resources</id>
293-
<phase>generate-resources</phase>
294-
<goals>
295-
<goal>add-resource</goal>
296-
</goals>
297-
<configuration>
265+
<?xml version="1.0" encoding="UTF-8"?>
266+
<project xmlns="http://maven.apache.org/POM/4.0.0" ...>
267+
<build>
298268
<resources>
299-
<resource>
300-
<directory>${project.build.directory}/generated-resources/json</directory>
301-
</resource>
269+
<resource>
270+
<directory>${project.build.directory}/generated-resources/json</directory>
271+
</resource>
302272
</resources>
303-
</configuration>
304-
</execution>
273+
</build>
274+
</project>
305275
----
306276

307-
308277
== Samples
309278

310279
See the maven sample in the xref:samples::index.adoc[samples] for a working spring boot example.

0 commit comments

Comments
 (0)