File tree Expand file tree Collapse file tree 3 files changed +47
-3
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/v31/app244 Expand file tree Collapse file tree 3 files changed +47
-3
lines changed Original file line number Diff line number Diff line change 35
35
import java .util .ArrayList ;
36
36
import java .util .Arrays ;
37
37
import java .util .Collections ;
38
- import java .util .HashMap ;
38
+ import java .util .LinkedHashMap ;
39
39
import java .util .List ;
40
40
import java .util .Locale ;
41
41
import java .util .Map ;
@@ -452,7 +452,7 @@ else if (parameterInfo.isRequestPart() || ParameterIn.QUERY.toString().equals(pa
452
452
* @param parameter the parameter
453
453
*/
454
454
private void setExamples (io .swagger .v3 .oas .annotations .Parameter parameterDoc , Parameter parameter ) {
455
- Map <String , Example > exampleMap = new HashMap <>();
455
+ Map <String , Example > exampleMap = new LinkedHashMap <>();
456
456
if (parameterDoc .examples ().length == 1 && StringUtils .isBlank (parameterDoc .examples ()[0 ].name ())) {
457
457
Optional <Example > exampleOptional = AnnotationsUtils .getExample (parameterDoc .examples ()[0 ]);
458
458
exampleOptional .ifPresent (parameter ::setExample );
Original file line number Diff line number Diff line change 26
26
27
27
package test .org .springdoc .api .v31 .app244 ;
28
28
29
+ import io .swagger .v3 .oas .annotations .enums .ParameterIn ;
29
30
import io .swagger .v3 .oas .annotations .headers .Header ;
31
+ import io .swagger .v3 .oas .annotations .media .ExampleObject ;
30
32
import io .swagger .v3 .oas .annotations .media .Schema ;
31
33
import io .swagger .v3 .oas .annotations .responses .ApiResponse ;
32
34
35
+ import org .springframework .web .bind .annotation .GetMapping ;
33
36
import org .springframework .web .bind .annotation .PostMapping ;
34
37
import org .springframework .web .bind .annotation .RequestMapping ;
35
38
import org .springframework .web .bind .annotation .RestController ;
@@ -48,6 +51,16 @@ public class HelloController {
48
51
)
49
52
public void uploadMultipartWithBody (){
50
53
}
51
-
54
+
55
+ @ GetMapping
56
+ @ io .swagger .v3 .oas .annotations .Parameter (
57
+ in = ParameterIn .HEADER ,
58
+ name = "x-header" ,
59
+ examples = {
60
+ @ ExampleObject (value = "AAA" , name = "First" ),
61
+ @ ExampleObject (value = "BBB" , name = "Second" ),
62
+ @ ExampleObject (value = "CCC" , name = "Third" )
63
+ })
64
+ void nope () {}
52
65
53
66
}
Original file line number Diff line number Diff line change 12
12
],
13
13
"paths" : {
14
14
"/test" : {
15
+ "get" : {
16
+ "tags" : [
17
+ " hello-controller"
18
+ ],
19
+ "operationId" : " nope" ,
20
+ "parameters" : [
21
+ {
22
+ "name" : " x-header" ,
23
+ "in" : " header" ,
24
+ "examples" : {
25
+ "First" : {
26
+ "description" : " First" ,
27
+ "value" : " AAA"
28
+ },
29
+ "Second" : {
30
+ "description" : " Second" ,
31
+ "value" : " BBB"
32
+ },
33
+ "Third" : {
34
+ "description" : " Third" ,
35
+ "value" : " CCC"
36
+ }
37
+ }
38
+ }
39
+ ],
40
+ "responses" : {
41
+ "200" : {
42
+ "description" : " OK"
43
+ }
44
+ }
45
+ },
15
46
"post" : {
16
47
"tags" : [
17
48
" hello-controller"
You can’t perform that action at this time.
0 commit comments