From 151de79a9811a00997df8de1c90cce5db885256a Mon Sep 17 00:00:00 2001 From: Tony Tam Date: Wed, 6 Jan 2016 09:31:06 -0800 Subject: [PATCH 1/2] formatting --- .travis.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.travis.yml b/.travis.yml index 6696cd332e..46286b5e5c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,16 +2,21 @@ sudo: required language: java jdk: - oraclejdk7 + services: - docker + before_install: # required when sudo: required for the Ruby petstore tests - gem install bundler + install: - docker login --email=$DOCKER_HUB_EMAIL --username=$DOCKER_HUB_USERNAME --password=$DOCKER_HUB_PASSWORD + script: - mvn verify -Psamples - docker build -t $DOCKER_IMAGE_NAME ./modules/swagger-generator - if [ ! -z "$TRAVIS_TAG" ]; then docker tag $DOCKER_IMAGE_NAME:latest $DOCKER_IMAGE_NAME:$TRAVIS_TAG; fi && docker push $DOCKER_IMAGE_NAME + env: - DOCKER_IMAGE_NAME=swaggerapi/swagger-generator From 1110bd7a089515b249c000306ae3b264b1bc7542 Mon Sep 17 00:00:00 2001 From: Tony Tam Date: Wed, 6 Jan 2016 09:31:14 -0800 Subject: [PATCH 2/2] added to templates --- .../codegen/languages/NodeJSServerCodegen.java | 17 +++++++++++++++++ .../src/main/resources/nodejs/README.mustache | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/NodeJSServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/NodeJSServerCodegen.java index 75581e6a06..d4bb00bb65 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/NodeJSServerCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/NodeJSServerCodegen.java @@ -245,6 +245,23 @@ public class NodeJSServerCodegen extends DefaultCodegen implements CodegenConfig } @Override + public void preprocessSwagger(Swagger swagger) { + if ("/".equals(swagger.getBasePath())) { + swagger.setBasePath(""); + } + + String host = swagger.getHost(); + String port = "8080"; + if (host != null) { + String[] parts = host.split(":"); + if (parts.length > 1) { + port = parts[1]; + } + } + this.additionalProperties.put("serverPort", port); + } + + @Override public Map postProcessSupportingFileData(Map objs) { Swagger swagger = (Swagger)objs.get("swagger"); if(swagger != null) { diff --git a/modules/swagger-codegen/src/main/resources/nodejs/README.mustache b/modules/swagger-codegen/src/main/resources/nodejs/README.mustache index d94aa385ec..d755fb4305 100644 --- a/modules/swagger-codegen/src/main/resources/nodejs/README.mustache +++ b/modules/swagger-codegen/src/main/resources/nodejs/README.mustache @@ -18,7 +18,7 @@ node . To view the Swagger UI interface: ``` -open http://localhost:8080/docs +open http://localhost:{{serverPort}}/docs ``` This project leverages the mega-awesome [swagger-tools](https://github.com/apigee-127/swagger-tools) middleware which does most all the work.