Skip to content

Commit 2993578

Browse files
author
bnasslahsen
committed
Merge branch 'vitvvv1-master'
2 parents df1df6e + faa71ce commit 2993578

File tree

4 files changed

+59
-1
lines changed

4 files changed

+59
-1
lines changed

springdoc-openapi-common/src/main/java/org/springdoc/core/MethodAttributes.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ else if (ArrayUtils.isNotEmpty(classConsumes))
147147
if (ArrayUtils.isNotEmpty(headers))
148148
for (String header : headers) {
149149
String[] keyValueHeader = header.split("=");
150-
this.headers.put(keyValueHeader[0], keyValueHeader[1]);
150+
String headerValue = keyValueHeader.length > 1 ? keyValueHeader[1] : "";
151+
this.headers.put(keyValueHeader[0], headerValue);
151152
}
152153
}
153154

springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app97/HelloController.java

+4
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,8 @@ public StudentV2 headerV2() {
3636
return new StudentV2("Charlie");
3737
}
3838

39+
@GetMapping(value = "/student/header3", headers = "X-API-VERSION")
40+
public StudentV3 headerV3() {
41+
return new StudentV3("Tom Charlie");
42+
}
3943
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package test.org.springdoc.api.app97;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
5+
public class StudentV3 {
6+
7+
@JsonProperty("name")
8+
private String name;
9+
10+
public StudentV3(String name) {
11+
this.name = name;
12+
}
13+
}

springdoc-openapi-webmvc-core/src/test/resources/results/app97.json

+40
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,38 @@
1111
}
1212
],
1313
"paths": {
14+
"/api/student/header3": {
15+
"get": {
16+
"tags": [
17+
"hello-controller"
18+
],
19+
"operationId": "headerV3",
20+
"parameters": [
21+
{
22+
"name": "X-API-VERSION",
23+
"in": "header",
24+
"schema": {
25+
"type": "string",
26+
"enum": [
27+
""
28+
]
29+
}
30+
}
31+
],
32+
"responses": {
33+
"200": {
34+
"description": "default response",
35+
"content": {
36+
"*/*": {
37+
"schema": {
38+
"$ref": "#/components/schemas/StudentV3"
39+
}
40+
}
41+
}
42+
}
43+
}
44+
}
45+
},
1446
"/api/student/header2": {
1547
"get": {
1648
"tags": [
@@ -78,6 +110,14 @@
78110
},
79111
"components": {
80112
"schemas": {
113+
"StudentV3": {
114+
"type": "object",
115+
"properties": {
116+
"name": {
117+
"type": "string"
118+
}
119+
}
120+
},
81121
"StudentV2": {
82122
"type": "object",
83123
"properties": {

0 commit comments

Comments
 (0)