Skip to content

Commit 508a11a

Browse files
committed
add documentation (#439)
1 parent 8f358f7 commit 508a11a

File tree

3 files changed

+117
-0
lines changed

3 files changed

+117
-0
lines changed

docs/modules/ROOT/nav.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* xref:build.adoc[Build Integration]
33
* xref:processor/index.adoc[The Processor]
44
** xref:processor/configuration.adoc[Configuration]
5+
** xref:processor/annotations.adoc[Spring Annotations]
56
** xref:processor/endpoint-interface.adoc[Endpoint Grouping]
67
** xref:processor/endpoint-content.adoc[Endpoint Content Type]
78
** xref:processor/models.adoc[Models]
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
= Spring Annotations
2+
include::partial$links.adoc[]
3+
4+
Apart from the basic build plugin configuration, `openapi-processor-spring` has an additional configuration to select the annotation style.
5+
6+
== `annotations`
7+
8+
Spring Boot provides two annotation families
9+
10+
* the standard _mapping_ annotations, i.e., `@RequestMapping`, `@GetMapping` and friends to define server side controllers
11+
12+
* and the new _exchange_ (HTTP service clients) annotations, i.e., `@HttpExchange`, `@GetExchange` and friends to define server side controllers and http clients based on the same interface.
13+
14+
`openapi-processor-spring` supports both kinds of annotations.
15+
16+
In contrast to the usual `mapping.yaml` based configuration, it has to be configured as part of a processor configuration in the build instructions.
17+
18+
19+
[tabs]
20+
====
21+
Maven::
22+
+
23+
++++
24+
<div></div>
25+
++++
26+
In the `pom.xml` configure the `annotations` in the processor `<execution>` block.
27+
+
28+
[source,xml]
29+
----
30+
<!--pom.xml -->
31+
32+
<plugin>
33+
<groupId>io.openapiprocessor</groupId>
34+
<artifactId>openapi-processor-maven-plugin</artifactId>
35+
<version>${openapiprocessor.maven}</version>
36+
37+
<dependencies>
38+
<dependency>
39+
<groupId>io.openapiprocessor</groupId>
40+
<artifactId>openapi-processor-spring</artifactId>
41+
<version>${openapiprocessor.spring}</version>
42+
</dependency>
43+
</dependencies>
44+
45+
<configuration>
46+
<id>processor-api</id>
47+
<apiPath>${project.basedir}/src/api/openapi.yaml</apiPath>
48+
</configuration>
49+
50+
<executions>
51+
<execution>
52+
<id>server</id>
53+
<phase>generate-sources</phase>
54+
55+
<configuration>
56+
<id>server</id>
57+
<processor>spring</processor>
58+
<addSourceRoot>true</addSourceRoot>
59+
60+
<options>
61+
<values>
62+
<targetDir>${project.basedir}/target/generated-sources/openapi/server</targetDir>
63+
<mapping>${project.basedir}/src/api/mapping-server.yaml</mapping>
64+
<annotations>exchange</annotations> <!-- <1> -->
65+
</values>
66+
</options>
67+
</configuration>
68+
69+
<goals>
70+
<goal>process</goal>
71+
</goals>
72+
</execution>
73+
</executions>
74+
</plugin>
75+
76+
<!-- .... -->
77+
----
78+
Gradle::
79+
+
80+
++++
81+
<div></div>
82+
++++
83+
In the `build.gradle.kts` configure the `annotations` in to the processor configuration block.
84+
+
85+
[source,kotlin]
86+
----
87+
// build.gradle.kts
88+
89+
openapiProcessor {
90+
91+
// the path to the open api YAML file. Usually the same for all processors.
92+
apiPath("${projectDir}/src/api/openapi.yaml")
93+
94+
process("server") {
95+
processorName("spring")
96+
97+
// the spring processor dependenc(y|ies)
98+
dependencies {
99+
//process("${oap.processor.core.get()}")
100+
process("${oap.processor.spring.get()}")
101+
}
102+
103+
targetDir("$projectDir/build/openapi")
104+
105+
prop("annotations", "exchange") // <1>
106+
prop("mapping", layout.projectDirectory.file("src/api/mapping.yaml"))
107+
}
108+
}
109+
----
110+
====
111+
112+
<1> this configures the processor to use the `Exchange` annotations instead of the `Mapping` annotations.
113+
+
114+
Using the `Mapping` annotations is the default and will be used if the `annotations` property is not set.

docs/modules/ROOT/pages/processor/configuration.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ map:
5050

5151
The only required option is `package-name` or alternatively `package-names.base`. All other options or the type mappings are optional.
5252

53+
Configuration of the annotation style i.e., `Mapping` or `Exchange`, see xref:processor/annotations.adoc[].
54+
5355
== options:
5456

5557

0 commit comments

Comments
 (0)