mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-07 19:08:52 +00:00
Merge remote-tracking branch 'origin/master' into csharp_default_paths
This commit is contained in:
commit
7d8df7ef93
@ -790,6 +790,7 @@ Here are some companies/projects using Swagger Codegen in production. To add you
|
|||||||
- [uShip](https://www.uship.com/)
|
- [uShip](https://www.uship.com/)
|
||||||
- [Zalando](https://tech.zalando.com)
|
- [Zalando](https://tech.zalando.com)
|
||||||
- [ZEEF.com](https://zeef.com/)
|
- [ZEEF.com](https://zeef.com/)
|
||||||
|
- [REstore](https://www.restore.eu)
|
||||||
|
|
||||||
License
|
License
|
||||||
-------
|
-------
|
||||||
|
@ -49,5 +49,6 @@ cd $APP_DIR
|
|||||||
./bin/tizen-petstore.sh
|
./bin/tizen-petstore.sh
|
||||||
./bin/typescript-angular-petstore.sh
|
./bin/typescript-angular-petstore.sh
|
||||||
./bin/typescript-angular2-petstore.sh
|
./bin/typescript-angular2-petstore.sh
|
||||||
|
./bin/typescript-angular2-petstore-with-npm.sh
|
||||||
./bin/typescript-node-petstore.sh
|
./bin/typescript-node-petstore.sh
|
||||||
./bin/lumen-petstore-server.sh
|
./bin/lumen-petstore-server.sh
|
@ -26,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# 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"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/go -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l go -o samples/client/petstore/go/go-petstore"
|
ags="$@ generate -t modules/swagger-codegen/src/main/resources/go -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l go -o samples/client/petstore/go/go-petstore -DpackageName=petstore "
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -26,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# 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"
|
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.json -l typescript-angular2 -c bin/typescript-angular2-petstore-with-npm.json -o samples/client/petstore/typescript-angular2-with-npm"
|
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l typescript-angular2 -c bin/typescript-petstore-npm.json -o samples/client/petstore/typescript-angular2/npm"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -26,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# 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"
|
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.json -l typescript-angular2 -o samples/client/petstore/typescript-angular2"
|
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l typescript-angular2 -o samples/client/petstore/typescript-angular2/default"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
31
bin/typescript-node-petstore-with-npm.sh
Executable file
31
bin/typescript-node-petstore-with-npm.sh
Executable file
@ -0,0 +1,31 @@
|
|||||||
|
#!/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.json -l typescript-node -c bin/typescript-petstore-npm.json -o samples/client/petstore/typescript-node/npm"
|
||||||
|
|
||||||
|
java $JAVA_OPTS -jar $executable $ags
|
@ -26,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# 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"
|
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.json -l typescript-node -o samples/client/petstore/typescript-node"
|
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l typescript-node -o samples/client/petstore/typescript-node/default"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
10
bin/windows/spring-mvc-petstore-j8-async-server.bat
Normal file
10
bin/windows/spring-mvc-petstore-j8-async-server.bat
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
set executable=.\modules\swagger-codegen-cli\target\swagger-codegen-cli.jar
|
||||||
|
|
||||||
|
If Not Exist %executable% (
|
||||||
|
mvn clean package
|
||||||
|
)
|
||||||
|
|
||||||
|
set JAVA_OPTS=%JAVA_OPTS% -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties
|
||||||
|
set ags=generate -t modules\swagger-codegen\src\main\resources\JavaSpringMVC -i modules\swagger-codegen\src\test\resources\2_0\petstore.json -l spring-mvc -o samples/server/petstore/spring-mvc-j8-async -c bin/spring-mvc-petstore-j8-async.json
|
||||||
|
|
||||||
|
java %JAVA_OPTS% -jar %executable% %ags%
|
10
bin/windows/spring-mvc-petstore-server.bat
Normal file
10
bin/windows/spring-mvc-petstore-server.bat
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
set executable=.\modules\swagger-codegen-cli\target\swagger-codegen-cli.jar
|
||||||
|
|
||||||
|
If Not Exist %executable% (
|
||||||
|
mvn clean package
|
||||||
|
)
|
||||||
|
|
||||||
|
set JAVA_OPTS=%JAVA_OPTS% -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties
|
||||||
|
set ags=generate -t modules\swagger-codegen\src\main\resources\JavaSpringMVC -i modules\swagger-codegen\src\test\resources\2_0\petstore.json -l spring-mvc -o samples\server\petstore\spring-mvc
|
||||||
|
|
||||||
|
java %JAVA_OPTS% -jar %executable% %ags%
|
10
bin/windows/typescript-angular2-with-npm.bat
Normal file
10
bin/windows/typescript-angular2-with-npm.bat
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
set executable=.\modules\swagger-codegen-cli\target\swagger-codegen-cli.jar
|
||||||
|
|
||||||
|
If Not Exist %executable% (
|
||||||
|
mvn clean package
|
||||||
|
)
|
||||||
|
|
||||||
|
set JAVA_OPTS=%JAVA_OPTS% -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties
|
||||||
|
set ags=generate -t modules\swagger-codegen\src\main\resources\typescript-angular -i modules\swagger-codegen\src\test\resources\2_0\petstore.json -c bin/typescript-petstore-npm.json -l typescript-angular2 -o samples\client\petstore\typescript-angular2\npm
|
||||||
|
|
||||||
|
java %JAVA_OPTS% -jar %executable% %ags%
|
@ -5,6 +5,6 @@ If Not Exist %executable% (
|
|||||||
)
|
)
|
||||||
|
|
||||||
set JAVA_OPTS=%JAVA_OPTS% -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties
|
set JAVA_OPTS=%JAVA_OPTS% -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties
|
||||||
set ags=generate -t modules\swagger-codegen\src\main\resources\typescript-angular -i modules\swagger-codegen\src\test\resources\2_0\petstore.json -l typescript-angular2 -o samples\client\petstore\typescript-angular
|
set ags=generate -t modules\swagger-codegen\src\main\resources\typescript-angular -i modules\swagger-codegen\src\test\resources\2_0\petstore.json -l typescript-angular2 -o samples\client\petstore\typescript-angular2\default
|
||||||
|
|
||||||
java %JAVA_OPTS% -jar %executable% %ags%
|
java %JAVA_OPTS% -jar %executable% %ags%
|
||||||
|
10
bin/windows/typescript-node-with-npm.bat
Executable file
10
bin/windows/typescript-node-with-npm.bat
Executable file
@ -0,0 +1,10 @@
|
|||||||
|
set executable=.\modules\swagger-codegen-cli\target\swagger-codegen-cli.jar
|
||||||
|
|
||||||
|
If Not Exist %executable% (
|
||||||
|
mvn clean package
|
||||||
|
)
|
||||||
|
|
||||||
|
set JAVA_OPTS=%JAVA_OPTS% -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties
|
||||||
|
set ags=generate -t modules\swagger-codegen\src\main\resources\typescript-node -i modules\swagger-codegen\src\test\resources\2_0\petstore.json -c bin/typescript-petstore-npm.json -l typescript-node -o samples\client\petstore\typescript-node\npm
|
||||||
|
|
||||||
|
java %JAVA_OPTS% -jar %executable% %ags%
|
@ -5,6 +5,6 @@ If Not Exist %executable% (
|
|||||||
)
|
)
|
||||||
|
|
||||||
set JAVA_OPTS=%JAVA_OPTS% -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties
|
set JAVA_OPTS=%JAVA_OPTS% -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties
|
||||||
set ags=generate -t modules\swagger-codegen\src\main\resources\typescript-node -i modules\swagger-codegen\src\test\resources\2_0\petstore.json -l typescript-node -o samples\client\petstore\typescript-node
|
set ags=generate -t modules\swagger-codegen\src\main\resources\typescript-node -i modules\swagger-codegen\src\test\resources\2_0\petstore.json -l typescript-node -o samples\client\petstore\typescript-node\default
|
||||||
|
|
||||||
java %JAVA_OPTS% -jar %executable% %ags%
|
java %JAVA_OPTS% -jar %executable% %ags%
|
||||||
|
@ -54,4 +54,33 @@ public class ClientOpts {
|
|||||||
sb.append("}");
|
sb.append("}");
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
|
||||||
|
ClientOpts that = (ClientOpts) o;
|
||||||
|
|
||||||
|
if (uri != null ? !uri.equals(that.uri) : that.uri != null)
|
||||||
|
return false;
|
||||||
|
if (target != null ? !target.equals(that.target) : that.target != null)
|
||||||
|
return false;
|
||||||
|
if (auth != null ? !auth.equals(that.auth) : that.auth != null)
|
||||||
|
return false;
|
||||||
|
if (properties != null ? !properties.equals(that.properties) : that.properties != null)
|
||||||
|
return false;
|
||||||
|
return outputDirectory != null ? outputDirectory.equals(that.outputDirectory) : that.outputDirectory == null;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
int result = uri != null ? uri.hashCode() : 0;
|
||||||
|
result = 31 * result + (target != null ? target.hashCode() : 0);
|
||||||
|
result = 31 * result + (auth != null ? auth.hashCode() : 0);
|
||||||
|
result = 31 * result + (properties != null ? properties.hashCode() : 0);
|
||||||
|
result = 31 * result + (outputDirectory != null ? outputDirectory.hashCode() : 0);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package io.swagger.codegen;
|
package io.swagger.codegen;
|
||||||
|
|
||||||
import io.swagger.models.ExternalDocs;
|
import io.swagger.models.ExternalDocs;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class CodegenModel {
|
public class CodegenModel {
|
||||||
@ -39,4 +38,113 @@ public class CodegenModel {
|
|||||||
allVars = vars;
|
allVars = vars;
|
||||||
allMandatory = mandatory;
|
allMandatory = mandatory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return String.format("%s(%s)", name, classname);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
|
||||||
|
CodegenModel that = (CodegenModel) o;
|
||||||
|
|
||||||
|
if (parent != null ? !parent.equals(that.parent) : that.parent != null)
|
||||||
|
return false;
|
||||||
|
if (parentSchema != null ? !parentSchema.equals(that.parentSchema) : that.parentSchema != null)
|
||||||
|
return false;
|
||||||
|
if (interfaces != null ? !interfaces.equals(that.interfaces) : that.interfaces != null)
|
||||||
|
return false;
|
||||||
|
if (parentModel != null ? !parentModel.equals(that.parentModel) : that.parentModel != null)
|
||||||
|
return false;
|
||||||
|
if (interfaceModels != null ? !interfaceModels.equals(that.interfaceModels) : that.interfaceModels != null)
|
||||||
|
return false;
|
||||||
|
if (name != null ? !name.equals(that.name) : that.name != null)
|
||||||
|
return false;
|
||||||
|
if (classname != null ? !classname.equals(that.classname) : that.classname != null)
|
||||||
|
return false;
|
||||||
|
if (description != null ? !description.equals(that.description) : that.description != null)
|
||||||
|
return false;
|
||||||
|
if (classVarName != null ? !classVarName.equals(that.classVarName) : that.classVarName != null)
|
||||||
|
return false;
|
||||||
|
if (modelJson != null ? !modelJson.equals(that.modelJson) : that.modelJson != null)
|
||||||
|
return false;
|
||||||
|
if (dataType != null ? !dataType.equals(that.dataType) : that.dataType != null)
|
||||||
|
return false;
|
||||||
|
if (classFilename != null ? !classFilename.equals(that.classFilename) : that.classFilename != null)
|
||||||
|
return false;
|
||||||
|
if (unescapedDescription != null ? !unescapedDescription.equals(that.unescapedDescription) : that.unescapedDescription != null)
|
||||||
|
return false;
|
||||||
|
if (discriminator != null ? !discriminator.equals(that.discriminator) : that.discriminator != null)
|
||||||
|
return false;
|
||||||
|
if (defaultValue != null ? !defaultValue.equals(that.defaultValue) : that.defaultValue != null)
|
||||||
|
return false;
|
||||||
|
if (vars != null ? !vars.equals(that.vars) : that.vars != null)
|
||||||
|
return false;
|
||||||
|
if (requiredVars != null ? !requiredVars.equals(that.requiredVars) : that.requiredVars != null)
|
||||||
|
return false;
|
||||||
|
if (optionalVars != null ? !optionalVars.equals(that.optionalVars) : that.optionalVars != null)
|
||||||
|
return false;
|
||||||
|
if (allVars != null ? !allVars.equals(that.allVars) : that.allVars != null)
|
||||||
|
return false;
|
||||||
|
if (allowableValues != null ? !allowableValues.equals(that.allowableValues) : that.allowableValues != null)
|
||||||
|
return false;
|
||||||
|
if (mandatory != null ? !mandatory.equals(that.mandatory) : that.mandatory != null)
|
||||||
|
return false;
|
||||||
|
if (allMandatory != null ? !allMandatory.equals(that.allMandatory) : that.allMandatory != null)
|
||||||
|
return false;
|
||||||
|
if (imports != null ? !imports.equals(that.imports) : that.imports != null)
|
||||||
|
return false;
|
||||||
|
if (hasVars != null ? !hasVars.equals(that.hasVars) : that.hasVars != null)
|
||||||
|
return false;
|
||||||
|
if (emptyVars != null ? !emptyVars.equals(that.emptyVars) : that.emptyVars != null)
|
||||||
|
return false;
|
||||||
|
if (hasMoreModels != null ? !hasMoreModels.equals(that.hasMoreModels) : that.hasMoreModels != null)
|
||||||
|
return false;
|
||||||
|
if (hasEnums != null ? !hasEnums.equals(that.hasEnums) : that.hasEnums != null)
|
||||||
|
return false;
|
||||||
|
if (isEnum != null ? !isEnum.equals(that.isEnum) : that.isEnum != null)
|
||||||
|
return false;
|
||||||
|
if (externalDocs != null ? !externalDocs.equals(that.externalDocs) : that.externalDocs != null)
|
||||||
|
return false;
|
||||||
|
return vendorExtensions != null ? vendorExtensions.equals(that.vendorExtensions) : that.vendorExtensions == null;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
int result = parent != null ? parent.hashCode() : 0;
|
||||||
|
result = 31 * result + (parentSchema != null ? parentSchema.hashCode() : 0);
|
||||||
|
result = 31 * result + (interfaces != null ? interfaces.hashCode() : 0);
|
||||||
|
result = 31 * result + (parentModel != null ? parentModel.hashCode() : 0);
|
||||||
|
result = 31 * result + (interfaceModels != null ? interfaceModels.hashCode() : 0);
|
||||||
|
result = 31 * result + (name != null ? name.hashCode() : 0);
|
||||||
|
result = 31 * result + (classname != null ? classname.hashCode() : 0);
|
||||||
|
result = 31 * result + (description != null ? description.hashCode() : 0);
|
||||||
|
result = 31 * result + (classVarName != null ? classVarName.hashCode() : 0);
|
||||||
|
result = 31 * result + (modelJson != null ? modelJson.hashCode() : 0);
|
||||||
|
result = 31 * result + (dataType != null ? dataType.hashCode() : 0);
|
||||||
|
result = 31 * result + (classFilename != null ? classFilename.hashCode() : 0);
|
||||||
|
result = 31 * result + (unescapedDescription != null ? unescapedDescription.hashCode() : 0);
|
||||||
|
result = 31 * result + (discriminator != null ? discriminator.hashCode() : 0);
|
||||||
|
result = 31 * result + (defaultValue != null ? defaultValue.hashCode() : 0);
|
||||||
|
result = 31 * result + (vars != null ? vars.hashCode() : 0);
|
||||||
|
result = 31 * result + (requiredVars != null ? requiredVars.hashCode() : 0);
|
||||||
|
result = 31 * result + (optionalVars != null ? optionalVars.hashCode() : 0);
|
||||||
|
result = 31 * result + (allVars != null ? allVars.hashCode() : 0);
|
||||||
|
result = 31 * result + (allowableValues != null ? allowableValues.hashCode() : 0);
|
||||||
|
result = 31 * result + (mandatory != null ? mandatory.hashCode() : 0);
|
||||||
|
result = 31 * result + (allMandatory != null ? allMandatory.hashCode() : 0);
|
||||||
|
result = 31 * result + (imports != null ? imports.hashCode() : 0);
|
||||||
|
result = 31 * result + (hasVars != null ? hasVars.hashCode() : 0);
|
||||||
|
result = 31 * result + (emptyVars != null ? emptyVars.hashCode() : 0);
|
||||||
|
result = 31 * result + (hasMoreModels != null ? hasMoreModels.hashCode() : 0);
|
||||||
|
result = 31 * result + (hasEnums != null ? hasEnums.hashCode() : 0);
|
||||||
|
result = 31 * result + (isEnum != null ? isEnum.hashCode() : 0);
|
||||||
|
result = 31 * result + (externalDocs != null ? externalDocs.hashCode() : 0);
|
||||||
|
result = 31 * result + (vendorExtensions != null ? vendorExtensions.hashCode() : 0);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -88,4 +88,157 @@ public class CodegenOperation {
|
|||||||
return nonempty(formParams);
|
return nonempty(formParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return String.format("%s(%s)", baseName, path);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
|
||||||
|
CodegenOperation that = (CodegenOperation) o;
|
||||||
|
|
||||||
|
if (responseHeaders != null ? !responseHeaders.equals(that.responseHeaders) : that.responseHeaders != null)
|
||||||
|
return false;
|
||||||
|
if (hasAuthMethods != null ? !hasAuthMethods.equals(that.hasAuthMethods) : that.hasAuthMethods != null)
|
||||||
|
return false;
|
||||||
|
if (hasConsumes != null ? !hasConsumes.equals(that.hasConsumes) : that.hasConsumes != null)
|
||||||
|
return false;
|
||||||
|
if (hasProduces != null ? !hasProduces.equals(that.hasProduces) : that.hasProduces != null)
|
||||||
|
return false;
|
||||||
|
if (hasParams != null ? !hasParams.equals(that.hasParams) : that.hasParams != null)
|
||||||
|
return false;
|
||||||
|
if (hasOptionalParams != null ? !hasOptionalParams.equals(that.hasOptionalParams) : that.hasOptionalParams != null)
|
||||||
|
return false;
|
||||||
|
if (returnTypeIsPrimitive != null ? !returnTypeIsPrimitive.equals(that.returnTypeIsPrimitive) : that.returnTypeIsPrimitive != null)
|
||||||
|
return false;
|
||||||
|
if (returnSimpleType != null ? !returnSimpleType.equals(that.returnSimpleType) : that.returnSimpleType != null)
|
||||||
|
return false;
|
||||||
|
if (subresourceOperation != null ? !subresourceOperation.equals(that.subresourceOperation) : that.subresourceOperation != null)
|
||||||
|
return false;
|
||||||
|
if (isMapContainer != null ? !isMapContainer.equals(that.isMapContainer) : that.isMapContainer != null)
|
||||||
|
return false;
|
||||||
|
if (isListContainer != null ? !isListContainer.equals(that.isListContainer) : that.isListContainer != null)
|
||||||
|
return false;
|
||||||
|
if (isMultipart != null ? !isMultipart.equals(that.isMultipart) : that.isMultipart != null)
|
||||||
|
return false;
|
||||||
|
if (hasMore != null ? !hasMore.equals(that.hasMore) : that.hasMore != null)
|
||||||
|
return false;
|
||||||
|
if (isResponseBinary != null ? !isResponseBinary.equals(that.isResponseBinary) : that.isResponseBinary != null)
|
||||||
|
return false;
|
||||||
|
if (hasReference != null ? !hasReference.equals(that.hasReference) : that.hasReference != null)
|
||||||
|
return false;
|
||||||
|
if (path != null ? !path.equals(that.path) : that.path != null)
|
||||||
|
return false;
|
||||||
|
if (operationId != null ? !operationId.equals(that.operationId) : that.operationId != null)
|
||||||
|
return false;
|
||||||
|
if (returnType != null ? !returnType.equals(that.returnType) : that.returnType != null)
|
||||||
|
return false;
|
||||||
|
if (httpMethod != null ? !httpMethod.equals(that.httpMethod) : that.httpMethod != null)
|
||||||
|
return false;
|
||||||
|
if (returnBaseType != null ? !returnBaseType.equals(that.returnBaseType) : that.returnBaseType != null)
|
||||||
|
return false;
|
||||||
|
if (returnContainer != null ? !returnContainer.equals(that.returnContainer) : that.returnContainer != null)
|
||||||
|
return false;
|
||||||
|
if (summary != null ? !summary.equals(that.summary) : that.summary != null)
|
||||||
|
return false;
|
||||||
|
if (unescapedNotes != null ? !unescapedNotes.equals(that.unescapedNotes) : that.unescapedNotes != null)
|
||||||
|
return false;
|
||||||
|
if (notes != null ? !notes.equals(that.notes) : that.notes != null)
|
||||||
|
return false;
|
||||||
|
if (baseName != null ? !baseName.equals(that.baseName) : that.baseName != null)
|
||||||
|
return false;
|
||||||
|
if (defaultResponse != null ? !defaultResponse.equals(that.defaultResponse) : that.defaultResponse != null)
|
||||||
|
return false;
|
||||||
|
if (discriminator != null ? !discriminator.equals(that.discriminator) : that.discriminator != null)
|
||||||
|
return false;
|
||||||
|
if (consumes != null ? !consumes.equals(that.consumes) : that.consumes != null)
|
||||||
|
return false;
|
||||||
|
if (produces != null ? !produces.equals(that.produces) : that.produces != null)
|
||||||
|
return false;
|
||||||
|
if (bodyParam != null ? !bodyParam.equals(that.bodyParam) : that.bodyParam != null)
|
||||||
|
return false;
|
||||||
|
if (allParams != null ? !allParams.equals(that.allParams) : that.allParams != null)
|
||||||
|
return false;
|
||||||
|
if (bodyParams != null ? !bodyParams.equals(that.bodyParams) : that.bodyParams != null)
|
||||||
|
return false;
|
||||||
|
if (pathParams != null ? !pathParams.equals(that.pathParams) : that.pathParams != null)
|
||||||
|
return false;
|
||||||
|
if (queryParams != null ? !queryParams.equals(that.queryParams) : that.queryParams != null)
|
||||||
|
return false;
|
||||||
|
if (headerParams != null ? !headerParams.equals(that.headerParams) : that.headerParams != null)
|
||||||
|
return false;
|
||||||
|
if (formParams != null ? !formParams.equals(that.formParams) : that.formParams != null)
|
||||||
|
return false;
|
||||||
|
if (authMethods != null ? !authMethods.equals(that.authMethods) : that.authMethods != null)
|
||||||
|
return false;
|
||||||
|
if (tags != null ? !tags.equals(that.tags) : that.tags != null)
|
||||||
|
return false;
|
||||||
|
if (responses != null ? !responses.equals(that.responses) : that.responses != null)
|
||||||
|
return false;
|
||||||
|
if (imports != null ? !imports.equals(that.imports) : that.imports != null)
|
||||||
|
return false;
|
||||||
|
if (examples != null ? !examples.equals(that.examples) : that.examples != null)
|
||||||
|
return false;
|
||||||
|
if (externalDocs != null ? !externalDocs.equals(that.externalDocs) : that.externalDocs != null)
|
||||||
|
return false;
|
||||||
|
if (vendorExtensions != null ? !vendorExtensions.equals(that.vendorExtensions) : that.vendorExtensions != null)
|
||||||
|
return false;
|
||||||
|
if (nickname != null ? !nickname.equals(that.nickname) : that.nickname != null)
|
||||||
|
return false;
|
||||||
|
return operationIdLowerCase != null ? operationIdLowerCase.equals(that.operationIdLowerCase) : that.operationIdLowerCase == null;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
int result = responseHeaders != null ? responseHeaders.hashCode() : 0;
|
||||||
|
result = 31 * result + (hasAuthMethods != null ? hasAuthMethods.hashCode() : 0);
|
||||||
|
result = 31 * result + (hasConsumes != null ? hasConsumes.hashCode() : 0);
|
||||||
|
result = 31 * result + (hasProduces != null ? hasProduces.hashCode() : 0);
|
||||||
|
result = 31 * result + (hasParams != null ? hasParams.hashCode() : 0);
|
||||||
|
result = 31 * result + (hasOptionalParams != null ? hasOptionalParams.hashCode() : 0);
|
||||||
|
result = 31 * result + (returnTypeIsPrimitive != null ? returnTypeIsPrimitive.hashCode() : 0);
|
||||||
|
result = 31 * result + (returnSimpleType != null ? returnSimpleType.hashCode() : 0);
|
||||||
|
result = 31 * result + (subresourceOperation != null ? subresourceOperation.hashCode() : 0);
|
||||||
|
result = 31 * result + (isMapContainer != null ? isMapContainer.hashCode() : 0);
|
||||||
|
result = 31 * result + (isListContainer != null ? isListContainer.hashCode() : 0);
|
||||||
|
result = 31 * result + (isMultipart != null ? isMultipart.hashCode() : 0);
|
||||||
|
result = 31 * result + (hasMore != null ? hasMore.hashCode() : 0);
|
||||||
|
result = 31 * result + (isResponseBinary != null ? isResponseBinary.hashCode() : 0);
|
||||||
|
result = 31 * result + (hasReference != null ? hasReference.hashCode() : 0);
|
||||||
|
result = 31 * result + (path != null ? path.hashCode() : 0);
|
||||||
|
result = 31 * result + (operationId != null ? operationId.hashCode() : 0);
|
||||||
|
result = 31 * result + (returnType != null ? returnType.hashCode() : 0);
|
||||||
|
result = 31 * result + (httpMethod != null ? httpMethod.hashCode() : 0);
|
||||||
|
result = 31 * result + (returnBaseType != null ? returnBaseType.hashCode() : 0);
|
||||||
|
result = 31 * result + (returnContainer != null ? returnContainer.hashCode() : 0);
|
||||||
|
result = 31 * result + (summary != null ? summary.hashCode() : 0);
|
||||||
|
result = 31 * result + (unescapedNotes != null ? unescapedNotes.hashCode() : 0);
|
||||||
|
result = 31 * result + (notes != null ? notes.hashCode() : 0);
|
||||||
|
result = 31 * result + (baseName != null ? baseName.hashCode() : 0);
|
||||||
|
result = 31 * result + (defaultResponse != null ? defaultResponse.hashCode() : 0);
|
||||||
|
result = 31 * result + (discriminator != null ? discriminator.hashCode() : 0);
|
||||||
|
result = 31 * result + (consumes != null ? consumes.hashCode() : 0);
|
||||||
|
result = 31 * result + (produces != null ? produces.hashCode() : 0);
|
||||||
|
result = 31 * result + (bodyParam != null ? bodyParam.hashCode() : 0);
|
||||||
|
result = 31 * result + (allParams != null ? allParams.hashCode() : 0);
|
||||||
|
result = 31 * result + (bodyParams != null ? bodyParams.hashCode() : 0);
|
||||||
|
result = 31 * result + (pathParams != null ? pathParams.hashCode() : 0);
|
||||||
|
result = 31 * result + (queryParams != null ? queryParams.hashCode() : 0);
|
||||||
|
result = 31 * result + (headerParams != null ? headerParams.hashCode() : 0);
|
||||||
|
result = 31 * result + (formParams != null ? formParams.hashCode() : 0);
|
||||||
|
result = 31 * result + (authMethods != null ? authMethods.hashCode() : 0);
|
||||||
|
result = 31 * result + (tags != null ? tags.hashCode() : 0);
|
||||||
|
result = 31 * result + (responses != null ? responses.hashCode() : 0);
|
||||||
|
result = 31 * result + (imports != null ? imports.hashCode() : 0);
|
||||||
|
result = 31 * result + (examples != null ? examples.hashCode() : 0);
|
||||||
|
result = 31 * result + (externalDocs != null ? externalDocs.hashCode() : 0);
|
||||||
|
result = 31 * result + (vendorExtensions != null ? vendorExtensions.hashCode() : 0);
|
||||||
|
result = 31 * result + (nickname != null ? nickname.hashCode() : 0);
|
||||||
|
result = 31 * result + (operationIdLowerCase != null ? operationIdLowerCase.hashCode() : 0);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -137,5 +137,185 @@ public class CodegenParameter {
|
|||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return String.format("%s(%s)", baseName, dataType);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
|
||||||
|
CodegenParameter that = (CodegenParameter) o;
|
||||||
|
|
||||||
|
if (isEnum != that.isEnum) return false;
|
||||||
|
if (isFormParam != null ? !isFormParam.equals(that.isFormParam) : that.isFormParam != null)
|
||||||
|
return false;
|
||||||
|
if (isQueryParam != null ? !isQueryParam.equals(that.isQueryParam) : that.isQueryParam != null)
|
||||||
|
return false;
|
||||||
|
if (isPathParam != null ? !isPathParam.equals(that.isPathParam) : that.isPathParam != null)
|
||||||
|
return false;
|
||||||
|
if (isHeaderParam != null ? !isHeaderParam.equals(that.isHeaderParam) : that.isHeaderParam != null)
|
||||||
|
return false;
|
||||||
|
if (isCookieParam != null ? !isCookieParam.equals(that.isCookieParam) : that.isCookieParam != null)
|
||||||
|
return false;
|
||||||
|
if (isBodyParam != null ? !isBodyParam.equals(that.isBodyParam) : that.isBodyParam != null)
|
||||||
|
return false;
|
||||||
|
if (hasMore != null ? !hasMore.equals(that.hasMore) : that.hasMore != null)
|
||||||
|
return false;
|
||||||
|
if (isContainer != null ? !isContainer.equals(that.isContainer) : that.isContainer != null)
|
||||||
|
return false;
|
||||||
|
if (secondaryParam != null ? !secondaryParam.equals(that.secondaryParam) : that.secondaryParam != null)
|
||||||
|
return false;
|
||||||
|
if (isCollectionFormatMulti != null ? !isCollectionFormatMulti.equals(that.isCollectionFormatMulti) : that.isCollectionFormatMulti != null)
|
||||||
|
return false;
|
||||||
|
if (isPrimitiveType != null ? !isPrimitiveType.equals(that.isPrimitiveType) : that.isPrimitiveType != null)
|
||||||
|
return false;
|
||||||
|
if (baseName != null ? !baseName.equals(that.baseName) : that.baseName != null)
|
||||||
|
return false;
|
||||||
|
if (paramName != null ? !paramName.equals(that.paramName) : that.paramName != null)
|
||||||
|
return false;
|
||||||
|
if (dataType != null ? !dataType.equals(that.dataType) : that.dataType != null)
|
||||||
|
return false;
|
||||||
|
if (datatypeWithEnum != null ? !datatypeWithEnum.equals(that.datatypeWithEnum) : that.datatypeWithEnum != null)
|
||||||
|
return false;
|
||||||
|
if (collectionFormat != null ? !collectionFormat.equals(that.collectionFormat) : that.collectionFormat != null)
|
||||||
|
return false;
|
||||||
|
if (description != null ? !description.equals(that.description) : that.description != null)
|
||||||
|
return false;
|
||||||
|
if (unescapedDescription != null ? !unescapedDescription.equals(that.unescapedDescription) : that.unescapedDescription != null)
|
||||||
|
return false;
|
||||||
|
if (baseType != null ? !baseType.equals(that.baseType) : that.baseType != null)
|
||||||
|
return false;
|
||||||
|
if (defaultValue != null ? !defaultValue.equals(that.defaultValue) : that.defaultValue != null)
|
||||||
|
return false;
|
||||||
|
if (example != null ? !example.equals(that.example) : that.example != null)
|
||||||
|
return false;
|
||||||
|
if (jsonSchema != null ? !jsonSchema.equals(that.jsonSchema) : that.jsonSchema != null)
|
||||||
|
return false;
|
||||||
|
if (isString != null ? !isString.equals(that.isString) : that.isString != null)
|
||||||
|
return false;
|
||||||
|
if (isInteger != null ? !isInteger.equals(that.isInteger) : that.isInteger != null)
|
||||||
|
return false;
|
||||||
|
if (isLong != null ? !isLong.equals(that.isLong) : that.isLong != null)
|
||||||
|
return false;
|
||||||
|
if (isFloat != null ? !isFloat.equals(that.isFloat) : that.isFloat != null)
|
||||||
|
return false;
|
||||||
|
if (isDouble != null ? !isDouble.equals(that.isDouble) : that.isDouble != null)
|
||||||
|
return false;
|
||||||
|
if (isByteArray != null ? !isByteArray.equals(that.isByteArray) : that.isByteArray != null)
|
||||||
|
return false;
|
||||||
|
if (isBinary != null ? !isBinary.equals(that.isBinary) : that.isBinary != null)
|
||||||
|
return false;
|
||||||
|
if (isBoolean != null ? !isBoolean.equals(that.isBoolean) : that.isBoolean != null)
|
||||||
|
return false;
|
||||||
|
if (isDate != null ? !isDate.equals(that.isDate) : that.isDate != null)
|
||||||
|
return false;
|
||||||
|
if (isDateTime != null ? !isDateTime.equals(that.isDateTime) : that.isDateTime != null)
|
||||||
|
return false;
|
||||||
|
if (isListContainer != null ? !isListContainer.equals(that.isListContainer) : that.isListContainer != null)
|
||||||
|
return false;
|
||||||
|
if (isMapContainer != null ? !isMapContainer.equals(that.isMapContainer) : that.isMapContainer != null)
|
||||||
|
return false;
|
||||||
|
if (isFile != null ? !isFile.equals(that.isFile) : that.isFile != null)
|
||||||
|
return false;
|
||||||
|
if (notFile != null ? !notFile.equals(that.notFile) : that.notFile != null)
|
||||||
|
return false;
|
||||||
|
if (_enum != null ? !_enum.equals(that._enum) : that._enum != null)
|
||||||
|
return false;
|
||||||
|
if (allowableValues != null ? !allowableValues.equals(that.allowableValues) : that.allowableValues != null)
|
||||||
|
return false;
|
||||||
|
if (items != null ? !items.equals(that.items) : that.items != null)
|
||||||
|
return false;
|
||||||
|
if (vendorExtensions != null ? !vendorExtensions.equals(that.vendorExtensions) : that.vendorExtensions != null)
|
||||||
|
return false;
|
||||||
|
if (hasValidation != null ? !hasValidation.equals(that.hasValidation) : that.hasValidation != null)
|
||||||
|
return false;
|
||||||
|
if (required != null ? !required.equals(that.required) : that.required != null)
|
||||||
|
return false;
|
||||||
|
if (maximum != null ? !maximum.equals(that.maximum) : that.maximum != null)
|
||||||
|
return false;
|
||||||
|
if (exclusiveMaximum != null ? !exclusiveMaximum.equals(that.exclusiveMaximum) : that.exclusiveMaximum != null)
|
||||||
|
return false;
|
||||||
|
if (minimum != null ? !minimum.equals(that.minimum) : that.minimum != null)
|
||||||
|
return false;
|
||||||
|
if (exclusiveMinimum != null ? !exclusiveMinimum.equals(that.exclusiveMinimum) : that.exclusiveMinimum != null)
|
||||||
|
return false;
|
||||||
|
if (maxLength != null ? !maxLength.equals(that.maxLength) : that.maxLength != null)
|
||||||
|
return false;
|
||||||
|
if (minLength != null ? !minLength.equals(that.minLength) : that.minLength != null)
|
||||||
|
return false;
|
||||||
|
if (pattern != null ? !pattern.equals(that.pattern) : that.pattern != null)
|
||||||
|
return false;
|
||||||
|
if (maxItems != null ? !maxItems.equals(that.maxItems) : that.maxItems != null)
|
||||||
|
return false;
|
||||||
|
if (minItems != null ? !minItems.equals(that.minItems) : that.minItems != null)
|
||||||
|
return false;
|
||||||
|
if (uniqueItems != null ? !uniqueItems.equals(that.uniqueItems) : that.uniqueItems != null)
|
||||||
|
return false;
|
||||||
|
return multipleOf != null ? multipleOf.equals(that.multipleOf) : that.multipleOf == null;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
int result = isFormParam != null ? isFormParam.hashCode() : 0;
|
||||||
|
result = 31 * result + (isQueryParam != null ? isQueryParam.hashCode() : 0);
|
||||||
|
result = 31 * result + (isPathParam != null ? isPathParam.hashCode() : 0);
|
||||||
|
result = 31 * result + (isHeaderParam != null ? isHeaderParam.hashCode() : 0);
|
||||||
|
result = 31 * result + (isCookieParam != null ? isCookieParam.hashCode() : 0);
|
||||||
|
result = 31 * result + (isBodyParam != null ? isBodyParam.hashCode() : 0);
|
||||||
|
result = 31 * result + (hasMore != null ? hasMore.hashCode() : 0);
|
||||||
|
result = 31 * result + (isContainer != null ? isContainer.hashCode() : 0);
|
||||||
|
result = 31 * result + (secondaryParam != null ? secondaryParam.hashCode() : 0);
|
||||||
|
result = 31 * result + (isCollectionFormatMulti != null ? isCollectionFormatMulti.hashCode() : 0);
|
||||||
|
result = 31 * result + (isPrimitiveType != null ? isPrimitiveType.hashCode() : 0);
|
||||||
|
result = 31 * result + (baseName != null ? baseName.hashCode() : 0);
|
||||||
|
result = 31 * result + (paramName != null ? paramName.hashCode() : 0);
|
||||||
|
result = 31 * result + (dataType != null ? dataType.hashCode() : 0);
|
||||||
|
result = 31 * result + (datatypeWithEnum != null ? datatypeWithEnum.hashCode() : 0);
|
||||||
|
result = 31 * result + (collectionFormat != null ? collectionFormat.hashCode() : 0);
|
||||||
|
result = 31 * result + (description != null ? description.hashCode() : 0);
|
||||||
|
result = 31 * result + (unescapedDescription != null ? unescapedDescription.hashCode() : 0);
|
||||||
|
result = 31 * result + (baseType != null ? baseType.hashCode() : 0);
|
||||||
|
result = 31 * result + (defaultValue != null ? defaultValue.hashCode() : 0);
|
||||||
|
result = 31 * result + (example != null ? example.hashCode() : 0);
|
||||||
|
result = 31 * result + (jsonSchema != null ? jsonSchema.hashCode() : 0);
|
||||||
|
result = 31 * result + (isString != null ? isString.hashCode() : 0);
|
||||||
|
result = 31 * result + (isInteger != null ? isInteger.hashCode() : 0);
|
||||||
|
result = 31 * result + (isLong != null ? isLong.hashCode() : 0);
|
||||||
|
result = 31 * result + (isFloat != null ? isFloat.hashCode() : 0);
|
||||||
|
result = 31 * result + (isDouble != null ? isDouble.hashCode() : 0);
|
||||||
|
result = 31 * result + (isByteArray != null ? isByteArray.hashCode() : 0);
|
||||||
|
result = 31 * result + (isBinary != null ? isBinary.hashCode() : 0);
|
||||||
|
result = 31 * result + (isBoolean != null ? isBoolean.hashCode() : 0);
|
||||||
|
result = 31 * result + (isDate != null ? isDate.hashCode() : 0);
|
||||||
|
result = 31 * result + (isDateTime != null ? isDateTime.hashCode() : 0);
|
||||||
|
result = 31 * result + (isListContainer != null ? isListContainer.hashCode() : 0);
|
||||||
|
result = 31 * result + (isMapContainer != null ? isMapContainer.hashCode() : 0);
|
||||||
|
result = 31 * result + (isFile != null ? isFile.hashCode() : 0);
|
||||||
|
result = 31 * result + (notFile != null ? notFile.hashCode() : 0);
|
||||||
|
result = 31 * result + (isEnum ? 1 : 0);
|
||||||
|
result = 31 * result + (_enum != null ? _enum.hashCode() : 0);
|
||||||
|
result = 31 * result + (allowableValues != null ? allowableValues.hashCode() : 0);
|
||||||
|
result = 31 * result + (items != null ? items.hashCode() : 0);
|
||||||
|
result = 31 * result + (vendorExtensions != null ? vendorExtensions.hashCode() : 0);
|
||||||
|
result = 31 * result + (hasValidation != null ? hasValidation.hashCode() : 0);
|
||||||
|
result = 31 * result + (required != null ? required.hashCode() : 0);
|
||||||
|
result = 31 * result + (maximum != null ? maximum.hashCode() : 0);
|
||||||
|
result = 31 * result + (exclusiveMaximum != null ? exclusiveMaximum.hashCode() : 0);
|
||||||
|
result = 31 * result + (minimum != null ? minimum.hashCode() : 0);
|
||||||
|
result = 31 * result + (exclusiveMinimum != null ? exclusiveMinimum.hashCode() : 0);
|
||||||
|
result = 31 * result + (maxLength != null ? maxLength.hashCode() : 0);
|
||||||
|
result = 31 * result + (minLength != null ? minLength.hashCode() : 0);
|
||||||
|
result = 31 * result + (pattern != null ? pattern.hashCode() : 0);
|
||||||
|
result = 31 * result + (maxItems != null ? maxItems.hashCode() : 0);
|
||||||
|
result = 31 * result + (minItems != null ? minItems.hashCode() : 0);
|
||||||
|
result = 31 * result + (uniqueItems != null ? uniqueItems.hashCode() : 0);
|
||||||
|
result = 31 * result + (multipleOf != null ? multipleOf.hashCode() : 0);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,6 +44,12 @@ public class CodegenProperty {
|
|||||||
public Map<String, Object> vendorExtensions;
|
public Map<String, Object> vendorExtensions;
|
||||||
public Boolean hasValidation; // true if pattern, maximum, etc are set (only used in the mustache template)
|
public Boolean hasValidation; // true if pattern, maximum, etc are set (only used in the mustache template)
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return String.format("%s(%s)", baseName, datatype);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode()
|
public int hashCode()
|
||||||
{
|
{
|
||||||
|
@ -22,4 +22,71 @@ public class CodegenResponse {
|
|||||||
public boolean isWildcard() {
|
public boolean isWildcard() {
|
||||||
return "0".equals(code) || "default".equals(code);
|
return "0".equals(code) || "default".equals(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return String.format("%s(%s)", code, containerType);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
|
||||||
|
CodegenResponse that = (CodegenResponse) o;
|
||||||
|
|
||||||
|
if (headers != null ? !headers.equals(that.headers) : that.headers != null)
|
||||||
|
return false;
|
||||||
|
if (code != null ? !code.equals(that.code) : that.code != null)
|
||||||
|
return false;
|
||||||
|
if (message != null ? !message.equals(that.message) : that.message != null)
|
||||||
|
return false;
|
||||||
|
if (hasMore != null ? !hasMore.equals(that.hasMore) : that.hasMore != null)
|
||||||
|
return false;
|
||||||
|
if (examples != null ? !examples.equals(that.examples) : that.examples != null)
|
||||||
|
return false;
|
||||||
|
if (dataType != null ? !dataType.equals(that.dataType) : that.dataType != null)
|
||||||
|
return false;
|
||||||
|
if (baseType != null ? !baseType.equals(that.baseType) : that.baseType != null)
|
||||||
|
return false;
|
||||||
|
if (containerType != null ? !containerType.equals(that.containerType) : that.containerType != null)
|
||||||
|
return false;
|
||||||
|
if (isDefault != null ? !isDefault.equals(that.isDefault) : that.isDefault != null)
|
||||||
|
return false;
|
||||||
|
if (simpleType != null ? !simpleType.equals(that.simpleType) : that.simpleType != null)
|
||||||
|
return false;
|
||||||
|
if (primitiveType != null ? !primitiveType.equals(that.primitiveType) : that.primitiveType != null)
|
||||||
|
return false;
|
||||||
|
if (isMapContainer != null ? !isMapContainer.equals(that.isMapContainer) : that.isMapContainer != null)
|
||||||
|
return false;
|
||||||
|
if (isListContainer != null ? !isListContainer.equals(that.isListContainer) : that.isListContainer != null)
|
||||||
|
return false;
|
||||||
|
if (isBinary != null ? !isBinary.equals(that.isBinary) : that.isBinary != null)
|
||||||
|
return false;
|
||||||
|
if (schema != null ? !schema.equals(that.schema) : that.schema != null)
|
||||||
|
return false;
|
||||||
|
return jsonSchema != null ? jsonSchema.equals(that.jsonSchema) : that.jsonSchema == null;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
int result = headers != null ? headers.hashCode() : 0;
|
||||||
|
result = 31 * result + (code != null ? code.hashCode() : 0);
|
||||||
|
result = 31 * result + (message != null ? message.hashCode() : 0);
|
||||||
|
result = 31 * result + (hasMore != null ? hasMore.hashCode() : 0);
|
||||||
|
result = 31 * result + (examples != null ? examples.hashCode() : 0);
|
||||||
|
result = 31 * result + (dataType != null ? dataType.hashCode() : 0);
|
||||||
|
result = 31 * result + (baseType != null ? baseType.hashCode() : 0);
|
||||||
|
result = 31 * result + (containerType != null ? containerType.hashCode() : 0);
|
||||||
|
result = 31 * result + (isDefault != null ? isDefault.hashCode() : 0);
|
||||||
|
result = 31 * result + (simpleType != null ? simpleType.hashCode() : 0);
|
||||||
|
result = 31 * result + (primitiveType != null ? primitiveType.hashCode() : 0);
|
||||||
|
result = 31 * result + (isMapContainer != null ? isMapContainer.hashCode() : 0);
|
||||||
|
result = 31 * result + (isListContainer != null ? isListContainer.hashCode() : 0);
|
||||||
|
result = 31 * result + (isBinary != null ? isBinary.hashCode() : 0);
|
||||||
|
result = 31 * result + (schema != null ? schema.hashCode() : 0);
|
||||||
|
result = 31 * result + (jsonSchema != null ? jsonSchema.hashCode() : 0);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,4 +13,62 @@ public class CodegenSecurity {
|
|||||||
// Oauth specific
|
// Oauth specific
|
||||||
public String flow, authorizationUrl, tokenUrl;
|
public String flow, authorizationUrl, tokenUrl;
|
||||||
public List<Map<String, Object>> scopes;
|
public List<Map<String, Object>> scopes;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return String.format("%s(%s)", name, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
|
||||||
|
CodegenSecurity that = (CodegenSecurity) o;
|
||||||
|
|
||||||
|
if (name != null ? !name.equals(that.name) : that.name != null)
|
||||||
|
return false;
|
||||||
|
if (type != null ? !type.equals(that.type) : that.type != null)
|
||||||
|
return false;
|
||||||
|
if (hasMore != null ? !hasMore.equals(that.hasMore) : that.hasMore != null)
|
||||||
|
return false;
|
||||||
|
if (isBasic != null ? !isBasic.equals(that.isBasic) : that.isBasic != null)
|
||||||
|
return false;
|
||||||
|
if (isOAuth != null ? !isOAuth.equals(that.isOAuth) : that.isOAuth != null)
|
||||||
|
return false;
|
||||||
|
if (isApiKey != null ? !isApiKey.equals(that.isApiKey) : that.isApiKey != null)
|
||||||
|
return false;
|
||||||
|
if (keyParamName != null ? !keyParamName.equals(that.keyParamName) : that.keyParamName != null)
|
||||||
|
return false;
|
||||||
|
if (isKeyInQuery != null ? !isKeyInQuery.equals(that.isKeyInQuery) : that.isKeyInQuery != null)
|
||||||
|
return false;
|
||||||
|
if (isKeyInHeader != null ? !isKeyInHeader.equals(that.isKeyInHeader) : that.isKeyInHeader != null)
|
||||||
|
return false;
|
||||||
|
if (flow != null ? !flow.equals(that.flow) : that.flow != null)
|
||||||
|
return false;
|
||||||
|
if (authorizationUrl != null ? !authorizationUrl.equals(that.authorizationUrl) : that.authorizationUrl != null)
|
||||||
|
return false;
|
||||||
|
if (tokenUrl != null ? !tokenUrl.equals(that.tokenUrl) : that.tokenUrl != null)
|
||||||
|
return false;
|
||||||
|
return scopes != null ? scopes.equals(that.scopes) : that.scopes == null;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
int result = name != null ? name.hashCode() : 0;
|
||||||
|
result = 31 * result + (type != null ? type.hashCode() : 0);
|
||||||
|
result = 31 * result + (hasMore != null ? hasMore.hashCode() : 0);
|
||||||
|
result = 31 * result + (isBasic != null ? isBasic.hashCode() : 0);
|
||||||
|
result = 31 * result + (isOAuth != null ? isOAuth.hashCode() : 0);
|
||||||
|
result = 31 * result + (isApiKey != null ? isApiKey.hashCode() : 0);
|
||||||
|
result = 31 * result + (keyParamName != null ? keyParamName.hashCode() : 0);
|
||||||
|
result = 31 * result + (isKeyInQuery != null ? isKeyInQuery.hashCode() : 0);
|
||||||
|
result = 31 * result + (isKeyInHeader != null ? isKeyInHeader.hashCode() : 0);
|
||||||
|
result = 31 * result + (flow != null ? flow.hashCode() : 0);
|
||||||
|
result = 31 * result + (authorizationUrl != null ? authorizationUrl.hashCode() : 0);
|
||||||
|
result = 31 * result + (tokenUrl != null ? tokenUrl.hashCode() : 0);
|
||||||
|
result = 31 * result + (scopes != null ? scopes.hashCode() : 0);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,10 +97,10 @@ public class DefaultCodegen {
|
|||||||
@SuppressWarnings({ "static-method", "unchecked" })
|
@SuppressWarnings({ "static-method", "unchecked" })
|
||||||
public Map<String, Object> postProcessAllModels(Map<String, Object> objs) {
|
public Map<String, Object> postProcessAllModels(Map<String, Object> objs) {
|
||||||
if (supportsInheritance) {
|
if (supportsInheritance) {
|
||||||
// Index all CodegenModels by name.
|
// Index all CodegenModels by model name.
|
||||||
Map<String, CodegenModel> allModels = new HashMap<String, CodegenModel>();
|
Map<String, CodegenModel> allModels = new HashMap<String, CodegenModel>();
|
||||||
for (Entry<String, Object> entry : objs.entrySet()) {
|
for (Entry<String, Object> entry : objs.entrySet()) {
|
||||||
String modelName = entry.getKey();
|
String modelName = toModelName(entry.getKey());
|
||||||
Map<String, Object> inner = (Map<String, Object>) entry.getValue();
|
Map<String, Object> inner = (Map<String, Object>) entry.getValue();
|
||||||
List<Map<String, Object>> models = (List<Map<String, Object>>) inner.get("models");
|
List<Map<String, Object>> models = (List<Map<String, Object>>) inner.get("models");
|
||||||
for (Map<String, Object> mo : models) {
|
for (Map<String, Object> mo : models) {
|
||||||
@ -328,12 +328,12 @@ public class DefaultCodegen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the JSON schema pattern (http://json-schema.org/latest/json-schema-validation.html#anchor33)
|
* Return the regular expression/JSON schema pattern (http://json-schema.org/latest/json-schema-validation.html#anchor33)
|
||||||
*
|
*
|
||||||
* @param pattern the pattern (regular expression)
|
* @param pattern the pattern (regular expression)
|
||||||
* @return properly-escaped pattern
|
* @return properly-escaped pattern
|
||||||
*/
|
*/
|
||||||
public String toJSONSchemaPattern(String pattern) {
|
public String toRegularExpression(String pattern) {
|
||||||
return escapeText(pattern);
|
return escapeText(pattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -986,7 +986,7 @@ public class DefaultCodegen {
|
|||||||
m.interfaces.add(interfaceRef);
|
m.interfaces.add(interfaceRef);
|
||||||
addImport(m, interfaceRef);
|
addImport(m, interfaceRef);
|
||||||
if (allDefinitions != null) {
|
if (allDefinitions != null) {
|
||||||
final Model interfaceModel = allDefinitions.get(interfaceRef);
|
final Model interfaceModel = allDefinitions.get(_interface.getSimpleRef());
|
||||||
if (supportsInheritance) {
|
if (supportsInheritance) {
|
||||||
addProperties(allProperties, allRequired, interfaceModel, allDefinitions);
|
addProperties(allProperties, allRequired, interfaceModel, allDefinitions);
|
||||||
} else {
|
} else {
|
||||||
@ -1043,7 +1043,7 @@ public class DefaultCodegen {
|
|||||||
required.addAll(mi.getRequired());
|
required.addAll(mi.getRequired());
|
||||||
}
|
}
|
||||||
} else if (model instanceof RefModel) {
|
} else if (model instanceof RefModel) {
|
||||||
String interfaceRef = toModelName(((RefModel) model).getSimpleRef());
|
String interfaceRef = ((RefModel) model).getSimpleRef();
|
||||||
Model interfaceModel = allDefinitions.get(interfaceRef);
|
Model interfaceModel = allDefinitions.get(interfaceRef);
|
||||||
addProperties(properties, required, interfaceModel, allDefinitions);
|
addProperties(properties, required, interfaceModel, allDefinitions);
|
||||||
} else if (model instanceof ComposedModel) {
|
} else if (model instanceof ComposedModel) {
|
||||||
@ -1125,7 +1125,7 @@ public class DefaultCodegen {
|
|||||||
StringProperty sp = (StringProperty) p;
|
StringProperty sp = (StringProperty) p;
|
||||||
property.maxLength = sp.getMaxLength();
|
property.maxLength = sp.getMaxLength();
|
||||||
property.minLength = sp.getMinLength();
|
property.minLength = sp.getMinLength();
|
||||||
property.pattern = toJSONSchemaPattern(sp.getPattern());
|
property.pattern = toRegularExpression(sp.getPattern());
|
||||||
|
|
||||||
// check if any validation rule defined
|
// check if any validation rule defined
|
||||||
if (property.pattern != null || property.minLength != null || property.maxLength != null)
|
if (property.pattern != null || property.minLength != null || property.maxLength != null)
|
||||||
@ -1828,7 +1828,7 @@ public class DefaultCodegen {
|
|||||||
p.exclusiveMinimum = qp.isExclusiveMinimum();
|
p.exclusiveMinimum = qp.isExclusiveMinimum();
|
||||||
p.maxLength = qp.getMaxLength();
|
p.maxLength = qp.getMaxLength();
|
||||||
p.minLength = qp.getMinLength();
|
p.minLength = qp.getMinLength();
|
||||||
p.pattern = toJSONSchemaPattern(qp.getPattern());
|
p.pattern = toRegularExpression(qp.getPattern());
|
||||||
p.maxItems = qp.getMaxItems();
|
p.maxItems = qp.getMaxItems();
|
||||||
p.minItems = qp.getMinItems();
|
p.minItems = qp.getMinItems();
|
||||||
p.uniqueItems = qp.isUniqueItems();
|
p.uniqueItems = qp.isUniqueItems();
|
||||||
|
@ -264,6 +264,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
|||||||
String suffix = config.modelTemplateFiles().get(templateName);
|
String suffix = config.modelTemplateFiles().get(templateName);
|
||||||
String filename = config.modelFileFolder() + File.separator + config.toModelFilename(name) + suffix;
|
String filename = config.modelFileFolder() + File.separator + config.toModelFilename(name) + suffix;
|
||||||
if (!config.shouldOverwrite(filename)) {
|
if (!config.shouldOverwrite(filename)) {
|
||||||
|
LOGGER.info("Skipped overwriting " + filename);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
String templateFile = getFullTemplateFile(config, templateName);
|
String templateFile = getFullTemplateFile(config, templateName);
|
||||||
@ -286,6 +287,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
|||||||
String suffix = config.modelTestTemplateFiles().get(templateName);
|
String suffix = config.modelTestTemplateFiles().get(templateName);
|
||||||
String filename = config.modelTestFileFolder() + File.separator + config.toModelTestFilename(name) + suffix;
|
String filename = config.modelTestFileFolder() + File.separator + config.toModelTestFilename(name) + suffix;
|
||||||
if (!config.shouldOverwrite(filename)) {
|
if (!config.shouldOverwrite(filename)) {
|
||||||
|
LOGGER.info("Skipped overwriting " + filename);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
String templateFile = getFullTemplateFile(config, templateName);
|
String templateFile = getFullTemplateFile(config, templateName);
|
||||||
@ -308,6 +310,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
|||||||
String suffix = config.modelDocTemplateFiles().get(templateName);
|
String suffix = config.modelDocTemplateFiles().get(templateName);
|
||||||
String filename = config.modelDocFileFolder() + File.separator + config.toModelDocFilename(name) + suffix;
|
String filename = config.modelDocFileFolder() + File.separator + config.toModelDocFilename(name) + suffix;
|
||||||
if (!config.shouldOverwrite(filename)) {
|
if (!config.shouldOverwrite(filename)) {
|
||||||
|
LOGGER.info("Skipped overwriting " + filename);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
String templateFile = getFullTemplateFile(config, templateName);
|
String templateFile = getFullTemplateFile(config, templateName);
|
||||||
@ -393,6 +396,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
|||||||
for (String templateName : config.apiTemplateFiles().keySet()) {
|
for (String templateName : config.apiTemplateFiles().keySet()) {
|
||||||
String filename = config.apiFilename(templateName, tag);
|
String filename = config.apiFilename(templateName, tag);
|
||||||
if (!config.shouldOverwrite(filename) && new File(filename).exists()) {
|
if (!config.shouldOverwrite(filename) && new File(filename).exists()) {
|
||||||
|
LOGGER.info("Skipped overwriting " + filename);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -416,6 +420,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
|||||||
for (String templateName : config.apiTestTemplateFiles().keySet()) {
|
for (String templateName : config.apiTestTemplateFiles().keySet()) {
|
||||||
String filename = config.apiTestFilename(templateName, tag);
|
String filename = config.apiTestFilename(templateName, tag);
|
||||||
if (!config.shouldOverwrite(filename) && new File(filename).exists()) {
|
if (!config.shouldOverwrite(filename) && new File(filename).exists()) {
|
||||||
|
LOGGER.info("Skipped overwriting " + filename);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -439,6 +444,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
|||||||
for (String templateName : config.apiDocTemplateFiles().keySet()) {
|
for (String templateName : config.apiDocTemplateFiles().keySet()) {
|
||||||
String filename = config.apiDocFilename(templateName, tag);
|
String filename = config.apiDocFilename(templateName, tag);
|
||||||
if (!config.shouldOverwrite(filename) && new File(filename).exists()) {
|
if (!config.shouldOverwrite(filename) && new File(filename).exists()) {
|
||||||
|
LOGGER.info("Skipped overwriting " + filename);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -521,6 +527,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
|||||||
}
|
}
|
||||||
String outputFilename = outputFolder + File.separator + support.destinationFilename;
|
String outputFilename = outputFolder + File.separator + support.destinationFilename;
|
||||||
if (!config.shouldOverwrite(outputFilename)) {
|
if (!config.shouldOverwrite(outputFilename)) {
|
||||||
|
LOGGER.info("Skipped overwriting " + outputFilename);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,4 +21,27 @@ public class SupportingFile {
|
|||||||
|
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
|
||||||
|
SupportingFile that = (SupportingFile) o;
|
||||||
|
|
||||||
|
if (templateFile != null ? !templateFile.equals(that.templateFile) : that.templateFile != null)
|
||||||
|
return false;
|
||||||
|
if (folder != null ? !folder.equals(that.folder) : that.folder != null)
|
||||||
|
return false;
|
||||||
|
return destinationFilename != null ? destinationFilename.equals(that.destinationFilename) : that.destinationFilename == null;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
int result = templateFile != null ? templateFile.hashCode() : 0;
|
||||||
|
result = 31 * result + (folder != null ? folder.hashCode() : 0);
|
||||||
|
result = 31 * result + (destinationFilename != null ? destinationFilename.hashCode() : 0);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
@ -60,8 +60,8 @@ public class CodegenConfigurator {
|
|||||||
private Map<String, String> additionalProperties = new HashMap<String, String>();
|
private Map<String, String> additionalProperties = new HashMap<String, String>();
|
||||||
private Map<String, String> importMappings = new HashMap<String, String>();
|
private Map<String, String> importMappings = new HashMap<String, String>();
|
||||||
private Set<String> languageSpecificPrimitives = new HashSet<String>();
|
private Set<String> languageSpecificPrimitives = new HashSet<String>();
|
||||||
private String gitUserId="YOUR_GIT_USR_ID";
|
private String gitUserId="GIT_USER_ID";
|
||||||
private String gitRepoId="YOUR_GIT_REPO_ID";
|
private String gitRepoId="GIT_REPO_ID";
|
||||||
private String releaseNote="Minor update";
|
private String releaseNote="Minor update";
|
||||||
private String httpUserAgent;
|
private String httpUserAgent;
|
||||||
|
|
||||||
|
@ -375,6 +375,15 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
if (_import.startsWith(apiPackage()))
|
if (_import.startsWith(apiPackage()))
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
}
|
}
|
||||||
|
// if the return type is not primitive, import encoding/json
|
||||||
|
for (CodegenOperation operation : operations) {
|
||||||
|
if(operation.returnBaseType != null && needToImport(operation.returnBaseType)) {
|
||||||
|
Map<String, String> customImport = new HashMap<String, String>();
|
||||||
|
customImport.put("import", "encoding/json");
|
||||||
|
imports.add(customImport);
|
||||||
|
break; //just need to import once
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// recursivly add import for mapping one type to multipe imports
|
// recursivly add import for mapping one type to multipe imports
|
||||||
List<Map<String, String>> recursiveImports = (List<Map<String, String>>) objs.get("imports");
|
List<Map<String, String>> recursiveImports = (List<Map<String, String>>) objs.get("imports");
|
||||||
|
@ -110,7 +110,7 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
supportedLibraries.put("jersey2", "HTTP client: Jersey client 2.6");
|
supportedLibraries.put("jersey2", "HTTP client: Jersey client 2.6");
|
||||||
supportedLibraries.put("okhttp-gson", "HTTP client: OkHttp 2.4.0. JSON processing: Gson 2.3.1");
|
supportedLibraries.put("okhttp-gson", "HTTP client: OkHttp 2.4.0. JSON processing: Gson 2.3.1");
|
||||||
supportedLibraries.put(RETROFIT_1, "HTTP client: OkHttp 2.4.0. JSON processing: Gson 2.3.1 (Retrofit 1.9.0)");
|
supportedLibraries.put(RETROFIT_1, "HTTP client: OkHttp 2.4.0. JSON processing: Gson 2.3.1 (Retrofit 1.9.0)");
|
||||||
supportedLibraries.put(RETROFIT_2, "HTTP client: OkHttp 2.5.0. JSON processing: Gson 2.4 (Retrofit 2.0.0-beta4). Enable the RxJava adapter using '-DuseRxJava=true'.");
|
supportedLibraries.put(RETROFIT_2, "HTTP client: OkHttp 2.5.0. JSON processing: Gson 2.4 (Retrofit 2.0.1). Enable the RxJava adapter using '-DuseRxJava=true'. (RxJava 1.1.2)");
|
||||||
|
|
||||||
CliOption library = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use");
|
CliOption library = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use");
|
||||||
library.setDefault(DEFAULT_LIBRARY);
|
library.setDefault(DEFAULT_LIBRARY);
|
||||||
|
@ -12,9 +12,12 @@ import io.swagger.codegen.CodegenProperty;
|
|||||||
import io.swagger.codegen.CodegenType;
|
import io.swagger.codegen.CodegenType;
|
||||||
import io.swagger.codegen.SupportingFile;
|
import io.swagger.codegen.SupportingFile;
|
||||||
import io.swagger.codegen.DefaultCodegen;
|
import io.swagger.codegen.DefaultCodegen;
|
||||||
|
import io.swagger.models.ArrayModel;
|
||||||
|
import io.swagger.models.ComposedModel;
|
||||||
import io.swagger.models.Info;
|
import io.swagger.models.Info;
|
||||||
import io.swagger.models.License;
|
import io.swagger.models.License;
|
||||||
import io.swagger.models.Model;
|
import io.swagger.models.Model;
|
||||||
|
import io.swagger.models.ModelImpl;
|
||||||
import io.swagger.models.Operation;
|
import io.swagger.models.Operation;
|
||||||
import io.swagger.models.Swagger;
|
import io.swagger.models.Swagger;
|
||||||
import io.swagger.models.properties.ArrayProperty;
|
import io.swagger.models.properties.ArrayProperty;
|
||||||
@ -63,6 +66,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
|||||||
protected String projectVersion;
|
protected String projectVersion;
|
||||||
protected String projectLicenseName;
|
protected String projectLicenseName;
|
||||||
|
|
||||||
|
protected String invokerPackage;
|
||||||
protected String sourceFolder = "src";
|
protected String sourceFolder = "src";
|
||||||
protected String localVariablePrefix = "";
|
protected String localVariablePrefix = "";
|
||||||
protected boolean usePromises;
|
protected boolean usePromises;
|
||||||
@ -137,6 +141,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
|||||||
|
|
||||||
cliOptions.add(new CliOption(CodegenConstants.SOURCE_FOLDER, CodegenConstants.SOURCE_FOLDER_DESC).defaultValue("src"));
|
cliOptions.add(new CliOption(CodegenConstants.SOURCE_FOLDER, CodegenConstants.SOURCE_FOLDER_DESC).defaultValue("src"));
|
||||||
cliOptions.add(new CliOption(CodegenConstants.LOCAL_VARIABLE_PREFIX, CodegenConstants.LOCAL_VARIABLE_PREFIX_DESC));
|
cliOptions.add(new CliOption(CodegenConstants.LOCAL_VARIABLE_PREFIX, CodegenConstants.LOCAL_VARIABLE_PREFIX_DESC));
|
||||||
|
cliOptions.add(new CliOption(CodegenConstants.INVOKER_PACKAGE, CodegenConstants.INVOKER_PACKAGE_DESC));
|
||||||
cliOptions.add(new CliOption(CodegenConstants.API_PACKAGE, CodegenConstants.API_PACKAGE_DESC));
|
cliOptions.add(new CliOption(CodegenConstants.API_PACKAGE, CodegenConstants.API_PACKAGE_DESC));
|
||||||
cliOptions.add(new CliOption(CodegenConstants.MODEL_PACKAGE, CodegenConstants.MODEL_PACKAGE_DESC));
|
cliOptions.add(new CliOption(CodegenConstants.MODEL_PACKAGE, CodegenConstants.MODEL_PACKAGE_DESC));
|
||||||
cliOptions.add(new CliOption(PROJECT_NAME,
|
cliOptions.add(new CliOption(PROJECT_NAME,
|
||||||
@ -203,6 +208,9 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
|||||||
if (additionalProperties.containsKey(CodegenConstants.SOURCE_FOLDER)) {
|
if (additionalProperties.containsKey(CodegenConstants.SOURCE_FOLDER)) {
|
||||||
setSourceFolder((String) additionalProperties.get(CodegenConstants.SOURCE_FOLDER));
|
setSourceFolder((String) additionalProperties.get(CodegenConstants.SOURCE_FOLDER));
|
||||||
}
|
}
|
||||||
|
if (additionalProperties.containsKey(CodegenConstants.INVOKER_PACKAGE)) {
|
||||||
|
setInvokerPackage((String) additionalProperties.get(CodegenConstants.INVOKER_PACKAGE));
|
||||||
|
}
|
||||||
if (additionalProperties.containsKey(USE_PROMISES)) {
|
if (additionalProperties.containsKey(USE_PROMISES)) {
|
||||||
setUsePromises(Boolean.parseBoolean((String)additionalProperties.get(USE_PROMISES)));
|
setUsePromises(Boolean.parseBoolean((String)additionalProperties.get(USE_PROMISES)));
|
||||||
}
|
}
|
||||||
@ -265,6 +273,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
|||||||
additionalProperties.put(PROJECT_DESCRIPTION, escapeText(projectDescription));
|
additionalProperties.put(PROJECT_DESCRIPTION, escapeText(projectDescription));
|
||||||
additionalProperties.put(PROJECT_VERSION, projectVersion);
|
additionalProperties.put(PROJECT_VERSION, projectVersion);
|
||||||
additionalProperties.put(CodegenConstants.API_PACKAGE, apiPackage);
|
additionalProperties.put(CodegenConstants.API_PACKAGE, apiPackage);
|
||||||
|
additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage);
|
||||||
additionalProperties.put(CodegenConstants.LOCAL_VARIABLE_PREFIX, localVariablePrefix);
|
additionalProperties.put(CodegenConstants.LOCAL_VARIABLE_PREFIX, localVariablePrefix);
|
||||||
additionalProperties.put(CodegenConstants.MODEL_PACKAGE, modelPackage);
|
additionalProperties.put(CodegenConstants.MODEL_PACKAGE, modelPackage);
|
||||||
additionalProperties.put(CodegenConstants.SOURCE_FOLDER, sourceFolder);
|
additionalProperties.put(CodegenConstants.SOURCE_FOLDER, sourceFolder);
|
||||||
@ -278,8 +287,8 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
|||||||
additionalProperties.put("modelDocPath", modelDocPath);
|
additionalProperties.put("modelDocPath", modelDocPath);
|
||||||
|
|
||||||
supportingFiles.add(new SupportingFile("package.mustache", "", "package.json"));
|
supportingFiles.add(new SupportingFile("package.mustache", "", "package.json"));
|
||||||
supportingFiles.add(new SupportingFile("index.mustache", sourceFolder, "index.js"));
|
supportingFiles.add(new SupportingFile("index.mustache", createPath(sourceFolder, invokerPackage), "index.js"));
|
||||||
supportingFiles.add(new SupportingFile("ApiClient.mustache", sourceFolder, "ApiClient.js"));
|
supportingFiles.add(new SupportingFile("ApiClient.mustache", createPath(sourceFolder, invokerPackage), "ApiClient.js"));
|
||||||
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
|
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
|
||||||
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
||||||
}
|
}
|
||||||
@ -289,14 +298,41 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
|||||||
return "_" + name;
|
return "_" + name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Concatenates an array of path segments into a path string.
|
||||||
|
* @param segments The path segments to concatenate. A segment may contain either of the file separator characters '\' or '/'.
|
||||||
|
* A segment is ignored if it is <code>null</code>, empty or ".".
|
||||||
|
* @return A path string using the correct platform-specific file separator character.
|
||||||
|
*/
|
||||||
|
private String createPath(String... segments) {
|
||||||
|
StringBuilder buf = new StringBuilder();
|
||||||
|
for (String segment : segments) {
|
||||||
|
if (!StringUtils.isEmpty(segment) && !segment.equals(".")) {
|
||||||
|
if (buf.length() != 0)
|
||||||
|
buf.append(File.separatorChar);
|
||||||
|
buf.append(segment);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i = 0; i < buf.length(); i++) {
|
||||||
|
char c = buf.charAt(i);
|
||||||
|
if ((c == '/' || c == '\\') && c != File.separatorChar)
|
||||||
|
buf.setCharAt(i, File.separatorChar);
|
||||||
|
}
|
||||||
|
return buf.toString();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String apiFileFolder() {
|
public String apiFileFolder() {
|
||||||
return outputFolder + '/' + sourceFolder + '/' + apiPackage().replace('.', '/');
|
return createPath(outputFolder, sourceFolder, invokerPackage, apiPackage());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String modelFileFolder() {
|
public String modelFileFolder() {
|
||||||
return outputFolder + '/' + sourceFolder + '/' + modelPackage().replace('.', '/');
|
return createPath(outputFolder, sourceFolder, invokerPackage, modelPackage());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInvokerPackage(String invokerPackage) {
|
||||||
|
this.invokerPackage = invokerPackage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSourceFolder(String sourceFolder) {
|
public void setSourceFolder(String sourceFolder) {
|
||||||
@ -345,12 +381,12 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String apiDocFileFolder() {
|
public String apiDocFileFolder() {
|
||||||
return (outputFolder + "/" + apiDocPath).replace('/', File.separatorChar);
|
return createPath(outputFolder, apiDocPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String modelDocFileFolder() {
|
public String modelDocFileFolder() {
|
||||||
return (outputFolder + "/" + modelDocPath).replace('/', File.separatorChar);
|
return createPath(outputFolder, modelDocPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -654,10 +690,23 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
|||||||
CodegenModel codegenModel = super.fromModel(name, model, allDefinitions);
|
CodegenModel codegenModel = super.fromModel(name, model, allDefinitions);
|
||||||
|
|
||||||
if (allDefinitions != null && codegenModel != null && codegenModel.parent != null && codegenModel.hasEnums) {
|
if (allDefinitions != null && codegenModel != null && codegenModel.parent != null && codegenModel.hasEnums) {
|
||||||
final Model parentModel = allDefinitions.get(toModelName(codegenModel.parent));
|
final Model parentModel = allDefinitions.get(codegenModel.parentSchema);
|
||||||
final CodegenModel parentCodegenModel = super.fromModel(codegenModel.parent, parentModel);
|
final CodegenModel parentCodegenModel = super.fromModel(codegenModel.parent, parentModel, allDefinitions);
|
||||||
codegenModel = JavascriptClientCodegen.reconcileInlineEnums(codegenModel, parentCodegenModel);
|
codegenModel = JavascriptClientCodegen.reconcileInlineEnums(codegenModel, parentCodegenModel);
|
||||||
}
|
}
|
||||||
|
if (model instanceof ArrayModel) {
|
||||||
|
ArrayModel am = (ArrayModel) model;
|
||||||
|
if (am.getItems() != null) {
|
||||||
|
codegenModel.vendorExtensions.put("x-isArray", true);
|
||||||
|
codegenModel.vendorExtensions.put("x-itemType", getSwaggerType(am.getItems()));
|
||||||
|
}
|
||||||
|
} else if (model instanceof ModelImpl) {
|
||||||
|
ModelImpl mm = (ModelImpl)model;
|
||||||
|
if (mm.getAdditionalProperties() != null) {
|
||||||
|
codegenModel.vendorExtensions.put("x-isMap", true);
|
||||||
|
codegenModel.vendorExtensions.put("x-itemType", getSwaggerType(mm.getAdditionalProperties()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return codegenModel;
|
return codegenModel;
|
||||||
}
|
}
|
||||||
@ -674,7 +723,8 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String getModelledType(String dataType) {
|
private String getModelledType(String dataType) {
|
||||||
return "module:" + (StringUtils.isEmpty(modelPackage) ? "" : (modelPackage + "/")) + dataType;
|
return "module:" + (StringUtils.isEmpty(invokerPackage) ? "" : (invokerPackage + "/"))
|
||||||
|
+ (StringUtils.isEmpty(modelPackage) ? "" : (modelPackage + "/")) + dataType;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getJSDocTypeWithBraces(CodegenModel cm, CodegenProperty cp) {
|
private String getJSDocTypeWithBraces(CodegenModel cm, CodegenProperty cp) {
|
||||||
|
@ -20,6 +20,8 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
protected String packageVersion;
|
protected String packageVersion;
|
||||||
protected String apiDocPath = "docs/";
|
protected String apiDocPath = "docs/";
|
||||||
protected String modelDocPath = "docs/";
|
protected String modelDocPath = "docs/";
|
||||||
|
|
||||||
|
private String testFolder;
|
||||||
|
|
||||||
public PythonClientCodegen() {
|
public PythonClientCodegen() {
|
||||||
super();
|
super();
|
||||||
@ -27,12 +29,19 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
modelPackage = "models";
|
modelPackage = "models";
|
||||||
apiPackage = "api";
|
apiPackage = "api";
|
||||||
outputFolder = "generated-code" + File.separatorChar + "python";
|
outputFolder = "generated-code" + File.separatorChar + "python";
|
||||||
|
|
||||||
modelTemplateFiles.put("model.mustache", ".py");
|
modelTemplateFiles.put("model.mustache", ".py");
|
||||||
apiTemplateFiles.put("api.mustache", ".py");
|
apiTemplateFiles.put("api.mustache", ".py");
|
||||||
|
|
||||||
|
modelTestTemplateFiles.put("model_test.mustache", ".py");
|
||||||
|
apiTestTemplateFiles.put("api_test.mustache", ".py");
|
||||||
|
|
||||||
embeddedTemplateDir = templateDir = "python";
|
embeddedTemplateDir = templateDir = "python";
|
||||||
|
|
||||||
modelDocTemplateFiles.put("model_doc.mustache", ".md");
|
modelDocTemplateFiles.put("model_doc.mustache", ".md");
|
||||||
apiDocTemplateFiles.put("api_doc.mustache", ".md");
|
apiDocTemplateFiles.put("api_doc.mustache", ".md");
|
||||||
|
|
||||||
|
testFolder = "test";
|
||||||
|
|
||||||
languageSpecificPrimitives.clear();
|
languageSpecificPrimitives.clear();
|
||||||
languageSpecificPrimitives.add("int");
|
languageSpecificPrimitives.add("int");
|
||||||
@ -58,10 +67,12 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
typeMapping.put("DateTime", "datetime");
|
typeMapping.put("DateTime", "datetime");
|
||||||
typeMapping.put("object", "object");
|
typeMapping.put("object", "object");
|
||||||
typeMapping.put("file", "file");
|
typeMapping.put("file", "file");
|
||||||
//TODO binary should be mapped to byte array
|
// TODO binary should be mapped to byte array
|
||||||
// mapped to String as a workaround
|
// mapped to String as a workaround
|
||||||
typeMapping.put("binary", "str");
|
typeMapping.put("binary", "str");
|
||||||
typeMapping.put("ByteArray", "str");
|
typeMapping.put("ByteArray", "str");
|
||||||
|
// map uuid to string for the time being
|
||||||
|
typeMapping.put("UUID", "str");
|
||||||
|
|
||||||
// from https://docs.python.org/release/2.5.4/ref/keywords.html
|
// from https://docs.python.org/release/2.5.4/ref/keywords.html
|
||||||
setReservedWordsLowerCase(
|
setReservedWordsLowerCase(
|
||||||
@ -124,6 +135,7 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
supportingFiles.add(new SupportingFile("__init__package.mustache", swaggerFolder, "__init__.py"));
|
supportingFiles.add(new SupportingFile("__init__package.mustache", swaggerFolder, "__init__.py"));
|
||||||
supportingFiles.add(new SupportingFile("__init__model.mustache", modelPackage, "__init__.py"));
|
supportingFiles.add(new SupportingFile("__init__model.mustache", modelPackage, "__init__.py"));
|
||||||
supportingFiles.add(new SupportingFile("__init__api.mustache", apiPackage, "__init__.py"));
|
supportingFiles.add(new SupportingFile("__init__api.mustache", apiPackage, "__init__.py"));
|
||||||
|
supportingFiles.add(new SupportingFile("__init__test.mustache", testFolder, "__init__.py"));
|
||||||
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
|
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
|
||||||
supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
|
supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
|
||||||
}
|
}
|
||||||
@ -182,6 +194,16 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
public String modelFileFolder() {
|
public String modelFileFolder() {
|
||||||
return outputFolder + File.separatorChar + modelPackage().replace('.', File.separatorChar);
|
return outputFolder + File.separatorChar + modelPackage().replace('.', File.separatorChar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String apiTestFileFolder() {
|
||||||
|
return outputFolder + File.separatorChar + testFolder;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String modelTestFileFolder() {
|
||||||
|
return outputFolder + File.separatorChar + testFolder;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTypeDeclaration(Property p) {
|
public String getTypeDeclaration(Property p) {
|
||||||
@ -308,6 +330,11 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
// PhoneNumber => phone_number
|
// PhoneNumber => phone_number
|
||||||
return underscore(dropDots(name));
|
return underscore(dropDots(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toModelTestFilename(String name) {
|
||||||
|
return "test_" + toModelFilename(name);
|
||||||
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toApiFilename(String name) {
|
public String toApiFilename(String name) {
|
||||||
@ -317,6 +344,11 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
// e.g. PhoneNumberApi.rb => phone_number_api.rb
|
// e.g. PhoneNumberApi.rb => phone_number_api.rb
|
||||||
return underscore(name) + "_api";
|
return underscore(name) + "_api";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toApiTestFilename(String name) {
|
||||||
|
return "test_" + toApiFilename(name);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toApiName(String name) {
|
public String toApiName(String name) {
|
||||||
|
@ -111,7 +111,7 @@ public class Qt5CPPGenerator extends DefaultCodegen implements CodegenConfig {
|
|||||||
|
|
||||||
super.typeMapping = new HashMap<String, String>();
|
super.typeMapping = new HashMap<String, String>();
|
||||||
|
|
||||||
typeMapping.put("Date", "QDate");
|
typeMapping.put("date", "QDate");
|
||||||
typeMapping.put("DateTime", "QDateTime");
|
typeMapping.put("DateTime", "QDateTime");
|
||||||
typeMapping.put("string", "QString");
|
typeMapping.put("string", "QString");
|
||||||
typeMapping.put("integer", "qint32");
|
typeMapping.put("integer", "qint32");
|
||||||
|
@ -642,4 +642,11 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
public void setGemAuthorEmail(String gemAuthorEmail) {
|
public void setGemAuthorEmail(String gemAuthorEmail) {
|
||||||
this.gemAuthorEmail = gemAuthorEmail;
|
this.gemAuthorEmail = gemAuthorEmail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldOverwrite(String filename) {
|
||||||
|
// skip spec file as the file might have been updated with new test cases
|
||||||
|
return super.shouldOverwrite(filename) && !filename.endsWith("_spec.rb");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
|
|||||||
outputFolder = "generated-code/typescript-angular";
|
outputFolder = "generated-code/typescript-angular";
|
||||||
modelTemplateFiles.put("model.mustache", ".ts");
|
modelTemplateFiles.put("model.mustache", ".ts");
|
||||||
apiTemplateFiles.put("api.mustache", ".ts");
|
apiTemplateFiles.put("api.mustache", ".ts");
|
||||||
embeddedTemplateDir = templateDir = "TypeScript-Angular";
|
embeddedTemplateDir = templateDir = "typescript-angular";
|
||||||
apiPackage = "API.Client";
|
apiPackage = "API.Client";
|
||||||
modelPackage = "API.Client";
|
modelPackage = "API.Client";
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,82 @@
|
|||||||
package io.swagger.codegen.languages;
|
package io.swagger.codegen.languages;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import io.swagger.codegen.CliOption;
|
||||||
import io.swagger.codegen.SupportingFile;
|
import io.swagger.codegen.SupportingFile;
|
||||||
|
import io.swagger.models.properties.BooleanProperty;
|
||||||
|
|
||||||
public class TypeScriptNodeClientCodegen extends AbstractTypeScriptClientCodegen {
|
public class TypeScriptNodeClientCodegen extends AbstractTypeScriptClientCodegen {
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(TypeScriptNodeClientCodegen.class);
|
||||||
|
private static final SimpleDateFormat SNAPSHOT_SUFFIX_FORMAT = new SimpleDateFormat("yyyyMMddHHmm");
|
||||||
|
|
||||||
|
public static final String NPM_NAME = "npmName";
|
||||||
|
public static final String NPM_VERSION = "npmVersion";
|
||||||
|
public static final String NPM_REPOSITORY = "npmRepository";
|
||||||
|
public static final String SNAPSHOT = "snapshot";
|
||||||
|
|
||||||
|
protected String npmName = null;
|
||||||
|
protected String npmVersion = "1.0.0";
|
||||||
|
protected String npmRepository = null;
|
||||||
|
|
||||||
|
public TypeScriptNodeClientCodegen() {
|
||||||
|
super();
|
||||||
|
outputFolder = "generated-code/typescript-node";
|
||||||
|
embeddedTemplateDir = templateDir = "typescript-node";
|
||||||
|
|
||||||
|
this.cliOptions.add(new CliOption(NPM_NAME, "The name under which you want to publish generated npm package"));
|
||||||
|
this.cliOptions.add(new CliOption(NPM_VERSION, "The version of your npm package"));
|
||||||
|
this.cliOptions.add(new CliOption(NPM_REPOSITORY, "Use this property to set an url your private npmRepo in the package.json"));
|
||||||
|
this.cliOptions.add(new CliOption(SNAPSHOT, "When setting this property to true the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm", BooleanProperty.TYPE).defaultValue(Boolean.FALSE.toString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void processOpts() {
|
||||||
|
super.processOpts();
|
||||||
|
supportingFiles.add(new SupportingFile("api.mustache", null, "api.ts"));
|
||||||
|
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
|
||||||
|
//supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
|
||||||
|
|
||||||
|
LOGGER.warn("check additionals: " + additionalProperties.get(NPM_NAME));
|
||||||
|
if(additionalProperties.containsKey(NPM_NAME)) {
|
||||||
|
addNpmPackageGeneration();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addNpmPackageGeneration() {
|
||||||
|
if(additionalProperties.containsKey(NPM_NAME)) {
|
||||||
|
this.setNpmName(additionalProperties.get(NPM_NAME).toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (additionalProperties.containsKey(NPM_VERSION)) {
|
||||||
|
this.setNpmVersion(additionalProperties.get(NPM_VERSION).toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (additionalProperties.containsKey(SNAPSHOT) && Boolean.valueOf(additionalProperties.get(SNAPSHOT).toString())) {
|
||||||
|
this.setNpmVersion(npmVersion + "-SNAPSHOT." + SNAPSHOT_SUFFIX_FORMAT.format(new Date()));
|
||||||
|
}
|
||||||
|
additionalProperties.put(NPM_VERSION, npmVersion);
|
||||||
|
|
||||||
|
if (additionalProperties.containsKey(NPM_REPOSITORY)) {
|
||||||
|
this.setNpmRepository(additionalProperties.get(NPM_REPOSITORY).toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
//Files for building our lib
|
||||||
|
supportingFiles.add(new SupportingFile("package.mustache", getPackageRootDirectory(), "package.json"));
|
||||||
|
supportingFiles.add(new SupportingFile("typings.mustache", getPackageRootDirectory(), "typings.json"));
|
||||||
|
supportingFiles.add(new SupportingFile("tsconfig.mustache", getPackageRootDirectory(), "tsconfig.json"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getPackageRootDirectory() {
|
||||||
|
String indexPackage = modelPackage.substring(0, Math.max(0, modelPackage.lastIndexOf('.')));
|
||||||
|
return indexPackage.replace('.', File.separatorChar);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
@ -14,18 +88,24 @@ public class TypeScriptNodeClientCodegen extends AbstractTypeScriptClientCodegen
|
|||||||
return "Generates a TypeScript nodejs client library.";
|
return "Generates a TypeScript nodejs client library.";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void processOpts() {
|
public void setNpmName(String npmName) {
|
||||||
super.processOpts();
|
this.npmName = npmName;
|
||||||
supportingFiles.add(new SupportingFile("api.mustache", null, "api.ts"));
|
|
||||||
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
|
|
||||||
//supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
|
|
||||||
}
|
|
||||||
|
|
||||||
public TypeScriptNodeClientCodegen() {
|
|
||||||
super();
|
|
||||||
outputFolder = "generated-code/typescript-node";
|
|
||||||
embeddedTemplateDir = templateDir = "TypeScript-node";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setNpmVersion(String npmVersion) {
|
||||||
|
this.npmVersion = npmVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNpmVersion() {
|
||||||
|
return npmVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNpmRepository() {
|
||||||
|
return npmRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNpmRepository(String npmRepository) {
|
||||||
|
this.npmRepository = npmRepository;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,8 +95,7 @@ if(hasProperty('target') && target == 'android') {
|
|||||||
|
|
||||||
ext {
|
ext {
|
||||||
oltu_version = "1.0.1"
|
oltu_version = "1.0.1"
|
||||||
retrofit_version = "2.0.0-beta4"
|
retrofit_version = "2.0.2"
|
||||||
gson_version = "2.6.2"
|
|
||||||
swagger_annotations_version = "1.5.8"
|
swagger_annotations_version = "1.5.8"
|
||||||
junit_version = "4.12"
|
junit_version = "4.12"
|
||||||
{{#useRxJava}}
|
{{#useRxJava}}
|
||||||
|
@ -112,6 +112,11 @@
|
|||||||
<artifactId>swagger-annotations</artifactId>
|
<artifactId>swagger-annotations</artifactId>
|
||||||
<version>${swagger-core-version}</version>
|
<version>${swagger-core-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.squareup.retrofit2</groupId>
|
||||||
|
<artifactId>converter-gson</artifactId>
|
||||||
|
<version>${retrofit-version}</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.squareup.retrofit2</groupId>
|
<groupId>com.squareup.retrofit2</groupId>
|
||||||
<artifactId>retrofit</artifactId>
|
<artifactId>retrofit</artifactId>
|
||||||
@ -122,11 +127,6 @@
|
|||||||
<artifactId>converter-scalars</artifactId>
|
<artifactId>converter-scalars</artifactId>
|
||||||
<version>${retrofit-version}</version>
|
<version>${retrofit-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.squareup.retrofit2</groupId>
|
|
||||||
<artifactId>converter-gson</artifactId>
|
|
||||||
<version>${retrofit-version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.oltu.oauth2</groupId>
|
<groupId>org.apache.oltu.oauth2</groupId>
|
||||||
<artifactId>org.apache.oltu.oauth2.client</artifactId>
|
<artifactId>org.apache.oltu.oauth2.client</artifactId>
|
||||||
@ -153,8 +153,9 @@
|
|||||||
</dependencies>
|
</dependencies>
|
||||||
<properties>
|
<properties>
|
||||||
<swagger-core-version>1.5.8</swagger-core-version>
|
<swagger-core-version>1.5.8</swagger-core-version>
|
||||||
<retrofit-version>2.0.0-beta4</retrofit-version>{{#useRxJava}}
|
<retrofit-version>2.0.2</retrofit-version>
|
||||||
<rxjava-version>1.1.3</rxjava-version>{{/useRxJava}}
|
{{#useRxJava}}<rxjava-version>1.1.3</rxjava-version>{{/useRxJava}}
|
||||||
|
<okhttp-version>3.2.0</okhttp-version>
|
||||||
<oltu-version>1.0.1</oltu-version>
|
<oltu-version>1.0.1</oltu-version>
|
||||||
<maven-plugin-version>1.0.0</maven-plugin-version>
|
<maven-plugin-version>1.0.0</maven-plugin-version>
|
||||||
<junit-version>4.12</junit-version>
|
<junit-version>4.12</junit-version>
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-war-plugin</artifactId>
|
<artifactId>maven-war-plugin</artifactId>
|
||||||
<version>2.1.1</version>
|
<version>2.6</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-failsafe-plugin</artifactId>
|
<artifactId>maven-failsafe-plugin</artifactId>
|
||||||
@ -119,12 +119,12 @@
|
|||||||
</dependencies>
|
</dependencies>
|
||||||
<properties>
|
<properties>
|
||||||
<swagger-core-version>1.5.8</swagger-core-version>
|
<swagger-core-version>1.5.8</swagger-core-version>
|
||||||
<jetty-version>9.2.9.v20150224</jetty-version>
|
<jetty-version>9.2.15.v20160210</jetty-version>
|
||||||
<jersey-version>1.13</jersey-version>
|
<jersey-version>1.13</jersey-version>
|
||||||
<slf4j-version>1.6.3</slf4j-version>
|
<slf4j-version>1.7.21</slf4j-version>
|
||||||
<junit-version>4.8.1</junit-version>
|
<junit-version>4.12</junit-version>
|
||||||
<servlet-api-version>2.5</servlet-api-version>
|
<servlet-api-version>2.5</servlet-api-version>
|
||||||
<springfox-version>2.3.1</springfox-version>
|
<springfox-version>2.4.0</springfox-version>
|
||||||
<spring-version>4.1.8.RELEASE</spring-version>
|
<spring-version>4.2.5.RELEASE</spring-version>
|
||||||
</properties>
|
</properties>
|
||||||
</project>
|
</project>
|
||||||
|
@ -6,7 +6,9 @@ import org.springframework.context.annotation.Configuration;
|
|||||||
import org.springframework.context.annotation.PropertySource;
|
import org.springframework.context.annotation.PropertySource;
|
||||||
import org.springframework.context.annotation.Import;
|
import org.springframework.context.annotation.Import;
|
||||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||||
|
import springfox.documentation.builders.ApiInfoBuilder;
|
||||||
import springfox.documentation.service.ApiInfo;
|
import springfox.documentation.service.ApiInfo;
|
||||||
|
import springfox.documentation.service.Contact;
|
||||||
import springfox.documentation.spi.DocumentationType;
|
import springfox.documentation.spi.DocumentationType;
|
||||||
import springfox.documentation.spring.web.plugins.Docket;
|
import springfox.documentation.spring.web.plugins.Docket;
|
||||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||||
@ -22,15 +24,15 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
|||||||
public class SwaggerConfig {
|
public class SwaggerConfig {
|
||||||
@Bean
|
@Bean
|
||||||
ApiInfo apiInfo() {
|
ApiInfo apiInfo() {
|
||||||
ApiInfo apiInfo = new ApiInfo(
|
return new ApiInfoBuilder()
|
||||||
"{{appName}}",
|
.title("{{appName}}")
|
||||||
"{{{appDescription}}}",
|
.description("{{{appDescription}}}")
|
||||||
"{{appVersion}}",
|
.license("{{licenseInfo}}")
|
||||||
"{{infoUrl}}",
|
.licenseUrl("{{licenseUrl}}")
|
||||||
"{{infoEmail}}",
|
.termsOfServiceUrl("{{infoUrl}}")
|
||||||
"{{licenseInfo}}",
|
.version("{{appVersion}}")
|
||||||
"{{licenseUrl}}" );
|
.contact(new Contact("","", "{{infoEmail}}"))
|
||||||
return apiInfo;
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ -38,4 +40,4 @@ public class SwaggerConfig {
|
|||||||
return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo());
|
return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -47,8 +47,8 @@ goog.require('{{import}}');
|
|||||||
/** @private {!angular.$http} */
|
/** @private {!angular.$http} */
|
||||||
this.http_ = $http;
|
this.http_ = $http;
|
||||||
|
|
||||||
/** @private {!Object} */
|
/** @package {!Object} */
|
||||||
this.httpParamSerializer_ = $injector.get('$httpParamSerializer');
|
this.httpParamSerializer = $injector.get('$httpParamSerializer');
|
||||||
}
|
}
|
||||||
{{package}}.{{classname}}.$inject = ['$http', '$httpParamSerializer', '$injector'];
|
{{package}}.{{classname}}.$inject = ['$http', '$httpParamSerializer', '$injector'];
|
||||||
{{#operation}}
|
{{#operation}}
|
||||||
@ -69,7 +69,7 @@ goog.require('{{import}}');
|
|||||||
var queryParameters = {};
|
var queryParameters = {};
|
||||||
|
|
||||||
/** @type {!Object} */
|
/** @type {!Object} */
|
||||||
var headerParams = angular.extend({}, this.defaultHeaders);
|
var headerParams = angular.extend({}, this.defaultHeaders_);
|
||||||
{{#hasFormParams}}
|
{{#hasFormParams}}
|
||||||
/** @type {!Object} */
|
/** @type {!Object} */
|
||||||
var formParams = {};
|
var formParams = {};
|
||||||
@ -108,7 +108,7 @@ goog.require('{{import}}');
|
|||||||
json: {{#hasFormParams}}false{{/hasFormParams}}{{^hasFormParams}}true{{/hasFormParams}},
|
json: {{#hasFormParams}}false{{/hasFormParams}}{{^hasFormParams}}true{{/hasFormParams}},
|
||||||
{{#bodyParam}}data: {{^required}}opt_{{/required}}{{paramName}},
|
{{#bodyParam}}data: {{^required}}opt_{{/required}}{{paramName}},
|
||||||
{{/bodyParam}}
|
{{/bodyParam}}
|
||||||
{{#hasFormParams}}data: this.httpParamSerializer_(formParams),
|
{{#hasFormParams}}data: this.httpParamSerializer(formParams),
|
||||||
{{/hasFormParams}}
|
{{/hasFormParams}}
|
||||||
params: queryParameters,
|
params: queryParameters,
|
||||||
headers: headerParams
|
headers: headerParams
|
||||||
@ -118,7 +118,7 @@ goog.require('{{import}}');
|
|||||||
httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams);
|
httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.http_(httpRequestParams);
|
return (/** @type {?} */ (this.http_))(httpRequestParams);
|
||||||
}
|
}
|
||||||
{{/operation}}
|
{{/operation}}
|
||||||
{{/operations}}
|
{{/operations}}
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
{{#emitJSDoc}} /**
|
{{#emitJSDoc}} /**
|
||||||
* @module ApiClient
|
* @module {{#invokerPackage}}{{invokerPackage}}/{{/invokerPackage}}ApiClient
|
||||||
* @version {{projectVersion}}
|
* @version {{projectVersion}}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -24,7 +24,7 @@
|
|||||||
* Manages low level client-server communications, parameter marshalling, etc. There should not be any need for an
|
* Manages low level client-server communications, parameter marshalling, etc. There should not be any need for an
|
||||||
* application to use this class directly - the *Api and model classes provide the public API for the service. The
|
* application to use this class directly - the *Api and model classes provide the public API for the service. The
|
||||||
* contents of this file should be regarded as internal but are documented for completeness.
|
* contents of this file should be regarded as internal but are documented for completeness.
|
||||||
* @alias module:ApiClient
|
* @alias module:{{#invokerPackage}}{{invokerPackage}}/{{/invokerPackage}}ApiClient
|
||||||
* @class
|
* @class
|
||||||
*/
|
*/
|
||||||
{{/emitJSDoc}} var exports = function() {
|
{{/emitJSDoc}} var exports = function() {
|
||||||
@ -218,7 +218,7 @@
|
|||||||
/**
|
/**
|
||||||
* Builds a string representation of an array-type actual parameter, according to the given collection format.
|
* Builds a string representation of an array-type actual parameter, according to the given collection format.
|
||||||
* @param {Array} param An array parameter.
|
* @param {Array} param An array parameter.
|
||||||
* @param {module:ApiClient.CollectionFormatEnum} collectionFormat The array element separator strategy.
|
* @param {module:{{#invokerPackage}}{{invokerPackage}}/{{/invokerPackage}}ApiClient.CollectionFormatEnum} collectionFormat The array element separator strategy.
|
||||||
* @returns {String|Array} A string representation of the supplied collection, using the specified delimiter. Returns
|
* @returns {String|Array} A string representation of the supplied collection, using the specified delimiter. Returns
|
||||||
* <code>param</code> as is if <code>collectionFormat</code> is <code>multi</code>.
|
* <code>param</code> as is if <code>collectionFormat</code> is <code>multi</code>.
|
||||||
*/
|
*/
|
||||||
@ -309,7 +309,7 @@
|
|||||||
|
|
||||||
{{#emitJSDoc}}{{^usePromises}} /**
|
{{#emitJSDoc}}{{^usePromises}} /**
|
||||||
* Callback function to receive the result of the operation.
|
* Callback function to receive the result of the operation.
|
||||||
* @callback module:ApiClient~callApiCallback
|
* @callback module:{{#invokerPackage}}{{invokerPackage}}/{{/invokerPackage}}ApiClient~callApiCallback
|
||||||
* @param {String} error Error message, if any.
|
* @param {String} error Error message, if any.
|
||||||
* @param data The data returned by the service call.
|
* @param data The data returned by the service call.
|
||||||
* @param {String} response The complete HTTP response.
|
* @param {String} response The complete HTTP response.
|
||||||
@ -329,7 +329,7 @@
|
|||||||
* @param {Array.<String>} accepts An array of acceptable response MIME types.
|
* @param {Array.<String>} accepts An array of acceptable response MIME types.
|
||||||
* @param {(String|Array|ObjectFunction)} returnType The required type to return; can be a string for simple types or the
|
* @param {(String|Array|ObjectFunction)} returnType The required type to return; can be a string for simple types or the
|
||||||
* constructor for a complex type.{{^usePromises}}
|
* constructor for a complex type.{{^usePromises}}
|
||||||
* @param {module:ApiClient~callApiCallback} callback The callback function.
|
* @param {module:{{#invokerPackage}}{{invokerPackage}}/{{/invokerPackage}}ApiClient~callApiCallback} callback The callback function.
|
||||||
{{/usePromises}} * @returns {{#usePromises}}{Promise} A Promise object{{/usePromises}}{{^usePromises}}{Object} The SuperAgent request object{{/usePromises}}.
|
{{/usePromises}} * @returns {{#usePromises}}{Promise} A Promise object{{/usePromises}}{{^usePromises}}{Object} The SuperAgent request object{{/usePromises}}.
|
||||||
*/
|
*/
|
||||||
{{/emitJSDoc}} exports.prototype.callApi = function callApi(path, httpMethod, pathParams,
|
{{/emitJSDoc}} exports.prototype.callApi = function callApi(path, httpMethod, pathParams,
|
||||||
@ -474,9 +474,28 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
{{#emitJSDoc}} /**
|
||||||
|
* Constructs a new map or array model from REST data.
|
||||||
|
* @param data {Object|Array} The REST data.
|
||||||
|
* @param obj {Object|Array} The target object or array.
|
||||||
|
*/
|
||||||
|
{{/emitJSDoc}} exports.constructFromObject = function(data, obj, itemType) {
|
||||||
|
if (Array.isArray(data)) {
|
||||||
|
for (var i = 0; i < data.length; i++) {
|
||||||
|
if (data.hasOwnProperty(i))
|
||||||
|
obj[i] = exports.convertToType(data[i], itemType);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (var k in data) {
|
||||||
|
if (data.hasOwnProperty(k))
|
||||||
|
result[k] = exports.convertToType(data[k], itemType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
{{#emitJSDoc}} /**
|
{{#emitJSDoc}} /**
|
||||||
* The default API client implementation.
|
* The default API client implementation.
|
||||||
* @type {module:ApiClient}
|
* @type {module:{{#invokerPackage}}{{invokerPackage}}/{{/invokerPackage}}ApiClient}
|
||||||
*/
|
*/
|
||||||
{{/emitJSDoc}} exports.instance = new exports();
|
{{/emitJSDoc}} exports.instance = new exports();
|
||||||
|
|
||||||
|
@ -32,11 +32,11 @@ npm install {{{projectName}}} --save
|
|||||||
#### git
|
#### git
|
||||||
#
|
#
|
||||||
If the library is hosted at a git repository, e.g.
|
If the library is hosted at a git repository, e.g.
|
||||||
https://github.com/{{#gitUserName}}{{.}}{{/gitUserName}}{{^gitUserName}}YOUR_USERNAME{{/gitUserName}}/{{#gitRepoId}}{{.}}{{/gitRepoId}}{{^gitRepoId}}{{projectName}}{{/gitRepoId}}
|
https://github.com/{{#gitUserId}}{{.}}{{/gitUserId}}{{^gitUserId}}YOUR_USERNAME{{/gitUserId}}/{{#gitRepoId}}{{.}}{{/gitRepoId}}{{^gitRepoId}}{{projectName}}{{/gitRepoId}}
|
||||||
then install it via:
|
then install it via:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
npm install {{#gitUserName}}{{.}}{{/gitUserName}}{{^gitUserName}}YOUR_USERNAME{{/gitUserName}}/{{#gitRepoId}}{{.}}{{/gitRepoId}}{{^gitRepoId}}{{projectName}}{{/gitRepoId}} --save
|
npm install {{#gitUserId}}{{.}}{{/gitUserId}}{{^gitUserId}}YOUR_USERNAME{{/gitUserId}}/{{#gitRepoId}}{{.}}{{/gitRepoId}}{{^gitRepoId}}{{projectName}}{{/gitRepoId}} --save
|
||||||
```
|
```
|
||||||
|
|
||||||
### For browser
|
### For browser
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{{=< >=}}(function(root, factory) {
|
{{=< >=}}(function(root, factory) {
|
||||||
if (typeof define === 'function' && define.amd) {
|
if (typeof define === 'function' && define.amd) {
|
||||||
// AMD. Register as an anonymous module.
|
// AMD. Register as an anonymous module.
|
||||||
define(['../ApiClient'<#imports>, '../<#modelPackage><modelPackage>/</modelPackage><import>'</imports>], factory);
|
define(['<#invokerPackage><invokerPackage>/</invokerPackage>ApiClient'<#imports>, '<#invokerPackage><invokerPackage>/</invokerPackage><#modelPackage><modelPackage>/</modelPackage><import>'</imports>], factory);
|
||||||
} else if (typeof module === 'object' && module.exports) {
|
} else if (typeof module === 'object' && module.exports) {
|
||||||
// CommonJS-like environments that support module.exports, like Node.
|
// CommonJS-like environments that support module.exports, like Node.
|
||||||
module.exports = factory(require('../ApiClient')<#imports>, require('../<#modelPackage><modelPackage>/</modelPackage><import>')</imports>);
|
module.exports = factory(require('../ApiClient')<#imports>, require('../<#modelPackage><modelPackage>/</modelPackage><import>')</imports>);
|
||||||
@ -17,17 +17,17 @@
|
|||||||
|
|
||||||
<#emitJSDoc> /**
|
<#emitJSDoc> /**
|
||||||
* <baseName> service.
|
* <baseName> service.
|
||||||
* @module <#apiPackage><apiPackage>/</apiPackage><classname>
|
* @module <#invokerPackage><invokerPackage>/</invokerPackage><#apiPackage><apiPackage>/</apiPackage><classname>
|
||||||
* @version <projectVersion>
|
* @version <projectVersion>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new <classname>. <#description>
|
* Constructs a new <classname>. <#description>
|
||||||
* <description></description>
|
* <description></description>
|
||||||
* @alias module:<#apiPackage><apiPackage>/</apiPackage><classname>
|
* @alias module:<#invokerPackage><invokerPackage>/</invokerPackage><#apiPackage><apiPackage>/</apiPackage><classname>
|
||||||
* @class
|
* @class
|
||||||
* @param {module:ApiClient} apiClient Optional API client implementation to use, default to {@link module:ApiClient#instance}
|
* @param {module:<#invokerPackage><invokerPackage>/</invokerPackage>ApiClient} apiClient Optional API client implementation to use,
|
||||||
* if unspecified.
|
* default to {@link module:<#invokerPackage><invokerPackage>/</invokerPackage>ApiClient#instance} if unspecified.
|
||||||
*/
|
*/
|
||||||
</emitJSDoc> var exports = function(apiClient) {
|
</emitJSDoc> var exports = function(apiClient) {
|
||||||
this.apiClient = apiClient || ApiClient.instance;
|
this.apiClient = apiClient || ApiClient.instance;
|
||||||
@ -35,7 +35,7 @@
|
|||||||
<#operations><#operation><#emitJSDoc><^usePromises>
|
<#operations><#operation><#emitJSDoc><^usePromises>
|
||||||
/**
|
/**
|
||||||
* Callback function to receive the result of the <nickname> operation.
|
* Callback function to receive the result of the <nickname> operation.
|
||||||
* @callback module:<#apiPackage><apiPackage>/</apiPackage><classname>~<nickname>Callback
|
* @callback module:<#invokerPackage><invokerPackage>/</invokerPackage><#apiPackage><apiPackage>/</apiPackage><classname>~<nickname>Callback
|
||||||
* @param {String} error Error message, if any.
|
* @param {String} error Error message, if any.
|
||||||
* @param <#vendorExtensions.x-jsdoc-type><&vendorExtensions.x-jsdoc-type> data The data returned by the service call.</vendorExtensions.x-jsdoc-type><^vendorExtensions.x-jsdoc-type>data This operation does not return a value.</vendorExtensions.x-jsdoc-type>
|
* @param <#vendorExtensions.x-jsdoc-type><&vendorExtensions.x-jsdoc-type> data The data returned by the service call.</vendorExtensions.x-jsdoc-type><^vendorExtensions.x-jsdoc-type>data This operation does not return a value.</vendorExtensions.x-jsdoc-type>
|
||||||
* @param {String} response The complete HTTP response.
|
* @param {String} response The complete HTTP response.
|
||||||
@ -47,7 +47,7 @@
|
|||||||
* @param <&vendorExtensions.x-jsdoc-type> <paramName> <description></required></allParams><#hasOptionalParams>
|
* @param <&vendorExtensions.x-jsdoc-type> <paramName> <description></required></allParams><#hasOptionalParams>
|
||||||
* @param {Object} opts Optional parameters<#allParams><^required>
|
* @param {Object} opts Optional parameters<#allParams><^required>
|
||||||
* @param <&vendorExtensions.x-jsdoc-type> opts.<paramName> <description><#defaultValue> (default to <.>)</defaultValue></required></allParams></hasOptionalParams><^usePromises>
|
* @param <&vendorExtensions.x-jsdoc-type> opts.<paramName> <description><#defaultValue> (default to <.>)</defaultValue></required></allParams></hasOptionalParams><^usePromises>
|
||||||
* @param {module:<#apiPackage><apiPackage>/</apiPackage><classname>~<nickname>Callback} callback The callback function, accepting three arguments: error, data, response</usePromises><#returnType>
|
* @param {module:<#invokerPackage><invokerPackage>/</invokerPackage><#apiPackage><apiPackage>/</apiPackage><classname>~<nickname>Callback} callback The callback function, accepting three arguments: error, data, response</usePromises><#returnType>
|
||||||
* data is of type: <&vendorExtensions.x-jsdoc-type></returnType>
|
* data is of type: <&vendorExtensions.x-jsdoc-type></returnType>
|
||||||
*/
|
*/
|
||||||
</emitJSDoc> this.<nickname> = function(<vendorExtensions.x-codegen-argList>) {<#hasOptionalParams>
|
</emitJSDoc> this.<nickname> = function(<vendorExtensions.x-codegen-argList>) {<#hasOptionalParams>
|
||||||
|
@ -36,7 +36,7 @@ git_remote=`git remote`
|
|||||||
if [ "$git_remote" = "" ]; then # git remote not defined
|
if [ "$git_remote" = "" ]; then # git remote not defined
|
||||||
|
|
||||||
if [ "$GIT_TOKEN" = "" ]; then
|
if [ "$GIT_TOKEN" = "" ]; then
|
||||||
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git crediential in your environment."
|
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the Git credential in your environment."
|
||||||
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
|
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
|
||||||
else
|
else
|
||||||
git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
|
git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
(function(factory) {
|
(function(factory) {
|
||||||
if (typeof define === 'function' && define.amd) {
|
if (typeof define === 'function' && define.amd) {
|
||||||
// AMD. Register as an anonymous module.
|
// AMD. Register as an anonymous module.
|
||||||
define(['./ApiClient'{{#models}}, './{{#modelPackage}}{{modelPackage}}/{{/modelPackage}}{{importPath}}'{{/models}}{{#apiInfo}}{{#apis}}, './{{#apiPackage}}{{apiPackage}}/{{/apiPackage}}{{importPath}}'{{/apis}}{{/apiInfo}}], factory);
|
define(['{{#invokerPackage}}{{invokerPackage}}/{{/invokerPackage}}ApiClient'{{#models}}, '{{#invokerPackage}}{{invokerPackage}}/{{/invokerPackage}}{{#modelPackage}}{{modelPackage}}/{{/modelPackage}}{{importPath}}'{{/models}}{{#apiInfo}}{{#apis}}, '{{#invokerPackage}}{{invokerPackage}}/{{/invokerPackage}}{{#apiPackage}}{{apiPackage}}/{{/apiPackage}}{{importPath}}'{{/apis}}{{/apiInfo}}], factory);
|
||||||
} else if (typeof module === 'object' && module.exports) {
|
} else if (typeof module === 'object' && module.exports) {
|
||||||
// CommonJS-like environments that support module.exports, like Node.
|
// CommonJS-like environments that support module.exports, like Node.
|
||||||
module.exports = factory(require('./ApiClient'){{#models}}, require('./{{#modelPackage}}{{modelPackage}}/{{/modelPackage}}{{importPath}}'){{/models}}{{#apiInfo}}{{#apis}}, require('./{{#apiPackage}}{{apiPackage}}/{{/apiPackage}}{{importPath}}'){{/apis}}{{/apiInfo}});
|
module.exports = factory(require('./ApiClient'){{#models}}, require('./{{#modelPackage}}{{modelPackage}}/{{/modelPackage}}{{importPath}}'){{/models}}{{#apiInfo}}{{#apis}}, require('./{{#apiPackage}}{{apiPackage}}/{{/apiPackage}}{{importPath}}'){{/apis}}{{/apiInfo}});
|
||||||
@ -15,7 +15,7 @@
|
|||||||
* <p>
|
* <p>
|
||||||
* An AMD (recommended!) or CommonJS application will generally do something equivalent to the following:
|
* An AMD (recommended!) or CommonJS application will generally do something equivalent to the following:
|
||||||
* <pre>
|
* <pre>
|
||||||
* var {{moduleName}} = require('./index'); // See note below*.
|
* var {{moduleName}} = require('{{#invokerPackage}}{{invokerPackage}}/{{/invokerPackage}}index'); // See note below*.
|
||||||
* var xxxSvc = new {{moduleName}}.XxxApi(); // Allocate the API class we're going to use.
|
* var xxxSvc = new {{moduleName}}.XxxApi(); // Allocate the API class we're going to use.
|
||||||
* var yyyModel = new {{moduleName}}.Yyy(); // Construct a model instance.
|
* var yyyModel = new {{moduleName}}.Yyy(); // Construct a model instance.
|
||||||
* yyyModel.someProperty = 'someValue';
|
* yyyModel.someProperty = 'someValue';
|
||||||
@ -23,8 +23,8 @@
|
|||||||
* var zzz = xxxSvc.doSomething(yyyModel); // Invoke the service.
|
* var zzz = xxxSvc.doSomething(yyyModel); // Invoke the service.
|
||||||
* ...
|
* ...
|
||||||
* </pre>
|
* </pre>
|
||||||
* <em>*NOTE: For a top-level AMD script, use require(['./index'], function(){...}) and put the application logic within the
|
* <em>*NOTE: For a top-level AMD script, use require(['{{#invokerPackage}}{{invokerPackage}}/{{/invokerPackage}}index'], function(){...})
|
||||||
* callback function.</em>
|
* and put the application logic within the callback function.</em>
|
||||||
* </p>
|
* </p>
|
||||||
* <p>
|
* <p>
|
||||||
* A non-AMD browser application (discouraged) might do something like this:
|
* A non-AMD browser application (discouraged) might do something like this:
|
||||||
@ -37,23 +37,23 @@
|
|||||||
* ...
|
* ...
|
||||||
* </pre>
|
* </pre>
|
||||||
* </p>
|
* </p>
|
||||||
* @module index
|
* @module {{#invokerPackage}}{{invokerPackage}}/{{/invokerPackage}}index
|
||||||
* @version {{projectVersion}}
|
* @version {{projectVersion}}
|
||||||
*/{{/emitJSDoc}}
|
*/{{/emitJSDoc}}
|
||||||
{{=< >=}} var exports = {<#emitJSDoc>
|
{{=< >=}} var exports = {<#emitJSDoc>
|
||||||
/**
|
/**
|
||||||
* The ApiClient constructor.
|
* The ApiClient constructor.
|
||||||
* @property {module:ApiClient}
|
* @property {module:<#invokerPackage><invokerPackage>/</invokerPackage>ApiClient}
|
||||||
*/</emitJSDoc>
|
*/</emitJSDoc>
|
||||||
ApiClient: ApiClient<#models>,<#emitJSDoc>
|
ApiClient: ApiClient<#models>,<#emitJSDoc>
|
||||||
/**
|
/**
|
||||||
* The <importPath> model constructor.
|
* The <importPath> model constructor.
|
||||||
* @property {module:<#modelPackage><modelPackage>/</modelPackage><importPath>}
|
* @property {module:<#invokerPackage><invokerPackage>/</invokerPackage><#modelPackage><modelPackage>/</modelPackage><importPath>}
|
||||||
*/</emitJSDoc>
|
*/</emitJSDoc>
|
||||||
<importPath>: <importPath></models><#apiInfo><#apis>,<#emitJSDoc>
|
<importPath>: <importPath></models><#apiInfo><#apis>,<#emitJSDoc>
|
||||||
/**
|
/**
|
||||||
* The <importPath> service constructor.
|
* The <importPath> service constructor.
|
||||||
* @property {module:<#apiPackage><apiPackage>/</apiPackage><importPath>}
|
* @property {module:<#invokerPackage><invokerPackage>/</invokerPackage><#apiPackage><apiPackage>/</apiPackage><importPath>}
|
||||||
*/</emitJSDoc>
|
*/</emitJSDoc>
|
||||||
<importPath>: <importPath></apis></apiInfo>
|
<importPath>: <importPath></apis></apiInfo>
|
||||||
};
|
};
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
(function(root, factory) {
|
(function(root, factory) {
|
||||||
if (typeof define === 'function' && define.amd) {
|
if (typeof define === 'function' && define.amd) {
|
||||||
// AMD. Register as an anonymous module.
|
// AMD. Register as an anonymous module.
|
||||||
define(['../ApiClient'{{#imports}}, './{{import}}'{{/imports}}], factory);
|
define(['{{#invokerPackage}}{{invokerPackage}}/{{/invokerPackage}}ApiClient'{{#imports}}, '{{#invokerPackage}}{{invokerPackage}}/{{/invokerPackage}}{{#modelPackage}}{{modelPackage}}/{{/modelPackage}}{{import}}'{{/imports}}], factory);
|
||||||
} else if (typeof module === 'object' && module.exports) {
|
} else if (typeof module === 'object' && module.exports) {
|
||||||
// CommonJS-like environments that support module.exports, like Node.
|
// CommonJS-like environments that support module.exports, like Node.
|
||||||
module.exports = factory(require('../ApiClient'){{#imports}}, require('./{{import}}'){{/imports}});
|
module.exports = factory(require('../ApiClient'){{#imports}}, require('./{{import}}'){{/imports}});
|
||||||
@ -17,36 +17,41 @@
|
|||||||
|
|
||||||
{{#models}}{{#model}}{{#emitJSDoc}} /**
|
{{#models}}{{#model}}{{#emitJSDoc}} /**
|
||||||
* The {{classname}} model module.
|
* The {{classname}} model module.
|
||||||
* @module {{#modelPackage}}{{modelPackage}}/{{/modelPackage}}{{classname}}
|
* @module {{#invokerPackage}}{{invokerPackage}}/{{/invokerPackage}}{{#modelPackage}}{{modelPackage}}/{{/modelPackage}}{{classname}}
|
||||||
* @version {{projectVersion}}
|
* @version {{projectVersion}}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new <code>{{classname}}</code>.{{#description}}
|
* Constructs a new <code>{{classname}}</code>.{{#description}}
|
||||||
* {{description}}{{/description}}
|
* {{description}}{{/description}}
|
||||||
* @alias module:{{#modelPackage}}{{modelPackage}}/{{/modelPackage}}{{classname}}
|
* @alias module:{{#invokerPackage}}{{invokerPackage}}/{{/invokerPackage}}{{#modelPackage}}{{modelPackage}}/{{/modelPackage}}{{classname}}
|
||||||
* @class{{#useInheritance}}{{#parent}}
|
* @class{{#useInheritance}}{{#parent}}
|
||||||
* @extends module:{{#modelPackage}}{{modelPackage}}/{{/modelPackage}}{{parent}}{{/parent}}{{#interfaces}}
|
* @extends {{#parentModel}}module:{{#invokerPackage}}{{invokerPackage}}/{{/invokerPackage}}{{#modelPackage}}{{modelPackage}}/{{/modelPackage}}{{classname}}{{/parentModel}}{{^parentModel}}{{#vendorExtensions.x-isArray}}Array{{/vendorExtensions.x-isArray}}{{#vendorExtensions.x-isMap}}Object{{/vendorExtensions.x-isMap}}{{/parentModel}}{{/parent}}{{#interfaces}}
|
||||||
* @implements module:{{#modelPackage}}{{modelPackage}}/{{/modelPackage}}{{.}}{{/interfaces}}{{/useInheritance}}{{#vendorExtensions.x-all-required}}
|
* @implements module:{{#invokerPackage}}{{invokerPackage}}/{{/invokerPackage}}{{#modelPackage}}{{modelPackage}}/{{/modelPackage}}{{.}}{{/interfaces}}{{/useInheritance}}{{#vendorExtensions.x-all-required}}
|
||||||
* @param {{.}}{{/vendorExtensions.x-all-required}}
|
* @param {{.}}{{/vendorExtensions.x-all-required}}
|
||||||
*/{{/emitJSDoc}}
|
*/
|
||||||
var exports = function({{#vendorExtensions.x-all-required}}{{.}}{{^-last}}, {{/-last}}{{/vendorExtensions.x-all-required}}) {
|
{{/emitJSDoc}} var exports = function({{#vendorExtensions.x-all-required}}{{.}}{{^-last}}, {{/-last}}{{/vendorExtensions.x-all-required}}) {
|
||||||
{{#useInheritance}}{{#parentModel}} {{classname}}.call(this{{#vendorExtensions.x-all-required}}, {{.}}{{/vendorExtensions.x-all-required}});{{/parentModel}}
|
var _this = this;
|
||||||
{{#interfaceModels}} {{classname}}.call(this{{#vendorExtensions.x-all-required}}, {{.}}{{/vendorExtensions.x-all-required}});
|
{{#parent}}{{^parentModel}}{{#vendorExtensions.x-isArray}} _this = new Array();
|
||||||
{{/interfaceModels}}{{/useInheritance}}{{#vars}}{{#required}} this['{{baseName}}'] = {{name}};{{/required}}
|
Object.setPrototypeOf(_this, exports);
|
||||||
{{/vars}} };
|
{{/vendorExtensions.x-isArray}}{{/parentModel}}{{/parent}}{{#useInheritance}}{{#parentModel}} {{classname}}.call(_this{{#vendorExtensions.x-all-required}}, {{.}}{{/vendorExtensions.x-all-required}});{{/parentModel}}
|
||||||
|
{{#interfaceModels}} {{classname}}.call(_this{{#vendorExtensions.x-all-required}}, {{.}}{{/vendorExtensions.x-all-required}});
|
||||||
|
{{/interfaceModels}}{{/useInheritance}}{{#vars}}{{#required}} _this['{{baseName}}'] = {{name}};{{/required}}
|
||||||
|
{{/vars}}{{#parent}}{{^parentModel}} return _this;
|
||||||
|
{{/parentModel}}{{/parent}} };
|
||||||
|
|
||||||
{{#emitJSDoc}} /**
|
{{#emitJSDoc}} /**
|
||||||
* Constructs a <code>{{classname}}</code> from a plain JavaScript object, optionally creating a new instance.
|
* Constructs a <code>{{classname}}</code> from a plain JavaScript object, optionally creating a new instance.
|
||||||
* Copies all relevant properties from <code>data</code> to <code>obj</code> if supplied or a new instance if not.
|
* Copies all relevant properties from <code>data</code> to <code>obj</code> if supplied or a new instance if not.
|
||||||
* @param {Object} data The plain JavaScript object bearing properties of interest.
|
* @param {Object} data The plain JavaScript object bearing properties of interest.
|
||||||
* @param {{=< >=}}{module:<#modelPackage><modelPackage>/</modelPackage><classname>}<={{ }}=> obj Optional instance to populate.
|
* @param {{=< >=}}{module:<#invokerPackage><invokerPackage>/</invokerPackage><#modelPackage><modelPackage>/</modelPackage><classname>}<={{ }}=> obj Optional instance to populate.
|
||||||
* @return {{=< >=}}{module:<#modelPackage><modelPackage>/</modelPackage><classname>}<={{ }}=> The populated <code>{{classname}}</code> instance.
|
* @return {{=< >=}}{module:<#invokerPackage><invokerPackage>/</invokerPackage><#modelPackage><modelPackage>/</modelPackage><classname>}<={{ }}=> The populated <code>{{classname}}</code> instance.
|
||||||
*/
|
*/
|
||||||
{{/emitJSDoc}} exports.constructFromObject = function(data, obj) {
|
{{/emitJSDoc}} exports.constructFromObject = function(data, obj) {
|
||||||
if (data) { {{!// TODO: support polymorphism: discriminator property on data determines class to instantiate.}}
|
if (data){{! TODO: support polymorphism: discriminator property on data determines class to instantiate.}} {
|
||||||
obj = obj || new exports();
|
obj = obj || new exports();
|
||||||
{{#useInheritance}}{{#parent}} {{.}}.constructFromObject(data, obj);{{/parent}}
|
{{#parent}}{{^parentModel}} ApiClient.constructFromObject(data, obj, {{vendorExtensions.x-itemType}});
|
||||||
|
{{/parentModel}}{{/parent}}{{#useInheritance}}{{#parentModel}} {{classname}}.constructFromObject(data, obj);{{/parentModel}}
|
||||||
{{#interfaces}} {{.}}.constructFromObject(data, obj);
|
{{#interfaces}} {{.}}.constructFromObject(data, obj);
|
||||||
{{/interfaces}}{{/useInheritance}}{{#vars}} if (data.hasOwnProperty('{{baseName}}')) {
|
{{/interfaces}}{{/useInheritance}}{{#vars}} if (data.hasOwnProperty('{{baseName}}')) {
|
||||||
obj['{{baseName}}']{{{defaultValueWithParam}}}
|
obj['{{baseName}}']{{{defaultValueWithParam}}}
|
||||||
@ -54,10 +59,10 @@
|
|||||||
{{/vars}} }
|
{{/vars}} }
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
{{#useInheritance}}{{#parent}}
|
{{#useInheritance}}{{#parentModel}}
|
||||||
exports.prototype = Object.create({{parent}}.prototype);
|
exports.prototype = Object.create({{classname}}.prototype);
|
||||||
exports.prototype.constructor = exports;
|
exports.prototype.constructor = exports;
|
||||||
{{/parent}}{{/useInheritance}}
|
{{/parentModel}}{{/useInheritance}}
|
||||||
{{#vars}}{{#emitJSDoc}}
|
{{#vars}}{{#emitJSDoc}}
|
||||||
/**{{#description}}
|
/**{{#description}}
|
||||||
* {{{description}}}{{/description}}
|
* {{{description}}}{{/description}}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
"version": "{{{projectVersion}}}",
|
"version": "{{{projectVersion}}}",
|
||||||
"description": "{{{projectDescription}}}",{{#projectLicenseName}}
|
"description": "{{{projectDescription}}}",{{#projectLicenseName}}
|
||||||
"license": "{{{projectLicenseName}}}",{{/projectLicenseName}}
|
"license": "{{{projectLicenseName}}}",{{/projectLicenseName}}
|
||||||
"main": "{{sourceFolder}}/index.js",
|
"main": "{{sourceFolder}}{{#invokerPackage}}/{{invokerPackage}}{{/invokerPackage}}/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "./node_modules/mocha/bin/mocha --recursive"
|
"test": "./node_modules/mocha/bin/mocha --recursive"
|
||||||
},
|
},
|
||||||
|
@ -40,14 +40,14 @@ export namespace {{classname}} {
|
|||||||
{{/model}}
|
{{/model}}
|
||||||
{{/models}}
|
{{/models}}
|
||||||
|
|
||||||
interface Authentication {
|
export interface Authentication {
|
||||||
/**
|
/**
|
||||||
* Apply authentication settings to header and query params.
|
* Apply authentication settings to header and query params.
|
||||||
*/
|
*/
|
||||||
applyToRequest(requestOptions: request.Options): void;
|
applyToRequest(requestOptions: request.Options): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
class HttpBasicAuth implements Authentication {
|
export class HttpBasicAuth implements Authentication {
|
||||||
public username: string;
|
public username: string;
|
||||||
public password: string;
|
public password: string;
|
||||||
applyToRequest(requestOptions: request.Options): void {
|
applyToRequest(requestOptions: request.Options): void {
|
||||||
@ -57,7 +57,7 @@ class HttpBasicAuth implements Authentication {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ApiKeyAuth implements Authentication {
|
export class ApiKeyAuth implements Authentication {
|
||||||
public apiKey: string;
|
public apiKey: string;
|
||||||
|
|
||||||
constructor(private location: string, private paramName: string) {
|
constructor(private location: string, private paramName: string) {
|
||||||
@ -72,7 +72,7 @@ class ApiKeyAuth implements Authentication {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class OAuth implements Authentication {
|
export class OAuth implements Authentication {
|
||||||
public accessToken: string;
|
public accessToken: string;
|
||||||
|
|
||||||
applyToRequest(requestOptions: request.Options): void {
|
applyToRequest(requestOptions: request.Options): void {
|
||||||
@ -80,7 +80,7 @@ class OAuth implements Authentication {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class VoidAuth implements Authentication {
|
export class VoidAuth implements Authentication {
|
||||||
public username: string;
|
public username: string;
|
||||||
public password: string;
|
public password: string;
|
||||||
applyToRequest(requestOptions: request.Options): void {
|
applyToRequest(requestOptions: request.Options): void {
|
||||||
|
@ -4,7 +4,6 @@ package {{packageName}}
|
|||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
"fmt"
|
"fmt"
|
||||||
"encoding/json"
|
|
||||||
"errors"
|
"errors"
|
||||||
{{#imports}} "{{import}}"
|
{{#imports}} "{{import}}"
|
||||||
{{/imports}}
|
{{/imports}}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package swagger
|
package {{packageName}}
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -122,7 +122,37 @@ use \{{invokerPackage}}\ObjectSerializer;
|
|||||||
// verify the required parameter '{{paramName}}' is set
|
// verify the required parameter '{{paramName}}' is set
|
||||||
if (${{paramName}} === null) {
|
if (${{paramName}} === null) {
|
||||||
throw new \InvalidArgumentException('Missing the required parameter ${{paramName}} when calling {{operationId}}');
|
throw new \InvalidArgumentException('Missing the required parameter ${{paramName}} when calling {{operationId}}');
|
||||||
}{{/required}}{{/allParams}}
|
}
|
||||||
|
{{/required}}
|
||||||
|
{{#hasValidation}}
|
||||||
|
{{#maxLength}}
|
||||||
|
if (strlen(${{paramName}}) > {{maxLength}}) {
|
||||||
|
throw new \InvalidArgumentException('invalid length for "${{paramName}}" when calling {{classname}}.{{operationId}}, must be smaller than or equal to {{maxLength}}.');
|
||||||
|
}
|
||||||
|
{{/maxLength}}
|
||||||
|
{{#minLength}}
|
||||||
|
if (strlen(${{paramName}}) > {{minLength}}) {
|
||||||
|
throw new \InvalidArgumentException('invalid length for "${{paramName}}" when calling {{classname}}.{{operationId}}, must be bigger than or equal to {{minLength}}.');
|
||||||
|
}
|
||||||
|
{{/minLength}}
|
||||||
|
{{#maximum}}
|
||||||
|
if (${{paramName}} > {{maximum}}) {
|
||||||
|
throw new \InvalidArgumentException('invalid value for "${{paramName}}" when calling {{classname}}.{{operationId}}, must be smaller than or equal to {{maximum}}.');
|
||||||
|
}
|
||||||
|
{{/maximum}}
|
||||||
|
{{#minimum}}
|
||||||
|
if (${{paramName}} < {{minimum}}) {
|
||||||
|
throw new \InvalidArgumentException('invalid value for "${{paramName}}" when calling {{classname}}.{{operationId}}, must be bigger than or equal to {{minimum}}.');
|
||||||
|
}
|
||||||
|
{{/minimum}}
|
||||||
|
{{#pattern}}
|
||||||
|
if (!preg_match("{{pattern}}", ${{paramName}})) {
|
||||||
|
throw new \InvalidArgumentException('invalid value for "{{paramName}}" when calling {{classname}}.{{operationId}}, must conform to the pattern {{pattern}}.');
|
||||||
|
}
|
||||||
|
{{/pattern}}
|
||||||
|
|
||||||
|
{{/hasValidation}}
|
||||||
|
{{/allParams}}
|
||||||
|
|
||||||
// parse inputs
|
// parse inputs
|
||||||
$resourcePath = "{{path}}";
|
$resourcePath = "{{path}}";
|
||||||
|
@ -0,0 +1,54 @@
|
|||||||
|
# coding: utf-8
|
||||||
|
|
||||||
|
"""
|
||||||
|
Copyright 2016 SmartBear Software
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
ref: https://github.com/swagger-api/swagger-codegen
|
||||||
|
"""
|
||||||
|
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
import swagger_client
|
||||||
|
from swagger_client.rest import ApiException
|
||||||
|
from swagger_client.apis.{{classVarName}} import {{classname}}
|
||||||
|
|
||||||
|
|
||||||
|
class {{#operations}}Test{{classname}}(unittest.TestCase):
|
||||||
|
""" {{classname}} unit test stubs """
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
self.api = swagger_client.apis.{{classVarName}}.{{classname}}()
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
{{#operation}}
|
||||||
|
def test_{{operationId}}(self):
|
||||||
|
"""
|
||||||
|
Test case for {{{operationId}}}
|
||||||
|
|
||||||
|
{{{summary}}}
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
{{/operation}}
|
||||||
|
{{/operations}}
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
@ -0,0 +1,53 @@
|
|||||||
|
# coding: utf-8
|
||||||
|
|
||||||
|
"""
|
||||||
|
Copyright 2016 SmartBear Software
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
ref: https://github.com/swagger-api/swagger-codegen
|
||||||
|
"""
|
||||||
|
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
{{#models}}
|
||||||
|
{{#model}}
|
||||||
|
import swagger_client
|
||||||
|
from swagger_client.rest import ApiException
|
||||||
|
from swagger_client.models.{{classFilename}} import {{classname}}
|
||||||
|
|
||||||
|
|
||||||
|
class Test{{classname}}(unittest.TestCase):
|
||||||
|
""" {{classname}} unit test stubs """
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def test{{classname}}(self):
|
||||||
|
"""
|
||||||
|
Test {{classname}}
|
||||||
|
"""
|
||||||
|
model = swagger_client.models.{{classFilename}}.{{classname}}()
|
||||||
|
|
||||||
|
{{/model}}
|
||||||
|
{{/models}}
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
@ -38,7 +38,7 @@ module {{moduleName}}{{#models}}{{#model}}{{#description}}
|
|||||||
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
||||||
|
|
||||||
{{#vars}}
|
{{#vars}}
|
||||||
if attributes[:'{{{baseName}}}']
|
if attributes.has_key?(:'{{{baseName}}}')
|
||||||
{{#isContainer}}
|
{{#isContainer}}
|
||||||
if (value = attributes[:'{{{baseName}}}']).is_a?(Array)
|
if (value = attributes[:'{{{baseName}}}']).is_a?(Array)
|
||||||
self.{{{name}}} = value
|
self.{{{name}}} = value
|
||||||
|
@ -137,9 +137,22 @@ class Decoders {
|
|||||||
// Decoder for {{{classname}}}
|
// Decoder for {{{classname}}}
|
||||||
Decoders.addDecoder(clazz: {{{classname}}}.self) { (source: AnyObject) -> {{{classname}}} in
|
Decoders.addDecoder(clazz: {{{classname}}}.self) { (source: AnyObject) -> {{{classname}}} in
|
||||||
let sourceDictionary = source as! [NSObject:AnyObject]
|
let sourceDictionary = source as! [NSObject:AnyObject]
|
||||||
|
{{#unwrapRequired}}
|
||||||
|
let instance = {{classname}}({{#requiredVars}}{{^-first}}, {{/-first}}{{#isEnum}}{{name}}: {{classname}}.{{datatypeWithEnum}}(rawValue: (sourceDictionary["{{baseName}}"] as? String) ?? "")! {{/isEnum}}{{^isEnum}}{{name}}: Decoders.decode(clazz: {{{baseType}}}.self, source: sourceDictionary["{{baseName}}"]!){{/isEnum}}{{/requiredVars}})
|
||||||
|
{{#optionalVars}}
|
||||||
|
{{#isEnum}}
|
||||||
|
instance.{{name}} = {{classname}}.{{datatypeWithEnum}}(rawValue: (sourceDictionary["{{baseName}}"] as? String) ?? "")
|
||||||
|
{{/isEnum}}
|
||||||
|
{{^isEnum}}
|
||||||
|
instance.{{name}} = Decoders.decodeOptional(clazz: {{{baseType}}}.self, source: sourceDictionary["{{baseName}}"])
|
||||||
|
{{/isEnum}}
|
||||||
|
{{/optionalVars}}
|
||||||
|
{{/unwrapRequired}}
|
||||||
|
{{^unwrapRequired}}
|
||||||
let instance = {{classname}}(){{#vars}}{{#isEnum}}
|
let instance = {{classname}}(){{#vars}}{{#isEnum}}
|
||||||
instance.{{name}} = {{classname}}.{{datatypeWithEnum}}(rawValue: (sourceDictionary["{{baseName}}"] as? String) ?? ""){{#unwrapRequired}}{{#required}}!{{/required}}{{/unwrapRequired}} {{/isEnum}}{{^isEnum}}
|
instance.{{name}} = {{classname}}.{{datatypeWithEnum}}(rawValue: (sourceDictionary["{{baseName}}"] as? String) ?? "") {{/isEnum}}{{^isEnum}}
|
||||||
instance.{{name}} = Decoders.decode{{^unwrapRequired}}Optional{{/unwrapRequired}}{{#unwrapRequired}}{{^required}}Optional{{/required}}{{/unwrapRequired}}(clazz: {{{baseType}}}.self, source: sourceDictionary["{{baseName}}"]{{#unwrapRequired}}{{#required}}!{{/required}}{{/unwrapRequired}}){{/isEnum}}{{/vars}}
|
instance.{{name}} = Decoders.decodeOptional(clazz: {{{baseType}}}.self, source: sourceDictionary["{{baseName}}"]){{/isEnum}}{{/vars}}
|
||||||
|
{{/unwrapRequired}}
|
||||||
return instance
|
return instance
|
||||||
}{{/model}}
|
}{{/model}}
|
||||||
{{/models}}
|
{{/models}}
|
||||||
|
@ -21,15 +21,24 @@ public class {{classname}}: JSONEncodable {
|
|||||||
{{#vars}}
|
{{#vars}}
|
||||||
{{#isEnum}}
|
{{#isEnum}}
|
||||||
{{#description}}/** {{description}} */
|
{{#description}}/** {{description}} */
|
||||||
{{/description}}public var {{name}}: {{{datatypeWithEnum}}}{{^unwrapRequired}}?{{/unwrapRequired}}{{#unwrapRequired}}{{^required}}?{{/required}}{{#required}}!{{/required}}{{/unwrapRequired}}{{#defaultValue}} = {{{defaultValue}}}{{/defaultValue}}
|
{{/description}}public var {{name}}: {{{datatypeWithEnum}}}{{^unwrapRequired}}?{{/unwrapRequired}}{{#unwrapRequired}}{{^required}}?{{/required}}{{/unwrapRequired}}{{#defaultValue}} = {{{defaultValue}}}{{/defaultValue}}
|
||||||
{{/isEnum}}
|
{{/isEnum}}
|
||||||
{{^isEnum}}
|
{{^isEnum}}
|
||||||
{{#description}}/** {{description}} */
|
{{#description}}/** {{description}} */
|
||||||
{{/description}}public var {{name}}: {{{datatype}}}{{^unwrapRequired}}?{{/unwrapRequired}}{{#unwrapRequired}}{{^required}}?{{/required}}{{#required}}!{{/required}}{{/unwrapRequired}}{{#defaultValue}} = {{{defaultValue}}}{{/defaultValue}}
|
{{/description}}public var {{name}}: {{{datatype}}}{{^unwrapRequired}}?{{/unwrapRequired}}{{#unwrapRequired}}{{^required}}?{{/required}}{{/unwrapRequired}}{{#defaultValue}} = {{{defaultValue}}}{{/defaultValue}}
|
||||||
{{/isEnum}}
|
{{/isEnum}}
|
||||||
{{/vars}}
|
{{/vars}}
|
||||||
|
|
||||||
|
{{^unwrapRequired}}
|
||||||
public init() {}
|
public init() {}
|
||||||
|
{{/unwrapRequired}}
|
||||||
|
{{#unwrapRequired}}
|
||||||
|
public init({{#requiredVars}}{{^-first}}, {{/-first}}{{name}}: {{#isEnum}}{{datatypeWithEnum}}!{{/isEnum}}{{^isEnum}}{{datatype}}!{{/isEnum}}{{/requiredVars}}) {
|
||||||
|
{{#requiredVars}}
|
||||||
|
self.{{name}} = {{name}}
|
||||||
|
{{/requiredVars}}
|
||||||
|
}
|
||||||
|
{{/unwrapRequired}}
|
||||||
|
|
||||||
// MARK: JSONEncodable
|
// MARK: JSONEncodable
|
||||||
func encodeToJSON() -> AnyObject {
|
func encodeToJSON() -> AnyObject {
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
"name": "{{npmName}}",
|
"name": "{{npmName}}",
|
||||||
"version": "{{npmVersion}}",
|
"version": "{{npmVersion}}",
|
||||||
"description": "swagger client for {{npmName}}",
|
"description": "swagger client for {{npmName}}",
|
||||||
|
"author": "Swagger Codegen Contributors",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"swagger-client"
|
"swagger-client"
|
||||||
],
|
],
|
||||||
@ -31,5 +32,4 @@
|
|||||||
"registry":"{{npmRepository}}"
|
"registry":"{{npmRepository}}"
|
||||||
}
|
}
|
||||||
{{/npmRepository}}
|
{{/npmRepository}}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,4 +2,4 @@
|
|||||||
"ambientDependencies": {
|
"ambientDependencies": {
|
||||||
"core-js": "registry:dt/core-js#0.0.0+20160317120654"
|
"core-js": "registry:dt/core-js#0.0.0+20160317120654"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"name": "{{npmName}}",
|
||||||
|
"version": "{{npmVersion}}",
|
||||||
|
"description": "NodeJS client for {{npmName}}",
|
||||||
|
"main": "api.js",
|
||||||
|
"scripts": {
|
||||||
|
"build": "typings install && tsc"
|
||||||
|
},
|
||||||
|
"author": "Swagger Codegen Contributors",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"bluebird": "^3.3.5",
|
||||||
|
"request": "^2.72.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"typescript": "^1.8.10",
|
||||||
|
"typings": "^0.8.1"
|
||||||
|
}{{#npmRepository}},
|
||||||
|
"publishConfig":{
|
||||||
|
"registry":"{{npmRepository}}"
|
||||||
|
}{{/npmRepository}}
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"module": "commonjs",
|
||||||
|
"noImplicitAny": false,
|
||||||
|
"suppressImplicitAnyIndexErrors": true,
|
||||||
|
"target": "ES5",
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"removeComments": true,
|
||||||
|
"sourceMap": true,
|
||||||
|
"noLib": false,
|
||||||
|
"declaration": true
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"api.ts",
|
||||||
|
"typings/main.d.ts"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"ambientDependencies": {
|
||||||
|
"bluebird": "registry:dt/bluebird#2.0.0+20160319051630",
|
||||||
|
"core-js": "registry:dt/core-js#0.0.0+20160317120654",
|
||||||
|
"node": "registry:dt/node#4.0.0+20160423143914"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"request": "registry:npm/request#2.69.0+20160304121250"
|
||||||
|
}
|
||||||
|
}
|
@ -30,6 +30,8 @@ public class JavaScriptClientOptionsTest extends AbstractOptionsTest {
|
|||||||
protected void setExpectations() {
|
protected void setExpectations() {
|
||||||
// Commented generic options not yet supported by JavaScript codegen.
|
// Commented generic options not yet supported by JavaScript codegen.
|
||||||
new Expectations(clientCodegen) {{
|
new Expectations(clientCodegen) {{
|
||||||
|
clientCodegen.setInvokerPackage(JavaScriptOptionsProvider.INVOKER_PACKAGE_VALUE);
|
||||||
|
times = 1;
|
||||||
clientCodegen.setModelPackage(JavaScriptOptionsProvider.MODEL_PACKAGE_VALUE);
|
clientCodegen.setModelPackage(JavaScriptOptionsProvider.MODEL_PACKAGE_VALUE);
|
||||||
times = 1;
|
times = 1;
|
||||||
clientCodegen.setApiPackage(JavaScriptOptionsProvider.API_PACKAGE_VALUE);
|
clientCodegen.setApiPackage(JavaScriptOptionsProvider.API_PACKAGE_VALUE);
|
||||||
|
@ -10,9 +10,9 @@ import java.util.Map;
|
|||||||
|
|
||||||
public class JavaScriptOptionsProvider implements OptionsProvider {
|
public class JavaScriptOptionsProvider implements OptionsProvider {
|
||||||
public static final String ARTIFACT_ID_VALUE = "swagger-javascript-client-test";
|
public static final String ARTIFACT_ID_VALUE = "swagger-javascript-client-test";
|
||||||
|
public static final String INVOKER_PACKAGE_VALUE = "invoker";
|
||||||
public static final String MODEL_PACKAGE_VALUE = "model";
|
public static final String MODEL_PACKAGE_VALUE = "model";
|
||||||
public static final String API_PACKAGE_VALUE = "api";
|
public static final String API_PACKAGE_VALUE = "api";
|
||||||
// public static final String INVOKER_PACKAGE_VALUE = "js";
|
|
||||||
public static final String SORT_PARAMS_VALUE = "false";
|
public static final String SORT_PARAMS_VALUE = "false";
|
||||||
public static final String GROUP_ID_VALUE = "io.swagger.test";
|
public static final String GROUP_ID_VALUE = "io.swagger.test";
|
||||||
public static final String ARTIFACT_VERSION_VALUE = "1.0.0-SNAPSHOT";
|
public static final String ARTIFACT_VERSION_VALUE = "1.0.0-SNAPSHOT";
|
||||||
@ -38,11 +38,11 @@ public class JavaScriptOptionsProvider implements OptionsProvider {
|
|||||||
public JavaScriptOptionsProvider() {
|
public JavaScriptOptionsProvider() {
|
||||||
// Commented generic options not yet supported by JavaScript codegen.
|
// Commented generic options not yet supported by JavaScript codegen.
|
||||||
options = new ImmutableMap.Builder<String, String>()
|
options = new ImmutableMap.Builder<String, String>()
|
||||||
|
.put(CodegenConstants.INVOKER_PACKAGE, INVOKER_PACKAGE_VALUE)
|
||||||
.put(CodegenConstants.MODEL_PACKAGE, MODEL_PACKAGE_VALUE)
|
.put(CodegenConstants.MODEL_PACKAGE, MODEL_PACKAGE_VALUE)
|
||||||
.put(CodegenConstants.API_PACKAGE, API_PACKAGE_VALUE)
|
.put(CodegenConstants.API_PACKAGE, API_PACKAGE_VALUE)
|
||||||
.put(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG, SORT_PARAMS_VALUE)
|
.put(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG, SORT_PARAMS_VALUE)
|
||||||
.put(CodegenConstants.ENSURE_UNIQUE_PARAMS, ENSURE_UNIQUE_PARAMS_VALUE)
|
.put(CodegenConstants.ENSURE_UNIQUE_PARAMS, ENSURE_UNIQUE_PARAMS_VALUE)
|
||||||
// .put(CodegenConstants.INVOKER_PACKAGE, INVOKER_PACKAGE_VALUE)
|
|
||||||
// .put(CodegenConstants.GROUP_ID, GROUP_ID_VALUE)
|
// .put(CodegenConstants.GROUP_ID, GROUP_ID_VALUE)
|
||||||
// .put(CodegenConstants.ARTIFACT_ID, ARTIFACT_ID_VALUE)
|
// .put(CodegenConstants.ARTIFACT_ID, ARTIFACT_ID_VALUE)
|
||||||
// .put(CodegenConstants.ARTIFACT_VERSION, ARTIFACT_VERSION_VALUE)
|
// .put(CodegenConstants.ARTIFACT_VERSION, ARTIFACT_VERSION_VALUE)
|
||||||
|
@ -10,8 +10,8 @@ import io.swagger.codegen.languages.TypeScriptAngular2ClientCodegen;
|
|||||||
public class TypeScriptAngular2ClientOptionsProvider implements OptionsProvider {
|
public class TypeScriptAngular2ClientOptionsProvider implements OptionsProvider {
|
||||||
public static final String SORT_PARAMS_VALUE = "false";
|
public static final String SORT_PARAMS_VALUE = "false";
|
||||||
public static final String ENSURE_UNIQUE_PARAMS_VALUE = "true";
|
public static final String ENSURE_UNIQUE_PARAMS_VALUE = "true";
|
||||||
public static final String MODEL_PROPERTY_NAMING_VALUE = "camelCase";
|
private static final String MODEL_PROPERTY_NAMING_VALUE = "camelCase";
|
||||||
public static final String NMP_NAME = "npmName";
|
private static final String NMP_NAME = "npmName";
|
||||||
private static final String NMP_VERSION = "1.1.2";
|
private static final String NMP_VERSION = "1.1.2";
|
||||||
private static final String NPM_REPOSITORY = "https://registry.npmjs.org";
|
private static final String NPM_REPOSITORY = "https://registry.npmjs.org";
|
||||||
|
|
||||||
|
@ -1,16 +1,22 @@
|
|||||||
package io.swagger.codegen.options;
|
package io.swagger.codegen.options;
|
||||||
|
|
||||||
import io.swagger.codegen.CodegenConstants;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import io.swagger.codegen.CodegenConstants;
|
||||||
|
import io.swagger.codegen.languages.TypeScriptAngular2ClientCodegen;
|
||||||
|
|
||||||
|
|
||||||
public class TypeScriptNodeClientOptionsProvider implements OptionsProvider {
|
public class TypeScriptNodeClientOptionsProvider implements OptionsProvider {
|
||||||
public static final String SORT_PARAMS_VALUE = "false";
|
public static final String SORT_PARAMS_VALUE = "false";
|
||||||
public static final String ENSURE_UNIQUE_PARAMS_VALUE = "true";
|
public static final String ENSURE_UNIQUE_PARAMS_VALUE = "true";
|
||||||
public static final String MODEL_PROPERTY_NAMING_VALUE = "camelCase";
|
public static final String MODEL_PROPERTY_NAMING_VALUE = "camelCase";
|
||||||
|
|
||||||
|
private static final String NMP_NAME = "npmName";
|
||||||
|
private static final String NMP_VERSION = "1.1.2";
|
||||||
|
private static final String NPM_REPOSITORY = "https://registry.npmjs.org";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getLanguage() {
|
public String getLanguage() {
|
||||||
return "typescript-node";
|
return "typescript-node";
|
||||||
@ -22,6 +28,10 @@ public class TypeScriptNodeClientOptionsProvider implements OptionsProvider {
|
|||||||
return builder.put(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG, SORT_PARAMS_VALUE)
|
return builder.put(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG, SORT_PARAMS_VALUE)
|
||||||
.put(CodegenConstants.ENSURE_UNIQUE_PARAMS, ENSURE_UNIQUE_PARAMS_VALUE)
|
.put(CodegenConstants.ENSURE_UNIQUE_PARAMS, ENSURE_UNIQUE_PARAMS_VALUE)
|
||||||
.put(CodegenConstants.MODEL_PROPERTY_NAMING, MODEL_PROPERTY_NAMING_VALUE)
|
.put(CodegenConstants.MODEL_PROPERTY_NAMING, MODEL_PROPERTY_NAMING_VALUE)
|
||||||
|
.put(TypeScriptAngular2ClientCodegen.NPM_NAME, NMP_NAME)
|
||||||
|
.put(TypeScriptAngular2ClientCodegen.NPM_VERSION, NMP_VERSION)
|
||||||
|
.put(TypeScriptAngular2ClientCodegen.SNAPSHOT, Boolean.FALSE.toString())
|
||||||
|
.put(TypeScriptAngular2ClientCodegen.NPM_REPOSITORY, NPM_REPOSITORY)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -590,6 +590,7 @@ paths:
|
|||||||
in: formData
|
in: formData
|
||||||
description: None
|
description: None
|
||||||
- name: number
|
- name: number
|
||||||
|
type: number
|
||||||
maximum: 543.2
|
maximum: 543.2
|
||||||
minimum: 32.1
|
minimum: 32.1
|
||||||
in: formData
|
in: formData
|
||||||
@ -890,6 +891,9 @@ definitions:
|
|||||||
dateTime:
|
dateTime:
|
||||||
type: string
|
type: string
|
||||||
format: date-time
|
format: date-time
|
||||||
|
uuid:
|
||||||
|
type: string
|
||||||
|
format: uuid
|
||||||
password:
|
password:
|
||||||
type: string
|
type: string
|
||||||
format: password
|
format: password
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# Go API client for swagger
|
# Go API client for petstore
|
||||||
|
|
||||||
This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.
|
This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
|
||||||
@ -7,13 +7,13 @@ This API client was generated by the [swagger-codegen](https://github.com/swagge
|
|||||||
|
|
||||||
- API version: 1.0.0
|
- API version: 1.0.0
|
||||||
- Package version: 1.0.0
|
- Package version: 1.0.0
|
||||||
- Build date: 2016-04-23T17:00:49.475-07:00
|
- Build date: 2016-04-27T21:14:49.805-07:00
|
||||||
- Build package: class io.swagger.codegen.languages.GoClientCodegen
|
- Build package: class io.swagger.codegen.languages.GoClientCodegen
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
Put the package under your project folder and add the following in import:
|
Put the package under your project folder and add the following in import:
|
||||||
```
|
```
|
||||||
"./swagger"
|
"./petstore"
|
||||||
```
|
```
|
||||||
|
|
||||||
## Documentation for API Endpoints
|
## Documentation for API Endpoints
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package swagger
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package swagger
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package swagger
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
)
|
)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package swagger
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package swagger
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
)
|
)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package swagger
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package swagger
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
)
|
)
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
package swagger
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
"fmt"
|
"fmt"
|
||||||
"encoding/json"
|
|
||||||
"errors"
|
"errors"
|
||||||
"os"
|
"os"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"encoding/json"
|
||||||
)
|
)
|
||||||
|
|
||||||
type PetApi struct {
|
type PetApi struct {
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
<project>
|
<project>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.wordnik</groupId>
|
<groupId>com.wordnik</groupId>
|
||||||
<artifactId>Goswagger</artifactId>
|
<artifactId>Gopetstore</artifactId>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<version>1.0.0</version>
|
<version>1.0.0</version>
|
||||||
<name>Goswagger</name>
|
<name>Gopetstore</name>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package swagger
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
"fmt"
|
"fmt"
|
||||||
"encoding/json"
|
|
||||||
"errors"
|
"errors"
|
||||||
|
"encoding/json"
|
||||||
)
|
)
|
||||||
|
|
||||||
type StoreApi struct {
|
type StoreApi struct {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package swagger
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
)
|
)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package swagger
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
)
|
)
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package swagger
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
"fmt"
|
"fmt"
|
||||||
"encoding/json"
|
|
||||||
"errors"
|
"errors"
|
||||||
|
"encoding/json"
|
||||||
)
|
)
|
||||||
|
|
||||||
type UserApi struct {
|
type UserApi struct {
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
<execution>
|
<execution>
|
||||||
<id>go-get-sling</id>
|
<id>go-get-resty</id>
|
||||||
<phase>pre-integration-test</phase>
|
<phase>pre-integration-test</phase>
|
||||||
<goals>
|
<goals>
|
||||||
<goal>exec</goal>
|
<goal>exec</goal>
|
||||||
@ -50,7 +50,7 @@
|
|||||||
<executable>go</executable>
|
<executable>go</executable>
|
||||||
<arguments>
|
<arguments>
|
||||||
<argument>get</argument>
|
<argument>get</argument>
|
||||||
<argument>github.com/dghubble/sling</argument>
|
<argument>github.com/go-resty/resty</argument>
|
||||||
</arguments>
|
</arguments>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
|
@ -22,7 +22,7 @@ func main() {
|
|||||||
s.UpdatePetWithForm(12830, "golang", "available")
|
s.UpdatePetWithForm(12830, "golang", "available")
|
||||||
|
|
||||||
// test GET
|
// test GET
|
||||||
resp, err, apiResponse := s.GetPetById(12830)
|
resp, apiResponse, err := s.GetPetById(12830)
|
||||||
fmt.Println("GetPetById: ", resp, err, apiResponse)
|
fmt.Println("GetPetById: ", resp, err, apiResponse)
|
||||||
|
|
||||||
err2, apiResponse2 := s.DeletePet(12830, "")
|
err2, apiResponse2 := s.DeletePet(12830, "")
|
@ -95,8 +95,7 @@ if(hasProperty('target') && target == 'android') {
|
|||||||
|
|
||||||
ext {
|
ext {
|
||||||
oltu_version = "1.0.1"
|
oltu_version = "1.0.1"
|
||||||
retrofit_version = "2.0.0-beta4"
|
retrofit_version = "2.0.2"
|
||||||
gson_version = "2.6.2"
|
|
||||||
swagger_annotations_version = "1.5.8"
|
swagger_annotations_version = "1.5.8"
|
||||||
junit_version = "4.12"
|
junit_version = "4.12"
|
||||||
|
|
||||||
|
@ -1 +0,0 @@
|
|||||||
Hello world!
|
|
@ -100,8 +100,7 @@
|
|||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>2.3.2</version>
|
<version>2.3.2</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>
|
<source>1.7</source>
|
||||||
1.7</source>
|
|
||||||
<target>1.7</target>
|
<target>1.7</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
@ -113,6 +112,11 @@
|
|||||||
<artifactId>swagger-annotations</artifactId>
|
<artifactId>swagger-annotations</artifactId>
|
||||||
<version>${swagger-core-version}</version>
|
<version>${swagger-core-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.squareup.retrofit2</groupId>
|
||||||
|
<artifactId>converter-gson</artifactId>
|
||||||
|
<version>${retrofit-version}</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.squareup.retrofit2</groupId>
|
<groupId>com.squareup.retrofit2</groupId>
|
||||||
<artifactId>retrofit</artifactId>
|
<artifactId>retrofit</artifactId>
|
||||||
@ -123,11 +127,6 @@
|
|||||||
<artifactId>converter-scalars</artifactId>
|
<artifactId>converter-scalars</artifactId>
|
||||||
<version>${retrofit-version}</version>
|
<version>${retrofit-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.squareup.retrofit2</groupId>
|
|
||||||
<artifactId>converter-gson</artifactId>
|
|
||||||
<version>${retrofit-version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.oltu.oauth2</groupId>
|
<groupId>org.apache.oltu.oauth2</groupId>
|
||||||
<artifactId>org.apache.oltu.oauth2.client</artifactId>
|
<artifactId>org.apache.oltu.oauth2.client</artifactId>
|
||||||
@ -144,7 +143,9 @@
|
|||||||
</dependencies>
|
</dependencies>
|
||||||
<properties>
|
<properties>
|
||||||
<swagger-core-version>1.5.8</swagger-core-version>
|
<swagger-core-version>1.5.8</swagger-core-version>
|
||||||
<retrofit-version>2.0.0-beta4</retrofit-version>
|
<retrofit-version>2.0.2</retrofit-version>
|
||||||
|
|
||||||
|
<okhttp-version>3.2.0</okhttp-version>
|
||||||
<oltu-version>1.0.1</oltu-version>
|
<oltu-version>1.0.1</oltu-version>
|
||||||
<maven-plugin-version>1.0.0</maven-plugin-version>
|
<maven-plugin-version>1.0.0</maven-plugin-version>
|
||||||
<junit-version>4.12</junit-version>
|
<junit-version>4.12</junit-version>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package io.swagger.client;
|
package io.swagger.client;
|
||||||
|
|
||||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T23:08:50.551+08:00")
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-27T10:03:24.454+02:00")
|
||||||
public class StringUtil {
|
public class StringUtil {
|
||||||
/**
|
/**
|
||||||
* Check if the given array contains the given value (with case-insensitive comparison).
|
* Check if the given array contains the given value (with case-insensitive comparison).
|
||||||
|
@ -0,0 +1,43 @@
|
|||||||
|
package io.swagger.client.api;
|
||||||
|
|
||||||
|
import io.swagger.client.CollectionFormats.*;
|
||||||
|
|
||||||
|
|
||||||
|
import retrofit2.Call;
|
||||||
|
import retrofit2.http.*;
|
||||||
|
|
||||||
|
import okhttp3.RequestBody;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public interface FakeApi {
|
||||||
|
/**
|
||||||
|
* Fake endpoint for testing various parameters
|
||||||
|
* Fake endpoint for testing various parameters
|
||||||
|
* @param number None (required)
|
||||||
|
* @param _double None (required)
|
||||||
|
* @param string None (required)
|
||||||
|
* @param _byte None (required)
|
||||||
|
* @param integer None (optional)
|
||||||
|
* @param int32 None (optional)
|
||||||
|
* @param int64 None (optional)
|
||||||
|
* @param _float None (optional)
|
||||||
|
* @param binary None (optional)
|
||||||
|
* @param date None (optional)
|
||||||
|
* @param dateTime None (optional)
|
||||||
|
* @param password None (optional)
|
||||||
|
* @return Call<Void>
|
||||||
|
*/
|
||||||
|
|
||||||
|
@FormUrlEncoded
|
||||||
|
@POST("fake")
|
||||||
|
Call<Void> testEndpointParameters(
|
||||||
|
@Field("number") String number, @Field("double") Double _double, @Field("string") String string, @Field("byte") byte[] _byte, @Field("integer") Integer integer, @Field("int32") Integer int32, @Field("int64") Long int64, @Field("float") Float _float, @Field("binary") byte[] binary, @Field("date") Date date, @Field("dateTime") Date dateTime, @Field("password") String password
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
@ -9,8 +9,8 @@ import retrofit2.http.*;
|
|||||||
import okhttp3.RequestBody;
|
import okhttp3.RequestBody;
|
||||||
|
|
||||||
import io.swagger.client.model.Pet;
|
import io.swagger.client.model.Pet;
|
||||||
import java.io.File;
|
|
||||||
import io.swagger.client.model.ModelApiResponse;
|
import io.swagger.client.model.ModelApiResponse;
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -51,6 +51,8 @@ public class FormatTest {
|
|||||||
private String password = null;
|
private String password = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* minimum: 10.0
|
||||||
|
* maximum: 100.0
|
||||||
**/
|
**/
|
||||||
@ApiModelProperty(value = "")
|
@ApiModelProperty(value = "")
|
||||||
public Integer getInteger() {
|
public Integer getInteger() {
|
||||||
@ -61,6 +63,8 @@ public class FormatTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* minimum: 20.0
|
||||||
|
* maximum: 200.0
|
||||||
**/
|
**/
|
||||||
@ApiModelProperty(value = "")
|
@ApiModelProperty(value = "")
|
||||||
public Integer getInt32() {
|
public Integer getInt32() {
|
||||||
@ -81,6 +85,8 @@ public class FormatTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* minimum: 32.1
|
||||||
|
* maximum: 543.2
|
||||||
**/
|
**/
|
||||||
@ApiModelProperty(required = true, value = "")
|
@ApiModelProperty(required = true, value = "")
|
||||||
public BigDecimal getNumber() {
|
public BigDecimal getNumber() {
|
||||||
@ -91,6 +97,8 @@ public class FormatTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* minimum: 54.3
|
||||||
|
* maximum: 987.6
|
||||||
**/
|
**/
|
||||||
@ApiModelProperty(value = "")
|
@ApiModelProperty(value = "")
|
||||||
public Float getFloat() {
|
public Float getFloat() {
|
||||||
@ -101,6 +109,8 @@ public class FormatTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* minimum: 67.8
|
||||||
|
* maximum: 123.4
|
||||||
**/
|
**/
|
||||||
@ApiModelProperty(value = "")
|
@ApiModelProperty(value = "")
|
||||||
public Double getDouble() {
|
public Double getDouble() {
|
||||||
@ -122,7 +132,7 @@ public class FormatTest {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
**/
|
**/
|
||||||
@ApiModelProperty(value = "")
|
@ApiModelProperty(required = true, value = "")
|
||||||
public byte[] getByte() {
|
public byte[] getByte() {
|
||||||
return _byte;
|
return _byte;
|
||||||
}
|
}
|
||||||
@ -142,7 +152,7 @@ public class FormatTest {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
**/
|
**/
|
||||||
@ApiModelProperty(value = "")
|
@ApiModelProperty(required = true, value = "")
|
||||||
public Date getDate() {
|
public Date getDate() {
|
||||||
return date;
|
return date;
|
||||||
}
|
}
|
||||||
@ -162,7 +172,7 @@ public class FormatTest {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
**/
|
**/
|
||||||
@ApiModelProperty(value = "")
|
@ApiModelProperty(required = true, value = "")
|
||||||
public String getPassword() {
|
public String getPassword() {
|
||||||
return password;
|
return password;
|
||||||
}
|
}
|
||||||
|
@ -1,17 +0,0 @@
|
|||||||
package io.swagger;
|
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
|
||||||
|
|
||||||
public class TestUtils {
|
|
||||||
private static final AtomicLong atomicId = createAtomicId();
|
|
||||||
|
|
||||||
public static long nextId() {
|
|
||||||
return atomicId.getAndIncrement();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static AtomicLong createAtomicId() {
|
|
||||||
int baseId = new Random(System.currentTimeMillis()).nextInt(1000000) + 20000;
|
|
||||||
return new AtomicLong((long) baseId);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,190 +0,0 @@
|
|||||||
package io.swagger.petstore.test;
|
|
||||||
|
|
||||||
import io.swagger.TestUtils;
|
|
||||||
|
|
||||||
import io.swagger.client.ApiClient;
|
|
||||||
import io.swagger.client.CollectionFormats.*;
|
|
||||||
import io.swagger.client.api.*;
|
|
||||||
import io.swagger.client.model.*;
|
|
||||||
|
|
||||||
import java.io.BufferedWriter;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileWriter;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.junit.*;
|
|
||||||
|
|
||||||
import retrofit2.Response;
|
|
||||||
|
|
||||||
import okhttp3.MediaType;
|
|
||||||
import okhttp3.RequestBody;
|
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
|
||||||
|
|
||||||
public class PetApiTest {
|
|
||||||
PetApi api = null;
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setup() {
|
|
||||||
api = new ApiClient().createService(PetApi.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testCreateAndGetPet() throws Exception {
|
|
||||||
Pet pet = createRandomPet();
|
|
||||||
Response<Void> rp2 = api.addPet(pet).execute();
|
|
||||||
|
|
||||||
Response<Pet> rp = api.getPetById(pet.getId()).execute();
|
|
||||||
Pet fetched = rp.body();
|
|
||||||
assertNotNull(fetched);
|
|
||||||
assertEquals(pet.getId(), fetched.getId());
|
|
||||||
assertNotNull(fetched.getCategory());
|
|
||||||
assertEquals(fetched.getCategory().getName(), pet.getCategory().getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testUpdatePet() throws Exception {
|
|
||||||
Pet pet = createRandomPet();
|
|
||||||
pet.setName("programmer");
|
|
||||||
|
|
||||||
api.updatePet(pet).execute();
|
|
||||||
|
|
||||||
Pet fetched = api.getPetById(pet.getId()).execute().body();
|
|
||||||
assertNotNull(fetched);
|
|
||||||
assertEquals(pet.getId(), fetched.getId());
|
|
||||||
assertNotNull(fetched.getCategory());
|
|
||||||
assertEquals(fetched.getCategory().getName(), pet.getCategory().getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testFindPetsByStatus() throws Exception {
|
|
||||||
Pet pet = createRandomPet();
|
|
||||||
pet.setName("programmer");
|
|
||||||
pet.setStatus(Pet.StatusEnum.AVAILABLE);
|
|
||||||
|
|
||||||
api.updatePet(pet).execute();
|
|
||||||
|
|
||||||
List<Pet> pets = api.findPetsByStatus(new CSVParams("available")).execute().body();
|
|
||||||
assertNotNull(pets);
|
|
||||||
|
|
||||||
boolean found = false;
|
|
||||||
for (Pet fetched : pets) {
|
|
||||||
if (fetched.getId().equals(pet.getId())) {
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
assertTrue(found);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testFindPetsByTags() throws Exception {
|
|
||||||
Pet pet = createRandomPet();
|
|
||||||
pet.setName("monster");
|
|
||||||
pet.setStatus(Pet.StatusEnum.AVAILABLE);
|
|
||||||
|
|
||||||
List<Tag> tags = new ArrayList<Tag>();
|
|
||||||
Tag tag1 = new Tag();
|
|
||||||
tag1.setName("friendly");
|
|
||||||
tags.add(tag1);
|
|
||||||
pet.setTags(tags);
|
|
||||||
|
|
||||||
api.updatePet(pet).execute();
|
|
||||||
|
|
||||||
List<Pet> pets = api.findPetsByTags(new CSVParams("friendly")).execute().body();
|
|
||||||
assertNotNull(pets);
|
|
||||||
|
|
||||||
boolean found = false;
|
|
||||||
for (Pet fetched : pets) {
|
|
||||||
if (fetched.getId().equals(pet.getId())) {
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
assertTrue(found);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testUpdatePetWithForm() throws Exception {
|
|
||||||
Pet pet = createRandomPet();
|
|
||||||
pet.setName("frank");
|
|
||||||
api.addPet(pet).execute();
|
|
||||||
|
|
||||||
Pet fetched = api.getPetById(pet.getId()).execute().body();
|
|
||||||
|
|
||||||
api.updatePetWithForm(fetched.getId(), "furt", null).execute();
|
|
||||||
Pet updated = api.getPetById(fetched.getId()).execute().body();
|
|
||||||
|
|
||||||
assertEquals(updated.getName(), "furt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testDeletePet() throws Exception {
|
|
||||||
Pet pet = createRandomPet();
|
|
||||||
api.addPet(pet).execute();
|
|
||||||
|
|
||||||
Pet fetched = api.getPetById(pet.getId()).execute().body();
|
|
||||||
api.deletePet(fetched.getId(), null).execute();
|
|
||||||
|
|
||||||
assertFalse(api.getPetById(fetched.getId()).execute().isSuccess());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testUploadFile() throws Exception {
|
|
||||||
Pet pet = createRandomPet();
|
|
||||||
api.addPet(pet).execute();
|
|
||||||
|
|
||||||
File file = new File("hello.txt");
|
|
||||||
BufferedWriter writer = new BufferedWriter(new FileWriter(file));
|
|
||||||
writer.write("Hello world!");
|
|
||||||
writer.close();
|
|
||||||
|
|
||||||
api.uploadFile(pet.getId(), null, RequestBody.create(MediaType.parse("text/plain"), file)).execute();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testEqualsAndHashCode() {
|
|
||||||
Pet pet1 = new Pet();
|
|
||||||
Pet pet2 = new Pet();
|
|
||||||
assertTrue(pet1.equals(pet2));
|
|
||||||
assertTrue(pet2.equals(pet1));
|
|
||||||
assertTrue(pet1.hashCode() == pet2.hashCode());
|
|
||||||
assertTrue(pet1.equals(pet1));
|
|
||||||
assertTrue(pet1.hashCode() == pet1.hashCode());
|
|
||||||
|
|
||||||
pet2.setName("really-happy");
|
|
||||||
pet2.setPhotoUrls(Arrays.asList(new String[]{"http://foo.bar.com/1", "http://foo.bar.com/2"}));
|
|
||||||
assertFalse(pet1.equals(pet2));
|
|
||||||
assertFalse(pet2.equals(pet1));
|
|
||||||
assertFalse(pet1.hashCode() == (pet2.hashCode()));
|
|
||||||
assertTrue(pet2.equals(pet2));
|
|
||||||
assertTrue(pet2.hashCode() == pet2.hashCode());
|
|
||||||
|
|
||||||
pet1.setName("really-happy");
|
|
||||||
pet1.setPhotoUrls(Arrays.asList(new String[]{"http://foo.bar.com/1", "http://foo.bar.com/2"}));
|
|
||||||
assertTrue(pet1.equals(pet2));
|
|
||||||
assertTrue(pet2.equals(pet1));
|
|
||||||
assertTrue(pet1.hashCode() == pet2.hashCode());
|
|
||||||
assertTrue(pet1.equals(pet1));
|
|
||||||
assertTrue(pet1.hashCode() == pet1.hashCode());
|
|
||||||
}
|
|
||||||
|
|
||||||
private Pet createRandomPet() {
|
|
||||||
Pet pet = new Pet();
|
|
||||||
pet.setId(TestUtils.nextId());
|
|
||||||
pet.setName("gorilla");
|
|
||||||
|
|
||||||
Category category = new Category();
|
|
||||||
category.setName("really-happy");
|
|
||||||
|
|
||||||
pet.setCategory(category);
|
|
||||||
pet.setStatus(Pet.StatusEnum.AVAILABLE);
|
|
||||||
List<String> photos = Arrays.asList(new String[]{"http://foo.bar.com/1", "http://foo.bar.com/2"});
|
|
||||||
pet.setPhotoUrls(photos);
|
|
||||||
|
|
||||||
return pet;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,74 +0,0 @@
|
|||||||
package io.swagger.petstore.test;
|
|
||||||
|
|
||||||
import io.swagger.TestUtils;
|
|
||||||
|
|
||||||
import io.swagger.client.ApiClient;
|
|
||||||
import io.swagger.client.api.*;
|
|
||||||
import io.swagger.client.model.*;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.junit.*;
|
|
||||||
|
|
||||||
import retrofit2.Response;
|
|
||||||
import static org.junit.Assert.*;
|
|
||||||
|
|
||||||
public class StoreApiTest {
|
|
||||||
StoreApi api = null;
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setup() {
|
|
||||||
api = new ApiClient().createService(StoreApi.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testGetInventory() throws Exception {
|
|
||||||
Map<String, Integer> inventory = api.getInventory().execute().body();
|
|
||||||
assertTrue(inventory.keySet().size() > 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testPlaceOrder() throws Exception {
|
|
||||||
Order order = createOrder();
|
|
||||||
api.placeOrder(order).execute();
|
|
||||||
|
|
||||||
Order fetched = api.getOrderById(order.getId()).execute().body();
|
|
||||||
assertEquals(order.getId(), fetched.getId());
|
|
||||||
assertEquals(order.getPetId(), fetched.getPetId());
|
|
||||||
assertEquals(order.getQuantity(), fetched.getQuantity());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testDeleteOrder() throws Exception {
|
|
||||||
Order order = createOrder();
|
|
||||||
Response<Order> aa = api.placeOrder(order).execute();
|
|
||||||
|
|
||||||
Order fetched = api.getOrderById(order.getId()).execute().body();
|
|
||||||
assertEquals(fetched.getId(), order.getId());
|
|
||||||
|
|
||||||
api.deleteOrder(String.valueOf(order.getId())).execute();
|
|
||||||
|
|
||||||
api.getOrderById(order.getId()).execute();
|
|
||||||
//also in retrofit 1 should return an error but don't, check server api impl.
|
|
||||||
}
|
|
||||||
|
|
||||||
private Order createOrder() {
|
|
||||||
Order order = new Order();
|
|
||||||
order.setPetId(new Long(200));
|
|
||||||
order.setQuantity(new Integer(13));
|
|
||||||
order.setShipDate(new java.util.Date());
|
|
||||||
order.setStatus(Order.StatusEnum.PLACED);
|
|
||||||
order.setComplete(true);
|
|
||||||
|
|
||||||
try {
|
|
||||||
Field idField = Order.class.getDeclaredField("id");
|
|
||||||
idField.setAccessible(true);
|
|
||||||
idField.set(order, TestUtils.nextId());
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return order;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,86 +0,0 @@
|
|||||||
package io.swagger.petstore.test;
|
|
||||||
|
|
||||||
import io.swagger.TestUtils;
|
|
||||||
|
|
||||||
import io.swagger.client.ApiClient;
|
|
||||||
import io.swagger.client.api.*;
|
|
||||||
import io.swagger.client.model.*;
|
|
||||||
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
import org.junit.*;
|
|
||||||
import static org.junit.Assert.*;
|
|
||||||
|
|
||||||
public class UserApiTest {
|
|
||||||
UserApi api = null;
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setup() {
|
|
||||||
api = new ApiClient().createService(UserApi.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testCreateUser() throws Exception {
|
|
||||||
User user = createUser();
|
|
||||||
|
|
||||||
api.createUser(user).execute();
|
|
||||||
|
|
||||||
User fetched = api.getUserByName(user.getUsername()).execute().body();
|
|
||||||
assertEquals(user.getId(), fetched.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testCreateUsersWithArray() throws Exception {
|
|
||||||
User user1 = createUser();
|
|
||||||
user1.setUsername("user" + user1.getId());
|
|
||||||
User user2 = createUser();
|
|
||||||
user2.setUsername("user" + user2.getId());
|
|
||||||
|
|
||||||
api.createUsersWithArrayInput(Arrays.asList(new User[]{user1, user2})).execute();
|
|
||||||
|
|
||||||
User fetched = api.getUserByName(user1.getUsername()).execute().body();
|
|
||||||
assertEquals(user1.getId(), fetched.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testCreateUsersWithList() throws Exception {
|
|
||||||
User user1 = createUser();
|
|
||||||
user1.setUsername("user" + user1.getId());
|
|
||||||
User user2 = createUser();
|
|
||||||
user2.setUsername("user" + user2.getId());
|
|
||||||
|
|
||||||
api.createUsersWithListInput(Arrays.asList(new User[]{user1, user2})).execute();
|
|
||||||
|
|
||||||
User fetched = api.getUserByName(user1.getUsername()).execute().body();
|
|
||||||
assertEquals(user1.getId(), fetched.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testLoginUser() throws Exception {
|
|
||||||
User user = createUser();
|
|
||||||
api.createUser(user).execute();
|
|
||||||
|
|
||||||
String token = api.loginUser(user.getUsername(), user.getPassword()).execute().body();
|
|
||||||
assertTrue(token.startsWith("logged in user session:"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void logoutUser() throws Exception {
|
|
||||||
api.logoutUser().execute();
|
|
||||||
}
|
|
||||||
|
|
||||||
private User createUser() {
|
|
||||||
User user = new User();
|
|
||||||
user.setId(TestUtils.nextId());
|
|
||||||
user.setUsername("fred");
|
|
||||||
user.setFirstName("Fred");
|
|
||||||
user.setLastName("Meyer");
|
|
||||||
user.setEmail("fred@fredmeyer.com");
|
|
||||||
user.setPassword("xxXXxx");
|
|
||||||
user.setPhone("408-867-5309");
|
|
||||||
user.setUserStatus(123);
|
|
||||||
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
}
|
|
@ -94,12 +94,11 @@ if(hasProperty('target') && target == 'android') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ext {
|
ext {
|
||||||
oltu_version = "1.0.0"
|
oltu_version = "1.0.1"
|
||||||
retrofit_version = "2.0.0-beta4"
|
retrofit_version = "2.0.2"
|
||||||
gson_version = "2.4"
|
swagger_annotations_version = "1.5.8"
|
||||||
swagger_annotations_version = "1.5.0"
|
|
||||||
junit_version = "4.12"
|
junit_version = "4.12"
|
||||||
rx_java_version = "1.0.16"
|
rx_java_version = "1.1.3"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,8 +100,7 @@
|
|||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>2.3.2</version>
|
<version>2.3.2</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>
|
<source>1.7</source>
|
||||||
1.7</source>
|
|
||||||
<target>1.7</target>
|
<target>1.7</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
@ -111,7 +110,12 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.swagger</groupId>
|
<groupId>io.swagger</groupId>
|
||||||
<artifactId>swagger-annotations</artifactId>
|
<artifactId>swagger-annotations</artifactId>
|
||||||
<version>${swagger-annotations-version}</version>
|
<version>${swagger-core-version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.squareup.retrofit2</groupId>
|
||||||
|
<artifactId>converter-gson</artifactId>
|
||||||
|
<version>${retrofit-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.squareup.retrofit2</groupId>
|
<groupId>com.squareup.retrofit2</groupId>
|
||||||
@ -123,11 +127,6 @@
|
|||||||
<artifactId>converter-scalars</artifactId>
|
<artifactId>converter-scalars</artifactId>
|
||||||
<version>${retrofit-version}</version>
|
<version>${retrofit-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.squareup.retrofit2</groupId>
|
|
||||||
<artifactId>converter-gson</artifactId>
|
|
||||||
<version>${retrofit-version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.oltu.oauth2</groupId>
|
<groupId>org.apache.oltu.oauth2</groupId>
|
||||||
<artifactId>org.apache.oltu.oauth2.client</artifactId>
|
<artifactId>org.apache.oltu.oauth2.client</artifactId>
|
||||||
@ -153,10 +152,11 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<properties>
|
<properties>
|
||||||
<swagger-annotations-version>1.5.0</swagger-annotations-version>
|
<swagger-core-version>1.5.8</swagger-core-version>
|
||||||
<retrofit-version>2.0.0-beta4</retrofit-version>
|
<retrofit-version>2.0.2</retrofit-version>
|
||||||
<rxjava-version>1.0.16</rxjava-version>
|
<rxjava-version>1.1.3</rxjava-version>
|
||||||
<oltu-version>1.0.0</oltu-version>
|
<okhttp-version>3.2.0</okhttp-version>
|
||||||
|
<oltu-version>1.0.1</oltu-version>
|
||||||
<maven-plugin-version>1.0.0</maven-plugin-version>
|
<maven-plugin-version>1.0.0</maven-plugin-version>
|
||||||
<junit-version>4.12</junit-version>
|
<junit-version>4.12</junit-version>
|
||||||
</properties>
|
</properties>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package io.swagger.client;
|
package io.swagger.client;
|
||||||
|
|
||||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T23:10:58.658+08:00")
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-27T10:03:29.641+02:00")
|
||||||
public class StringUtil {
|
public class StringUtil {
|
||||||
/**
|
/**
|
||||||
* Check if the given array contains the given value (with case-insensitive comparison).
|
* Check if the given array contains the given value (with case-insensitive comparison).
|
||||||
|
@ -0,0 +1,43 @@
|
|||||||
|
package io.swagger.client.api;
|
||||||
|
|
||||||
|
import io.swagger.client.CollectionFormats.*;
|
||||||
|
|
||||||
|
import rx.Observable;
|
||||||
|
|
||||||
|
import retrofit2.http.*;
|
||||||
|
|
||||||
|
import okhttp3.RequestBody;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public interface FakeApi {
|
||||||
|
/**
|
||||||
|
* Fake endpoint for testing various parameters
|
||||||
|
* Fake endpoint for testing various parameters
|
||||||
|
* @param number None (required)
|
||||||
|
* @param _double None (required)
|
||||||
|
* @param string None (required)
|
||||||
|
* @param _byte None (required)
|
||||||
|
* @param integer None (optional)
|
||||||
|
* @param int32 None (optional)
|
||||||
|
* @param int64 None (optional)
|
||||||
|
* @param _float None (optional)
|
||||||
|
* @param binary None (optional)
|
||||||
|
* @param date None (optional)
|
||||||
|
* @param dateTime None (optional)
|
||||||
|
* @param password None (optional)
|
||||||
|
* @return Call<Void>
|
||||||
|
*/
|
||||||
|
|
||||||
|
@FormUrlEncoded
|
||||||
|
@POST("fake")
|
||||||
|
Observable<Void> testEndpointParameters(
|
||||||
|
@Field("number") String number, @Field("double") Double _double, @Field("string") String string, @Field("byte") byte[] _byte, @Field("integer") Integer integer, @Field("int32") Integer int32, @Field("int64") Long int64, @Field("float") Float _float, @Field("binary") byte[] binary, @Field("date") Date date, @Field("dateTime") Date dateTime, @Field("password") String password
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
@ -9,8 +9,8 @@ import retrofit2.http.*;
|
|||||||
import okhttp3.RequestBody;
|
import okhttp3.RequestBody;
|
||||||
|
|
||||||
import io.swagger.client.model.Pet;
|
import io.swagger.client.model.Pet;
|
||||||
import java.io.File;
|
|
||||||
import io.swagger.client.model.ModelApiResponse;
|
import io.swagger.client.model.ModelApiResponse;
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -51,6 +51,8 @@ public class FormatTest {
|
|||||||
private String password = null;
|
private String password = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* minimum: 10.0
|
||||||
|
* maximum: 100.0
|
||||||
**/
|
**/
|
||||||
@ApiModelProperty(value = "")
|
@ApiModelProperty(value = "")
|
||||||
public Integer getInteger() {
|
public Integer getInteger() {
|
||||||
@ -61,6 +63,8 @@ public class FormatTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* minimum: 20.0
|
||||||
|
* maximum: 200.0
|
||||||
**/
|
**/
|
||||||
@ApiModelProperty(value = "")
|
@ApiModelProperty(value = "")
|
||||||
public Integer getInt32() {
|
public Integer getInt32() {
|
||||||
@ -81,6 +85,8 @@ public class FormatTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* minimum: 32.1
|
||||||
|
* maximum: 543.2
|
||||||
**/
|
**/
|
||||||
@ApiModelProperty(required = true, value = "")
|
@ApiModelProperty(required = true, value = "")
|
||||||
public BigDecimal getNumber() {
|
public BigDecimal getNumber() {
|
||||||
@ -91,6 +97,8 @@ public class FormatTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* minimum: 54.3
|
||||||
|
* maximum: 987.6
|
||||||
**/
|
**/
|
||||||
@ApiModelProperty(value = "")
|
@ApiModelProperty(value = "")
|
||||||
public Float getFloat() {
|
public Float getFloat() {
|
||||||
@ -101,6 +109,8 @@ public class FormatTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* minimum: 67.8
|
||||||
|
* maximum: 123.4
|
||||||
**/
|
**/
|
||||||
@ApiModelProperty(value = "")
|
@ApiModelProperty(value = "")
|
||||||
public Double getDouble() {
|
public Double getDouble() {
|
||||||
@ -122,7 +132,7 @@ public class FormatTest {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
**/
|
**/
|
||||||
@ApiModelProperty(value = "")
|
@ApiModelProperty(required = true, value = "")
|
||||||
public byte[] getByte() {
|
public byte[] getByte() {
|
||||||
return _byte;
|
return _byte;
|
||||||
}
|
}
|
||||||
@ -142,7 +152,7 @@ public class FormatTest {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
**/
|
**/
|
||||||
@ApiModelProperty(value = "")
|
@ApiModelProperty(required = true, value = "")
|
||||||
public Date getDate() {
|
public Date getDate() {
|
||||||
return date;
|
return date;
|
||||||
}
|
}
|
||||||
@ -162,7 +172,7 @@ public class FormatTest {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
**/
|
**/
|
||||||
@ApiModelProperty(value = "")
|
@ApiModelProperty(required = true, value = "")
|
||||||
public String getPassword() {
|
public String getPassword() {
|
||||||
return password;
|
return password;
|
||||||
}
|
}
|
||||||
|
@ -1,255 +0,0 @@
|
|||||||
package io.swagger.petstore.test;
|
|
||||||
|
|
||||||
import io.swagger.client.ApiClient;
|
|
||||||
import io.swagger.client.CollectionFormats.*;
|
|
||||||
import io.swagger.client.api.*;
|
|
||||||
import io.swagger.client.model.*;
|
|
||||||
|
|
||||||
import java.io.BufferedWriter;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileWriter;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.junit.*;
|
|
||||||
|
|
||||||
import okhttp3.MediaType;
|
|
||||||
import okhttp3.RequestBody;
|
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
|
||||||
|
|
||||||
public class PetApiTest {
|
|
||||||
PetApi api = null;
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setup() {
|
|
||||||
api = new ApiClient().createService(PetApi.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testCreateAndGetPet() throws Exception {
|
|
||||||
final Pet pet = createRandomPet();
|
|
||||||
api.addPet(pet).subscribe(new SkeletonSubscriber<Void>() {
|
|
||||||
@Override
|
|
||||||
public void onCompleted() {
|
|
||||||
api.getPetById(pet.getId()).subscribe(new SkeletonSubscriber<Pet>() {
|
|
||||||
@Override
|
|
||||||
public void onNext(Pet fetched) {
|
|
||||||
assertNotNull(fetched);
|
|
||||||
assertEquals(pet.getId(), fetched.getId());
|
|
||||||
assertNotNull(fetched.getCategory());
|
|
||||||
assertEquals(fetched.getCategory().getName(), pet.getCategory().getName());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testUpdatePet() throws Exception {
|
|
||||||
final Pet pet = createRandomPet();
|
|
||||||
pet.setName("programmer");
|
|
||||||
|
|
||||||
api.updatePet(pet).subscribe(new SkeletonSubscriber<Void>() {
|
|
||||||
@Override
|
|
||||||
public void onCompleted() {
|
|
||||||
api.getPetById(pet.getId()).subscribe(new SkeletonSubscriber<Pet>() {
|
|
||||||
@Override
|
|
||||||
public void onNext(Pet fetched) {
|
|
||||||
assertNotNull(fetched);
|
|
||||||
assertEquals(pet.getId(), fetched.getId());
|
|
||||||
assertNotNull(fetched.getCategory());
|
|
||||||
assertEquals(fetched.getCategory().getName(), pet.getCategory().getName());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testFindPetsByStatus() throws Exception {
|
|
||||||
final Pet pet = createRandomPet();
|
|
||||||
pet.setName("programmer");
|
|
||||||
pet.setStatus(Pet.StatusEnum.AVAILABLE);
|
|
||||||
|
|
||||||
api.updatePet(pet).subscribe(new SkeletonSubscriber<Void>() {
|
|
||||||
@Override
|
|
||||||
public void onCompleted() {
|
|
||||||
api.findPetsByStatus(new CSVParams("available")).subscribe(new SkeletonSubscriber<List<Pet>>() {
|
|
||||||
@Override
|
|
||||||
public void onNext(List<Pet> pets) {
|
|
||||||
assertNotNull(pets);
|
|
||||||
|
|
||||||
boolean found = false;
|
|
||||||
for (Pet fetched : pets) {
|
|
||||||
if (fetched.getId().equals(pet.getId())) {
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
assertTrue(found);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testFindPetsByTags() throws Exception {
|
|
||||||
final Pet pet = createRandomPet();
|
|
||||||
pet.setName("monster");
|
|
||||||
pet.setStatus(Pet.StatusEnum.AVAILABLE);
|
|
||||||
|
|
||||||
List<Tag> tags = new ArrayList<Tag>();
|
|
||||||
Tag tag1 = new Tag();
|
|
||||||
tag1.setName("friendly");
|
|
||||||
tags.add(tag1);
|
|
||||||
pet.setTags(tags);
|
|
||||||
|
|
||||||
api.updatePet(pet).subscribe(new SkeletonSubscriber<Void>() {
|
|
||||||
@Override
|
|
||||||
public void onCompleted() {
|
|
||||||
api.findPetsByTags(new CSVParams("friendly")).subscribe(new SkeletonSubscriber<List<Pet>>() {
|
|
||||||
@Override
|
|
||||||
public void onNext(List<Pet> pets) {
|
|
||||||
assertNotNull(pets);
|
|
||||||
|
|
||||||
boolean found = false;
|
|
||||||
for (Pet fetched : pets) {
|
|
||||||
if (fetched.getId().equals(pet.getId())) {
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
assertTrue(found);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testUpdatePetWithForm() throws Exception {
|
|
||||||
final Pet pet = createRandomPet();
|
|
||||||
pet.setName("frank");
|
|
||||||
api.addPet(pet).subscribe(SkeletonSubscriber.failTestOnError());
|
|
||||||
api.getPetById(pet.getId()).subscribe(new SkeletonSubscriber<Pet>() {
|
|
||||||
@Override
|
|
||||||
public void onNext(final Pet fetched) {
|
|
||||||
api.updatePetWithForm(fetched.getId(), "furt", null)
|
|
||||||
.subscribe(new SkeletonSubscriber<Void>() {
|
|
||||||
@Override
|
|
||||||
public void onCompleted() {
|
|
||||||
api.getPetById(fetched.getId()).subscribe(new SkeletonSubscriber<Pet>() {
|
|
||||||
@Override
|
|
||||||
public void onNext(Pet updated) {
|
|
||||||
assertEquals(updated.getName(), "furt");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testDeletePet() throws Exception {
|
|
||||||
Pet pet = createRandomPet();
|
|
||||||
api.addPet(pet).subscribe(SkeletonSubscriber.failTestOnError());
|
|
||||||
|
|
||||||
api.getPetById(pet.getId()).subscribe(new SkeletonSubscriber<Pet>() {
|
|
||||||
@Override
|
|
||||||
public void onNext(Pet fetched) {
|
|
||||||
|
|
||||||
api.deletePet(fetched.getId(), null).subscribe(SkeletonSubscriber.failTestOnError());
|
|
||||||
api.getPetById(fetched.getId()).subscribe(new SkeletonSubscriber<Pet>() {
|
|
||||||
@Override
|
|
||||||
public void onNext(Pet deletedPet) {
|
|
||||||
fail("Should not have found deleted pet.");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError(Throwable e) {
|
|
||||||
// expected, because the pet has been deleted.
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testUploadFile() throws Exception {
|
|
||||||
File file = File.createTempFile("test", "hello.txt");
|
|
||||||
BufferedWriter writer = new BufferedWriter(new FileWriter(file));
|
|
||||||
|
|
||||||
writer.write("Hello world!");
|
|
||||||
writer.close();
|
|
||||||
|
|
||||||
Pet pet = createRandomPet();
|
|
||||||
api.addPet(pet).subscribe(SkeletonSubscriber.failTestOnError());
|
|
||||||
|
|
||||||
RequestBody body = RequestBody.create(MediaType.parse("text/plain"), file);
|
|
||||||
api.uploadFile(pet.getId(), "a test file", body).subscribe(new SkeletonSubscriber<ModelApiResponse>() {
|
|
||||||
@Override
|
|
||||||
public void onError(Throwable e) {
|
|
||||||
// this also yields a 400 for other tests, so I guess it's okay...
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testEqualsAndHashCode() {
|
|
||||||
Pet pet1 = new Pet();
|
|
||||||
Pet pet2 = new Pet();
|
|
||||||
assertTrue(pet1.equals(pet2));
|
|
||||||
assertTrue(pet2.equals(pet1));
|
|
||||||
assertTrue(pet1.hashCode() == pet2.hashCode());
|
|
||||||
assertTrue(pet1.equals(pet1));
|
|
||||||
assertTrue(pet1.hashCode() == pet1.hashCode());
|
|
||||||
|
|
||||||
pet2.setName("really-happy");
|
|
||||||
pet2.setPhotoUrls(Arrays.asList(new String[]{"http://foo.bar.com/1", "http://foo.bar.com/2"}));
|
|
||||||
assertFalse(pet1.equals(pet2));
|
|
||||||
assertFalse(pet2.equals(pet1));
|
|
||||||
assertFalse(pet1.hashCode() == (pet2.hashCode()));
|
|
||||||
assertTrue(pet2.equals(pet2));
|
|
||||||
assertTrue(pet2.hashCode() == pet2.hashCode());
|
|
||||||
|
|
||||||
pet1.setName("really-happy");
|
|
||||||
pet1.setPhotoUrls(Arrays.asList(new String[]{"http://foo.bar.com/1", "http://foo.bar.com/2"}));
|
|
||||||
assertTrue(pet1.equals(pet2));
|
|
||||||
assertTrue(pet2.equals(pet1));
|
|
||||||
assertTrue(pet1.hashCode() == pet2.hashCode());
|
|
||||||
assertTrue(pet1.equals(pet1));
|
|
||||||
assertTrue(pet1.hashCode() == pet1.hashCode());
|
|
||||||
}
|
|
||||||
|
|
||||||
private Pet createRandomPet() {
|
|
||||||
Pet pet = new Pet();
|
|
||||||
pet.setId(System.currentTimeMillis());
|
|
||||||
pet.setName("gorilla");
|
|
||||||
|
|
||||||
Category category = new Category();
|
|
||||||
category.setName("really-happy");
|
|
||||||
|
|
||||||
pet.setCategory(category);
|
|
||||||
pet.setStatus(Pet.StatusEnum.AVAILABLE);
|
|
||||||
List<String> photos = Arrays.asList(new String[]{"http://foo.bar.com/1", "http://foo.bar.com/2"});
|
|
||||||
pet.setPhotoUrls(photos);
|
|
||||||
|
|
||||||
return pet;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,30 +0,0 @@
|
|||||||
package io.swagger.petstore.test;
|
|
||||||
|
|
||||||
import junit.framework.TestFailure;
|
|
||||||
import rx.Subscriber;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Skeleton subscriber for tests that will fail when onError() is called unexpectedly.
|
|
||||||
*/
|
|
||||||
public abstract class SkeletonSubscriber<T> extends Subscriber<T> {
|
|
||||||
|
|
||||||
public static <T> SkeletonSubscriber<T> failTestOnError() {
|
|
||||||
return new SkeletonSubscriber<T>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCompleted() {
|
|
||||||
// space for rent
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onNext(T t) {
|
|
||||||
// space for rent
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError(Throwable e) {
|
|
||||||
throw new RuntimeException("Subscriber onError() called with unhandled exception!", e);
|
|
||||||
}
|
|
||||||
}
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user