File tree Expand file tree Collapse file tree 3 files changed +83
-1
lines changed
springdoc-openapi-starter-common/src/main/java/org/springdoc/core/service
springdoc-openapi-starter-webmvc-api/src/test
java/test/org/springdoc/api/v30/app47 Expand file tree Collapse file tree 3 files changed +83
-1
lines changed Original file line number Diff line number Diff line change @@ -403,7 +403,10 @@ public static Collection<Parameter> getHeaders(MethodAttributes methodAttributes
403403 Parameter parameter = new Parameter ().in (ParameterIn .HEADER .toString ()).name (entry .getKey ()).schema (schema );
404404 if (map .containsKey (entry .getKey ())) {
405405 parameter = map .get (entry .getKey ());
406- if (StringUtils .isNotEmpty (entry .getValue ()))
406+ List existingEnum = null ;
407+ if (parameter .getSchema () != null && !CollectionUtils .isEmpty (parameter .getSchema ().getEnum ()))
408+ existingEnum = parameter .getSchema ().getEnum ();
409+ if (StringUtils .isNotEmpty (entry .getValue ()) && (existingEnum ==null || !existingEnum .contains (entry .getValue ())))
407410 parameter .getSchema ().addEnumItemObject (entry .getValue ());
408411 parameter .setSchema (parameter .getSchema ());
409412 }
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 4040 }
4141 }
4242 }
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+ }
4395 }
4496 },
4597 "components" : {}
4698}
99+
You can’t perform that action at this time.
0 commit comments