Skip to content

Commit 1110bd7

Browse files
committed
added to templates
1 parent 151de79 commit 1110bd7

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/NodeJSServerCodegen.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,23 @@ private List<Map<String, Object>> sortOperationsByPath(List<CodegenOperation> op
245245
}
246246

247247
@Override
248+
public void preprocessSwagger(Swagger swagger) {
249+
if ("/".equals(swagger.getBasePath())) {
250+
swagger.setBasePath("");
251+
}
252+
253+
String host = swagger.getHost();
254+
String port = "8080";
255+
if (host != null) {
256+
String[] parts = host.split(":");
257+
if (parts.length > 1) {
258+
port = parts[1];
259+
}
260+
}
261+
this.additionalProperties.put("serverPort", port);
262+
}
263+
264+
@Override
248265
public Map<String, Object> postProcessSupportingFileData(Map<String, Object> objs) {
249266
Swagger swagger = (Swagger)objs.get("swagger");
250267
if(swagger != null) {

modules/swagger-codegen/src/main/resources/nodejs/README.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ node .
1818
To view the Swagger UI interface:
1919

2020
```
21-
open http://localhost:8080/docs
21+
open http://localhost:{{serverPort}}/docs
2222
```
2323

2424
This project leverages the mega-awesome [swagger-tools](https://github.com/apigee-127/swagger-tools) middleware which does most all the work.

0 commit comments

Comments
 (0)