13 files changed +75
-32
lines changed Original file line number Diff line number Diff line change 26
26
27
27
package org .springdoc .core .customizers ;
28
28
29
+ import java .util .ArrayList ;
29
30
import java .util .List ;
30
31
import java .util .Map ;
31
32
import java .util .function .Consumer ;
@@ -144,6 +145,9 @@ private void customizeOpenApi(OpenAPI openApi, OpenAPI openApiProperties) {
144
145
if (!CollectionUtils .isEmpty (securityRequirementsProperties )) {
145
146
customizeSecurity (openApi , securityRequirementsProperties );
146
147
}
148
+ if (!CollectionUtils .isEmpty (openApiProperties .getServers ())) {
149
+ openApi .setServers (new ArrayList <>(openApiProperties .getServers ()));
150
+ }
147
151
}
148
152
}
149
153
@@ -364,5 +368,4 @@ private void resolveSet(Consumer<List> setter, Supplier<List> getter) {
364
368
}
365
369
}
366
370
367
-
368
371
}
Original file line number Diff line number Diff line change 1
1
springdoc :
2
2
open-api :
3
+ servers :
4
+ - url : " https://api.example.com"
5
+ description : " Production Server"
6
+ - url : " https://staging.example.com"
7
+ description : " Staging Server"
3
8
info :
4
9
title : Api info title
5
10
description : Api info description
Original file line number Diff line number Diff line change @@ -13,6 +13,9 @@ springdoc:
13
13
termsOfService : http://localhost:8080/
14
14
license :
15
15
name : Apache 2.0
16
+ servers :
17
+ - url : " https://demo.example.com"
18
+ description : " demo Server"
16
19
components :
17
20
schemas :
18
21
PersonDTO :
@@ -34,6 +37,9 @@ springdoc:
34
37
termsOfService : http://localhost:8080/
35
38
license :
36
39
name : Apache 2.0
40
+ servers :
41
+ - url : " https://user.example.com"
42
+ description : " user Server"
37
43
components :
38
44
schemas :
39
45
PersonDTO :
@@ -42,7 +48,12 @@ springdoc:
42
48
name :
43
49
description : Description for 'name' property
44
50
example : Example value for 'name' property
45
- open-api :
51
+ open-api :
52
+ servers :
53
+ - url : " https://api.example.com"
54
+ description : " Production Server"
55
+ - url : " https://staging.example.com"
56
+ description : " Staging Server"
46
57
info :
47
58
title : Api info title
48
59
description : Api info description
Original file line number Diff line number Diff line change 7
7
},
8
8
"servers" : [
9
9
{
10
- "url" : " http://localhost" ,
11
- "description" : " Generated server url"
10
+ "url" : " https://api.example.com" ,
11
+ "description" : " Production Server"
12
+ },
13
+ {
14
+ "url" : " https://staging.example.com" ,
15
+ "description" : " Staging Server"
12
16
}
13
17
],
14
18
"security" : [
Original file line number Diff line number Diff line change 7
7
},
8
8
"servers" : [
9
9
{
10
- "url" : " http://localhost" ,
11
- "description" : " Generated server url"
10
+ "url" : " https://api.example.com" ,
11
+ "description" : " Production Server"
12
+ },
13
+ {
14
+ "url" : " https://staging.example.com" ,
15
+ "description" : " Staging Server"
12
16
}
13
17
],
14
18
"security" : [
Original file line number Diff line number Diff line change 11
11
},
12
12
"servers" : [
13
13
{
14
- "url" : " http ://localhost " ,
15
- "description" : " Generated server url "
14
+ "url" : " https ://demo.example.com " ,
15
+ "description" : " demo Server "
16
16
}
17
17
],
18
18
"paths" : {
Original file line number Diff line number Diff line change 11
11
},
12
12
"servers" : [
13
13
{
14
- "url" : " http ://localhost " ,
15
- "description" : " Generated server url "
14
+ "url" : " https ://user.example.com " ,
15
+ "description" : " user Server "
16
16
}
17
17
],
18
18
"paths" : {
Original file line number Diff line number Diff line change 7
7
},
8
8
"servers" : [
9
9
{
10
- "url" : " http://localhost" ,
11
- "description" : " Generated server url"
10
+ "url" : " https://api.example.com" ,
11
+ "description" : " Production Server"
12
+ },
13
+ {
14
+ "url" : " https://staging.example.com" ,
15
+ "description" : " Staging Server"
12
16
}
13
17
],
14
18
"paths" : {
Original file line number Diff line number Diff line change 7
7
},
8
8
"servers" : [
9
9
{
10
- "url" : " http://localhost" ,
11
- "description" : " Generated server url"
10
+ "url" : " https://api.example.com" ,
11
+ "description" : " Production Server"
12
+ },
13
+ {
14
+ "url" : " https://staging.example.com" ,
15
+ "description" : " Staging Server"
12
16
}
13
17
],
14
18
"security" : [
106
110
"schemas" : {
107
111
"PersonDTO" : {
108
112
"type" : " object" ,
113
+ "description" : " Description for PersonDTO component in ApiGroupName" ,
109
114
"properties" : {
110
115
"name" : {
111
116
"type" : " string" ,
112
117
"description" : " Description for 'name' property in ApiGroupName" ,
113
118
"example" : " Example value for 'name' property in ApiGroupName"
114
119
}
115
- },
116
- "description" : " Description for PersonDTO component in ApiGroupName"
120
+ }
117
121
}
118
122
},
119
123
"securitySchemes" : {
Original file line number Diff line number Diff line change 7
7
},
8
8
"servers" : [
9
9
{
10
- "url" : " http://localhost" ,
11
- "description" : " Generated server url"
10
+ "url" : " https://api.example.com" ,
11
+ "description" : " Production Server"
12
+ },
13
+ {
14
+ "url" : " https://staging.example.com" ,
15
+ "description" : " Staging Server"
12
16
}
13
17
],
14
18
"security" : [
104
108
"schemas" : {
105
109
"PersonDTO" : {
106
110
"type" : " object" ,
111
+ "description" : " Description for PersonDTO component" ,
107
112
"properties" : {
108
113
"name" : {
109
114
"type" : " string" ,
110
115
"description" : " Description for 'name' property" ,
111
116
"example" : " Example value for 'name' property"
112
117
}
113
- },
114
- "description" : " Description for PersonDTO component"
118
+ }
115
119
}
116
120
},
117
121
"securitySchemes" : {
Original file line number Diff line number Diff line change 11
11
},
12
12
"servers" : [
13
13
{
14
- "url" : " http ://localhost " ,
15
- "description" : " Generated server url "
14
+ "url" : " https ://demo.example.com " ,
15
+ "description" : " demo Server "
16
16
}
17
17
],
18
18
"paths" : {
41
41
"schemas" : {
42
42
"PersonDTO" : {
43
43
"type" : " object" ,
44
+ "description" : " Description for PersonDTO component" ,
44
45
"properties" : {
45
46
"name" : {
46
47
"type" : " string" ,
47
48
"description" : " Description for 'name' property" ,
48
49
"example" : " Example value for 'name' property"
49
50
}
50
- },
51
- "description" : " Description for PersonDTO component"
51
+ }
52
52
}
53
53
}
54
54
}
Original file line number Diff line number Diff line change 11
11
},
12
12
"servers" : [
13
13
{
14
- "url" : " http ://localhost " ,
15
- "description" : " Generated server url "
14
+ "url" : " https ://user.example.com " ,
15
+ "description" : " user Server "
16
16
}
17
17
],
18
18
"paths" : {
41
41
"schemas" : {
42
42
"PersonDTO" : {
43
43
"type" : " object" ,
44
+ "description" : " Description for PersonDTO component" ,
44
45
"properties" : {
45
46
"name" : {
46
47
"type" : " string" ,
47
48
"description" : " Description for 'name' property" ,
48
49
"example" : " Example value for 'name' property"
49
50
}
50
- },
51
- "description" : " Description for PersonDTO component"
51
+ }
52
52
}
53
53
}
54
54
}
Original file line number Diff line number Diff line change 7
7
},
8
8
"servers" : [
9
9
{
10
- "url" : " http://localhost" ,
11
- "description" : " Generated server url"
10
+ "url" : " https://api.example.com" ,
11
+ "description" : " Production Server"
12
+ },
13
+ {
14
+ "url" : " https://staging.example.com" ,
15
+ "description" : " Staging Server"
12
16
}
13
17
],
14
18
"paths" : {
37
41
"schemas" : {
38
42
"PersonDTO" : {
39
43
"type" : " object" ,
44
+ "description" : " Description for PersonDTO component" ,
40
45
"properties" : {
41
46
"name" : {
42
47
"type" : " string" ,
43
48
"description" : " Description for 'name' property" ,
44
49
"example" : " Example value for 'name' property"
45
50
}
46
- },
47
- "description" : " Description for PersonDTO component"
51
+ }
48
52
}
49
53
}
50
54
}
0 commit comments