mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-06 10:35:25 +00:00
Merge pull request #1826 from swagger-api/issue-1825
added serverPort detection from the spec
This commit is contained in:
commit
8c8e3227d9
@ -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
|
||||
|
@ -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<String, Object> postProcessSupportingFileData(Map<String, Object> objs) {
|
||||
Swagger swagger = (Swagger)objs.get("swagger");
|
||||
if(swagger != null) {
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user