Skip to content

Commit b97e98c

Browse files
committed
improve documentation
1 parent 4a5d97c commit b97e98c

File tree

1 file changed

+6
-34
lines changed

1 file changed

+6
-34
lines changed

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

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@ It is possible to add additional annotations to a `source type`. Currently, this
55

66
* global _annotation type mapping_:
77
+
8-
it adds an annotation to the model class generated for the `source type`.
8+
it adds an annotation to the *model class* generated for the `source type`.
99
1010
* global & endpoint parameter _annotation type mapping_:
1111
+
12-
it adds an annotation to a parameter of the `source type`. Since the request body is passed as parameter the mapping will work for it too.
12+
it adds an annotation to a *parameter* of the `source type` (this includes request body parameters).
1313
14-
It is defined like below, and it should be added to the `map/types` or `map/parameters` section in the mapping.yaml.
14+
The global annotation mapping should be added to the `map/types` or `map/parameters` section in the mapping.yaml.
1515

16-
It is also available as an endpoint (http method) mapping to restrict the mapping to a specific endpoint. This will go to the `map/paths/<endpoint path>/parameters` section in the mapping.yaml.
16+
The endpoint (http method) mapping restricts the mapping to a specific endpoint. This will go to the `map/paths/<endpoint path>/parameters` section in the mapping.yaml.
1717

1818
The annotation type mapping is similar to other mappings and is defined like this:
1919

2020
[source,yaml]
2121
----
22-
- type: {source type} @ {annotation type}
22+
type: {source type} @ {annotation type}
2323
----
2424

2525
* **type** is required.
@@ -135,7 +135,7 @@ The `Sum` annotation in the example is a custom bean validation but the feature
135135
<1> use `v2.1` as the mapping version to avoid validation warnings in the mapping file.
136136
<2> the `Bar` mapping is using a global type annotation mapping, so the annotation is added to the generated `Bar` class.
137137
<3> the `Foo` mapping adds the annotation to the parameter of the endpoint methods that use `Foo`.
138-
<4> this is a list of examples that shows annotation parameters. It is nearly java code.
138+
<4> this is a list of examples that shows annotation parameters.
139139

140140
Here are the generated interfaces, first the `FooApi`:
141141

@@ -199,34 +199,6 @@ public interface BarApi {
199199
}
200200
----
201201

202-
[source,java]
203-
----
204-
package io.openapiprocessor.openapi.api;
205-
206-
import io.openapiprocessor.openapi.model.Bar;
207-
import javax.validation.Valid;
208-
import javax.validation.constraints.NotNull;
209-
import org.springframework.web.bind.annotation.PostMapping;
210-
import org.springframework.web.bind.annotation.RequestBody;
211-
212-
public interface BarApi {
213-
214-
/**
215-
* annotation mapping example.
216-
*
217-
* <p>a simple endpoint where an annotation mapping is used on the request body
218-
*
219-
* @return echo of the source parameter
220-
*/
221-
@PostMapping(
222-
path = "/bar",
223-
consumes = {"application/json"},
224-
produces = {"application/json"})
225-
Bar postBar(@RequestBody @Valid @NotNull Bar body); // <1>
226-
227-
}
228-
----
229-
230202
<1> no annotation here, mapping says it should be on the class:
231203

232204
[source,java]

0 commit comments

Comments
 (0)