Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
wing328 committed Apr 24, 2017
2 parents 8153284 + e66566a commit 640b16b
Show file tree
Hide file tree
Showing 813 changed files with 21,488 additions and 15,663 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -67,7 +67,7 @@ script:
# fail if generators contain tab '\t'
- /bin/bash ./bin/utils/detect_tab_in_java_class.sh
# run integration tests defined in maven pom.xml
- mvn --batch-mode verify -Psamples
- mvn -q --batch-mode verify -Psamples
# docker: build generator image and push to Docker Hub
- if [ $DOCKER_HUB_USERNAME ]; then docker login --email=$DOCKER_HUB_EMAIL --username=$DOCKER_HUB_USERNAME --password=$DOCKER_HUB_PASSWORD && docker build -t $DOCKER_GENERATOR_IMAGE_NAME ./modules/swagger-generator && if [ ! -z "$TRAVIS_TAG" ]; then docker tag $DOCKER_GENERATOR_IMAGE_NAME:latest $DOCKER_GENERATOR_IMAGE_NAME:$TRAVIS_TAG; fi && if [ ! -z "$TRAVIS_TAG" ] || [ "$TRAVIS_BRANCH" = "master" ]; then docker push $DOCKER_GENERATOR_IMAGE_NAME; fi; fi
# docker: build cli image and push to Docker Hub
Expand Down
5 changes: 5 additions & 0 deletions README.md
Expand Up @@ -794,15 +794,18 @@ Here are some companies/projects using Swagger Codegen in production. To add you
- [Stingray](http://www.stingray.com)
- [StyleRecipe](http://stylerecipe.co.jp)
- [Svenska Spel AB](https://www.svenskaspel.se/)
- [Switch Database](https://www.switchdatabase.com/)
- [TaskData](http://www.taskdata.com/)
- [ThoughtWorks](https://www.thoughtworks.com)
- [Trexle](https://trexle.com/)
- [Upwork](http://upwork.com/)
- [uShip](https://www.uship.com/)
- [VMware](https://vmware.com/)
- [W.UP](http://wup.hu/?siteLang=en)
- [Wealthfront](https://www.wealthfront.com/)
- [Webever GmbH](https://www.webever.de/)
- [WEXO A/S](https://www.wexo.dk/)
- [XSky](http://www.xsky.com/)
- [Zalando](https://tech.zalando.com)
- [ZEEF.com](https://zeef.com/)

Expand Down Expand Up @@ -863,6 +866,7 @@ Here is a list of template creators:
* Bash: @bkryza
* C++ REST: @Danielku15
* C# (.NET 2.0): @who
* C# (.NET Standard 1.3 ): @Gronsak
* Clojure: @xhh
* Dart: @yissachar
* Elixir: @niku
Expand All @@ -873,6 +877,7 @@ Here is a list of template creators:
* Java (Retrofi2): @emilianobonassi
* Java (Jersey2): @xhh
* Java (okhttp-gson): @xhh
* Java (RestTemplate): @nbruno
* Javascript/NodeJS: @jfiala
* Javascript (Closure-annotated Angular) @achew22
* JMeter @davidkiss
Expand Down
4 changes: 2 additions & 2 deletions appveyor.yml
Expand Up @@ -30,8 +30,8 @@ build_script:
- nuget restore samples\client\petstore\csharp\SwaggerClientWithPropertyChanged\IO.Swagger.sln
- msbuild samples\client\petstore\csharp\SwaggerClientWithPropertyChanged\IO.Swagger.sln /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
# build C# .net standard 1.3+ API client
- nuget restore samples\client\petstore\csharp\SwaggerClient.v5\IO.Swagger.sln
- msbuild samples\client\petstore\csharp\SwaggerClient.v5\IO.Swagger.sln /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
- nuget restore samples\client\petstore\csharp\SwaggerClientNetStandard\IO.Swagger.sln
- msbuild samples\client\petstore\csharp\SwaggerClientNetStandard\IO.Swagger.sln /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
# install swagger codegen locally
- mvn clean install --batch-mode
test_script:
Expand Down
3 changes: 1 addition & 2 deletions bin/csharp-petstore-all.sh
Expand Up @@ -7,5 +7,4 @@
./bin/csharp-property-changed-petstore.sh

# C# Petstore API client (v5.0 for .net standarnd 1.3+)
./bin/csharp-petstore-v5.sh

./bin/csharp-petstore-net-standard.sh
File renamed without changes.
Expand Up @@ -26,6 +26,6 @@ fi

# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate $@ -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l csharp -o samples/client/petstore/csharp/SwaggerClient.v5 --additional-properties packageGuid={321C8C3F-0156-40C1-AE42-D59761FB9B6C} -c ./bin/csharp-petstore-v5.json"
ags="generate $@ -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l csharp -o samples/client/petstore/csharp/SwaggerClientNetStanard --additional-properties packageGuid={321C8C3F-0156-40C1-AE42-D59761FB9B6C} -c ./bin/csharp-petstore-net-standard.json"

java $JAVA_OPTS -jar $executable $ags
1 change: 1 addition & 0 deletions bin/java-petstore-all.sh
Expand Up @@ -11,3 +11,4 @@
./bin/java8-petstore-jersey2.sh
./bin/java-petstore-retrofit2-play24.sh
./bin/java-petstore-jersey2-java6.sh
./bin/java-petstore-resttemplate.sh
4 changes: 4 additions & 0 deletions bin/java-petstore-resttemplate.json
@@ -0,0 +1,4 @@
{
"library": "resttemplate",
"artifactId": "swagger-petstore-resttemplate"
}
34 changes: 34 additions & 0 deletions bin/java-petstore-resttemplate.sh
@@ -0,0 +1,34 @@
#!/bin/sh

SCRIPT="$0"

while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done

if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi

executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"

if [ ! -f "$executable" ]
then
mvn clean package
fi

# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l java -c bin/java-petstore-resttemplate.json -o samples/client/petstore/java/resttemplate -DhideGenerationTimestamp=true"

echo "Removing files and folders under samples/client/petstore/java/resttemplate/src/main"
rm -rf samples/client/petstore/java/resttemplate/src/main
find samples/client/petstore/java/resttemplate -maxdepth 1 -type f ! -name "README.md" -exec rm {} +
java $JAVA_OPTS -jar $executable $ags
1 change: 1 addition & 0 deletions bin/spring-all-pestore.sh
Expand Up @@ -7,3 +7,4 @@
./bin/spring-mvc-petstore-j8-async-server.sh
./bin/springboot-petstore-server.sh
./bin/spring-mvc-petstore-server.sh
./bin/springboot-petstore-server-beanvalidation.sh
5 changes: 5 additions & 0 deletions bin/springboot-petstore-server-beanvalidation.json
@@ -0,0 +1,5 @@
{
"artifactId": "spring-boot-beanvalidation",
"library": "spring-boot",
"useBeanValidation": true
}
34 changes: 34 additions & 0 deletions bin/springboot-petstore-server-beanvalidation.sh
@@ -0,0 +1,34 @@
#!/bin/sh

SCRIPT="$0"

while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done

if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi

executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"

if [ ! -f "$executable" ]
then
mvn clean package
fi

# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaSpring -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l spring -o samples/server/petstore/springboot-beanvalidation -c bin/springboot-petstore-server-beanvalidation.json -DhideGenerationTimestamp=true"

echo "Removing files and folders under samples/server/petstore/springboot-beanvalidation/src/main"
rm -rf samples/server/petstore/springboot-beanvalidation/src/main
find samples/server/petstore/springboot-beanvalidation -maxdepth 1 -type f ! -name "README.md" -exec rm {} +
java $JAVA_OPTS -jar $executable $ags
8 changes: 8 additions & 0 deletions bin/windows/csharp-petstore-all.bat
@@ -0,0 +1,8 @@
REM C# Petstore API client
.\bin\windows\csharp-petstore.bat

REM C# Petstore API client with PropertyChanged
.\bin\windows\csharp-property-changed-petstore.bat

REM C# Petstore API client (v5.0 for .net standarnd 1.3+)
.\bin\windows\csharp-petstore-netstandard.bat
10 changes: 10 additions & 0 deletions bin/windows/csharp-property-changed-petstore.bat
@@ -0,0 +1,10 @@
set executable=.\modules\swagger-codegen-cli\target\swagger-codegen-cli.jar

If Not Exist %executable% (
mvn clean package
)

REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
set ags=generate -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l csharp -o samples\client\petstore\csharp\SwaggerClientNetStandard --additional-properties targetFramework=v5.0,packageGuid={3AB1F259-1769-484B-9411-84505FCCBD55}

java %JAVA_OPTS% -jar %executable% %ags%
32 changes: 10 additions & 22 deletions circle.yml
@@ -1,14 +1,7 @@
# work in progress: the goal is to move all the existing tests
# handled by travis-ci to circle CI so that travis-ci can test
# objc/swift API client instead
# Java client, server tests
machine:
environment:
_JAVA_OPTIONS: "-Xms512m -Xmx1024m"
java:
# TODO we also need to test oraclejdk8
version: oraclejdk7
node:
version: 5.0.0
version: openjdk8
services:
- docker
# Override /etc/hosts
Expand All @@ -17,28 +10,23 @@ machine:

dependencies:
cache_directories:
- ~/.jspm
- ~/.npm
- ~/builder
- ~/.m2
pre:
- export MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=256m"
- gem install bundler
- npm install -g typescript
- sudo pip install virtualenv
# to run petstore server locally via docker
- docker pull swaggerapi/petstore
- docker run -d -e SWAGGER_HOST=http://petstore.swagger.io -e SWAGGER_BASE_PATH=/v2 -p 80:8080 swaggerapi/petstore
- docker ps -a
# show host table to confirm petstore.swagger.io is mapped to localhost
- cat /etc/hosts
override:
#- rvm --default use 2.1.0
#- ruby -v
- cp pom.xml.circleci pom.xml

test:
override:
- mvn verify -Psamples
#- mvn -q clean install
#- jdk_switcher use oraclejdk8
#- mvn -q clean install
# test with jdk8
- java -version
- mvn -q clean verify -Psamples
# test with jdk7
- sudo update-java-alternatives -s java-1.7.0-openjdk-amd64
- java -version
- mvn -q clean verify -Psamples
Expand Up @@ -91,6 +91,7 @@ public CodegenParameter copy() {
output.dataFormat = this.dataFormat;
output.collectionFormat = this.collectionFormat;
output.isCollectionFormatMulti = this.isCollectionFormatMulti;
output.isPrimitiveType = this.isPrimitiveType;
output.description = this.description;
output.unescapedDescription = this.unescapedDescription;
output.baseType = this.baseType;
Expand Down
Expand Up @@ -1739,12 +1739,16 @@ public CodegenProperty fromProperty(String name, Property p) {
CodegenProperty cp = fromProperty(property.name, ap.getItems());
updatePropertyForArray(property, cp);
} else if (p instanceof MapProperty) {
MapProperty ap = (MapProperty) p;

property.isContainer = true;
property.isMapContainer = true;
property.containerType = "map";
property.baseType = getSwaggerType(p);
property.minItems = ap.getMinProperties();
property.maxItems = ap.getMaxProperties();

// handle inner property
MapProperty ap = (MapProperty) p;
CodegenProperty cp = fromProperty("inner", ap.getAdditionalProperties());
updatePropertyForMap(property, cp);
} else {
Expand Down Expand Up @@ -1827,7 +1831,7 @@ protected Boolean isPropertyInnerMostEnum(CodegenProperty property) {
currentProperty = currentProperty.items;
}

return currentProperty.isEnum;
return currentProperty == null ? false : currentProperty.isEnum;
}

protected Map<String, Object> getInnerEnumAllowableValues(CodegenProperty property) {
Expand All @@ -1837,7 +1841,7 @@ protected Map<String, Object> getInnerEnumAllowableValues(CodegenProperty proper
currentProperty = currentProperty.items;
}

return currentProperty.allowableValues;
return currentProperty == null ? new HashMap<String, Object>() : currentProperty.allowableValues;
}


Expand All @@ -1851,16 +1855,18 @@ protected void updateDataTypeWithEnumForArray(CodegenProperty property) {
|| Boolean.TRUE.equals(baseItem.isListContainer))) {
baseItem = baseItem.items;
}
// set both datatype and datetypeWithEnum as only the inner type is enum
property.datatypeWithEnum = property.datatypeWithEnum.replace(baseItem.baseType, toEnumName(baseItem));
if (baseItem != null) {
// set both datatype and datetypeWithEnum as only the inner type is enum
property.datatypeWithEnum = property.datatypeWithEnum.replace(baseItem.baseType, toEnumName(baseItem));

// naming the enum with respect to the language enum naming convention
// e.g. remove [], {} from array/map of enum
property.enumName = toEnumName(property);
// naming the enum with respect to the language enum naming convention
// e.g. remove [], {} from array/map of enum
property.enumName = toEnumName(property);

// set default value for variable with inner enum
if (property.defaultValue != null) {
property.defaultValue = property.defaultValue.replace(baseItem.baseType, toEnumName(baseItem));
// set default value for variable with inner enum
if (property.defaultValue != null) {
property.defaultValue = property.defaultValue.replace(baseItem.baseType, toEnumName(baseItem));
}
}
}

Expand All @@ -1874,16 +1880,19 @@ protected void updateDataTypeWithEnumForMap(CodegenProperty property) {
|| Boolean.TRUE.equals(baseItem.isListContainer))) {
baseItem = baseItem.items;
}
// set both datatype and datetypeWithEnum as only the inner type is enum
property.datatypeWithEnum = property.datatypeWithEnum.replace(", " + baseItem.baseType, ", " + toEnumName(baseItem));

// naming the enum with respect to the language enum naming convention
// e.g. remove [], {} from array/map of enum
property.enumName = toEnumName(property);
if (baseItem != null) {
// set both datatype and datetypeWithEnum as only the inner type is enum
property.datatypeWithEnum = property.datatypeWithEnum.replace(", " + baseItem.baseType, ", " + toEnumName(baseItem));

// naming the enum with respect to the language enum naming convention
// e.g. remove [], {} from array/map of enum
property.enumName = toEnumName(property);

// set default value for variable with inner enum
if (property.defaultValue != null) {
property.defaultValue = property.defaultValue.replace(", " + property.items.baseType, ", " + toEnumName(property.items));
// set default value for variable with inner enum
if (property.defaultValue != null) {
property.defaultValue = property.defaultValue.replace(", " + property.items.baseType, ", " + toEnumName(property.items));
}
}
}

Expand Down
Expand Up @@ -126,6 +126,8 @@ private void configureGeneratorProperties() {
}
config.processOpts();
config.preprocessSwagger(swagger);
// TODO need to obtain version from a file instead of hardcoding it
config.additionalProperties().put("generatorVersion", "2.2.3-SNAPSHOT");
config.additionalProperties().put("generatedDate", DateTime.now().toString());
config.additionalProperties().put("generatorClass", config.getClass().getName());
config.additionalProperties().put("inputSpec", config.getInputSpec());
Expand Down
Expand Up @@ -704,6 +704,15 @@ public void setParameterExampleValue(CodegenParameter p) {
p.example = example;
}

@Override
public String toExampleValue(Property p) {
if(p.getExample() != null) {
return escapeText(p.getExample().toString());
} else {
return super.toExampleValue(p);
}
}

@Override
public String getSwaggerType(Property p) {
String swaggerType = super.getSwaggerType(p);
Expand Down

0 comments on commit 640b16b

Please sign in to comment.