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 3535import java .util .ArrayList ;
3636import java .util .Arrays ;
3737import java .util .Collections ;
38- import java .util .HashMap ;
38+ import java .util .LinkedHashMap ;
3939import java .util .List ;
4040import java .util .Locale ;
4141import java .util .Map ;
@@ -452,7 +452,7 @@ else if (parameterInfo.isRequestPart() || ParameterIn.QUERY.toString().equals(pa
452452 * @param parameter the parameter
453453 */
454454 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 <>();
456456 if (parameterDoc .examples ().length == 1 && StringUtils .isBlank (parameterDoc .examples ()[0 ].name ())) {
457457 Optional <Example > exampleOptional = AnnotationsUtils .getExample (parameterDoc .examples ()[0 ]);
458458 exampleOptional .ifPresent (parameter ::setExample );
Original file line number Diff line number Diff line change 2626
2727package test .org .springdoc .api .v31 .app244 ;
2828
29+ import io .swagger .v3 .oas .annotations .enums .ParameterIn ;
2930import io .swagger .v3 .oas .annotations .headers .Header ;
31+ import io .swagger .v3 .oas .annotations .media .ExampleObject ;
3032import io .swagger .v3 .oas .annotations .media .Schema ;
3133import io .swagger .v3 .oas .annotations .responses .ApiResponse ;
3234
35+ import org .springframework .web .bind .annotation .GetMapping ;
3336import org .springframework .web .bind .annotation .PostMapping ;
3437import org .springframework .web .bind .annotation .RequestMapping ;
3538import org .springframework .web .bind .annotation .RestController ;
@@ -48,6 +51,16 @@ public class HelloController {
4851 )
4952 public void uploadMultipartWithBody (){
5053 }
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 () {}
5265
5366}
Original file line number Diff line number Diff line change 1212 ],
1313 "paths" : {
1414 "/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+ },
1546 "post" : {
1647 "tags" : [
1748 " hello-controller"
You can’t perform that action at this time.
0 commit comments