Skip to content

Commit 6687d7b

Browse files
committed
add documentation (#339)
1 parent 5d8beb2 commit 6687d7b

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

docs/modules/ROOT/nav.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
** xref:mapping/parameter.adoc[Global Parameter Mapping]
2222
** xref:mapping/response.adoc[Global Response Mapping]
2323
** xref:mapping/result.adoc[Global Result Mapping]
24+
** xref:mapping/result-status.adoc[Global Result Status Mapping]
2425
** xref:mapping/result-style.adoc[Global Result Style]
2526
** xref:mapping/single-multi.adoc[Global Single & Multi Mapping]
2627
** xref:mapping/endpoint.adoc[Endpoint Mapping]
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
include::partial$links.adoc[]
2+
include::partial$vars.adoc[]
3+
4+
= Result Status
5+
6+
[.badge .badge-since]+since 2025.3+
7+
8+
The `result-status` configuration controls if the processor adds a `@ResponseStatus` annotation. If enabled (default) it will automatically add a `@ResponseStatus` annotation if the OpenAPI endpoint has a success result code not equal to 200 OK. I.e, 2xx != 200.
9+
10+
The default response status of Spring Boot is 200, so the processor will not add an unnecessary annotation for 200.
11+
12+
[NOTE]
13+
====
14+
This will conflict with manually added `@ResponseStatus` annotations.
15+
16+
To keep the old behavior, i.e., no automatically added `@ResponseStatus` annotations, set `result-status: false` on the global mapping level.
17+
====
18+
19+
It is configured by adding it to the mapping section of the configuration file. It is available on all levels, i.e., global, endpoint and endpoint method.
20+
21+
[source,yaml]
22+
----
23+
openapi-processor-mapping: {var-mapping-version}
24+
25+
options:
26+
# ...
27+
28+
map:
29+
# result-status: true is the default
30+
# setting it to false on the global level disables it
31+
result-status: false
32+
33+
paths:
34+
# enable it for a specific endpoint
35+
/foo:
36+
result-status: true
37+
38+
# ... or for a specific method of an endpoint
39+
#get:
40+
# result-status: true
41+
----
42+
43+
* **result-status** (optional).
44+
45+
** `true`: add a `@ResponseStatus` annotation if the response status of a response is a success code not equal to 200.
46+
47+
** `false` (default before 2025.3): do not generate any `@ResponseStatus` annotation.
48+
49+
** `result-status` is available at the endpoint & http method level.
50+

0 commit comments

Comments
 (0)