added serverPort

This commit is contained in:
Tony Tam 2015-12-30 00:06:24 -08:00
parent 405e09a057
commit 05b0d8f1bf
3 changed files with 12 additions and 2 deletions

View File

@ -166,6 +166,16 @@ public class JaxRSServerCodegen extends JavaClientCodegen implements CodegenConf
if("/".equals(swagger.getBasePath())) {
swagger.setBasePath("");
}
String host = swagger.getHost();
String port = "8080";
if(host != null) {
String[] parts = host.split(":");
if(parts.length > 0) {
port = parts[1];
}
}
this.additionalProperties.put("serverPort", port);
if(swagger != null && swagger.getPaths() != null) {
for(String pathname : swagger.getPaths().keySet()) {
Path path = swagger.getPath(pathname);

View File

@ -16,7 +16,7 @@ mvn clean package jetty:run
You can then view the swagger listing here:
```
http://localhost:8080{{contextPath}}/swagger.json
http://localhost:{{serverPort}}{{contextPath}}/swagger.json
```
Note that if you have configured the `host` to be something other than localhost, the calls through

View File

@ -37,7 +37,7 @@
<stopPort>8079</stopPort>
<stopKey>stopit</stopKey>
<httpConnector>
<port>8080</port>
<port>{{serverPort}}</port>
<idleTimeout>60000</idleTimeout>
</httpConnector>
</configuration>