Skip to content

Commit e2281b2

Browse files
committed
extract versions to variable
1 parent 658974f commit e2281b2

22 files changed

+143
-115
lines changed

docs/modules/ROOT/pages/mapping/annotation.adoc

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
= Annotation mapping
22
include::partial$links.adoc[]
3+
include::partial$vars.adoc[]
34

45
It is possible to add additional annotations to a `source type`. Currently, this is available as
56

@@ -100,9 +101,9 @@ Previously an annotation mapping was lost if the type was mapped at the same tim
100101

101102
Assume the following mapping:
102103

103-
[source,yaml]
104+
[source,yaml,subs="attributes"]
104105
----
105-
openapi-processor-mapping: v12
106+
openapi-processor-mapping: {var-mapping-version}
106107
107108
options:
108109
@@ -146,9 +147,9 @@ public class FooBar {
146147

147148
Given the following OpenAPI description, that describe two (echo like) endpoints that receive an object via post and return the same object. In the mapping file we add a custom bean validation annotation. It checks the sum of both properties in `Foo` and `Bar`.
148149

149-
[source,yaml]
150+
[source,yaml,subs="attributes"]
150151
----
151-
openapi: 3.1.0
152+
openapi: {var-openapi-version}
152153
info:
153154
title: openapi-processor-spring sample api
154155
version: 1.0.0
@@ -217,9 +218,9 @@ components:
217218

218219
and a `mapping.yaml` with annotation type mappings:
219220

220-
[source,yaml]
221+
[source,yaml,subs="attributes"]
221222
----
222-
openapi-processor-mapping: v12 # <1>
223+
openapi-processor-mapping: {var-mapping-version} # <1>
223224
224225
options:
225226
package-name: io.openapiprocessor.openapi

docs/modules/ROOT/pages/mapping/endpoint.adoc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
= Endpoint mappings
22
include::partial$links.adoc[]
3+
include::partial$vars.adoc[]
34

45
The global mapping variations are also available as explicit endpoint mappings. Instead of adding
56
the mapping in the global sections `map/types`, `map/parameters` and `map/responses` they can
@@ -84,9 +85,9 @@ It is possible to add mappings that apply only to a specific http method. Motiva
8485

8586
Here are a few examples of possible http endpoint mappings:
8687

87-
[source,yaml]
88+
[source,yaml,subs="attributes"]
8889
----
89-
openapi-processor-mapping: v12
90+
openapi-processor-mapping: {var-mapping-version}
9091
9192
map:
9293

docs/modules/ROOT/pages/mapping/extension.adoc

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
= Extension mapping
22
include::partial$links.adoc[]
3+
include::partial$vars.adoc[]
34

45
[.badge .badge-since]+since 2024.1+
56

@@ -9,8 +10,9 @@ Apart from the annotation mapping by an OpenAPI type, openapi-processor can use
910

1011
Here is a simple schema that has `x-` tensions on the `bar` property.
1112

12-
```yaml
13-
openapi: 3.1.0
13+
[source,yaml,subs="attributes"]
14+
----
15+
openapi: {var-openapi-version}
1416
# ...
1517
components:
1618
schemas:
@@ -23,12 +25,13 @@ components:
2325
x-bar:
2426
- listA
2527
- listB
26-
```
28+
----
2729

2830
In general openapi-processor will ignore the `x-` tension properties unless we map the `x-` tensions/values to annotations like this:
2931

30-
```yaml
31-
openapi-processor-mapping: v12
32+
[source,yaml,subs="attributes"]
33+
----
34+
openapi-processor-mapping: {var-mapping-version}
3235
options:
3336
# ...
3437
@@ -38,7 +41,7 @@ map:
3841
x-bar:
3942
- listA @ io.oap.FooB # <2>
4043
- listB @ io.oap.FooC
41-
```
44+
----
4245

4346
NOTE: openapi-processor will only recognize *strings* values of an extension. It will ignore any other type.
4447

@@ -50,7 +53,8 @@ The mapping allows two variations:
5053

5154
With this mapping the generated Dto class will have the additional annotations on the property.
5255

53-
```java
56+
[source,java]
57+
----
5458
package generated.model;
5559
5660
import com.fasterxml.jackson.annotation.JsonProperty;
@@ -77,4 +81,4 @@ public class Foo {
7781
}
7882
7983
}
80-
```
84+
----

docs/modules/ROOT/pages/mapping/global.adoc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
= Global mappings
2+
include::partial$vars.adoc[]
23

34
Global type mapping will replace **any** usage of an OpenAPI type in the api description to the given java type.
45

56
It is defined like below, and it should be added to the `map/types` section in the `mapping.yaml` which is a list of global type mappings:
67

7-
[source,yaml]
8+
[source,yaml,subs="attributes"]
89
----
9-
openapi-processor-mapping: v12
10+
openapi-processor-mapping: {var-mapping-version}
1011
1112
options:
1213
package-name: io.openapiprocessor.sample
@@ -143,9 +144,9 @@ This will generate the same code as the longer mapping version above.
143144

144145
It is possible to create type mappings with nested generics types. Here are a few examples:
145146

146-
[source,yaml]
147+
[source,yaml,subs="attributes"]
147148
----
148-
openapi-processor-mapping: v12
149+
openapi-processor-mapping: {var-mapping-version}
149150
150151
options:
151152
package-name: generated

docs/modules/ROOT/pages/mapping/logging.adoc

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
= log mapping lookup
2+
include::partial$vars.adoc[]
23

34
It is possible to let a processor log all the mapping lookups. It *may* be useful to understand why a mapping does not work.
45

@@ -10,9 +11,9 @@ In case the processor uses the mapping, but it still doesn't behave as expected
1011

1112
To control the logging there are two new xref:processor/configuration.adoc#_logging[logging options].
1213

13-
[source,yaml]
14+
[source,yaml,subs="attributes"]
1415
----
15-
openapi-processor-mapping: v12
16+
openapi-processor-mapping: {var-mapping-version}
1617
options:
1718
package-name: io.openapiprocessor.generated
1819
@@ -99,9 +100,9 @@ If the `mapping-target` is `stdout` the processor output will be written without
99100

100101
to enable logging with maven use:
101102

102-
[source,yaml]
103+
[source,yaml,subs="attributes"]
103104
----
104-
openapi-processor-mapping: v12
105+
openapi-processor-mapping: {var-mapping-version}
105106
options:
106107
package-name: ...
107108
@@ -115,9 +116,9 @@ logging:
115116

116117
to get the simple output, or
117118

118-
[source,yaml]
119+
[source,yaml,subs="attributes"]
119120
----
120-
openapi-processor-mapping: v12
121+
openapi-processor-mapping: {var-mapping-version}
121122
options:
122123
package-name: ...
123124
@@ -138,9 +139,9 @@ Gradle requires the `mapping-target` to be `stdout`. Gradle can only globally en
138139

139140
to enable logging with gradle use:
140141

141-
[source,yaml]
142+
[source,yaml,subs="attributes"]
142143
----
143-
openapi-processor-mapping: v12
144+
openapi-processor-mapping: {var-mapping-version}
144145
options:
145146
package-name: ...
146147

docs/modules/ROOT/pages/mapping/null.adoc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
include::partial$vars.adoc[]
12
:nullable: https://github.com/OpenAPITools/jackson-databind-nullable
23

34
= Null mapping
@@ -30,9 +31,9 @@ Normally the processor would generate a simple pojo with a `String` property.
3031

3132
By adding a `null` mapping for the `/foo` endpoint (this does work only on the endpoint level, a global null mapping gets ignored):
3233

33-
[source,yaml]
34+
[source,yaml,subs="attributes"]
3435
----
35-
openapi-processor-mapping: v12
36+
openapi-processor-mapping: {var-mapping-version}
3637
3738
map:
3839
paths:

docs/modules/ROOT/pages/mapping/package-name.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
The type mapping (v2 and up) configuration allows to reference the target `package-name` in generic parameters using the `+{package-name}+` expression. This makes it possible to adjust the `package-name` without touching the mapping, and it does reduce duplication.
44

5-
[source,yaml]
5+
[source,yaml,subs="attributes"]
66
----
7-
openapi-processor-mapping: v12
7+
openapi-processor-mapping: {var-mapping-version}
88
options:
99
package-name: io.openapiprocessor.generated
1010

docs/modules/ROOT/pages/mapping/parameter.adoc

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
= (global) Parameter mappings
2+
include::partial$vars.adoc[]
23

34
Parameter mappings, as the name suggests, apply to the parameters of an endpoint method.
45

@@ -51,9 +52,9 @@ map:
5152

5253
and an openapi.yaml with multiple endpoints having a parameter named "date"
5354

54-
[source,yaml]
55+
[source,yaml,subs="attributes"]
5556
----
56-
openapi: 3.0.2
57+
openapi: {var-openapi-version}
5758
info:
5859
title: global parameter type mapping example
5960
version: 1.0.0
@@ -107,9 +108,9 @@ It is possible to add additional parameters that is not described in the OpenAPI
107108

108109
While it is possible to add it at the global level, it is best used at the endpoint level.
109110

110-
[source,yaml]
111+
[source,yaml,subs="attributes"]
111112
----
112-
openapi-processor-mapping: v12
113+
openapi-processor-mapping: {var-mapping-version}
113114
114115
options:
115116
package-name: generated
@@ -123,9 +124,9 @@ map:
123124

124125
Given the mapping configuration above and the following endpoint description:
125126

126-
[source,yaml]
127+
[source,yaml,subs="attributes"]
127128
----
128-
openapi: 3.1.0
129+
openapi: {var-openapi-version}
129130
info:
130131
title: test additional endpoint parameter
131132
version: 1.0.0
@@ -174,9 +175,9 @@ It may also be useful to remove a parameter, maybe it is handled by a request fi
174175

175176
Again, even if it is possible to add it at the global level, it is best used at the endpoint level.
176177

177-
[source,yaml]
178+
[source,yaml,subs="attributes"]
178179
----
179-
openapi-processor-mapping: v12
180+
openapi-processor-mapping: {var-mapping-version}
180181
181182
options:
182183
package-name: generated
@@ -190,9 +191,9 @@ map:
190191

191192
Given the configuration above and the following endpoint description:
192193

193-
[source,yaml]
194+
[source,yaml,subs="attributes"]
194195
----
195-
openapi: 3.1.0
196+
openapi: {var-openapi-version}
196197
info:
197198
title: test unnecessary endpoint parameter
198199
version: 1.0.0

docs/modules/ROOT/pages/mapping/response.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ map:
5252
and an openapi.yaml with multiple endpoints returning their result as content type
5353
`application/vnd.something`
5454

55-
[source,yaml]
55+
[source,yaml,subs="attributes"]
5656
----
57-
openapi: 3.0.2
57+
openapi: {var-openapi-version}
5858
info:
5959
title: global response content type mapping example
6060
version: 1.0.0

docs/modules/ROOT/pages/mapping/schema.adoc

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
= (global) Schema mappings
2+
include::partial$vars.adoc[]
23

34
[.badge .badge-since]+since 2025.1+
45

@@ -19,9 +20,9 @@ The example will make this more clear.
1920

2021
In the example OpenAPI below is a year value (<1>) that is used on the response schema and as query parameter.
2122

22-
[source,yaml]
23+
[source,yaml,subs="attributes"]
2324
----
24-
openapi: 3.1.0
25+
openapi: {var-openapi-version}
2526
info:
2627
title: schema mapping
2728
version: 1.0.0
@@ -59,9 +60,9 @@ components:
5960

6061
Using a typical mapping the processor will use `java.time.Year` instead of a simple `Integer` type in the generated code.
6162

62-
[source,yaml]
63+
[source,yaml,subs="attributes"]
6364
----
64-
openapi-processor-mapping: v12
65+
openapi-processor-mapping: {var-mapping-version}
6566
6667
options:
6768
package-name: generated
@@ -83,9 +84,9 @@ would change serialization of `java.time.Year` to a number.
8384

8485
Adding the annotation mapping for this at the global type level
8586

86-
[source,yaml]
87+
[source,yaml,subs="attributes"]
8788
----
88-
openapi-processor-mapping: v12
89+
openapi-processor-mapping: {var-mapping-version}
8990
9091
options:
9192
package-name: generated
@@ -143,9 +144,9 @@ but also at the method parameter of the generated interface:
143144

144145
That is not wanted. To avoid it, the annotation mapping should be added to the new `schemas` mapping level:
145146

146-
[source,yaml]
147+
[source,yaml,subs="attributes"]
147148
----
148-
openapi-processor-mapping: v12
149+
openapi-processor-mapping: {var-mapping-version}
149150
150151
options:
151152
package-name: generated

0 commit comments

Comments
 (0)