File tree Expand file tree Collapse file tree 3 files changed +84
-2
lines changed
springdoc-openapi-common/src/main/java/org/springdoc/core
springdoc-openapi-webmvc-core/src/test
java/test/org/springdoc/api/v30/app47 Expand file tree Collapse file tree 3 files changed +84
-2
lines changed Original file line number Diff line number Diff line change @@ -334,7 +334,7 @@ else if (!RequestMethod.GET.equals(requestMethod)) {
334
334
Entry <String , Parameter > entry = it .next ();
335
335
Parameter parameter = entry .getValue ();
336
336
if (!ParameterIn .PATH .toString ().equals (parameter .getIn ())) {
337
- io .swagger .v3 .oas .models .media .Schema <?> itemSchema = new io .swagger .v3 .oas .models .media .Schema <>() ;
337
+ io .swagger .v3 .oas .models .media .Schema <?> itemSchema = new io .swagger .v3 .oas .models .media .Schema <>();
338
338
itemSchema .setName (entry .getKey ());
339
339
itemSchema .setDescription (parameter .getDescription ());
340
340
itemSchema .setDeprecated (parameter .getDeprecated ());
@@ -398,7 +398,10 @@ public static Collection<Parameter> getHeaders(MethodAttributes methodAttributes
398
398
Parameter parameter = new Parameter ().in (ParameterIn .HEADER .toString ()).name (entry .getKey ()).schema (schema );
399
399
if (map .containsKey (entry .getKey ())) {
400
400
parameter = map .get (entry .getKey ());
401
- if (StringUtils .isNotEmpty (entry .getValue ()))
401
+ List existingEnum = null ;
402
+ if (parameter .getSchema () != null && !CollectionUtils .isEmpty (parameter .getSchema ().getEnum ()))
403
+ existingEnum = parameter .getSchema ().getEnum ();
404
+ if (StringUtils .isNotEmpty (entry .getValue ()) && (existingEnum ==null || !existingEnum .contains (entry .getValue ())))
402
405
parameter .getSchema ().addEnumItemObject (entry .getValue ());
403
406
parameter .setSchema (parameter .getSchema ());
404
407
}
Original file line number Diff line number Diff line change
1
+ package test .org .springdoc .api .v30 .app47 ;
2
+
3
+ import org .springframework .web .bind .annotation .GetMapping ;
4
+ import org .springframework .web .bind .annotation .RequestMapping ;
5
+ import org .springframework .web .bind .annotation .RestController ;
6
+
7
+ @ RestController
8
+ @ RequestMapping (path = "/" )
9
+ public class BasicController {
10
+
11
+ @ GetMapping (headers = {"foo=bar" })
12
+ public String get1 () {
13
+ return null ;
14
+ }
15
+
16
+ @ GetMapping (headers = {"fi=ri" })
17
+ public String get2 () {
18
+ return null ;
19
+ }
20
+
21
+ @ GetMapping (
22
+ headers = {"User-Agent=" + "MyUserAgent" })
23
+ public String get3 () {
24
+ return null ;
25
+ }
26
+ }
Original file line number Diff line number Diff line change 40
40
}
41
41
}
42
42
}
43
+ },
44
+ "/" : {
45
+ "get" : {
46
+ "tags" : [
47
+ " basic-controller"
48
+ ],
49
+ "operationId" : " get1_1_1" ,
50
+ "parameters" : [
51
+ {
52
+ "name" : " foo" ,
53
+ "in" : " header" ,
54
+ "schema" : {
55
+ "type" : " string" ,
56
+ "enum" : [
57
+ " bar"
58
+ ]
59
+ }
60
+ },
61
+ {
62
+ "name" : " fi" ,
63
+ "in" : " header" ,
64
+ "schema" : {
65
+ "type" : " string" ,
66
+ "enum" : [
67
+ " ri"
68
+ ]
69
+ }
70
+ },
71
+ {
72
+ "name" : " User-Agent" ,
73
+ "in" : " header" ,
74
+ "schema" : {
75
+ "type" : " string" ,
76
+ "enum" : [
77
+ " MyUserAgent"
78
+ ]
79
+ }
80
+ }
81
+ ],
82
+ "responses" : {
83
+ "200" : {
84
+ "description" : " OK" ,
85
+ "content" : {
86
+ "*/*" : {
87
+ "schema" : {
88
+ "type" : " string"
89
+ }
90
+ }
91
+ }
92
+ }
93
+ }
94
+ }
43
95
}
44
96
},
45
97
"components" : {}
46
98
}
99
+
You can’t perform that action at this time.
0 commit comments