File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed
modules/swagger-generator/src/main/java/io/swagger/generator Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -38,9 +38,10 @@ public void init(ServletConfig config) throws ServletException {
38
38
if (scheme != null ) {
39
39
bc .setSchemes (new String [] { scheme });
40
40
}
41
- String host = hostURI .getHost ();
42
- if (host != null ) {
43
- bc .setHost (host );
41
+ String authority = hostURI .getAuthority ();
42
+ if (authority != null ) {
43
+ // In Swagger host refers to host _and_ port, a.k.a. the URI authority
44
+ bc .setHost (authority );
44
45
}
45
46
bc .setBasePath (hostURI .getPath () + "/api" );
46
47
} catch (URISyntaxException e ) {
Original file line number Diff line number Diff line change 7
7
import io .swagger .models .Operation ;
8
8
import io .swagger .models .Path ;
9
9
import io .swagger .models .Swagger ;
10
+ import io .swagger .models .Scheme ;
10
11
import io .swagger .models .parameters .Parameter ;
11
12
import io .swagger .models .parameters .PathParameter ;
12
13
13
14
import java .util .ArrayList ;
15
+ import java .util .Arrays ;
14
16
import java .util .Collections ;
15
17
import java .util .List ;
18
+ import java .util .stream .Collectors ;
16
19
17
20
public class DynamicSwaggerConfig extends BeanConfig {
18
21
static List <String > clients = new ArrayList <String >();
@@ -73,6 +76,15 @@ public Swagger configure(Swagger swagger) {
73
76
}
74
77
}
75
78
76
- return swagger .info (getInfo ()).host (getHost ()).basePath ("/api" );
79
+ Swagger result = swagger
80
+ .info (getInfo ())
81
+ .host (getHost ())
82
+ .basePath (getBasePath ());
83
+
84
+ if (getSchemes () != null ) {
85
+ result = result .schemes (Arrays .stream (getSchemes ()).map (s -> Scheme .forValue (s )).collect (Collectors .toList ()));
86
+ }
87
+
88
+ return result ;
77
89
}
78
90
}
You can’t perform that action at this time.
0 commit comments