forked from loafle/openapi-generator-original
Merge branch 'master' into auto-generate-operation-id
Conflicts: modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/api.mustache
This commit is contained in:
commit
2c6c902878
@ -41,6 +41,7 @@ cd $APP_DIR
|
||||
./bin/scala-petstore.sh
|
||||
./bin/scalatra-petstore-server.sh
|
||||
./bin/silex-petstore-server.sh
|
||||
./bin/slim-petstore-server.sh
|
||||
./bin/spring-mvc-petstore-server.sh
|
||||
./bin/swift-petstore.sh
|
||||
./bin/tizen-petstore.sh
|
||||
|
31
bin/slim-petstore-server.sh
Normal file
31
bin/slim-petstore-server.sh
Normal 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 -t modules/swagger-codegen/src/main/resources/slim -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l slim -o samples/server/petstore/slim"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
@ -46,4 +46,6 @@ public class CodegenConstants {
|
||||
public static final String PACKAGE_NAME = "packageName";
|
||||
public static final String PACKAGE_VERSION = "packageVersion";
|
||||
public static final String POD_VERSION = "podVersion";
|
||||
|
||||
public static final String OPTIONAL_METHOD_ARGUMENT = "optionalMethodArgument";
|
||||
}
|
||||
|
@ -45,13 +45,15 @@ public class InlineModelResolver {
|
||||
if (bp.getSchema() != null) {
|
||||
Model model = bp.getSchema();
|
||||
if(model instanceof ModelImpl) {
|
||||
String modelName = uniqueName(bp.getName());
|
||||
ModelImpl obj = (ModelImpl) model;
|
||||
flattenProperties(obj.getProperties(), pathname);
|
||||
if (obj.getType() == null || "object".equals(obj.getType())) {
|
||||
String modelName = uniqueName(bp.getName());
|
||||
flattenProperties(obj.getProperties(), pathname);
|
||||
|
||||
bp.setSchema(new RefModel(modelName));
|
||||
addGenerated(modelName, model);
|
||||
swagger.addDefinition(modelName, model);
|
||||
bp.setSchema(new RefModel(modelName));
|
||||
addGenerated(modelName, model);
|
||||
swagger.addDefinition(modelName, model);
|
||||
}
|
||||
}
|
||||
else if (model instanceof ArrayModel) {
|
||||
ArrayModel am = (ArrayModel) model;
|
||||
|
@ -25,6 +25,7 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
public class CSharpClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(CSharpClientCodegen.class);
|
||||
protected boolean optionalMethodArgumentFlag = true;
|
||||
protected String packageName = "IO.Swagger";
|
||||
protected String packageVersion = "1.0.0";
|
||||
protected String clientPackage = "IO.Swagger.Client";
|
||||
@ -91,6 +92,7 @@ public class CSharpClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
.defaultValue("IO.Swagger"));
|
||||
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_VERSION, "C# package version.").defaultValue("1.0.0"));
|
||||
cliOptions.add(new CliOption(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG, CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG_DESC));
|
||||
cliOptions.add(new CliOption(CodegenConstants.OPTIONAL_METHOD_ARGUMENT, "C# Optional method argument, e.g. void square(int x=10) (.net 4.0+ only). Default: false").defaultValue("false"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -114,6 +116,12 @@ public class CSharpClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
|
||||
additionalProperties.put("clientPackage", clientPackage);
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.OPTIONAL_METHOD_ARGUMENT)) {
|
||||
setOptionalMethodArgumentFlag(Boolean.valueOf(additionalProperties
|
||||
.get(CodegenConstants.OPTIONAL_METHOD_ARGUMENT).toString()));
|
||||
}
|
||||
additionalProperties.put("optionalMethodArgument", optionalMethodArgumentFlag);
|
||||
|
||||
supportingFiles.add(new SupportingFile("Configuration.mustache",
|
||||
sourceFolder + File.separator + clientPackage.replace(".", java.io.File.separator), "Configuration.cs"));
|
||||
supportingFiles.add(new SupportingFile("ApiClient.mustache",
|
||||
@ -261,6 +269,10 @@ public class CSharpClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
return camelize(sanitizeName(operationId));
|
||||
}
|
||||
|
||||
public void setOptionalMethodArgumentFlag(boolean flag) {
|
||||
this.optionalMethodArgumentFlag = flag;
|
||||
}
|
||||
|
||||
public void setPackageName(String packageName) {
|
||||
this.packageName = packageName;
|
||||
}
|
||||
|
@ -232,6 +232,8 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
if ("okhttp-gson".equals(getLibrary())) {
|
||||
// the "okhttp-gson" library template requires "ApiCallback.mustache" for async call
|
||||
supportingFiles.add(new SupportingFile("ApiCallback.mustache", invokerFolder, "ApiCallback.java"));
|
||||
supportingFiles.add(new SupportingFile("ProgressRequestBody.mustache", invokerFolder, "ProgressRequestBody.java"));
|
||||
supportingFiles.add(new SupportingFile("ProgressResponseBody.mustache", invokerFolder, "ProgressResponseBody.java"));
|
||||
// "build.sbt" is for development with SBT
|
||||
supportingFiles.add(new SupportingFile("build.sbt.mustache", "", "build.sbt"));
|
||||
} else if ("retrofit".equals(getLibrary()) || "retrofit2".equals(getLibrary())) {
|
||||
|
@ -0,0 +1,221 @@
|
||||
package io.swagger.codegen.languages;
|
||||
|
||||
import io.swagger.codegen.CodegenConfig;
|
||||
import io.swagger.codegen.CodegenConstants;
|
||||
import io.swagger.codegen.CodegenType;
|
||||
import io.swagger.codegen.DefaultCodegen;
|
||||
import io.swagger.codegen.SupportingFile;
|
||||
import io.swagger.models.properties.ArrayProperty;
|
||||
import io.swagger.models.properties.MapProperty;
|
||||
import io.swagger.models.properties.Property;
|
||||
import io.swagger.models.properties.RefProperty;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
||||
public class SlimFrameworkServerCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
protected String invokerPackage;
|
||||
protected String groupId = "io.swagger";
|
||||
protected String artifactId = "swagger-server";
|
||||
protected String artifactVersion = "1.0.0";
|
||||
private String variableNamingConvention = "camelCase";
|
||||
|
||||
public SlimFrameworkServerCodegen() {
|
||||
super();
|
||||
|
||||
invokerPackage = camelize("SwaggerServer");
|
||||
|
||||
String packagePath = "SwaggerServer";
|
||||
|
||||
modelPackage = packagePath + "\\lib\\Models";
|
||||
apiPackage = packagePath + "\\lib";
|
||||
outputFolder = "generated-code" + File.separator + "slim";
|
||||
modelTemplateFiles.put("model.mustache", ".php");
|
||||
|
||||
// no api files
|
||||
apiTemplateFiles.clear();
|
||||
|
||||
embeddedTemplateDir = templateDir = "slim";
|
||||
|
||||
reservedWords = new HashSet<String>(
|
||||
Arrays.asList(
|
||||
"__halt_compiler", "abstract", "and", "array", "as", "break", "callable", "case", "catch", "class", "clone", "const", "continue", "declare", "default", "die", "do", "echo", "else", "elseif", "empty", "enddeclare", "endfor", "endforeach", "endif", "endswitch", "endwhile", "eval", "exit", "extends", "final", "for", "foreach", "function", "global", "goto", "if", "implements", "include", "include_once", "instanceof", "insteadof", "interface", "isset", "list", "namespace", "new", "or", "print", "private", "protected", "public", "require", "require_once", "return", "static", "switch", "throw", "trait", "try", "unset", "use", "var", "while", "xor")
|
||||
);
|
||||
|
||||
additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage);
|
||||
additionalProperties.put(CodegenConstants.GROUP_ID, groupId);
|
||||
additionalProperties.put(CodegenConstants.ARTIFACT_ID, artifactId);
|
||||
additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion);
|
||||
|
||||
// ref: http://php.net/manual/en/language.types.intro.php
|
||||
languageSpecificPrimitives = new HashSet<String>(
|
||||
Arrays.asList(
|
||||
"boolean",
|
||||
"int",
|
||||
"integer",
|
||||
"double",
|
||||
"float",
|
||||
"string",
|
||||
"object",
|
||||
"DateTime",
|
||||
"mixed",
|
||||
"number")
|
||||
);
|
||||
|
||||
instantiationTypes.put("array", "array");
|
||||
instantiationTypes.put("map", "map");
|
||||
|
||||
// ref: https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#data-types
|
||||
typeMapping = new HashMap<String, String>();
|
||||
typeMapping.put("integer", "int");
|
||||
typeMapping.put("long", "int");
|
||||
typeMapping.put("float", "float");
|
||||
typeMapping.put("double", "double");
|
||||
typeMapping.put("string", "string");
|
||||
typeMapping.put("byte", "int");
|
||||
typeMapping.put("boolean", "bool");
|
||||
typeMapping.put("date", "\\DateTime");
|
||||
typeMapping.put("datetime", "\\DateTime");
|
||||
typeMapping.put("file", "\\SplFileObject");
|
||||
typeMapping.put("map", "map");
|
||||
typeMapping.put("array", "array");
|
||||
typeMapping.put("list", "array");
|
||||
typeMapping.put("object", "object");
|
||||
|
||||
supportingFiles.add(new SupportingFile("README.mustache", packagePath.replace('/', File.separatorChar), "README.md"));
|
||||
supportingFiles.add(new SupportingFile("composer.json", packagePath.replace('/', File.separatorChar), "composer.json"));
|
||||
supportingFiles.add(new SupportingFile("index.mustache", packagePath.replace('/', File.separatorChar), "index.php"));
|
||||
supportingFiles.add(new SupportingFile(".htaccess", packagePath.replace('/', File.separatorChar), ".htaccess"));
|
||||
}
|
||||
|
||||
public CodegenType getTag() {
|
||||
return CodegenType.SERVER;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "slim";
|
||||
}
|
||||
|
||||
public String getHelp() {
|
||||
return "Generates a Slim Framework server library.";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeReservedWord(String name) {
|
||||
return "_" + name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apiFileFolder() {
|
||||
return (outputFolder + "/" + apiPackage()).replace('/', File.separatorChar);
|
||||
}
|
||||
|
||||
public String modelFileFolder() {
|
||||
return (outputFolder + "/" + modelPackage()).replace('/', File.separatorChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeDeclaration(Property p) {
|
||||
if (p instanceof ArrayProperty) {
|
||||
ArrayProperty ap = (ArrayProperty) p;
|
||||
Property inner = ap.getItems();
|
||||
return getTypeDeclaration(inner) + "[]";
|
||||
} else if (p instanceof MapProperty) {
|
||||
MapProperty mp = (MapProperty) p;
|
||||
Property inner = mp.getAdditionalProperties();
|
||||
return getSwaggerType(p) + "[string," + getTypeDeclaration(inner) + "]";
|
||||
} else if (p instanceof RefProperty) {
|
||||
String type = super.getTypeDeclaration(p);
|
||||
return (!languageSpecificPrimitives.contains(type))
|
||||
? "\\" + modelPackage + "\\" + type : type;
|
||||
}
|
||||
return super.getTypeDeclaration(p);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSwaggerType(Property p) {
|
||||
String swaggerType = super.getSwaggerType(p);
|
||||
String type = null;
|
||||
if (typeMapping.containsKey(swaggerType)) {
|
||||
type = typeMapping.get(swaggerType);
|
||||
if (languageSpecificPrimitives.contains(type)) {
|
||||
return type;
|
||||
} else if (instantiationTypes.containsKey(type)) {
|
||||
return type;
|
||||
}
|
||||
} else {
|
||||
type = swaggerType;
|
||||
}
|
||||
if (type == null) {
|
||||
return null;
|
||||
}
|
||||
return toModelName(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeDeclaration(String name) {
|
||||
if (!languageSpecificPrimitives.contains(name)) {
|
||||
return "\\" + modelPackage + "\\" + name;
|
||||
}
|
||||
return super.getTypeDeclaration(name);
|
||||
}
|
||||
|
||||
public String toDefaultValue(Property p) {
|
||||
return "null";
|
||||
}
|
||||
|
||||
public void setParameterNamingConvention(String variableNamingConvention) {
|
||||
this.variableNamingConvention = variableNamingConvention;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toVarName(String name) {
|
||||
// sanitize name
|
||||
name = sanitizeName(name);
|
||||
|
||||
if ("camelCase".equals(variableNamingConvention)) {
|
||||
// return the name in camelCase style
|
||||
// phone_number => phoneNumber
|
||||
name = camelize(name, true);
|
||||
} else { // default to snake case
|
||||
// return the name in underscore style
|
||||
// PhoneNumber => phone_number
|
||||
name = underscore(name);
|
||||
}
|
||||
|
||||
// parameter name starting with number won't compile
|
||||
// need to escape it by appending _ at the beginning
|
||||
if (name.matches("^\\d.*")) {
|
||||
name = "_" + name;
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toParamName(String name) {
|
||||
// should be the same as variable name
|
||||
return toVarName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelName(String name) {
|
||||
// model name cannot use reserved keyword
|
||||
if (reservedWords.contains(name)) {
|
||||
escapeReservedWord(name); // e.g. return => _return
|
||||
}
|
||||
|
||||
// camelize the model name
|
||||
// phone_number => PhoneNumber
|
||||
return camelize(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelFilename(String name) {
|
||||
// should be the same as the model name
|
||||
return toModelName(name);
|
||||
}
|
||||
|
||||
}
|
@ -1,3 +1,4 @@
|
||||
|
||||
public enum {{datatypeWithEnum}} {
|
||||
{{#allowableValues}}{{#enumVars}}{{name}}("{{value}}"){{^-last}},
|
||||
{{/-last}}{{#-last}};{{/-last}}{{/enumVars}}{{/allowableValues}}
|
||||
@ -9,6 +10,7 @@ public enum {{datatypeWithEnum}} {
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonValue
|
||||
public String toString() {
|
||||
return value;
|
||||
}
|
||||
|
@ -28,4 +28,22 @@ public interface ApiCallback<T> {
|
||||
* @param responseHeaders Headers of the response
|
||||
*/
|
||||
void onSuccess(T result, int statusCode, Map<String, List<String>> responseHeaders);
|
||||
|
||||
/**
|
||||
* This is called when the API upload processing.
|
||||
*
|
||||
* @param bytesWritten bytes Written
|
||||
* @param contentLength content length of request body
|
||||
* @param done write end
|
||||
*/
|
||||
void onUploadProgress(long bytesWritten, long contentLength, boolean done);
|
||||
|
||||
/**
|
||||
* This is called when the API downlond processing.
|
||||
*
|
||||
* @param bytesRead bytes Read
|
||||
* @param contentLength content lenngth of the response
|
||||
* @param done Read end
|
||||
*/
|
||||
void onDownloadProgress(long bytesRead, long contentLength, boolean done);
|
||||
}
|
||||
|
@ -821,7 +821,7 @@ public class ApiClient {
|
||||
* @param authNames The authentications to apply
|
||||
* @return The HTTP call
|
||||
*/
|
||||
public Call buildCall(String path, String method, List<Pair> queryParams, Object body, Map<String, String> headerParams, Map<String, Object> formParams, String[] authNames) throws ApiException {
|
||||
public Call buildCall(String path, String method, List<Pair> queryParams, Object body, Map<String, String> headerParams, Map<String, Object> formParams, String[] authNames, ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
|
||||
updateParamsForAuth(authNames, queryParams, headerParams);
|
||||
|
||||
final String url = buildUrl(path, queryParams);
|
||||
@ -851,7 +851,15 @@ public class ApiClient {
|
||||
reqBody = RequestBody.create(MediaType.parse(contentType), serialize(body, contentType));
|
||||
}
|
||||
|
||||
Request request = reqBuilder.method(method, reqBody).build();
|
||||
Request request = null;
|
||||
|
||||
if(progressRequestListener != null && reqBody != null) {
|
||||
ProgressRequestBody progressRequestBody = new ProgressRequestBody(reqBody, progressRequestListener);
|
||||
request = reqBuilder.method(method, progressRequestBody).build();
|
||||
} else {
|
||||
request = reqBuilder.method(method, reqBody).build();
|
||||
}
|
||||
|
||||
return httpClient.newCall(request);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,70 @@
|
||||
package {{invokerPackage}};
|
||||
|
||||
import com.squareup.okhttp.MediaType;
|
||||
import com.squareup.okhttp.RequestBody;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import okio.Buffer;
|
||||
import okio.BufferedSink;
|
||||
import okio.ForwardingSink;
|
||||
import okio.Okio;
|
||||
import okio.Sink;
|
||||
|
||||
public class ProgressRequestBody extends RequestBody {
|
||||
|
||||
public interface ProgressRequestListener {
|
||||
void onRequestProgress(long bytesWritten, long contentLength, boolean done);
|
||||
}
|
||||
|
||||
private final RequestBody requestBody;
|
||||
|
||||
private final ProgressRequestListener progressListener;
|
||||
|
||||
private BufferedSink bufferedSink;
|
||||
|
||||
public ProgressRequestBody(RequestBody requestBody, ProgressRequestListener progressListener) {
|
||||
this.requestBody = requestBody;
|
||||
this.progressListener = progressListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MediaType contentType() {
|
||||
return requestBody.contentType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long contentLength() throws IOException {
|
||||
return requestBody.contentLength();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(BufferedSink sink) throws IOException {
|
||||
if (bufferedSink == null) {
|
||||
bufferedSink = Okio.buffer(sink(sink));
|
||||
}
|
||||
|
||||
requestBody.writeTo(bufferedSink);
|
||||
bufferedSink.flush();
|
||||
|
||||
}
|
||||
|
||||
private Sink sink(Sink sink) {
|
||||
return new ForwardingSink(sink) {
|
||||
|
||||
long bytesWritten = 0L;
|
||||
long contentLength = 0L;
|
||||
|
||||
@Override
|
||||
public void write(Buffer source, long byteCount) throws IOException {
|
||||
super.write(source, byteCount);
|
||||
if (contentLength == 0) {
|
||||
contentLength = contentLength();
|
||||
}
|
||||
|
||||
bytesWritten += byteCount;
|
||||
progressListener.onRequestProgress(bytesWritten, contentLength, bytesWritten == contentLength);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
package {{invokerPackage}};
|
||||
|
||||
import com.squareup.okhttp.MediaType;
|
||||
import com.squareup.okhttp.ResponseBody;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import okio.Buffer;
|
||||
import okio.BufferedSource;
|
||||
import okio.ForwardingSource;
|
||||
import okio.Okio;
|
||||
import okio.Source;
|
||||
|
||||
public class ProgressResponseBody extends ResponseBody {
|
||||
|
||||
public interface ProgressListener {
|
||||
void update(long bytesRead, long contentLength, boolean done);
|
||||
}
|
||||
|
||||
private final ResponseBody responseBody;
|
||||
private final ProgressListener progressListener;
|
||||
private BufferedSource bufferedSource;
|
||||
|
||||
public ProgressResponseBody(ResponseBody responseBody, ProgressListener progressListener) {
|
||||
this.responseBody = responseBody;
|
||||
this.progressListener = progressListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MediaType contentType() {
|
||||
return responseBody.contentType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long contentLength() throws IOException {
|
||||
return responseBody.contentLength();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BufferedSource source() throws IOException {
|
||||
if (bufferedSource == null) {
|
||||
bufferedSource = Okio.buffer(source(responseBody.source()));
|
||||
}
|
||||
return bufferedSource;
|
||||
}
|
||||
|
||||
private Source source(Source source) {
|
||||
return new ForwardingSource(source) {
|
||||
long totalBytesRead = 0L;
|
||||
|
||||
@Override
|
||||
public long read(Buffer sink, long byteCount) throws IOException {
|
||||
long bytesRead = super.read(sink, byteCount);
|
||||
// read() returns the number of bytes read, or -1 if this source is exhausted.
|
||||
totalBytesRead += bytesRead != -1 ? bytesRead : 0;
|
||||
progressListener.update(totalBytesRead, responseBody.contentLength(), bytesRead == -1);
|
||||
return bytesRead;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,10 +5,16 @@ import {{invokerPackage}}.ApiClient;
|
||||
import {{invokerPackage}}.ApiException;
|
||||
import {{invokerPackage}}.Configuration;
|
||||
import {{invokerPackage}}.Pair;
|
||||
import {{invokerPackage}}.ProgressRequestBody;
|
||||
import {{invokerPackage}}.ProgressResponseBody;
|
||||
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import com.squareup.okhttp.Call;
|
||||
import com.squareup.okhttp.Interceptor;
|
||||
import com.squareup.okhttp.Response;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
{{#imports}}import {{import}};
|
||||
{{/imports}}
|
||||
@ -40,7 +46,7 @@ public class {{classname}} {
|
||||
|
||||
{{#operation}}
|
||||
/* Build call for {{operationId}} */
|
||||
private Call {{operationId}}Call({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) throws ApiException {
|
||||
private Call {{operationId}}Call({{#allParams}}{{{dataType}}} {{paramName}}, {{/allParams}}final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
|
||||
Object {{localVariablePrefix}}postBody = {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}};
|
||||
{{#allParams}}{{#required}}
|
||||
// verify the required parameter '{{paramName}}' is set
|
||||
@ -77,8 +83,20 @@ public class {{classname}} {
|
||||
final String {{localVariablePrefix}}contentType = {{localVariablePrefix}}apiClient.selectHeaderContentType({{localVariablePrefix}}contentTypes);
|
||||
{{localVariablePrefix}}headerParams.put("Content-Type", {{localVariablePrefix}}contentType);
|
||||
|
||||
if(progressListener != null) {
|
||||
apiClient.getHttpClient().networkInterceptors().add(new Interceptor() {
|
||||
@Override
|
||||
public Response intercept(Interceptor.Chain chain) throws IOException {
|
||||
Response originalResponse = chain.proceed(chain.request());
|
||||
return originalResponse.newBuilder()
|
||||
.body(new ProgressResponseBody(originalResponse.body(), progressListener))
|
||||
.build();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
String[] {{localVariablePrefix}}authNames = new String[] { {{#authMethods}}"{{name}}"{{#hasMore}}, {{/hasMore}}{{/authMethods}} };
|
||||
return {{localVariablePrefix}}apiClient.buildCall({{localVariablePrefix}}path, "{{httpMethod}}", {{localVariablePrefix}}queryParams, {{localVariablePrefix}}postBody, {{localVariablePrefix}}headerParams, {{localVariablePrefix}}formParams, {{localVariablePrefix}}authNames);
|
||||
return {{localVariablePrefix}}apiClient.buildCall({{localVariablePrefix}}path, "{{httpMethod}}", {{localVariablePrefix}}queryParams, {{localVariablePrefix}}postBody, {{localVariablePrefix}}headerParams, {{localVariablePrefix}}formParams, {{localVariablePrefix}}authNames, progressRequestListener);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -88,7 +106,7 @@ public class {{classname}} {
|
||||
* @return {{{returnType}}}{{/returnType}}
|
||||
*/
|
||||
public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{operationId}}({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) throws ApiException {
|
||||
Call {{localVariablePrefix}}call = {{operationId}}Call({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
|
||||
Call {{localVariablePrefix}}call = {{operationId}}Call({{#allParams}}{{paramName}}, {{/allParams}}null, null);
|
||||
{{#returnType}}Type {{localVariablePrefix}}returnType = new TypeToken<{{{returnType}}}>(){}.getType();
|
||||
return {{localVariablePrefix}}apiClient.execute({{localVariablePrefix}}call, {{localVariablePrefix}}returnType);{{/returnType}}{{^returnType}}{{localVariablePrefix}}apiClient.execute({{localVariablePrefix}}call);{{/returnType}}
|
||||
}
|
||||
@ -100,8 +118,28 @@ public class {{classname}} {
|
||||
* @param callback The callback to be executed when the API call finishes
|
||||
* @return The request call
|
||||
*/
|
||||
public Call {{operationId}}Async({{#allParams}}{{{dataType}}} {{paramName}}, {{/allParams}}ApiCallback<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> {{localVariablePrefix}}callback) throws ApiException {
|
||||
Call {{localVariablePrefix}}call = {{operationId}}Call({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
|
||||
public Call {{operationId}}Async({{#allParams}}{{{dataType}}} {{paramName}}, {{/allParams}}final ApiCallback<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> {{localVariablePrefix}}callback) throws ApiException {
|
||||
|
||||
ProgressResponseBody.ProgressListener progressListener = null;
|
||||
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
|
||||
|
||||
if (callback != null) {
|
||||
progressListener = new ProgressResponseBody.ProgressListener() {
|
||||
@Override
|
||||
public void update(long bytesRead, long contentLength, boolean done) {
|
||||
callback.onDownloadProgress(bytesRead, contentLength, done);
|
||||
}
|
||||
};
|
||||
|
||||
progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
|
||||
@Override
|
||||
public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
|
||||
callback.onUploadProgress(bytesWritten, contentLength, done);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Call {{localVariablePrefix}}call = {{operationId}}Call({{#allParams}}{{paramName}}, {{/allParams}}progressListener, progressRequestListener);
|
||||
{{#returnType}}Type {{localVariablePrefix}}returnType = new TypeToken<{{{returnType}}}>(){}.getType();
|
||||
{{localVariablePrefix}}apiClient.executeAsync({{localVariablePrefix}}call, {{localVariablePrefix}}returnType, {{localVariablePrefix}}callback);{{/returnType}}{{^returnType}}{{localVariablePrefix}}apiClient.executeAsync({{localVariablePrefix}}call, {{localVariablePrefix}}callback);{{/returnType}}
|
||||
return {{localVariablePrefix}}call;
|
||||
|
@ -98,8 +98,8 @@ ext {
|
||||
dependencies {
|
||||
compile "com.squareup.okhttp:okhttp:$okhttp_version"
|
||||
compile "com.squareup.retrofit:retrofit:$retrofit_version"
|
||||
compile 'com.google.code.gson:gson:$gson_version'
|
||||
compile 'com.squareup.retrofit:converter-gson:$retrofit_version'
|
||||
compile "com.google.code.gson:gson:$gson_version"
|
||||
compile "com.squareup.retrofit:converter-gson:$retrofit_version"
|
||||
compile "io.swagger:swagger-annotations:$swagger_annotations_version"
|
||||
compile "org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:$oltu_version"
|
||||
testCompile "junit:junit:$junit_version"
|
||||
|
@ -9,7 +9,7 @@ import java.io.Serializable;{{/serializableModel}}
|
||||
import java.util.Objects;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
{{#models}}
|
||||
|
||||
{{#model}}{{#description}}
|
||||
|
@ -5,6 +5,8 @@ package {{package}};
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import java.util.Objects;
|
||||
{{#models}}
|
||||
|
||||
{{#model}}{{#unescapedDescription}}
|
||||
@ -38,6 +40,25 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {
|
||||
|
||||
{{/vars}}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
{{classname}} {{classVarName}} = ({{classname}}) o;{{#hasVars}}
|
||||
return {{#vars}}Objects.equals({{name}}, {{classVarName}}.{{name}}){{#hasMore}} &&
|
||||
{{/hasMore}}{{^hasMore}};{{/hasMore}}{{/vars}}{{/hasVars}}{{^hasVars}}
|
||||
return true;{{/hasVars}}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash({{#vars}}{{name}}{{#hasMore}}, {{/hasMore}}{{/vars}});
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
@ -5,6 +5,8 @@ package {{package}};
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import java.util.Objects;
|
||||
{{#models}}
|
||||
|
||||
{{#model}}{{#description}}
|
||||
@ -38,6 +40,25 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {
|
||||
|
||||
{{/vars}}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
{{classname}} {{classVarName}} = ({{classname}}) o;{{#hasVars}}
|
||||
return {{#vars}}Objects.equals({{name}}, {{classVarName}}.{{name}}){{#hasMore}} &&
|
||||
{{/hasMore}}{{^hasMore}};{{/hasMore}}{{/vars}}{{/hasVars}}{{^hasVars}}
|
||||
return true;{{/hasVars}}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash({{#vars}}{{name}}{{#hasMore}}, {{/hasMore}}{{/vars}});
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
@ -18,6 +18,7 @@ io.swagger.codegen.languages.ScalaClientCodegen
|
||||
io.swagger.codegen.languages.ScalatraServerCodegen
|
||||
io.swagger.codegen.languages.SilexServerCodegen
|
||||
io.swagger.codegen.languages.SinatraServerCodegen
|
||||
io.swagger.codegen.languages.SlimFrameworkServerCodegen
|
||||
io.swagger.codegen.languages.SpringMVCServerCodegen
|
||||
io.swagger.codegen.languages.StaticDocCodegen
|
||||
io.swagger.codegen.languages.StaticHtmlGenerator
|
||||
|
@ -23,7 +23,7 @@ namespace {{packageName}}.Api
|
||||
/// </remarks>
|
||||
{{#allParams}}/// <param name="{{paramName}}">{{description}}</param>
|
||||
{{/allParams}}/// <returns>{{#returnType}}{{^returnContainer}}{{{returnType}}}{{/returnContainer}}{{/returnType}}</returns>
|
||||
{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} {{nickname}} ({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
|
||||
{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} {{operationId}} ({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = null{{/optionalMethodArgument}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
|
||||
|
||||
/// <summary>
|
||||
/// {{summary}}
|
||||
@ -33,7 +33,7 @@ namespace {{packageName}}.Api
|
||||
/// </remarks>
|
||||
{{#allParams}}/// <param name="{{paramName}}">{{description}}</param>
|
||||
{{/allParams}}/// <returns>{{#returnType}}{{^returnContainer}}{{{returnType}}}{{/returnContainer}}{{/returnType}}</returns>
|
||||
{{#returnType}}System.Threading.Tasks.Task<{{{returnType}}}>{{/returnType}}{{^returnType}}System.Threading.Tasks.Task{{/returnType}} {{nickname}}Async ({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
|
||||
{{#returnType}}System.Threading.Tasks.Task<{{{returnType}}}>{{/returnType}}{{^returnType}}System.Threading.Tasks.Task{{/returnType}} {{operationId}}Async ({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = null{{/optionalMethodArgument}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
|
||||
{{/operation}}
|
||||
}
|
||||
|
||||
@ -95,11 +95,11 @@ namespace {{packageName}}.Api
|
||||
/// </summary>
|
||||
{{#allParams}}/// <param name="{{paramName}}">{{description}}</param>
|
||||
{{/allParams}}/// <returns>{{#returnType}}{{^returnContainer}}{{{returnType}}}{{/returnContainer}}{{/returnType}}</returns>
|
||||
public {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} {{nickname}} ({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}})
|
||||
public {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} {{operationId}} ({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = null{{/optionalMethodArgument}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}})
|
||||
{
|
||||
{{#allParams}}{{#required}}
|
||||
// verify the required parameter '{{paramName}}' is set
|
||||
if ({{paramName}} == null) throw new ApiException(400, "Missing required parameter '{{paramName}}' when calling {{nickname}}");
|
||||
if ({{paramName}} == null) throw new ApiException(400, "Missing required parameter '{{paramName}}' when calling {{operationId}}");
|
||||
{{/required}}{{/allParams}}
|
||||
|
||||
var path_ = "{{path}}";
|
||||
@ -140,9 +140,9 @@ namespace {{packageName}}.Api
|
||||
IRestResponse response = (IRestResponse) ApiClient.CallApi(path_, Method.{{httpMethod}}, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings);
|
||||
|
||||
if (((int)response.StatusCode) >= 400)
|
||||
throw new ApiException ((int)response.StatusCode, "Error calling {{nickname}}: " + response.Content, response.Content);
|
||||
throw new ApiException ((int)response.StatusCode, "Error calling {{operationId}}: " + response.Content, response.Content);
|
||||
else if (((int)response.StatusCode) == 0)
|
||||
throw new ApiException ((int)response.StatusCode, "Error calling {{nickname}}: " + response.ErrorMessage, response.ErrorMessage);
|
||||
throw new ApiException ((int)response.StatusCode, "Error calling {{operationId}}: " + response.ErrorMessage, response.ErrorMessage);
|
||||
|
||||
{{#returnType}}return ({{{returnType}}}) ApiClient.Deserialize(response, typeof({{{returnType}}}));{{/returnType}}{{^returnType}}return;{{/returnType}}
|
||||
}
|
||||
@ -152,10 +152,10 @@ namespace {{packageName}}.Api
|
||||
/// </summary>
|
||||
{{#allParams}}/// <param name="{{paramName}}">{{description}}</param>
|
||||
{{/allParams}}/// <returns>{{#returnType}}{{^returnContainer}}{{{returnType}}}{{/returnContainer}}{{/returnType}}</returns>
|
||||
{{#returnType}}public async System.Threading.Tasks.Task<{{{returnType}}}>{{/returnType}}{{^returnType}}public async System.Threading.Tasks.Task{{/returnType}} {{nickname}}Async ({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}})
|
||||
{{#returnType}}public async System.Threading.Tasks.Task<{{{returnType}}}>{{/returnType}}{{^returnType}}public async System.Threading.Tasks.Task{{/returnType}} {{operationId}}Async ({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = null{{/optionalMethodArgument}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}})
|
||||
{
|
||||
{{#allParams}}{{#required}}// verify the required parameter '{{paramName}}' is set
|
||||
if ({{paramName}} == null) throw new ApiException(400, "Missing required parameter '{{paramName}}' when calling {{nickname}}");
|
||||
if ({{paramName}} == null) throw new ApiException(400, "Missing required parameter '{{paramName}}' when calling {{operationId}}");
|
||||
{{/required}}{{/allParams}}
|
||||
|
||||
var path_ = "{{path}}";
|
||||
@ -195,7 +195,7 @@ namespace {{packageName}}.Api
|
||||
// make the HTTP request
|
||||
IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path_, Method.{{httpMethod}}, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings);
|
||||
if (((int)response.StatusCode) >= 400)
|
||||
throw new ApiException ((int)response.StatusCode, "Error calling {{nickname}}: " + response.Content, response.Content);
|
||||
throw new ApiException ((int)response.StatusCode, "Error calling {{operationId}}: " + response.Content, response.Content);
|
||||
|
||||
{{#returnType}}return ({{{returnType}}}) ApiClient.Deserialize(response, typeof({{{returnType}}}));{{/returnType}}{{^returnType}}
|
||||
return;{{/returnType}}
|
||||
|
@ -43,6 +43,19 @@ module {{moduleName}}
|
||||
@{{{name}}} = {{{name}}}
|
||||
end
|
||||
{{/isEnum}}{{/vars}}
|
||||
def ==(o)
|
||||
return true if self.equal?(o)
|
||||
self.class == o.class{{#vars}} &&
|
||||
{{name}} == o.{{name}}{{/vars}}
|
||||
end
|
||||
|
||||
def eql?(o)
|
||||
self == o
|
||||
end
|
||||
|
||||
def hash
|
||||
[{{#vars}}{{name}}{{#hasMore}}, {{/hasMore}}{{/vars}}].hash
|
||||
end
|
||||
end
|
||||
{{/model}}
|
||||
{{/models}}
|
||||
|
@ -0,0 +1,5 @@
|
||||
<IfModule mod_rewrite.c>
|
||||
RewriteEngine On
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteRule ^(.*)$ index.php?_url=/$1 [QSA,L]
|
||||
</IfModule>
|
@ -0,0 +1,10 @@
|
||||
# Swagger generated server
|
||||
|
||||
## Overview
|
||||
This server was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. By using the
|
||||
[swagger-spec](https://github.com/swagger-api/swagger-core/wiki) from a remote server, you can easily generate a server stub. This
|
||||
is an example of building a PHP server.
|
||||
|
||||
This example uses the [Slim Framework](http://www.slimframework.com/). To see how to make this your own, please take a look at the template here:
|
||||
|
||||
[TEMPLATES](https://github.com/swagger-api/swagger-codegen/tree/master/modules/swagger-codegen/src/main/resources/slim/)
|
@ -0,0 +1,6 @@
|
||||
{
|
||||
"minimum-stability": "RC",
|
||||
"require": {
|
||||
"slim/slim": "3.*"
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
{{#apiInfo}}/**
|
||||
* {{appName}}
|
||||
* @version {{appVersion}}
|
||||
*/
|
||||
|
||||
require_once __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
$app = new Slim\App();
|
||||
|
||||
{{#apis}}{{#operations}}{{#operation}}
|
||||
/**
|
||||
* {{httpMethod}} {{nickname}}
|
||||
* Summary: {{summary}}
|
||||
* Notes: {{notes}}
|
||||
{{#hasProduces}} * Output-Formats: [{{#produces}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/produces}}]{{/hasProduces}}
|
||||
*/
|
||||
$app->{{httpMethod}}('{{path}}', function($request, $response, $args) {
|
||||
{{#hasHeaderParams}}$headers = $request->getHeaders();{{/hasHeaderParams}}
|
||||
{{#hasQueryParams}}$queryParams = $request->getQueryParams();
|
||||
{{#queryParams}}${{paramName}} = $queryParams['{{paramName}}'];{{newline}} {{/queryParams}}{{/hasQueryParams}}
|
||||
{{#hasFormParams}}{{#formParams}}${{paramName}} = $args['{{paramName}}'];{{newline}} {{/formParams}}{{/hasFormParams}}
|
||||
{{#hasBodyParam}}$body = $request->getParsedBody();{{/hasBodyParam}}
|
||||
$response->write('How about implementing {{nickname}} as a {{httpMethod}} method ?');
|
||||
return $response;
|
||||
});
|
||||
|
||||
{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
|
||||
|
||||
$app->run();
|
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
{{#models}}{{#model}}/*
|
||||
* {{classname}}
|
||||
*/
|
||||
namespace {{package}};
|
||||
|
||||
/*
|
||||
* {{classname}}
|
||||
*/
|
||||
class {{classname}} {
|
||||
{{#vars}}/* @var {{datatype}} ${{name}} {{#description}}{{description}}{{/description}} */
|
||||
private ${{name}};
|
||||
{{/vars}}
|
||||
}
|
||||
{{/model}}{{/models}}
|
@ -14,7 +14,7 @@ public class CodegenTest {
|
||||
|
||||
@Test(description = "read a file upload param from a 2.0 spec")
|
||||
public void fileUploadParamTest() {
|
||||
final Swagger model = new SwaggerParser().read("src/test/resources/2_0/petstore.json");
|
||||
final Swagger model = parseAndPrepareSwagger("src/test/resources/2_0/petstore.json");
|
||||
final DefaultCodegen codegen = new DefaultCodegen();
|
||||
final String path = "/pet/{petId}/uploadImage";
|
||||
final Operation p = model.getPaths().get(path).getPost();
|
||||
@ -39,7 +39,7 @@ public class CodegenTest {
|
||||
|
||||
@Test(description = "read formParam values from a 2.0 spec")
|
||||
public void formParamTest() {
|
||||
final Swagger model = new SwaggerParser().read("src/test/resources/2_0/petstore.json");
|
||||
final Swagger model = parseAndPrepareSwagger("src/test/resources/2_0/petstore.json");
|
||||
final DefaultCodegen codegen = new DefaultCodegen();
|
||||
final String path = "/pet/{petId}";
|
||||
final Operation p = model.getPaths().get(path).getPost();
|
||||
@ -83,7 +83,7 @@ public class CodegenTest {
|
||||
|
||||
@Test(description = "handle required parameters from a 2.0 spec as required when figuring out Swagger types")
|
||||
public void requiredParametersTest() {
|
||||
final Swagger model = new SwaggerParser().read("src/test/resources/2_0/requiredTest.json");
|
||||
final Swagger model = parseAndPrepareSwagger("src/test/resources/2_0/requiredTest.json");
|
||||
|
||||
final DefaultCodegen codegen = new DefaultCodegen() {
|
||||
public String getSwaggerType(Property p) {
|
||||
@ -106,7 +106,7 @@ public class CodegenTest {
|
||||
|
||||
@Test(description = "select main response from a 2.0 spec using the lowest 2XX code")
|
||||
public void responseSelectionTest1() {
|
||||
final Swagger model = new SwaggerParser().read("src/test/resources/2_0/responseSelectionTest.json");
|
||||
final Swagger model = parseAndPrepareSwagger("src/test/resources/2_0/responseSelectionTest.json");
|
||||
final DefaultCodegen codegen = new DefaultCodegen();
|
||||
final String path = "/tests/withTwoHundredAndDefault";
|
||||
final Operation p = model.getPaths().get(path).getGet();
|
||||
@ -117,7 +117,7 @@ public class CodegenTest {
|
||||
|
||||
@Test(description = "select main response from a 2.0 spec using the default keyword when no 2XX code")
|
||||
public void responseSelectionTest2() {
|
||||
final Swagger model = new SwaggerParser().read("src/test/resources/2_0/responseSelectionTest.json");
|
||||
final Swagger model = parseAndPrepareSwagger("src/test/resources/2_0/responseSelectionTest.json");
|
||||
final DefaultCodegen codegen = new DefaultCodegen();
|
||||
final String path = "/tests/withoutTwoHundredButDefault";
|
||||
final Operation p = model.getPaths().get(path).getGet();
|
||||
@ -128,7 +128,7 @@ public class CodegenTest {
|
||||
|
||||
@Test(description = "return byte array when response format is byte")
|
||||
public void binaryDataTest() {
|
||||
final Swagger model = new SwaggerParser().read("src/test/resources/2_0/binaryDataTest.json");
|
||||
final Swagger model = parseAndPrepareSwagger("src/test/resources/2_0/binaryDataTest.json");
|
||||
final DefaultCodegen codegen = new DefaultCodegen();
|
||||
final String path = "/tests/binaryResponse";
|
||||
final Operation p = model.getPaths().get(path).getPost();
|
||||
@ -142,7 +142,7 @@ public class CodegenTest {
|
||||
|
||||
@Test(description = "use operation consumes and produces")
|
||||
public void localConsumesAndProducesTest() {
|
||||
final Swagger model = new SwaggerParser().read("src/test/resources/2_0/globalConsumesAndProduces.json");
|
||||
final Swagger model = parseAndPrepareSwagger("src/test/resources/2_0/globalConsumesAndProduces.json");
|
||||
final DefaultCodegen codegen = new DefaultCodegen();
|
||||
final String path = "/tests/localConsumesAndProduces";
|
||||
final Operation p = model.getPaths().get(path).getGet();
|
||||
@ -158,7 +158,7 @@ public class CodegenTest {
|
||||
|
||||
@Test(description = "use spec consumes and produces")
|
||||
public void globalConsumesAndProducesTest() {
|
||||
final Swagger model = new SwaggerParser().read("src/test/resources/2_0/globalConsumesAndProduces.json");
|
||||
final Swagger model = parseAndPrepareSwagger("src/test/resources/2_0/globalConsumesAndProduces.json");
|
||||
final DefaultCodegen codegen = new DefaultCodegen();
|
||||
final String path = "/tests/globalConsumesAndProduces";
|
||||
final Operation p = model.getPaths().get(path).getGet();
|
||||
@ -174,7 +174,7 @@ public class CodegenTest {
|
||||
|
||||
@Test(description = "use operation consumes and produces (reset in operation with empty array)")
|
||||
public void localResetConsumesAndProducesTest() {
|
||||
final Swagger model = new SwaggerParser().read("src/test/resources/2_0/globalConsumesAndProduces.json");
|
||||
final Swagger model = parseAndPrepareSwagger("src/test/resources/2_0/globalConsumesAndProduces.json");
|
||||
final DefaultCodegen codegen = new DefaultCodegen();
|
||||
final String path = "/tests/localResetConsumesAndProduces";
|
||||
final Operation p = model.getPaths().get(path).getGet();
|
||||
@ -187,4 +187,11 @@ public class CodegenTest {
|
||||
Assert.assertNull(op.produces);
|
||||
|
||||
}
|
||||
|
||||
private Swagger parseAndPrepareSwagger(String path) {
|
||||
Swagger swagger = new SwaggerParser().read(path);
|
||||
// resolve inline models
|
||||
new InlineModelResolver().flatten(swagger);
|
||||
return swagger;
|
||||
}
|
||||
}
|
||||
|
@ -127,6 +127,28 @@ public class InlineModelResolverTest {
|
||||
assertNotNull(impl.getProperties().get("address"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void notResolveNonModelBodyParameter() throws Exception {
|
||||
Swagger swagger = new Swagger();
|
||||
|
||||
swagger.path("/hello", new Path()
|
||||
.get(new Operation()
|
||||
.parameter(new BodyParameter()
|
||||
.name("body")
|
||||
.schema(new ModelImpl()
|
||||
.type("string")
|
||||
.format("binary")))));
|
||||
|
||||
new InlineModelResolver().flatten(swagger);
|
||||
|
||||
Operation operation = swagger.getPaths().get("/hello").getGet();
|
||||
BodyParameter bp = (BodyParameter)operation.getParameters().get(0);
|
||||
assertTrue(bp.getSchema() instanceof ModelImpl);
|
||||
ModelImpl m = (ModelImpl) bp.getSchema();
|
||||
assertEquals("string", m.getType());
|
||||
assertEquals("binary", m.getFormat());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resolveInlineArrayBodyParameter() throws Exception {
|
||||
Swagger swagger = new Swagger();
|
||||
|
@ -27,6 +27,8 @@ public class CSharpClientOptionsTest extends AbstractOptionsTest {
|
||||
new Expectations(clientCodegen) {{
|
||||
clientCodegen.setPackageName(CSharpClientOptionsProvider.PACKAGE_NAME_VALUE);
|
||||
times = 1;
|
||||
clientCodegen.setOptionalMethodArgumentFlag(true);
|
||||
times = 1;
|
||||
clientCodegen.setPackageVersion(CSharpClientOptionsProvider.PACKAGE_VERSION_VALUE);
|
||||
times = 1;
|
||||
}};
|
||||
|
@ -21,6 +21,7 @@ public class CSharpClientOptionsProvider implements OptionsProvider {
|
||||
return builder.put(CodegenConstants.PACKAGE_NAME, PACKAGE_NAME_VALUE)
|
||||
.put(CodegenConstants.PACKAGE_VERSION, PACKAGE_VERSION_VALUE)
|
||||
.put(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG, "true")
|
||||
.put(CodegenConstants.OPTIONAL_METHOD_ARGUMENT, "true")
|
||||
.build();
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,30 @@
|
||||
package io.swagger.codegen.options;
|
||||
|
||||
import io.swagger.codegen.CodegenConstants;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class SlimFrameworkServerOptionsProvider implements OptionsProvider {
|
||||
public static final String SORT_PARAMS_VALUE = "false";
|
||||
public static final String ENSURE_UNIQUE_PARAMS_VALUE = "true";
|
||||
|
||||
@Override
|
||||
public String getLanguage() {
|
||||
return "slim";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> createOptions() {
|
||||
ImmutableMap.Builder<String, String> builder = new ImmutableMap.Builder<String, String>();
|
||||
return builder.put(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG, SORT_PARAMS_VALUE)
|
||||
.put(CodegenConstants.ENSURE_UNIQUE_PARAMS, ENSURE_UNIQUE_PARAMS_VALUE)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isServer() {
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package io.swagger.codegen.slim;
|
||||
|
||||
import io.swagger.codegen.AbstractOptionsTest;
|
||||
import io.swagger.codegen.CodegenConfig;
|
||||
import io.swagger.codegen.languages.SlimFrameworkServerCodegen;
|
||||
import io.swagger.codegen.options.SlimFrameworkServerOptionsProvider;
|
||||
|
||||
import mockit.Expectations;
|
||||
import mockit.Tested;
|
||||
|
||||
public class SlimFrameworkServerOptionsTest extends AbstractOptionsTest {
|
||||
|
||||
@Tested
|
||||
private SlimFrameworkServerCodegen clientCodegen;
|
||||
|
||||
public SlimFrameworkServerOptionsTest() {
|
||||
super(new SlimFrameworkServerOptionsProvider());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CodegenConfig getCodegenConfig() {
|
||||
return clientCodegen;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setExpectations() {
|
||||
new Expectations(clientCodegen) {{
|
||||
clientCodegen.setSortParamsByRequiredFlag(Boolean.valueOf(SlimFrameworkServerOptionsProvider.SORT_PARAMS_VALUE));
|
||||
times = 1;
|
||||
}};
|
||||
}
|
||||
}
|
@ -28,6 +28,7 @@ import io.swagger.codegen.options.ScalaClientOptionsProvider;
|
||||
import io.swagger.codegen.options.ScalatraServerOptionsProvider;
|
||||
import io.swagger.codegen.options.SilexServerOptionsProvider;
|
||||
import io.swagger.codegen.options.SinatraServerOptionsProvider;
|
||||
import io.swagger.codegen.options.SlimFrameworkServerOptionsProvider;
|
||||
import io.swagger.codegen.options.SpringMVCServerOptionsProvider;
|
||||
import io.swagger.codegen.options.StaticDocOptionsProvider;
|
||||
import io.swagger.codegen.options.StaticHtmlOptionsProvider;
|
||||
@ -77,11 +78,12 @@ public class OnlineGeneratorOptionsTest {
|
||||
{new PythonClientOptionsProvider()}, {new Qt5CPPOptionsProvider()},
|
||||
{new RubyClientOptionsProvider()}, {new ScalaClientOptionsProvider()},
|
||||
{new ScalatraServerOptionsProvider()}, {new SilexServerOptionsProvider()},
|
||||
{new SinatraServerOptionsProvider()}, {new SpringMVCServerOptionsProvider()},
|
||||
{new StaticDocOptionsProvider()}, {new StaticHtmlOptionsProvider()},
|
||||
{new SwaggerOptionsProvider()}, {new SwaggerYamlOptionsProvider()},
|
||||
{new SwiftOptionsProvider()}, {new TizenClientOptionsProvider()},
|
||||
{new TypeScriptAngularClientOptionsProvider()}, {new TypeScriptNodeClientOptionsProvider()}
|
||||
{new SinatraServerOptionsProvider()}, {new SlimFrameworkServerOptionsProvider()},
|
||||
{new SpringMVCServerOptionsProvider()}, {new StaticDocOptionsProvider()},
|
||||
{new StaticHtmlOptionsProvider()}, {new SwaggerOptionsProvider()},
|
||||
{new SwaggerYamlOptionsProvider()}, {new SwiftOptionsProvider()},
|
||||
{new TizenClientOptionsProvider()}, {new TypeScriptAngularClientOptionsProvider()},
|
||||
{new TypeScriptNodeClientOptionsProvider()}
|
||||
};
|
||||
}
|
||||
|
||||
@ -107,7 +109,12 @@ public class OnlineGeneratorOptionsTest {
|
||||
outputFilename = Generator.generateClient(provider.getLanguage(), input);
|
||||
}
|
||||
final File dir = new File(new File(outputFilename).getParent());
|
||||
FileUtils.deleteDirectory(dir);
|
||||
|
||||
try {
|
||||
FileUtils.deleteDirectory(dir);
|
||||
} catch (Exception e) { // directory can't be deleted for some reasons
|
||||
e.printStackTrace();
|
||||
}
|
||||
for (InvocationCounter option : options.values()) {
|
||||
assertNotEquals(option.getCounter(), 0, String.format("Option \"%s\" wasn't processed.",
|
||||
option.getValue()));
|
||||
|
@ -22,7 +22,7 @@ namespace IO.Swagger.Api
|
||||
/// </remarks>
|
||||
/// <param name="body">Pet object that needs to be added to the store</param>
|
||||
/// <returns></returns>
|
||||
void UpdatePet (Pet body);
|
||||
void UpdatePet (Pet body = null);
|
||||
|
||||
/// <summary>
|
||||
/// Update an existing pet
|
||||
@ -32,7 +32,7 @@ namespace IO.Swagger.Api
|
||||
/// </remarks>
|
||||
/// <param name="body">Pet object that needs to be added to the store</param>
|
||||
/// <returns></returns>
|
||||
System.Threading.Tasks.Task UpdatePetAsync (Pet body);
|
||||
System.Threading.Tasks.Task UpdatePetAsync (Pet body = null);
|
||||
|
||||
/// <summary>
|
||||
/// Add a new pet to the store
|
||||
@ -42,7 +42,7 @@ namespace IO.Swagger.Api
|
||||
/// </remarks>
|
||||
/// <param name="body">Pet object that needs to be added to the store</param>
|
||||
/// <returns></returns>
|
||||
void AddPet (Pet body);
|
||||
void AddPet (Pet body = null);
|
||||
|
||||
/// <summary>
|
||||
/// Add a new pet to the store
|
||||
@ -52,7 +52,7 @@ namespace IO.Swagger.Api
|
||||
/// </remarks>
|
||||
/// <param name="body">Pet object that needs to be added to the store</param>
|
||||
/// <returns></returns>
|
||||
System.Threading.Tasks.Task AddPetAsync (Pet body);
|
||||
System.Threading.Tasks.Task AddPetAsync (Pet body = null);
|
||||
|
||||
/// <summary>
|
||||
/// Finds Pets by status
|
||||
@ -62,7 +62,7 @@ namespace IO.Swagger.Api
|
||||
/// </remarks>
|
||||
/// <param name="status">Status values that need to be considered for filter</param>
|
||||
/// <returns></returns>
|
||||
List<Pet> FindPetsByStatus (List<string> status);
|
||||
List<Pet> FindPetsByStatus (List<string> status = null);
|
||||
|
||||
/// <summary>
|
||||
/// Finds Pets by status
|
||||
@ -72,7 +72,7 @@ namespace IO.Swagger.Api
|
||||
/// </remarks>
|
||||
/// <param name="status">Status values that need to be considered for filter</param>
|
||||
/// <returns></returns>
|
||||
System.Threading.Tasks.Task<List<Pet>> FindPetsByStatusAsync (List<string> status);
|
||||
System.Threading.Tasks.Task<List<Pet>> FindPetsByStatusAsync (List<string> status = null);
|
||||
|
||||
/// <summary>
|
||||
/// Finds Pets by tags
|
||||
@ -82,7 +82,7 @@ namespace IO.Swagger.Api
|
||||
/// </remarks>
|
||||
/// <param name="tags">Tags to filter by</param>
|
||||
/// <returns></returns>
|
||||
List<Pet> FindPetsByTags (List<string> tags);
|
||||
List<Pet> FindPetsByTags (List<string> tags = null);
|
||||
|
||||
/// <summary>
|
||||
/// Finds Pets by tags
|
||||
@ -92,7 +92,7 @@ namespace IO.Swagger.Api
|
||||
/// </remarks>
|
||||
/// <param name="tags">Tags to filter by</param>
|
||||
/// <returns></returns>
|
||||
System.Threading.Tasks.Task<List<Pet>> FindPetsByTagsAsync (List<string> tags);
|
||||
System.Threading.Tasks.Task<List<Pet>> FindPetsByTagsAsync (List<string> tags = null);
|
||||
|
||||
/// <summary>
|
||||
/// Find pet by ID
|
||||
@ -124,7 +124,7 @@ namespace IO.Swagger.Api
|
||||
/// <param name="name">Updated name of the pet</param>
|
||||
/// <param name="status">Updated status of the pet</param>
|
||||
/// <returns></returns>
|
||||
void UpdatePetWithForm (string petId, string name, string status);
|
||||
void UpdatePetWithForm (string petId, string name = null, string status = null);
|
||||
|
||||
/// <summary>
|
||||
/// Updates a pet in the store with form data
|
||||
@ -136,7 +136,7 @@ namespace IO.Swagger.Api
|
||||
/// <param name="name">Updated name of the pet</param>
|
||||
/// <param name="status">Updated status of the pet</param>
|
||||
/// <returns></returns>
|
||||
System.Threading.Tasks.Task UpdatePetWithFormAsync (string petId, string name, string status);
|
||||
System.Threading.Tasks.Task UpdatePetWithFormAsync (string petId, string name = null, string status = null);
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a pet
|
||||
@ -147,7 +147,7 @@ namespace IO.Swagger.Api
|
||||
/// <param name="petId">Pet id to delete</param>
|
||||
/// <param name="apiKey"></param>
|
||||
/// <returns></returns>
|
||||
void DeletePet (long? petId, string apiKey);
|
||||
void DeletePet (long? petId, string apiKey = null);
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a pet
|
||||
@ -158,7 +158,7 @@ namespace IO.Swagger.Api
|
||||
/// <param name="petId">Pet id to delete</param>
|
||||
/// <param name="apiKey"></param>
|
||||
/// <returns></returns>
|
||||
System.Threading.Tasks.Task DeletePetAsync (long? petId, string apiKey);
|
||||
System.Threading.Tasks.Task DeletePetAsync (long? petId, string apiKey = null);
|
||||
|
||||
/// <summary>
|
||||
/// uploads an image
|
||||
@ -170,7 +170,7 @@ namespace IO.Swagger.Api
|
||||
/// <param name="additionalMetadata">Additional data to pass to server</param>
|
||||
/// <param name="file">file to upload</param>
|
||||
/// <returns></returns>
|
||||
void UploadFile (long? petId, string additionalMetadata, Stream file);
|
||||
void UploadFile (long? petId, string additionalMetadata = null, Stream file = null);
|
||||
|
||||
/// <summary>
|
||||
/// uploads an image
|
||||
@ -182,7 +182,7 @@ namespace IO.Swagger.Api
|
||||
/// <param name="additionalMetadata">Additional data to pass to server</param>
|
||||
/// <param name="file">file to upload</param>
|
||||
/// <returns></returns>
|
||||
System.Threading.Tasks.Task UploadFileAsync (long? petId, string additionalMetadata, Stream file);
|
||||
System.Threading.Tasks.Task UploadFileAsync (long? petId, string additionalMetadata = null, Stream file = null);
|
||||
|
||||
}
|
||||
|
||||
@ -244,7 +244,7 @@ namespace IO.Swagger.Api
|
||||
/// </summary>
|
||||
/// <param name="body">Pet object that needs to be added to the store</param>
|
||||
/// <returns></returns>
|
||||
public void UpdatePet (Pet body)
|
||||
public void UpdatePet (Pet body = null)
|
||||
{
|
||||
|
||||
|
||||
@ -294,7 +294,7 @@ namespace IO.Swagger.Api
|
||||
/// </summary>
|
||||
/// <param name="body">Pet object that needs to be added to the store</param>
|
||||
/// <returns></returns>
|
||||
public async System.Threading.Tasks.Task UpdatePetAsync (Pet body)
|
||||
public async System.Threading.Tasks.Task UpdatePetAsync (Pet body = null)
|
||||
{
|
||||
|
||||
|
||||
@ -342,7 +342,7 @@ namespace IO.Swagger.Api
|
||||
/// </summary>
|
||||
/// <param name="body">Pet object that needs to be added to the store</param>
|
||||
/// <returns></returns>
|
||||
public void AddPet (Pet body)
|
||||
public void AddPet (Pet body = null)
|
||||
{
|
||||
|
||||
|
||||
@ -392,7 +392,7 @@ namespace IO.Swagger.Api
|
||||
/// </summary>
|
||||
/// <param name="body">Pet object that needs to be added to the store</param>
|
||||
/// <returns></returns>
|
||||
public async System.Threading.Tasks.Task AddPetAsync (Pet body)
|
||||
public async System.Threading.Tasks.Task AddPetAsync (Pet body = null)
|
||||
{
|
||||
|
||||
|
||||
@ -440,7 +440,7 @@ namespace IO.Swagger.Api
|
||||
/// </summary>
|
||||
/// <param name="status">Status values that need to be considered for filter</param>
|
||||
/// <returns></returns>
|
||||
public List<Pet> FindPetsByStatus (List<string> status)
|
||||
public List<Pet> FindPetsByStatus (List<string> status = null)
|
||||
{
|
||||
|
||||
|
||||
@ -490,7 +490,7 @@ namespace IO.Swagger.Api
|
||||
/// </summary>
|
||||
/// <param name="status">Status values that need to be considered for filter</param>
|
||||
/// <returns></returns>
|
||||
public async System.Threading.Tasks.Task<List<Pet>> FindPetsByStatusAsync (List<string> status)
|
||||
public async System.Threading.Tasks.Task<List<Pet>> FindPetsByStatusAsync (List<string> status = null)
|
||||
{
|
||||
|
||||
|
||||
@ -537,7 +537,7 @@ namespace IO.Swagger.Api
|
||||
/// </summary>
|
||||
/// <param name="tags">Tags to filter by</param>
|
||||
/// <returns></returns>
|
||||
public List<Pet> FindPetsByTags (List<string> tags)
|
||||
public List<Pet> FindPetsByTags (List<string> tags = null)
|
||||
{
|
||||
|
||||
|
||||
@ -587,7 +587,7 @@ namespace IO.Swagger.Api
|
||||
/// </summary>
|
||||
/// <param name="tags">Tags to filter by</param>
|
||||
/// <returns></returns>
|
||||
public async System.Threading.Tasks.Task<List<Pet>> FindPetsByTagsAsync (List<string> tags)
|
||||
public async System.Threading.Tasks.Task<List<Pet>> FindPetsByTagsAsync (List<string> tags = null)
|
||||
{
|
||||
|
||||
|
||||
@ -738,7 +738,7 @@ namespace IO.Swagger.Api
|
||||
/// <param name="name">Updated name of the pet</param>
|
||||
/// <param name="status">Updated status of the pet</param>
|
||||
/// <returns></returns>
|
||||
public void UpdatePetWithForm (string petId, string name, string status)
|
||||
public void UpdatePetWithForm (string petId, string name = null, string status = null)
|
||||
{
|
||||
|
||||
// verify the required parameter 'petId' is set
|
||||
@ -795,7 +795,7 @@ namespace IO.Swagger.Api
|
||||
/// <param name="name">Updated name of the pet</param>
|
||||
/// <param name="status">Updated status of the pet</param>
|
||||
/// <returns></returns>
|
||||
public async System.Threading.Tasks.Task UpdatePetWithFormAsync (string petId, string name, string status)
|
||||
public async System.Threading.Tasks.Task UpdatePetWithFormAsync (string petId, string name = null, string status = null)
|
||||
{
|
||||
// verify the required parameter 'petId' is set
|
||||
if (petId == null) throw new ApiException(400, "Missing required parameter 'petId' when calling UpdatePetWithForm");
|
||||
@ -848,7 +848,7 @@ namespace IO.Swagger.Api
|
||||
/// <param name="petId">Pet id to delete</param>
|
||||
/// <param name="apiKey"></param>
|
||||
/// <returns></returns>
|
||||
public void DeletePet (long? petId, string apiKey)
|
||||
public void DeletePet (long? petId, string apiKey = null)
|
||||
{
|
||||
|
||||
// verify the required parameter 'petId' is set
|
||||
@ -903,7 +903,7 @@ namespace IO.Swagger.Api
|
||||
/// <param name="petId">Pet id to delete</param>
|
||||
/// <param name="apiKey"></param>
|
||||
/// <returns></returns>
|
||||
public async System.Threading.Tasks.Task DeletePetAsync (long? petId, string apiKey)
|
||||
public async System.Threading.Tasks.Task DeletePetAsync (long? petId, string apiKey = null)
|
||||
{
|
||||
// verify the required parameter 'petId' is set
|
||||
if (petId == null) throw new ApiException(400, "Missing required parameter 'petId' when calling DeletePet");
|
||||
@ -956,7 +956,7 @@ namespace IO.Swagger.Api
|
||||
/// <param name="additionalMetadata">Additional data to pass to server</param>
|
||||
/// <param name="file">file to upload</param>
|
||||
/// <returns></returns>
|
||||
public void UploadFile (long? petId, string additionalMetadata, Stream file)
|
||||
public void UploadFile (long? petId, string additionalMetadata = null, Stream file = null)
|
||||
{
|
||||
|
||||
// verify the required parameter 'petId' is set
|
||||
@ -1013,7 +1013,7 @@ namespace IO.Swagger.Api
|
||||
/// <param name="additionalMetadata">Additional data to pass to server</param>
|
||||
/// <param name="file">file to upload</param>
|
||||
/// <returns></returns>
|
||||
public async System.Threading.Tasks.Task UploadFileAsync (long? petId, string additionalMetadata, Stream file)
|
||||
public async System.Threading.Tasks.Task UploadFileAsync (long? petId, string additionalMetadata = null, Stream file = null)
|
||||
{
|
||||
// verify the required parameter 'petId' is set
|
||||
if (petId == null) throw new ApiException(400, "Missing required parameter 'petId' when calling UploadFile");
|
||||
|
@ -40,7 +40,7 @@ namespace IO.Swagger.Api
|
||||
/// </remarks>
|
||||
/// <param name="body">order placed for purchasing the pet</param>
|
||||
/// <returns>Order</returns>
|
||||
Order PlaceOrder (Order body);
|
||||
Order PlaceOrder (Order body = null);
|
||||
|
||||
/// <summary>
|
||||
/// Place an order for a pet
|
||||
@ -50,7 +50,7 @@ namespace IO.Swagger.Api
|
||||
/// </remarks>
|
||||
/// <param name="body">order placed for purchasing the pet</param>
|
||||
/// <returns>Order</returns>
|
||||
System.Threading.Tasks.Task<Order> PlaceOrderAsync (Order body);
|
||||
System.Threading.Tasks.Task<Order> PlaceOrderAsync (Order body = null);
|
||||
|
||||
/// <summary>
|
||||
/// Find purchase order by ID
|
||||
@ -245,7 +245,7 @@ namespace IO.Swagger.Api
|
||||
/// </summary>
|
||||
/// <param name="body">order placed for purchasing the pet</param>
|
||||
/// <returns>Order</returns>
|
||||
public Order PlaceOrder (Order body)
|
||||
public Order PlaceOrder (Order body = null)
|
||||
{
|
||||
|
||||
|
||||
@ -295,7 +295,7 @@ namespace IO.Swagger.Api
|
||||
/// </summary>
|
||||
/// <param name="body">order placed for purchasing the pet</param>
|
||||
/// <returns>Order</returns>
|
||||
public async System.Threading.Tasks.Task<Order> PlaceOrderAsync (Order body)
|
||||
public async System.Threading.Tasks.Task<Order> PlaceOrderAsync (Order body = null)
|
||||
{
|
||||
|
||||
|
||||
|
@ -22,7 +22,7 @@ namespace IO.Swagger.Api
|
||||
/// </remarks>
|
||||
/// <param name="body">Created user object</param>
|
||||
/// <returns></returns>
|
||||
void CreateUser (User body);
|
||||
void CreateUser (User body = null);
|
||||
|
||||
/// <summary>
|
||||
/// Create user
|
||||
@ -32,7 +32,7 @@ namespace IO.Swagger.Api
|
||||
/// </remarks>
|
||||
/// <param name="body">Created user object</param>
|
||||
/// <returns></returns>
|
||||
System.Threading.Tasks.Task CreateUserAsync (User body);
|
||||
System.Threading.Tasks.Task CreateUserAsync (User body = null);
|
||||
|
||||
/// <summary>
|
||||
/// Creates list of users with given input array
|
||||
@ -42,7 +42,7 @@ namespace IO.Swagger.Api
|
||||
/// </remarks>
|
||||
/// <param name="body">List of user object</param>
|
||||
/// <returns></returns>
|
||||
void CreateUsersWithArrayInput (List<User> body);
|
||||
void CreateUsersWithArrayInput (List<User> body = null);
|
||||
|
||||
/// <summary>
|
||||
/// Creates list of users with given input array
|
||||
@ -52,7 +52,7 @@ namespace IO.Swagger.Api
|
||||
/// </remarks>
|
||||
/// <param name="body">List of user object</param>
|
||||
/// <returns></returns>
|
||||
System.Threading.Tasks.Task CreateUsersWithArrayInputAsync (List<User> body);
|
||||
System.Threading.Tasks.Task CreateUsersWithArrayInputAsync (List<User> body = null);
|
||||
|
||||
/// <summary>
|
||||
/// Creates list of users with given input array
|
||||
@ -62,7 +62,7 @@ namespace IO.Swagger.Api
|
||||
/// </remarks>
|
||||
/// <param name="body">List of user object</param>
|
||||
/// <returns></returns>
|
||||
void CreateUsersWithListInput (List<User> body);
|
||||
void CreateUsersWithListInput (List<User> body = null);
|
||||
|
||||
/// <summary>
|
||||
/// Creates list of users with given input array
|
||||
@ -72,7 +72,7 @@ namespace IO.Swagger.Api
|
||||
/// </remarks>
|
||||
/// <param name="body">List of user object</param>
|
||||
/// <returns></returns>
|
||||
System.Threading.Tasks.Task CreateUsersWithListInputAsync (List<User> body);
|
||||
System.Threading.Tasks.Task CreateUsersWithListInputAsync (List<User> body = null);
|
||||
|
||||
/// <summary>
|
||||
/// Logs user into the system
|
||||
@ -83,7 +83,7 @@ namespace IO.Swagger.Api
|
||||
/// <param name="username">The user name for login</param>
|
||||
/// <param name="password">The password for login in clear text</param>
|
||||
/// <returns>string</returns>
|
||||
string LoginUser (string username, string password);
|
||||
string LoginUser (string username = null, string password = null);
|
||||
|
||||
/// <summary>
|
||||
/// Logs user into the system
|
||||
@ -94,7 +94,7 @@ namespace IO.Swagger.Api
|
||||
/// <param name="username">The user name for login</param>
|
||||
/// <param name="password">The password for login in clear text</param>
|
||||
/// <returns>string</returns>
|
||||
System.Threading.Tasks.Task<string> LoginUserAsync (string username, string password);
|
||||
System.Threading.Tasks.Task<string> LoginUserAsync (string username = null, string password = null);
|
||||
|
||||
/// <summary>
|
||||
/// Logs out current logged in user session
|
||||
@ -143,7 +143,7 @@ namespace IO.Swagger.Api
|
||||
/// <param name="username">name that need to be deleted</param>
|
||||
/// <param name="body">Updated user object</param>
|
||||
/// <returns></returns>
|
||||
void UpdateUser (string username, User body);
|
||||
void UpdateUser (string username, User body = null);
|
||||
|
||||
/// <summary>
|
||||
/// Updated user
|
||||
@ -154,7 +154,7 @@ namespace IO.Swagger.Api
|
||||
/// <param name="username">name that need to be deleted</param>
|
||||
/// <param name="body">Updated user object</param>
|
||||
/// <returns></returns>
|
||||
System.Threading.Tasks.Task UpdateUserAsync (string username, User body);
|
||||
System.Threading.Tasks.Task UpdateUserAsync (string username, User body = null);
|
||||
|
||||
/// <summary>
|
||||
/// Delete user
|
||||
@ -236,7 +236,7 @@ namespace IO.Swagger.Api
|
||||
/// </summary>
|
||||
/// <param name="body">Created user object</param>
|
||||
/// <returns></returns>
|
||||
public void CreateUser (User body)
|
||||
public void CreateUser (User body = null)
|
||||
{
|
||||
|
||||
|
||||
@ -286,7 +286,7 @@ namespace IO.Swagger.Api
|
||||
/// </summary>
|
||||
/// <param name="body">Created user object</param>
|
||||
/// <returns></returns>
|
||||
public async System.Threading.Tasks.Task CreateUserAsync (User body)
|
||||
public async System.Threading.Tasks.Task CreateUserAsync (User body = null)
|
||||
{
|
||||
|
||||
|
||||
@ -334,7 +334,7 @@ namespace IO.Swagger.Api
|
||||
/// </summary>
|
||||
/// <param name="body">List of user object</param>
|
||||
/// <returns></returns>
|
||||
public void CreateUsersWithArrayInput (List<User> body)
|
||||
public void CreateUsersWithArrayInput (List<User> body = null)
|
||||
{
|
||||
|
||||
|
||||
@ -384,7 +384,7 @@ namespace IO.Swagger.Api
|
||||
/// </summary>
|
||||
/// <param name="body">List of user object</param>
|
||||
/// <returns></returns>
|
||||
public async System.Threading.Tasks.Task CreateUsersWithArrayInputAsync (List<User> body)
|
||||
public async System.Threading.Tasks.Task CreateUsersWithArrayInputAsync (List<User> body = null)
|
||||
{
|
||||
|
||||
|
||||
@ -432,7 +432,7 @@ namespace IO.Swagger.Api
|
||||
/// </summary>
|
||||
/// <param name="body">List of user object</param>
|
||||
/// <returns></returns>
|
||||
public void CreateUsersWithListInput (List<User> body)
|
||||
public void CreateUsersWithListInput (List<User> body = null)
|
||||
{
|
||||
|
||||
|
||||
@ -482,7 +482,7 @@ namespace IO.Swagger.Api
|
||||
/// </summary>
|
||||
/// <param name="body">List of user object</param>
|
||||
/// <returns></returns>
|
||||
public async System.Threading.Tasks.Task CreateUsersWithListInputAsync (List<User> body)
|
||||
public async System.Threading.Tasks.Task CreateUsersWithListInputAsync (List<User> body = null)
|
||||
{
|
||||
|
||||
|
||||
@ -531,7 +531,7 @@ namespace IO.Swagger.Api
|
||||
/// <param name="username">The user name for login</param>
|
||||
/// <param name="password">The password for login in clear text</param>
|
||||
/// <returns>string</returns>
|
||||
public string LoginUser (string username, string password)
|
||||
public string LoginUser (string username = null, string password = null)
|
||||
{
|
||||
|
||||
|
||||
@ -583,7 +583,7 @@ namespace IO.Swagger.Api
|
||||
/// <param name="username">The user name for login</param>
|
||||
/// <param name="password">The password for login in clear text</param>
|
||||
/// <returns>string</returns>
|
||||
public async System.Threading.Tasks.Task<string> LoginUserAsync (string username, string password)
|
||||
public async System.Threading.Tasks.Task<string> LoginUserAsync (string username = null, string password = null)
|
||||
{
|
||||
|
||||
|
||||
@ -828,7 +828,7 @@ namespace IO.Swagger.Api
|
||||
/// <param name="username">name that need to be deleted</param>
|
||||
/// <param name="body">Updated user object</param>
|
||||
/// <returns></returns>
|
||||
public void UpdateUser (string username, User body)
|
||||
public void UpdateUser (string username, User body = null)
|
||||
{
|
||||
|
||||
// verify the required parameter 'username' is set
|
||||
@ -883,7 +883,7 @@ namespace IO.Swagger.Api
|
||||
/// <param name="username">name that need to be deleted</param>
|
||||
/// <param name="body">Updated user object</param>
|
||||
/// <returns></returns>
|
||||
public async System.Threading.Tasks.Task UpdateUserAsync (string username, User body)
|
||||
public async System.Threading.Tasks.Task UpdateUserAsync (string username, User body = null)
|
||||
{
|
||||
// verify the required parameter 'username' is set
|
||||
if (username == null) throw new ApiException(400, "Missing required parameter 'username' when calling UpdateUser");
|
||||
|
@ -2,7 +2,7 @@
|
||||
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
|
||||
<MonoDevelop.Ide.Workbench ActiveDocument="TestPet.cs">
|
||||
<Files>
|
||||
<File FileName="TestPet.cs" Line="8" Column="25" />
|
||||
<File FileName="TestPet.cs" Line="15" Column="3" />
|
||||
</Files>
|
||||
</MonoDevelop.Ide.Workbench>
|
||||
<MonoDevelop.Ide.DebuggingService.Breakpoints>
|
||||
|
@ -121,6 +121,11 @@ namespace SwaggerClient.TestPet
|
||||
|
||||
Assert.AreEqual (petId, response.Tags [0].Id);
|
||||
Assert.AreEqual (56, response.Category.Id);
|
||||
|
||||
// test optional parameter
|
||||
petApi.UpdatePetWithForm (petId.ToString(), "new form name2");
|
||||
Pet response2 = petApi.GetPetById (petId);
|
||||
Assert.AreEqual ("new form name2", response2.Name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -136,7 +141,8 @@ namespace SwaggerClient.TestPet
|
||||
petApi.UploadFile(petId, "new form name", fileStream);
|
||||
|
||||
// test file upload without any form parameters
|
||||
petApi.UploadFile(petId, null, fileStream);
|
||||
// using optional parameter syntax introduced at .net 4.0
|
||||
petApi.UploadFile(petId: petId, file: fileStream);
|
||||
|
||||
}
|
||||
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -39,7 +39,7 @@ import io.swagger.client.auth.HttpBasicAuth;
|
||||
import io.swagger.client.auth.ApiKeyAuth;
|
||||
import io.swagger.client.auth.OAuth;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-07T15:05:10.376+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-29T00:18:25.953+08:00")
|
||||
public class ApiClient {
|
||||
private Map<String, Client> hostMap = new HashMap<String, Client>();
|
||||
private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
|
||||
@ -69,8 +69,8 @@ public class ApiClient {
|
||||
|
||||
// Setup authentications (key: authentication name, value: authentication).
|
||||
authentications = new HashMap<String, Authentication>();
|
||||
authentications.put("petstore_auth", new OAuth());
|
||||
authentications.put("api_key", new ApiKeyAuth("header", "api_key"));
|
||||
authentications.put("petstore_auth", new OAuth());
|
||||
// Prevent the authentications from being modified.
|
||||
authentications = Collections.unmodifiableMap(authentications);
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package io.swagger.client;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-30T16:36:47.681+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-29T00:18:25.953+08:00")
|
||||
public class ApiException extends Exception {
|
||||
private int code = 0;
|
||||
private Map<String, List<String>> responseHeaders = null;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package io.swagger.client;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-30T16:36:47.681+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-29T00:18:25.953+08:00")
|
||||
public class Configuration {
|
||||
private static ApiClient defaultApiClient = new ApiClient();
|
||||
|
||||
|
@ -8,7 +8,7 @@ import java.text.DateFormat;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-07T15:05:10.376+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-29T00:18:25.953+08:00")
|
||||
public class JSON {
|
||||
private ObjectMapper mapper;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package io.swagger.client;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-30T16:36:47.681+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-29T00:18:25.953+08:00")
|
||||
public class Pair {
|
||||
private String name = "";
|
||||
private String value = "";
|
||||
|
@ -1,6 +1,6 @@
|
||||
package io.swagger.client;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-30T16:36:47.681+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-29T00:18:25.953+08:00")
|
||||
public class StringUtil {
|
||||
/**
|
||||
* Check if the given array contains the given value (with case-insensitive comparison).
|
||||
|
@ -3,7 +3,7 @@ package io.swagger.client;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-30T16:36:47.681+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-29T00:18:25.953+08:00")
|
||||
public class TypeRef<T> {
|
||||
private final Type type;
|
||||
|
||||
|
@ -11,7 +11,7 @@ import java.io.File;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-04T19:58:40.953+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-29T00:18:25.953+08:00")
|
||||
public class PetApi {
|
||||
private ApiClient apiClient;
|
||||
|
||||
|
@ -11,7 +11,7 @@ import io.swagger.client.model.Order;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-30T16:36:47.681+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-29T00:18:25.953+08:00")
|
||||
public class StoreApi {
|
||||
private ApiClient apiClient;
|
||||
|
||||
|
@ -11,7 +11,7 @@ import java.util.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-30T16:36:47.681+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-29T00:18:25.953+08:00")
|
||||
public class UserApi {
|
||||
private ApiClient apiClient;
|
||||
|
||||
|
@ -5,7 +5,7 @@ import io.swagger.client.Pair;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-20T17:28:23.285+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-29T00:18:25.953+08:00")
|
||||
public class ApiKeyAuth implements Authentication {
|
||||
private final String location;
|
||||
private final String paramName;
|
||||
|
@ -5,7 +5,7 @@ import io.swagger.client.Pair;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-30T16:36:47.681+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-29T00:18:25.953+08:00")
|
||||
public interface Authentication {
|
||||
/** Apply authentication settings to header and query params. */
|
||||
void applyToParams(List<Pair> queryParams, Map<String, String> headerParams);
|
||||
|
@ -9,7 +9,7 @@ import java.util.List;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-22T13:15:32.345+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-29T00:18:25.953+08:00")
|
||||
public class HttpBasicAuth implements Authentication {
|
||||
private String username;
|
||||
private String password;
|
||||
|
@ -5,7 +5,7 @@ import io.swagger.client.Pair;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-02T21:16:46.418+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-29T00:18:25.953+08:00")
|
||||
public class OAuth implements Authentication {
|
||||
private String accessToken;
|
||||
|
||||
|
@ -6,11 +6,11 @@ import io.swagger.client.StringUtil;
|
||||
import java.util.Objects;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
|
||||
|
||||
@ApiModel(description = "")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-23T19:53:03.542+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-29T00:18:25.953+08:00")
|
||||
public class Category {
|
||||
|
||||
private Long id = null;
|
||||
|
@ -7,11 +7,11 @@ import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
|
||||
|
||||
@ApiModel(description = "")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-23T19:53:03.542+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-29T00:18:25.953+08:00")
|
||||
public class Order {
|
||||
|
||||
private Long id = null;
|
||||
@ -19,6 +19,7 @@ public class Order {
|
||||
private Integer quantity = null;
|
||||
private Date shipDate = null;
|
||||
|
||||
|
||||
public enum StatusEnum {
|
||||
PLACED("placed"),
|
||||
APPROVED("approved"),
|
||||
@ -31,6 +32,7 @@ public enum StatusEnum {
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonValue
|
||||
public String toString() {
|
||||
return value;
|
||||
}
|
||||
|
@ -2,18 +2,18 @@ package io.swagger.client.model;
|
||||
|
||||
import io.swagger.client.StringUtil;
|
||||
import io.swagger.client.model.Category;
|
||||
import java.util.*;
|
||||
import io.swagger.client.model.Tag;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
|
||||
|
||||
@ApiModel(description = "")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-23T19:53:03.542+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-29T00:18:25.953+08:00")
|
||||
public class Pet {
|
||||
|
||||
private Long id = null;
|
||||
@ -22,6 +22,7 @@ public class Pet {
|
||||
private List<String> photoUrls = new ArrayList<String>();
|
||||
private List<Tag> tags = new ArrayList<Tag>();
|
||||
|
||||
|
||||
public enum StatusEnum {
|
||||
AVAILABLE("available"),
|
||||
PENDING("pending"),
|
||||
@ -34,6 +35,7 @@ public enum StatusEnum {
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonValue
|
||||
public String toString() {
|
||||
return value;
|
||||
}
|
||||
|
@ -6,11 +6,11 @@ import io.swagger.client.StringUtil;
|
||||
import java.util.Objects;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
|
||||
|
||||
@ApiModel(description = "")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-23T19:53:03.542+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-29T00:18:25.953+08:00")
|
||||
public class Tag {
|
||||
|
||||
private Long id = null;
|
||||
|
@ -6,11 +6,11 @@ import io.swagger.client.StringUtil;
|
||||
import java.util.Objects;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
|
||||
|
||||
@ApiModel(description = "")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-23T19:53:03.542+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-29T00:18:25.953+08:00")
|
||||
public class User {
|
||||
|
||||
private Long id = null;
|
||||
|
@ -179,19 +179,25 @@ public class PetApiTest {
|
||||
Pet pet1 = new Pet();
|
||||
Pet pet2 = new Pet();
|
||||
assertTrue(pet1.equals(pet2));
|
||||
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(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(pet1.equals(pet2));
|
||||
assertTrue(pet2.equals(pet1));
|
||||
assertTrue(pet1.hashCode() == pet2.hashCode());
|
||||
assertTrue(pet1.equals(pet1));
|
||||
assertTrue(pet1.hashCode() == pet1.hashCode());
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ import io.swagger.client.auth.HttpBasicAuth;
|
||||
import io.swagger.client.auth.ApiKeyAuth;
|
||||
import io.swagger.client.auth.OAuth;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-17T11:17:50.535-05:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-29T00:18:01.946+08:00")
|
||||
public class ApiClient {
|
||||
private Client client;
|
||||
private Map<String, Client> hostMap = new HashMap<String, Client>();
|
||||
@ -76,8 +76,8 @@ public class ApiClient {
|
||||
|
||||
// Setup authentications (key: authentication name, value: authentication).
|
||||
authentications = new HashMap<String, Authentication>();
|
||||
authentications.put("petstore_auth", new OAuth());
|
||||
authentications.put("api_key", new ApiKeyAuth("header", "api_key"));
|
||||
authentications.put("petstore_auth", new OAuth());
|
||||
// Prevent the authentications from being modified.
|
||||
authentications = Collections.unmodifiableMap(authentications);
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package io.swagger.client;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-17T11:17:50.535-05:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-29T00:18:01.946+08:00")
|
||||
public class ApiException extends Exception {
|
||||
private int code = 0;
|
||||
private Map<String, List<String>> responseHeaders = null;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package io.swagger.client;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-17T11:17:50.535-05:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-29T00:18:01.946+08:00")
|
||||
public class Configuration {
|
||||
private static ApiClient defaultApiClient = new ApiClient();
|
||||
|
||||
|
@ -8,7 +8,7 @@ import java.text.DateFormat;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-17T11:17:50.535-05:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-29T00:18:01.946+08:00")
|
||||
public class JSON {
|
||||
private ObjectMapper mapper;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package io.swagger.client;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-17T11:17:50.535-05:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-29T00:18:01.946+08:00")
|
||||
public class Pair {
|
||||
private String name = "";
|
||||
private String value = "";
|
||||
|
@ -1,6 +1,6 @@
|
||||
package io.swagger.client;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-17T11:17:50.535-05:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-29T00:18:01.946+08:00")
|
||||
public class StringUtil {
|
||||
/**
|
||||
* Check if the given array contains the given value (with case-insensitive comparison).
|
||||
|
@ -3,7 +3,7 @@ package io.swagger.client;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-17T11:17:50.535-05:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-29T00:18:01.946+08:00")
|
||||
public class TypeRef<T> {
|
||||
private final Type type;
|
||||
|
||||
|
@ -11,7 +11,7 @@ import java.io.File;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-17T11:17:50.535-05:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-29T00:18:01.946+08:00")
|
||||
public class PetApi {
|
||||
private ApiClient apiClient;
|
||||
|
||||
|
@ -11,7 +11,7 @@ import io.swagger.client.model.Order;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-17T11:17:50.535-05:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-29T00:18:01.946+08:00")
|
||||
public class StoreApi {
|
||||
private ApiClient apiClient;
|
||||
|
||||
|
@ -11,7 +11,7 @@ import java.util.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-17T11:17:50.535-05:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-29T00:18:01.946+08:00")
|
||||
public class UserApi {
|
||||
private ApiClient apiClient;
|
||||
|
||||
|
@ -5,7 +5,7 @@ import io.swagger.client.Pair;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-20T17:28:47.318+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-29T00:18:01.946+08:00")
|
||||
public class ApiKeyAuth implements Authentication {
|
||||
private final String location;
|
||||
private final String paramName;
|
||||
|
@ -5,7 +5,7 @@ import io.swagger.client.Pair;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-17T11:17:50.535-05:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-29T00:18:01.946+08:00")
|
||||
public interface Authentication {
|
||||
/** Apply authentication settings to header and query params. */
|
||||
void applyToParams(List<Pair> queryParams, Map<String, String> headerParams);
|
||||
|
@ -9,7 +9,7 @@ import java.util.List;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-22T13:15:27.225+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-29T00:18:01.946+08:00")
|
||||
public class HttpBasicAuth implements Authentication {
|
||||
private String username;
|
||||
private String password;
|
||||
|
@ -5,7 +5,7 @@ import io.swagger.client.Pair;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-17T11:17:50.535-05:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-29T00:18:01.946+08:00")
|
||||
public class OAuth implements Authentication {
|
||||
private String accessToken;
|
||||
|
||||
|
@ -6,11 +6,11 @@ import io.swagger.client.StringUtil;
|
||||
import java.util.Objects;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
|
||||
|
||||
@ApiModel(description = "")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-23T15:52:25.446+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-29T00:18:01.946+08:00")
|
||||
public class Category {
|
||||
|
||||
private Long id = null;
|
||||
@ -44,8 +44,12 @@ public class Category {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Category category = (Category) o;
|
||||
return Objects.equals(id, category.id) &&
|
||||
Objects.equals(name, category.name);
|
||||
|
@ -7,11 +7,11 @@ import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
|
||||
|
||||
@ApiModel(description = "")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-23T15:52:25.446+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-29T00:18:01.946+08:00")
|
||||
public class Order {
|
||||
|
||||
private Long id = null;
|
||||
@ -19,6 +19,7 @@ public class Order {
|
||||
private Integer quantity = null;
|
||||
private Date shipDate = null;
|
||||
|
||||
|
||||
public enum StatusEnum {
|
||||
PLACED("placed"),
|
||||
APPROVED("approved"),
|
||||
@ -31,6 +32,7 @@ public enum StatusEnum {
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonValue
|
||||
public String toString() {
|
||||
return value;
|
||||
}
|
||||
@ -116,8 +118,12 @@ public enum StatusEnum {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Order order = (Order) o;
|
||||
return Objects.equals(id, order.id) &&
|
||||
Objects.equals(petId, order.petId) &&
|
||||
|
@ -2,18 +2,18 @@ package io.swagger.client.model;
|
||||
|
||||
import io.swagger.client.StringUtil;
|
||||
import io.swagger.client.model.Category;
|
||||
import java.util.*;
|
||||
import io.swagger.client.model.Tag;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
|
||||
|
||||
@ApiModel(description = "")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-23T15:52:25.446+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-29T00:18:01.946+08:00")
|
||||
public class Pet {
|
||||
|
||||
private Long id = null;
|
||||
@ -22,6 +22,7 @@ public class Pet {
|
||||
private List<String> photoUrls = new ArrayList<String>();
|
||||
private List<Tag> tags = new ArrayList<Tag>();
|
||||
|
||||
|
||||
public enum StatusEnum {
|
||||
AVAILABLE("available"),
|
||||
PENDING("pending"),
|
||||
@ -34,6 +35,7 @@ public enum StatusEnum {
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonValue
|
||||
public String toString() {
|
||||
return value;
|
||||
}
|
||||
@ -118,8 +120,12 @@ public enum StatusEnum {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Pet pet = (Pet) o;
|
||||
return Objects.equals(id, pet.id) &&
|
||||
Objects.equals(category, pet.category) &&
|
||||
|
@ -6,11 +6,11 @@ import io.swagger.client.StringUtil;
|
||||
import java.util.Objects;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
|
||||
|
||||
@ApiModel(description = "")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-23T15:52:25.446+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-29T00:18:01.946+08:00")
|
||||
public class Tag {
|
||||
|
||||
private Long id = null;
|
||||
@ -44,8 +44,12 @@ public class Tag {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Tag tag = (Tag) o;
|
||||
return Objects.equals(id, tag.id) &&
|
||||
Objects.equals(name, tag.name);
|
||||
|
@ -6,11 +6,11 @@ import io.swagger.client.StringUtil;
|
||||
import java.util.Objects;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
|
||||
|
||||
@ApiModel(description = "")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-23T15:52:25.446+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-29T00:18:01.946+08:00")
|
||||
public class User {
|
||||
|
||||
private Long id = null;
|
||||
@ -123,8 +123,12 @@ public class User {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
User user = (User) o;
|
||||
return Objects.equals(id, user.id) &&
|
||||
Objects.equals(username, user.username) &&
|
||||
|
@ -179,19 +179,25 @@ public class PetApiTest {
|
||||
Pet pet1 = new Pet();
|
||||
Pet pet2 = new Pet();
|
||||
assertTrue(pet1.equals(pet2));
|
||||
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(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(pet1.equals(pet2));
|
||||
assertTrue(pet2.equals(pet1));
|
||||
assertTrue(pet1.hashCode() == pet2.hashCode());
|
||||
assertTrue(pet1.equals(pet1));
|
||||
assertTrue(pet1.hashCode() == pet1.hashCode());
|
||||
}
|
||||
|
||||
|
@ -28,4 +28,22 @@ public interface ApiCallback<T> {
|
||||
* @param responseHeaders Headers of the response
|
||||
*/
|
||||
void onSuccess(T result, int statusCode, Map<String, List<String>> responseHeaders);
|
||||
|
||||
/**
|
||||
* This is called when the API upload processing.
|
||||
*
|
||||
* @param bytesWritten bytes Written
|
||||
* @param contentLength content length of request body
|
||||
* @param done write end
|
||||
*/
|
||||
void onUploadProgress(long bytesWritten, long contentLength, boolean done);
|
||||
|
||||
/**
|
||||
* This is called when the API downlond processing.
|
||||
*
|
||||
* @param bytesRead bytes Read
|
||||
* @param contentLength content lenngth of the response
|
||||
* @param done Read end
|
||||
*/
|
||||
void onDownloadProgress(long bytesRead, long contentLength, boolean done);
|
||||
}
|
||||
|
@ -143,8 +143,8 @@ public class ApiClient {
|
||||
|
||||
// Setup authentications (key: authentication name, value: authentication).
|
||||
authentications = new HashMap<String, Authentication>();
|
||||
authentications.put("petstore_auth", new OAuth());
|
||||
authentications.put("api_key", new ApiKeyAuth("header", "api_key"));
|
||||
authentications.put("petstore_auth", new OAuth());
|
||||
// Prevent the authentications from being modified.
|
||||
authentications = Collections.unmodifiableMap(authentications);
|
||||
}
|
||||
@ -820,7 +820,7 @@ public class ApiClient {
|
||||
* @param authNames The authentications to apply
|
||||
* @return The HTTP call
|
||||
*/
|
||||
public Call buildCall(String path, String method, List<Pair> queryParams, Object body, Map<String, String> headerParams, Map<String, Object> formParams, String[] authNames) throws ApiException {
|
||||
public Call buildCall(String path, String method, List<Pair> queryParams, Object body, Map<String, String> headerParams, Map<String, Object> formParams, String[] authNames, ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
|
||||
updateParamsForAuth(authNames, queryParams, headerParams);
|
||||
|
||||
final String url = buildUrl(path, queryParams);
|
||||
@ -850,7 +850,15 @@ public class ApiClient {
|
||||
reqBody = RequestBody.create(MediaType.parse(contentType), serialize(body, contentType));
|
||||
}
|
||||
|
||||
Request request = reqBuilder.method(method, reqBody).build();
|
||||
Request request = null;
|
||||
|
||||
if(progressRequestListener != null && reqBody != null) {
|
||||
ProgressRequestBody progressRequestBody = new ProgressRequestBody(reqBody, progressRequestListener);
|
||||
request = reqBuilder.method(method, progressRequestBody).build();
|
||||
} else {
|
||||
request = reqBuilder.method(method, reqBody).build();
|
||||
}
|
||||
|
||||
return httpClient.newCall(request);
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@ package io.swagger.client;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-20T11:42:25.339-07:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-29T00:18:08.052+08:00")
|
||||
public class ApiException extends Exception {
|
||||
private int code = 0;
|
||||
private Map<String, List<String>> responseHeaders = null;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package io.swagger.client;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-20T11:42:25.339-07:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-29T00:18:08.052+08:00")
|
||||
public class Configuration {
|
||||
private static ApiClient defaultApiClient = new ApiClient();
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package io.swagger.client;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-20T11:42:25.339-07:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-29T00:18:08.052+08:00")
|
||||
public class Pair {
|
||||
private String name = "";
|
||||
private String value = "";
|
||||
|
@ -0,0 +1,70 @@
|
||||
package io.swagger.client;
|
||||
|
||||
import com.squareup.okhttp.MediaType;
|
||||
import com.squareup.okhttp.RequestBody;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import okio.Buffer;
|
||||
import okio.BufferedSink;
|
||||
import okio.ForwardingSink;
|
||||
import okio.Okio;
|
||||
import okio.Sink;
|
||||
|
||||
public class ProgressRequestBody extends RequestBody {
|
||||
|
||||
public interface ProgressRequestListener {
|
||||
void onRequestProgress(long bytesWritten, long contentLength, boolean done);
|
||||
}
|
||||
|
||||
private final RequestBody requestBody;
|
||||
|
||||
private final ProgressRequestListener progressListener;
|
||||
|
||||
private BufferedSink bufferedSink;
|
||||
|
||||
public ProgressRequestBody(RequestBody requestBody, ProgressRequestListener progressListener) {
|
||||
this.requestBody = requestBody;
|
||||
this.progressListener = progressListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MediaType contentType() {
|
||||
return requestBody.contentType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long contentLength() throws IOException {
|
||||
return requestBody.contentLength();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(BufferedSink sink) throws IOException {
|
||||
if (bufferedSink == null) {
|
||||
bufferedSink = Okio.buffer(sink(sink));
|
||||
}
|
||||
|
||||
requestBody.writeTo(bufferedSink);
|
||||
bufferedSink.flush();
|
||||
|
||||
}
|
||||
|
||||
private Sink sink(Sink sink) {
|
||||
return new ForwardingSink(sink) {
|
||||
|
||||
long bytesWritten = 0L;
|
||||
long contentLength = 0L;
|
||||
|
||||
@Override
|
||||
public void write(Buffer source, long byteCount) throws IOException {
|
||||
super.write(source, byteCount);
|
||||
if (contentLength == 0) {
|
||||
contentLength = contentLength();
|
||||
}
|
||||
|
||||
bytesWritten += byteCount;
|
||||
progressListener.onRequestProgress(bytesWritten, contentLength, bytesWritten == contentLength);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
package io.swagger.client;
|
||||
|
||||
import com.squareup.okhttp.MediaType;
|
||||
import com.squareup.okhttp.ResponseBody;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import okio.Buffer;
|
||||
import okio.BufferedSource;
|
||||
import okio.ForwardingSource;
|
||||
import okio.Okio;
|
||||
import okio.Source;
|
||||
|
||||
public class ProgressResponseBody extends ResponseBody {
|
||||
|
||||
public interface ProgressListener {
|
||||
void update(long bytesRead, long contentLength, boolean done);
|
||||
}
|
||||
|
||||
private final ResponseBody responseBody;
|
||||
private final ProgressListener progressListener;
|
||||
private BufferedSource bufferedSource;
|
||||
|
||||
public ProgressResponseBody(ResponseBody responseBody, ProgressListener progressListener) {
|
||||
this.responseBody = responseBody;
|
||||
this.progressListener = progressListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MediaType contentType() {
|
||||
return responseBody.contentType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long contentLength() throws IOException {
|
||||
return responseBody.contentLength();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BufferedSource source() throws IOException {
|
||||
if (bufferedSource == null) {
|
||||
bufferedSource = Okio.buffer(source(responseBody.source()));
|
||||
}
|
||||
return bufferedSource;
|
||||
}
|
||||
|
||||
private Source source(Source source) {
|
||||
return new ForwardingSource(source) {
|
||||
long totalBytesRead = 0L;
|
||||
|
||||
@Override
|
||||
public long read(Buffer sink, long byteCount) throws IOException {
|
||||
long bytesRead = super.read(sink, byteCount);
|
||||
// read() returns the number of bytes read, or -1 if this source is exhausted.
|
||||
totalBytesRead += bytesRead != -1 ? bytesRead : 0;
|
||||
progressListener.update(totalBytesRead, responseBody.contentLength(), bytesRead == -1);
|
||||
return bytesRead;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package io.swagger.client;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-20T11:42:25.339-07:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-29T00:18:08.052+08:00")
|
||||
public class StringUtil {
|
||||
/**
|
||||
* Check if the given array contains the given value (with case-insensitive comparison).
|
||||
|
@ -5,10 +5,16 @@ import io.swagger.client.ApiClient;
|
||||
import io.swagger.client.ApiException;
|
||||
import io.swagger.client.Configuration;
|
||||
import io.swagger.client.Pair;
|
||||
import io.swagger.client.ProgressRequestBody;
|
||||
import io.swagger.client.ProgressResponseBody;
|
||||
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import com.squareup.okhttp.Call;
|
||||
import com.squareup.okhttp.Interceptor;
|
||||
import com.squareup.okhttp.Response;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import io.swagger.client.model.Pet;
|
||||
import java.io.File;
|
||||
@ -37,7 +43,7 @@ public class PetApi {
|
||||
|
||||
|
||||
/* Build call for updatePet */
|
||||
private Call updatePetCall(Pet body) throws ApiException {
|
||||
private Call updatePetCall(Pet body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
|
||||
Object postBody = body;
|
||||
|
||||
|
||||
@ -62,8 +68,20 @@ public class PetApi {
|
||||
final String contentType = apiClient.selectHeaderContentType(contentTypes);
|
||||
headerParams.put("Content-Type", contentType);
|
||||
|
||||
if(progressListener != null) {
|
||||
apiClient.getHttpClient().networkInterceptors().add(new Interceptor() {
|
||||
@Override
|
||||
public Response intercept(Interceptor.Chain chain) throws IOException {
|
||||
Response originalResponse = chain.proceed(chain.request());
|
||||
return originalResponse.newBuilder()
|
||||
.body(new ProgressResponseBody(originalResponse.body(), progressListener))
|
||||
.build();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
String[] authNames = new String[] { "petstore_auth" };
|
||||
return apiClient.buildCall(path, "PUT", queryParams, postBody, headerParams, formParams, authNames);
|
||||
return apiClient.buildCall(path, "PUT", queryParams, postBody, headerParams, formParams, authNames, progressRequestListener);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -72,7 +90,7 @@ public class PetApi {
|
||||
* @param body Pet object that needs to be added to the store
|
||||
*/
|
||||
public void updatePet(Pet body) throws ApiException {
|
||||
Call call = updatePetCall(body);
|
||||
Call call = updatePetCall(body, null, null);
|
||||
apiClient.execute(call);
|
||||
}
|
||||
|
||||
@ -83,14 +101,34 @@ public class PetApi {
|
||||
* @param callback The callback to be executed when the API call finishes
|
||||
* @return The request call
|
||||
*/
|
||||
public Call updatePetAsync(Pet body, ApiCallback<Void> callback) throws ApiException {
|
||||
Call call = updatePetCall(body);
|
||||
public Call updatePetAsync(Pet body, final ApiCallback<Void> callback) throws ApiException {
|
||||
|
||||
ProgressResponseBody.ProgressListener progressListener = null;
|
||||
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
|
||||
|
||||
if(callback != null) {
|
||||
progressListener = new ProgressResponseBody.ProgressListener() {
|
||||
@Override
|
||||
public void update(long bytesRead, long contentLength, boolean done) {
|
||||
callback.onDownloadProgress(bytesRead, contentLength, done);
|
||||
}
|
||||
};
|
||||
|
||||
progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
|
||||
@Override
|
||||
public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
|
||||
callback.onUploadProgress(bytesWritten, contentLength, done);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Call call = updatePetCall(body, progressListener, progressRequestListener);
|
||||
apiClient.executeAsync(call, callback);
|
||||
return call;
|
||||
}
|
||||
|
||||
/* Build call for addPet */
|
||||
private Call addPetCall(Pet body) throws ApiException {
|
||||
private Call addPetCall(Pet body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
|
||||
Object postBody = body;
|
||||
|
||||
|
||||
@ -115,8 +153,20 @@ public class PetApi {
|
||||
final String contentType = apiClient.selectHeaderContentType(contentTypes);
|
||||
headerParams.put("Content-Type", contentType);
|
||||
|
||||
if(progressListener != null) {
|
||||
apiClient.getHttpClient().networkInterceptors().add(new Interceptor() {
|
||||
@Override
|
||||
public Response intercept(Interceptor.Chain chain) throws IOException {
|
||||
Response originalResponse = chain.proceed(chain.request());
|
||||
return originalResponse.newBuilder()
|
||||
.body(new ProgressResponseBody(originalResponse.body(), progressListener))
|
||||
.build();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
String[] authNames = new String[] { "petstore_auth" };
|
||||
return apiClient.buildCall(path, "POST", queryParams, postBody, headerParams, formParams, authNames);
|
||||
return apiClient.buildCall(path, "POST", queryParams, postBody, headerParams, formParams, authNames, progressRequestListener);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -125,7 +175,7 @@ public class PetApi {
|
||||
* @param body Pet object that needs to be added to the store
|
||||
*/
|
||||
public void addPet(Pet body) throws ApiException {
|
||||
Call call = addPetCall(body);
|
||||
Call call = addPetCall(body, null, null);
|
||||
apiClient.execute(call);
|
||||
}
|
||||
|
||||
@ -136,14 +186,34 @@ public class PetApi {
|
||||
* @param callback The callback to be executed when the API call finishes
|
||||
* @return The request call
|
||||
*/
|
||||
public Call addPetAsync(Pet body, ApiCallback<Void> callback) throws ApiException {
|
||||
Call call = addPetCall(body);
|
||||
public Call addPetAsync(Pet body, final ApiCallback<Void> callback) throws ApiException {
|
||||
|
||||
ProgressResponseBody.ProgressListener progressListener = null;
|
||||
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
|
||||
|
||||
if(callback != null) {
|
||||
progressListener = new ProgressResponseBody.ProgressListener() {
|
||||
@Override
|
||||
public void update(long bytesRead, long contentLength, boolean done) {
|
||||
callback.onDownloadProgress(bytesRead, contentLength, done);
|
||||
}
|
||||
};
|
||||
|
||||
progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
|
||||
@Override
|
||||
public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
|
||||
callback.onUploadProgress(bytesWritten, contentLength, done);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Call call = addPetCall(body, progressListener, progressRequestListener);
|
||||
apiClient.executeAsync(call, callback);
|
||||
return call;
|
||||
}
|
||||
|
||||
/* Build call for findPetsByStatus */
|
||||
private Call findPetsByStatusCall(List<String> status) throws ApiException {
|
||||
private Call findPetsByStatusCall(List<String> status, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
|
||||
Object postBody = null;
|
||||
|
||||
|
||||
@ -170,8 +240,20 @@ public class PetApi {
|
||||
final String contentType = apiClient.selectHeaderContentType(contentTypes);
|
||||
headerParams.put("Content-Type", contentType);
|
||||
|
||||
if(progressListener != null) {
|
||||
apiClient.getHttpClient().networkInterceptors().add(new Interceptor() {
|
||||
@Override
|
||||
public Response intercept(Interceptor.Chain chain) throws IOException {
|
||||
Response originalResponse = chain.proceed(chain.request());
|
||||
return originalResponse.newBuilder()
|
||||
.body(new ProgressResponseBody(originalResponse.body(), progressListener))
|
||||
.build();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
String[] authNames = new String[] { "petstore_auth" };
|
||||
return apiClient.buildCall(path, "GET", queryParams, postBody, headerParams, formParams, authNames);
|
||||
return apiClient.buildCall(path, "GET", queryParams, postBody, headerParams, formParams, authNames, progressRequestListener);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -181,7 +263,7 @@ public class PetApi {
|
||||
* @return List<Pet>
|
||||
*/
|
||||
public List<Pet> findPetsByStatus(List<String> status) throws ApiException {
|
||||
Call call = findPetsByStatusCall(status);
|
||||
Call call = findPetsByStatusCall(status, null, null);
|
||||
Type returnType = new TypeToken<List<Pet>>(){}.getType();
|
||||
return apiClient.execute(call, returnType);
|
||||
}
|
||||
@ -193,15 +275,35 @@ public class PetApi {
|
||||
* @param callback The callback to be executed when the API call finishes
|
||||
* @return The request call
|
||||
*/
|
||||
public Call findPetsByStatusAsync(List<String> status, ApiCallback<List<Pet>> callback) throws ApiException {
|
||||
Call call = findPetsByStatusCall(status);
|
||||
public Call findPetsByStatusAsync(List<String> status, final ApiCallback<List<Pet>> callback) throws ApiException {
|
||||
|
||||
ProgressResponseBody.ProgressListener progressListener = null;
|
||||
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
|
||||
|
||||
if(callback != null) {
|
||||
progressListener = new ProgressResponseBody.ProgressListener() {
|
||||
@Override
|
||||
public void update(long bytesRead, long contentLength, boolean done) {
|
||||
callback.onDownloadProgress(bytesRead, contentLength, done);
|
||||
}
|
||||
};
|
||||
|
||||
progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
|
||||
@Override
|
||||
public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
|
||||
callback.onUploadProgress(bytesWritten, contentLength, done);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Call call = findPetsByStatusCall(status, progressListener, progressRequestListener);
|
||||
Type returnType = new TypeToken<List<Pet>>(){}.getType();
|
||||
apiClient.executeAsync(call, returnType, callback);
|
||||
return call;
|
||||
}
|
||||
|
||||
/* Build call for findPetsByTags */
|
||||
private Call findPetsByTagsCall(List<String> tags) throws ApiException {
|
||||
private Call findPetsByTagsCall(List<String> tags, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
|
||||
Object postBody = null;
|
||||
|
||||
|
||||
@ -228,8 +330,20 @@ public class PetApi {
|
||||
final String contentType = apiClient.selectHeaderContentType(contentTypes);
|
||||
headerParams.put("Content-Type", contentType);
|
||||
|
||||
if(progressListener != null) {
|
||||
apiClient.getHttpClient().networkInterceptors().add(new Interceptor() {
|
||||
@Override
|
||||
public Response intercept(Interceptor.Chain chain) throws IOException {
|
||||
Response originalResponse = chain.proceed(chain.request());
|
||||
return originalResponse.newBuilder()
|
||||
.body(new ProgressResponseBody(originalResponse.body(), progressListener))
|
||||
.build();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
String[] authNames = new String[] { "petstore_auth" };
|
||||
return apiClient.buildCall(path, "GET", queryParams, postBody, headerParams, formParams, authNames);
|
||||
return apiClient.buildCall(path, "GET", queryParams, postBody, headerParams, formParams, authNames, progressRequestListener);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -239,7 +353,7 @@ public class PetApi {
|
||||
* @return List<Pet>
|
||||
*/
|
||||
public List<Pet> findPetsByTags(List<String> tags) throws ApiException {
|
||||
Call call = findPetsByTagsCall(tags);
|
||||
Call call = findPetsByTagsCall(tags, null, null);
|
||||
Type returnType = new TypeToken<List<Pet>>(){}.getType();
|
||||
return apiClient.execute(call, returnType);
|
||||
}
|
||||
@ -251,15 +365,35 @@ public class PetApi {
|
||||
* @param callback The callback to be executed when the API call finishes
|
||||
* @return The request call
|
||||
*/
|
||||
public Call findPetsByTagsAsync(List<String> tags, ApiCallback<List<Pet>> callback) throws ApiException {
|
||||
Call call = findPetsByTagsCall(tags);
|
||||
public Call findPetsByTagsAsync(List<String> tags, final ApiCallback<List<Pet>> callback) throws ApiException {
|
||||
|
||||
ProgressResponseBody.ProgressListener progressListener = null;
|
||||
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
|
||||
|
||||
if(callback != null) {
|
||||
progressListener = new ProgressResponseBody.ProgressListener() {
|
||||
@Override
|
||||
public void update(long bytesRead, long contentLength, boolean done) {
|
||||
callback.onDownloadProgress(bytesRead, contentLength, done);
|
||||
}
|
||||
};
|
||||
|
||||
progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
|
||||
@Override
|
||||
public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
|
||||
callback.onUploadProgress(bytesWritten, contentLength, done);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Call call = findPetsByTagsCall(tags, progressListener, progressRequestListener);
|
||||
Type returnType = new TypeToken<List<Pet>>(){}.getType();
|
||||
apiClient.executeAsync(call, returnType, callback);
|
||||
return call;
|
||||
}
|
||||
|
||||
/* Build call for getPetById */
|
||||
private Call getPetByIdCall(Long petId) throws ApiException {
|
||||
private Call getPetByIdCall(Long petId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
|
||||
Object postBody = null;
|
||||
|
||||
// verify the required parameter 'petId' is set
|
||||
@ -290,8 +424,20 @@ public class PetApi {
|
||||
final String contentType = apiClient.selectHeaderContentType(contentTypes);
|
||||
headerParams.put("Content-Type", contentType);
|
||||
|
||||
if(progressListener != null) {
|
||||
apiClient.getHttpClient().networkInterceptors().add(new Interceptor() {
|
||||
@Override
|
||||
public Response intercept(Interceptor.Chain chain) throws IOException {
|
||||
Response originalResponse = chain.proceed(chain.request());
|
||||
return originalResponse.newBuilder()
|
||||
.body(new ProgressResponseBody(originalResponse.body(), progressListener))
|
||||
.build();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
String[] authNames = new String[] { "api_key" };
|
||||
return apiClient.buildCall(path, "GET", queryParams, postBody, headerParams, formParams, authNames);
|
||||
return apiClient.buildCall(path, "GET", queryParams, postBody, headerParams, formParams, authNames, progressRequestListener);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -301,7 +447,7 @@ public class PetApi {
|
||||
* @return Pet
|
||||
*/
|
||||
public Pet getPetById(Long petId) throws ApiException {
|
||||
Call call = getPetByIdCall(petId);
|
||||
Call call = getPetByIdCall(petId, null, null);
|
||||
Type returnType = new TypeToken<Pet>(){}.getType();
|
||||
return apiClient.execute(call, returnType);
|
||||
}
|
||||
@ -313,15 +459,35 @@ public class PetApi {
|
||||
* @param callback The callback to be executed when the API call finishes
|
||||
* @return The request call
|
||||
*/
|
||||
public Call getPetByIdAsync(Long petId, ApiCallback<Pet> callback) throws ApiException {
|
||||
Call call = getPetByIdCall(petId);
|
||||
public Call getPetByIdAsync(Long petId, final ApiCallback<Pet> callback) throws ApiException {
|
||||
|
||||
ProgressResponseBody.ProgressListener progressListener = null;
|
||||
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
|
||||
|
||||
if(callback != null) {
|
||||
progressListener = new ProgressResponseBody.ProgressListener() {
|
||||
@Override
|
||||
public void update(long bytesRead, long contentLength, boolean done) {
|
||||
callback.onDownloadProgress(bytesRead, contentLength, done);
|
||||
}
|
||||
};
|
||||
|
||||
progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
|
||||
@Override
|
||||
public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
|
||||
callback.onUploadProgress(bytesWritten, contentLength, done);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Call call = getPetByIdCall(petId, progressListener, progressRequestListener);
|
||||
Type returnType = new TypeToken<Pet>(){}.getType();
|
||||
apiClient.executeAsync(call, returnType, callback);
|
||||
return call;
|
||||
}
|
||||
|
||||
/* Build call for updatePetWithForm */
|
||||
private Call updatePetWithFormCall(String petId, String name, String status) throws ApiException {
|
||||
private Call updatePetWithFormCall(String petId,String name,String status, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
|
||||
Object postBody = null;
|
||||
|
||||
// verify the required parameter 'petId' is set
|
||||
@ -356,8 +522,20 @@ public class PetApi {
|
||||
final String contentType = apiClient.selectHeaderContentType(contentTypes);
|
||||
headerParams.put("Content-Type", contentType);
|
||||
|
||||
if(progressListener != null) {
|
||||
apiClient.getHttpClient().networkInterceptors().add(new Interceptor() {
|
||||
@Override
|
||||
public Response intercept(Interceptor.Chain chain) throws IOException {
|
||||
Response originalResponse = chain.proceed(chain.request());
|
||||
return originalResponse.newBuilder()
|
||||
.body(new ProgressResponseBody(originalResponse.body(), progressListener))
|
||||
.build();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
String[] authNames = new String[] { "petstore_auth" };
|
||||
return apiClient.buildCall(path, "POST", queryParams, postBody, headerParams, formParams, authNames);
|
||||
return apiClient.buildCall(path, "POST", queryParams, postBody, headerParams, formParams, authNames, progressRequestListener);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -368,7 +546,7 @@ public class PetApi {
|
||||
* @param status Updated status of the pet
|
||||
*/
|
||||
public void updatePetWithForm(String petId, String name, String status) throws ApiException {
|
||||
Call call = updatePetWithFormCall(petId, name, status);
|
||||
Call call = updatePetWithFormCall(petId,name,status, null, null);
|
||||
apiClient.execute(call);
|
||||
}
|
||||
|
||||
@ -381,14 +559,34 @@ public class PetApi {
|
||||
* @param callback The callback to be executed when the API call finishes
|
||||
* @return The request call
|
||||
*/
|
||||
public Call updatePetWithFormAsync(String petId, String name, String status, ApiCallback<Void> callback) throws ApiException {
|
||||
Call call = updatePetWithFormCall(petId, name, status);
|
||||
public Call updatePetWithFormAsync(String petId, String name, String status, final ApiCallback<Void> callback) throws ApiException {
|
||||
|
||||
ProgressResponseBody.ProgressListener progressListener = null;
|
||||
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
|
||||
|
||||
if(callback != null) {
|
||||
progressListener = new ProgressResponseBody.ProgressListener() {
|
||||
@Override
|
||||
public void update(long bytesRead, long contentLength, boolean done) {
|
||||
callback.onDownloadProgress(bytesRead, contentLength, done);
|
||||
}
|
||||
};
|
||||
|
||||
progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
|
||||
@Override
|
||||
public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
|
||||
callback.onUploadProgress(bytesWritten, contentLength, done);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Call call = updatePetWithFormCall(petId,name,status, progressListener, progressRequestListener);
|
||||
apiClient.executeAsync(call, callback);
|
||||
return call;
|
||||
}
|
||||
|
||||
/* Build call for deletePet */
|
||||
private Call deletePetCall(Long petId, String apiKey) throws ApiException {
|
||||
private Call deletePetCall(Long petId,String apiKey, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
|
||||
Object postBody = null;
|
||||
|
||||
// verify the required parameter 'petId' is set
|
||||
@ -421,8 +619,20 @@ public class PetApi {
|
||||
final String contentType = apiClient.selectHeaderContentType(contentTypes);
|
||||
headerParams.put("Content-Type", contentType);
|
||||
|
||||
if(progressListener != null) {
|
||||
apiClient.getHttpClient().networkInterceptors().add(new Interceptor() {
|
||||
@Override
|
||||
public Response intercept(Interceptor.Chain chain) throws IOException {
|
||||
Response originalResponse = chain.proceed(chain.request());
|
||||
return originalResponse.newBuilder()
|
||||
.body(new ProgressResponseBody(originalResponse.body(), progressListener))
|
||||
.build();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
String[] authNames = new String[] { "petstore_auth" };
|
||||
return apiClient.buildCall(path, "DELETE", queryParams, postBody, headerParams, formParams, authNames);
|
||||
return apiClient.buildCall(path, "DELETE", queryParams, postBody, headerParams, formParams, authNames, progressRequestListener);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -432,7 +642,7 @@ public class PetApi {
|
||||
* @param apiKey
|
||||
*/
|
||||
public void deletePet(Long petId, String apiKey) throws ApiException {
|
||||
Call call = deletePetCall(petId, apiKey);
|
||||
Call call = deletePetCall(petId,apiKey, null, null);
|
||||
apiClient.execute(call);
|
||||
}
|
||||
|
||||
@ -444,14 +654,34 @@ public class PetApi {
|
||||
* @param callback The callback to be executed when the API call finishes
|
||||
* @return The request call
|
||||
*/
|
||||
public Call deletePetAsync(Long petId, String apiKey, ApiCallback<Void> callback) throws ApiException {
|
||||
Call call = deletePetCall(petId, apiKey);
|
||||
public Call deletePetAsync(Long petId, String apiKey, final ApiCallback<Void> callback) throws ApiException {
|
||||
|
||||
ProgressResponseBody.ProgressListener progressListener = null;
|
||||
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
|
||||
|
||||
if(callback != null) {
|
||||
progressListener = new ProgressResponseBody.ProgressListener() {
|
||||
@Override
|
||||
public void update(long bytesRead, long contentLength, boolean done) {
|
||||
callback.onDownloadProgress(bytesRead, contentLength, done);
|
||||
}
|
||||
};
|
||||
|
||||
progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
|
||||
@Override
|
||||
public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
|
||||
callback.onUploadProgress(bytesWritten, contentLength, done);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Call call = deletePetCall(petId,apiKey, progressListener, progressRequestListener);
|
||||
apiClient.executeAsync(call, callback);
|
||||
return call;
|
||||
}
|
||||
|
||||
/* Build call for uploadFile */
|
||||
private Call uploadFileCall(Long petId, String additionalMetadata, File file) throws ApiException {
|
||||
private Call uploadFileCall(Long petId,String additionalMetadata,File file, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
|
||||
Object postBody = null;
|
||||
|
||||
// verify the required parameter 'petId' is set
|
||||
@ -486,8 +716,20 @@ public class PetApi {
|
||||
final String contentType = apiClient.selectHeaderContentType(contentTypes);
|
||||
headerParams.put("Content-Type", contentType);
|
||||
|
||||
if(progressListener != null) {
|
||||
apiClient.getHttpClient().networkInterceptors().add(new Interceptor() {
|
||||
@Override
|
||||
public Response intercept(Interceptor.Chain chain) throws IOException {
|
||||
Response originalResponse = chain.proceed(chain.request());
|
||||
return originalResponse.newBuilder()
|
||||
.body(new ProgressResponseBody(originalResponse.body(), progressListener))
|
||||
.build();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
String[] authNames = new String[] { "petstore_auth" };
|
||||
return apiClient.buildCall(path, "POST", queryParams, postBody, headerParams, formParams, authNames);
|
||||
return apiClient.buildCall(path, "POST", queryParams, postBody, headerParams, formParams, authNames, progressRequestListener);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -498,7 +740,7 @@ public class PetApi {
|
||||
* @param file file to upload
|
||||
*/
|
||||
public void uploadFile(Long petId, String additionalMetadata, File file) throws ApiException {
|
||||
Call call = uploadFileCall(petId, additionalMetadata, file);
|
||||
Call call = uploadFileCall(petId,additionalMetadata,file, null, null);
|
||||
apiClient.execute(call);
|
||||
}
|
||||
|
||||
@ -511,8 +753,28 @@ public class PetApi {
|
||||
* @param callback The callback to be executed when the API call finishes
|
||||
* @return The request call
|
||||
*/
|
||||
public Call uploadFileAsync(Long petId, String additionalMetadata, File file, ApiCallback<Void> callback) throws ApiException {
|
||||
Call call = uploadFileCall(petId, additionalMetadata, file);
|
||||
public Call uploadFileAsync(Long petId, String additionalMetadata, File file, final ApiCallback<Void> callback) throws ApiException {
|
||||
|
||||
ProgressResponseBody.ProgressListener progressListener = null;
|
||||
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
|
||||
|
||||
if(callback != null) {
|
||||
progressListener = new ProgressResponseBody.ProgressListener() {
|
||||
@Override
|
||||
public void update(long bytesRead, long contentLength, boolean done) {
|
||||
callback.onDownloadProgress(bytesRead, contentLength, done);
|
||||
}
|
||||
};
|
||||
|
||||
progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
|
||||
@Override
|
||||
public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
|
||||
callback.onUploadProgress(bytesWritten, contentLength, done);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Call call = uploadFileCall(petId,additionalMetadata,file, progressListener, progressRequestListener);
|
||||
apiClient.executeAsync(call, callback);
|
||||
return call;
|
||||
}
|
||||
|
@ -5,10 +5,16 @@ import io.swagger.client.ApiClient;
|
||||
import io.swagger.client.ApiException;
|
||||
import io.swagger.client.Configuration;
|
||||
import io.swagger.client.Pair;
|
||||
import io.swagger.client.ProgressRequestBody;
|
||||
import io.swagger.client.ProgressResponseBody;
|
||||
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import com.squareup.okhttp.Call;
|
||||
import com.squareup.okhttp.Interceptor;
|
||||
import com.squareup.okhttp.Response;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import java.util.Map;
|
||||
import io.swagger.client.model.Order;
|
||||
@ -37,7 +43,7 @@ public class StoreApi {
|
||||
|
||||
|
||||
/* Build call for getInventory */
|
||||
private Call getInventoryCall() throws ApiException {
|
||||
private Call getInventoryCall( final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
|
||||
Object postBody = null;
|
||||
|
||||
|
||||
@ -62,8 +68,20 @@ public class StoreApi {
|
||||
final String contentType = apiClient.selectHeaderContentType(contentTypes);
|
||||
headerParams.put("Content-Type", contentType);
|
||||
|
||||
if(progressListener != null) {
|
||||
apiClient.getHttpClient().networkInterceptors().add(new Interceptor() {
|
||||
@Override
|
||||
public Response intercept(Interceptor.Chain chain) throws IOException {
|
||||
Response originalResponse = chain.proceed(chain.request());
|
||||
return originalResponse.newBuilder()
|
||||
.body(new ProgressResponseBody(originalResponse.body(), progressListener))
|
||||
.build();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
String[] authNames = new String[] { "api_key" };
|
||||
return apiClient.buildCall(path, "GET", queryParams, postBody, headerParams, formParams, authNames);
|
||||
return apiClient.buildCall(path, "GET", queryParams, postBody, headerParams, formParams, authNames, progressRequestListener);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -72,7 +90,7 @@ public class StoreApi {
|
||||
* @return Map<String, Integer>
|
||||
*/
|
||||
public Map<String, Integer> getInventory() throws ApiException {
|
||||
Call call = getInventoryCall();
|
||||
Call call = getInventoryCall( null, null);
|
||||
Type returnType = new TypeToken<Map<String, Integer>>(){}.getType();
|
||||
return apiClient.execute(call, returnType);
|
||||
}
|
||||
@ -83,15 +101,35 @@ public class StoreApi {
|
||||
* @param callback The callback to be executed when the API call finishes
|
||||
* @return The request call
|
||||
*/
|
||||
public Call getInventoryAsync(ApiCallback<Map<String, Integer>> callback) throws ApiException {
|
||||
Call call = getInventoryCall();
|
||||
public Call getInventoryAsync(final ApiCallback<Map<String, Integer>> callback) throws ApiException {
|
||||
|
||||
ProgressResponseBody.ProgressListener progressListener = null;
|
||||
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
|
||||
|
||||
if(callback != null) {
|
||||
progressListener = new ProgressResponseBody.ProgressListener() {
|
||||
@Override
|
||||
public void update(long bytesRead, long contentLength, boolean done) {
|
||||
callback.onDownloadProgress(bytesRead, contentLength, done);
|
||||
}
|
||||
};
|
||||
|
||||
progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
|
||||
@Override
|
||||
public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
|
||||
callback.onUploadProgress(bytesWritten, contentLength, done);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Call call = getInventoryCall( progressListener, progressRequestListener);
|
||||
Type returnType = new TypeToken<Map<String, Integer>>(){}.getType();
|
||||
apiClient.executeAsync(call, returnType, callback);
|
||||
return call;
|
||||
}
|
||||
|
||||
/* Build call for placeOrder */
|
||||
private Call placeOrderCall(Order body) throws ApiException {
|
||||
private Call placeOrderCall(Order body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
|
||||
Object postBody = body;
|
||||
|
||||
|
||||
@ -116,8 +154,20 @@ public class StoreApi {
|
||||
final String contentType = apiClient.selectHeaderContentType(contentTypes);
|
||||
headerParams.put("Content-Type", contentType);
|
||||
|
||||
if(progressListener != null) {
|
||||
apiClient.getHttpClient().networkInterceptors().add(new Interceptor() {
|
||||
@Override
|
||||
public Response intercept(Interceptor.Chain chain) throws IOException {
|
||||
Response originalResponse = chain.proceed(chain.request());
|
||||
return originalResponse.newBuilder()
|
||||
.body(new ProgressResponseBody(originalResponse.body(), progressListener))
|
||||
.build();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
String[] authNames = new String[] { };
|
||||
return apiClient.buildCall(path, "POST", queryParams, postBody, headerParams, formParams, authNames);
|
||||
return apiClient.buildCall(path, "POST", queryParams, postBody, headerParams, formParams, authNames, progressRequestListener);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -127,7 +177,7 @@ public class StoreApi {
|
||||
* @return Order
|
||||
*/
|
||||
public Order placeOrder(Order body) throws ApiException {
|
||||
Call call = placeOrderCall(body);
|
||||
Call call = placeOrderCall(body, null, null);
|
||||
Type returnType = new TypeToken<Order>(){}.getType();
|
||||
return apiClient.execute(call, returnType);
|
||||
}
|
||||
@ -139,15 +189,35 @@ public class StoreApi {
|
||||
* @param callback The callback to be executed when the API call finishes
|
||||
* @return The request call
|
||||
*/
|
||||
public Call placeOrderAsync(Order body, ApiCallback<Order> callback) throws ApiException {
|
||||
Call call = placeOrderCall(body);
|
||||
public Call placeOrderAsync(Order body, final ApiCallback<Order> callback) throws ApiException {
|
||||
|
||||
ProgressResponseBody.ProgressListener progressListener = null;
|
||||
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
|
||||
|
||||
if(callback != null) {
|
||||
progressListener = new ProgressResponseBody.ProgressListener() {
|
||||
@Override
|
||||
public void update(long bytesRead, long contentLength, boolean done) {
|
||||
callback.onDownloadProgress(bytesRead, contentLength, done);
|
||||
}
|
||||
};
|
||||
|
||||
progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
|
||||
@Override
|
||||
public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
|
||||
callback.onUploadProgress(bytesWritten, contentLength, done);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Call call = placeOrderCall(body, progressListener, progressRequestListener);
|
||||
Type returnType = new TypeToken<Order>(){}.getType();
|
||||
apiClient.executeAsync(call, returnType, callback);
|
||||
return call;
|
||||
}
|
||||
|
||||
/* Build call for getOrderById */
|
||||
private Call getOrderByIdCall(String orderId) throws ApiException {
|
||||
private Call getOrderByIdCall(String orderId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
|
||||
Object postBody = null;
|
||||
|
||||
// verify the required parameter 'orderId' is set
|
||||
@ -178,8 +248,20 @@ public class StoreApi {
|
||||
final String contentType = apiClient.selectHeaderContentType(contentTypes);
|
||||
headerParams.put("Content-Type", contentType);
|
||||
|
||||
if(progressListener != null) {
|
||||
apiClient.getHttpClient().networkInterceptors().add(new Interceptor() {
|
||||
@Override
|
||||
public Response intercept(Interceptor.Chain chain) throws IOException {
|
||||
Response originalResponse = chain.proceed(chain.request());
|
||||
return originalResponse.newBuilder()
|
||||
.body(new ProgressResponseBody(originalResponse.body(), progressListener))
|
||||
.build();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
String[] authNames = new String[] { };
|
||||
return apiClient.buildCall(path, "GET", queryParams, postBody, headerParams, formParams, authNames);
|
||||
return apiClient.buildCall(path, "GET", queryParams, postBody, headerParams, formParams, authNames, progressRequestListener);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -189,7 +271,7 @@ public class StoreApi {
|
||||
* @return Order
|
||||
*/
|
||||
public Order getOrderById(String orderId) throws ApiException {
|
||||
Call call = getOrderByIdCall(orderId);
|
||||
Call call = getOrderByIdCall(orderId, null, null);
|
||||
Type returnType = new TypeToken<Order>(){}.getType();
|
||||
return apiClient.execute(call, returnType);
|
||||
}
|
||||
@ -201,15 +283,35 @@ public class StoreApi {
|
||||
* @param callback The callback to be executed when the API call finishes
|
||||
* @return The request call
|
||||
*/
|
||||
public Call getOrderByIdAsync(String orderId, ApiCallback<Order> callback) throws ApiException {
|
||||
Call call = getOrderByIdCall(orderId);
|
||||
public Call getOrderByIdAsync(String orderId, final ApiCallback<Order> callback) throws ApiException {
|
||||
|
||||
ProgressResponseBody.ProgressListener progressListener = null;
|
||||
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
|
||||
|
||||
if(callback != null) {
|
||||
progressListener = new ProgressResponseBody.ProgressListener() {
|
||||
@Override
|
||||
public void update(long bytesRead, long contentLength, boolean done) {
|
||||
callback.onDownloadProgress(bytesRead, contentLength, done);
|
||||
}
|
||||
};
|
||||
|
||||
progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
|
||||
@Override
|
||||
public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
|
||||
callback.onUploadProgress(bytesWritten, contentLength, done);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Call call = getOrderByIdCall(orderId, progressListener, progressRequestListener);
|
||||
Type returnType = new TypeToken<Order>(){}.getType();
|
||||
apiClient.executeAsync(call, returnType, callback);
|
||||
return call;
|
||||
}
|
||||
|
||||
/* Build call for deleteOrder */
|
||||
private Call deleteOrderCall(String orderId) throws ApiException {
|
||||
private Call deleteOrderCall(String orderId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
|
||||
Object postBody = null;
|
||||
|
||||
// verify the required parameter 'orderId' is set
|
||||
@ -240,8 +342,20 @@ public class StoreApi {
|
||||
final String contentType = apiClient.selectHeaderContentType(contentTypes);
|
||||
headerParams.put("Content-Type", contentType);
|
||||
|
||||
if(progressListener != null) {
|
||||
apiClient.getHttpClient().networkInterceptors().add(new Interceptor() {
|
||||
@Override
|
||||
public Response intercept(Interceptor.Chain chain) throws IOException {
|
||||
Response originalResponse = chain.proceed(chain.request());
|
||||
return originalResponse.newBuilder()
|
||||
.body(new ProgressResponseBody(originalResponse.body(), progressListener))
|
||||
.build();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
String[] authNames = new String[] { };
|
||||
return apiClient.buildCall(path, "DELETE", queryParams, postBody, headerParams, formParams, authNames);
|
||||
return apiClient.buildCall(path, "DELETE", queryParams, postBody, headerParams, formParams, authNames, progressRequestListener);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -250,7 +364,7 @@ public class StoreApi {
|
||||
* @param orderId ID of the order that needs to be deleted
|
||||
*/
|
||||
public void deleteOrder(String orderId) throws ApiException {
|
||||
Call call = deleteOrderCall(orderId);
|
||||
Call call = deleteOrderCall(orderId, null, null);
|
||||
apiClient.execute(call);
|
||||
}
|
||||
|
||||
@ -261,8 +375,28 @@ public class StoreApi {
|
||||
* @param callback The callback to be executed when the API call finishes
|
||||
* @return The request call
|
||||
*/
|
||||
public Call deleteOrderAsync(String orderId, ApiCallback<Void> callback) throws ApiException {
|
||||
Call call = deleteOrderCall(orderId);
|
||||
public Call deleteOrderAsync(String orderId, final ApiCallback<Void> callback) throws ApiException {
|
||||
|
||||
ProgressResponseBody.ProgressListener progressListener = null;
|
||||
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
|
||||
|
||||
if(callback != null) {
|
||||
progressListener = new ProgressResponseBody.ProgressListener() {
|
||||
@Override
|
||||
public void update(long bytesRead, long contentLength, boolean done) {
|
||||
callback.onDownloadProgress(bytesRead, contentLength, done);
|
||||
}
|
||||
};
|
||||
|
||||
progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
|
||||
@Override
|
||||
public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
|
||||
callback.onUploadProgress(bytesWritten, contentLength, done);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Call call = deleteOrderCall(orderId, progressListener, progressRequestListener);
|
||||
apiClient.executeAsync(call, callback);
|
||||
return call;
|
||||
}
|
||||
|
@ -5,10 +5,16 @@ import io.swagger.client.ApiClient;
|
||||
import io.swagger.client.ApiException;
|
||||
import io.swagger.client.Configuration;
|
||||
import io.swagger.client.Pair;
|
||||
import io.swagger.client.ProgressRequestBody;
|
||||
import io.swagger.client.ProgressResponseBody;
|
||||
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import com.squareup.okhttp.Call;
|
||||
import com.squareup.okhttp.Interceptor;
|
||||
import com.squareup.okhttp.Response;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import io.swagger.client.model.User;
|
||||
import java.util.*;
|
||||
@ -37,7 +43,7 @@ public class UserApi {
|
||||
|
||||
|
||||
/* Build call for createUser */
|
||||
private Call createUserCall(User body) throws ApiException {
|
||||
private Call createUserCall(User body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
|
||||
Object postBody = body;
|
||||
|
||||
|
||||
@ -62,8 +68,20 @@ public class UserApi {
|
||||
final String contentType = apiClient.selectHeaderContentType(contentTypes);
|
||||
headerParams.put("Content-Type", contentType);
|
||||
|
||||
if(progressListener != null) {
|
||||
apiClient.getHttpClient().networkInterceptors().add(new Interceptor() {
|
||||
@Override
|
||||
public Response intercept(Interceptor.Chain chain) throws IOException {
|
||||
Response originalResponse = chain.proceed(chain.request());
|
||||
return originalResponse.newBuilder()
|
||||
.body(new ProgressResponseBody(originalResponse.body(), progressListener))
|
||||
.build();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
String[] authNames = new String[] { };
|
||||
return apiClient.buildCall(path, "POST", queryParams, postBody, headerParams, formParams, authNames);
|
||||
return apiClient.buildCall(path, "POST", queryParams, postBody, headerParams, formParams, authNames, progressRequestListener);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -72,7 +90,7 @@ public class UserApi {
|
||||
* @param body Created user object
|
||||
*/
|
||||
public void createUser(User body) throws ApiException {
|
||||
Call call = createUserCall(body);
|
||||
Call call = createUserCall(body, null, null);
|
||||
apiClient.execute(call);
|
||||
}
|
||||
|
||||
@ -83,14 +101,34 @@ public class UserApi {
|
||||
* @param callback The callback to be executed when the API call finishes
|
||||
* @return The request call
|
||||
*/
|
||||
public Call createUserAsync(User body, ApiCallback<Void> callback) throws ApiException {
|
||||
Call call = createUserCall(body);
|
||||
public Call createUserAsync(User body, final ApiCallback<Void> callback) throws ApiException {
|
||||
|
||||
ProgressResponseBody.ProgressListener progressListener = null;
|
||||
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
|
||||
|
||||
if(callback != null) {
|
||||
progressListener = new ProgressResponseBody.ProgressListener() {
|
||||
@Override
|
||||
public void update(long bytesRead, long contentLength, boolean done) {
|
||||
callback.onDownloadProgress(bytesRead, contentLength, done);
|
||||
}
|
||||
};
|
||||
|
||||
progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
|
||||
@Override
|
||||
public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
|
||||
callback.onUploadProgress(bytesWritten, contentLength, done);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Call call = createUserCall(body, progressListener, progressRequestListener);
|
||||
apiClient.executeAsync(call, callback);
|
||||
return call;
|
||||
}
|
||||
|
||||
/* Build call for createUsersWithArrayInput */
|
||||
private Call createUsersWithArrayInputCall(List<User> body) throws ApiException {
|
||||
private Call createUsersWithArrayInputCall(List<User> body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
|
||||
Object postBody = body;
|
||||
|
||||
|
||||
@ -115,8 +153,20 @@ public class UserApi {
|
||||
final String contentType = apiClient.selectHeaderContentType(contentTypes);
|
||||
headerParams.put("Content-Type", contentType);
|
||||
|
||||
if(progressListener != null) {
|
||||
apiClient.getHttpClient().networkInterceptors().add(new Interceptor() {
|
||||
@Override
|
||||
public Response intercept(Interceptor.Chain chain) throws IOException {
|
||||
Response originalResponse = chain.proceed(chain.request());
|
||||
return originalResponse.newBuilder()
|
||||
.body(new ProgressResponseBody(originalResponse.body(), progressListener))
|
||||
.build();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
String[] authNames = new String[] { };
|
||||
return apiClient.buildCall(path, "POST", queryParams, postBody, headerParams, formParams, authNames);
|
||||
return apiClient.buildCall(path, "POST", queryParams, postBody, headerParams, formParams, authNames, progressRequestListener);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -125,7 +175,7 @@ public class UserApi {
|
||||
* @param body List of user object
|
||||
*/
|
||||
public void createUsersWithArrayInput(List<User> body) throws ApiException {
|
||||
Call call = createUsersWithArrayInputCall(body);
|
||||
Call call = createUsersWithArrayInputCall(body, null, null);
|
||||
apiClient.execute(call);
|
||||
}
|
||||
|
||||
@ -136,14 +186,34 @@ public class UserApi {
|
||||
* @param callback The callback to be executed when the API call finishes
|
||||
* @return The request call
|
||||
*/
|
||||
public Call createUsersWithArrayInputAsync(List<User> body, ApiCallback<Void> callback) throws ApiException {
|
||||
Call call = createUsersWithArrayInputCall(body);
|
||||
public Call createUsersWithArrayInputAsync(List<User> body, final ApiCallback<Void> callback) throws ApiException {
|
||||
|
||||
ProgressResponseBody.ProgressListener progressListener = null;
|
||||
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
|
||||
|
||||
if(callback != null) {
|
||||
progressListener = new ProgressResponseBody.ProgressListener() {
|
||||
@Override
|
||||
public void update(long bytesRead, long contentLength, boolean done) {
|
||||
callback.onDownloadProgress(bytesRead, contentLength, done);
|
||||
}
|
||||
};
|
||||
|
||||
progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
|
||||
@Override
|
||||
public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
|
||||
callback.onUploadProgress(bytesWritten, contentLength, done);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Call call = createUsersWithArrayInputCall(body, progressListener, progressRequestListener);
|
||||
apiClient.executeAsync(call, callback);
|
||||
return call;
|
||||
}
|
||||
|
||||
/* Build call for createUsersWithListInput */
|
||||
private Call createUsersWithListInputCall(List<User> body) throws ApiException {
|
||||
private Call createUsersWithListInputCall(List<User> body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
|
||||
Object postBody = body;
|
||||
|
||||
|
||||
@ -168,8 +238,20 @@ public class UserApi {
|
||||
final String contentType = apiClient.selectHeaderContentType(contentTypes);
|
||||
headerParams.put("Content-Type", contentType);
|
||||
|
||||
if(progressListener != null) {
|
||||
apiClient.getHttpClient().networkInterceptors().add(new Interceptor() {
|
||||
@Override
|
||||
public Response intercept(Interceptor.Chain chain) throws IOException {
|
||||
Response originalResponse = chain.proceed(chain.request());
|
||||
return originalResponse.newBuilder()
|
||||
.body(new ProgressResponseBody(originalResponse.body(), progressListener))
|
||||
.build();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
String[] authNames = new String[] { };
|
||||
return apiClient.buildCall(path, "POST", queryParams, postBody, headerParams, formParams, authNames);
|
||||
return apiClient.buildCall(path, "POST", queryParams, postBody, headerParams, formParams, authNames, progressRequestListener);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -178,7 +260,7 @@ public class UserApi {
|
||||
* @param body List of user object
|
||||
*/
|
||||
public void createUsersWithListInput(List<User> body) throws ApiException {
|
||||
Call call = createUsersWithListInputCall(body);
|
||||
Call call = createUsersWithListInputCall(body, null, null);
|
||||
apiClient.execute(call);
|
||||
}
|
||||
|
||||
@ -189,14 +271,34 @@ public class UserApi {
|
||||
* @param callback The callback to be executed when the API call finishes
|
||||
* @return The request call
|
||||
*/
|
||||
public Call createUsersWithListInputAsync(List<User> body, ApiCallback<Void> callback) throws ApiException {
|
||||
Call call = createUsersWithListInputCall(body);
|
||||
public Call createUsersWithListInputAsync(List<User> body, final ApiCallback<Void> callback) throws ApiException {
|
||||
|
||||
ProgressResponseBody.ProgressListener progressListener = null;
|
||||
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
|
||||
|
||||
if(callback != null) {
|
||||
progressListener = new ProgressResponseBody.ProgressListener() {
|
||||
@Override
|
||||
public void update(long bytesRead, long contentLength, boolean done) {
|
||||
callback.onDownloadProgress(bytesRead, contentLength, done);
|
||||
}
|
||||
};
|
||||
|
||||
progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
|
||||
@Override
|
||||
public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
|
||||
callback.onUploadProgress(bytesWritten, contentLength, done);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Call call = createUsersWithListInputCall(body, progressListener, progressRequestListener);
|
||||
apiClient.executeAsync(call, callback);
|
||||
return call;
|
||||
}
|
||||
|
||||
/* Build call for loginUser */
|
||||
private Call loginUserCall(String username, String password) throws ApiException {
|
||||
private Call loginUserCall(String username,String password, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
|
||||
Object postBody = null;
|
||||
|
||||
|
||||
@ -225,8 +327,20 @@ public class UserApi {
|
||||
final String contentType = apiClient.selectHeaderContentType(contentTypes);
|
||||
headerParams.put("Content-Type", contentType);
|
||||
|
||||
if(progressListener != null) {
|
||||
apiClient.getHttpClient().networkInterceptors().add(new Interceptor() {
|
||||
@Override
|
||||
public Response intercept(Interceptor.Chain chain) throws IOException {
|
||||
Response originalResponse = chain.proceed(chain.request());
|
||||
return originalResponse.newBuilder()
|
||||
.body(new ProgressResponseBody(originalResponse.body(), progressListener))
|
||||
.build();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
String[] authNames = new String[] { };
|
||||
return apiClient.buildCall(path, "GET", queryParams, postBody, headerParams, formParams, authNames);
|
||||
return apiClient.buildCall(path, "GET", queryParams, postBody, headerParams, formParams, authNames, progressRequestListener);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -237,7 +351,7 @@ public class UserApi {
|
||||
* @return String
|
||||
*/
|
||||
public String loginUser(String username, String password) throws ApiException {
|
||||
Call call = loginUserCall(username, password);
|
||||
Call call = loginUserCall(username,password, null, null);
|
||||
Type returnType = new TypeToken<String>(){}.getType();
|
||||
return apiClient.execute(call, returnType);
|
||||
}
|
||||
@ -250,15 +364,35 @@ public class UserApi {
|
||||
* @param callback The callback to be executed when the API call finishes
|
||||
* @return The request call
|
||||
*/
|
||||
public Call loginUserAsync(String username, String password, ApiCallback<String> callback) throws ApiException {
|
||||
Call call = loginUserCall(username, password);
|
||||
public Call loginUserAsync(String username, String password, final ApiCallback<String> callback) throws ApiException {
|
||||
|
||||
ProgressResponseBody.ProgressListener progressListener = null;
|
||||
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
|
||||
|
||||
if(callback != null) {
|
||||
progressListener = new ProgressResponseBody.ProgressListener() {
|
||||
@Override
|
||||
public void update(long bytesRead, long contentLength, boolean done) {
|
||||
callback.onDownloadProgress(bytesRead, contentLength, done);
|
||||
}
|
||||
};
|
||||
|
||||
progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
|
||||
@Override
|
||||
public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
|
||||
callback.onUploadProgress(bytesWritten, contentLength, done);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Call call = loginUserCall(username,password, progressListener, progressRequestListener);
|
||||
Type returnType = new TypeToken<String>(){}.getType();
|
||||
apiClient.executeAsync(call, returnType, callback);
|
||||
return call;
|
||||
}
|
||||
|
||||
/* Build call for logoutUser */
|
||||
private Call logoutUserCall() throws ApiException {
|
||||
private Call logoutUserCall( final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
|
||||
Object postBody = null;
|
||||
|
||||
|
||||
@ -283,8 +417,20 @@ public class UserApi {
|
||||
final String contentType = apiClient.selectHeaderContentType(contentTypes);
|
||||
headerParams.put("Content-Type", contentType);
|
||||
|
||||
if(progressListener != null) {
|
||||
apiClient.getHttpClient().networkInterceptors().add(new Interceptor() {
|
||||
@Override
|
||||
public Response intercept(Interceptor.Chain chain) throws IOException {
|
||||
Response originalResponse = chain.proceed(chain.request());
|
||||
return originalResponse.newBuilder()
|
||||
.body(new ProgressResponseBody(originalResponse.body(), progressListener))
|
||||
.build();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
String[] authNames = new String[] { };
|
||||
return apiClient.buildCall(path, "GET", queryParams, postBody, headerParams, formParams, authNames);
|
||||
return apiClient.buildCall(path, "GET", queryParams, postBody, headerParams, formParams, authNames, progressRequestListener);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -292,7 +438,7 @@ public class UserApi {
|
||||
*
|
||||
*/
|
||||
public void logoutUser() throws ApiException {
|
||||
Call call = logoutUserCall();
|
||||
Call call = logoutUserCall( null, null);
|
||||
apiClient.execute(call);
|
||||
}
|
||||
|
||||
@ -302,14 +448,34 @@ public class UserApi {
|
||||
* @param callback The callback to be executed when the API call finishes
|
||||
* @return The request call
|
||||
*/
|
||||
public Call logoutUserAsync(ApiCallback<Void> callback) throws ApiException {
|
||||
Call call = logoutUserCall();
|
||||
public Call logoutUserAsync(final ApiCallback<Void> callback) throws ApiException {
|
||||
|
||||
ProgressResponseBody.ProgressListener progressListener = null;
|
||||
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
|
||||
|
||||
if(callback != null) {
|
||||
progressListener = new ProgressResponseBody.ProgressListener() {
|
||||
@Override
|
||||
public void update(long bytesRead, long contentLength, boolean done) {
|
||||
callback.onDownloadProgress(bytesRead, contentLength, done);
|
||||
}
|
||||
};
|
||||
|
||||
progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
|
||||
@Override
|
||||
public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
|
||||
callback.onUploadProgress(bytesWritten, contentLength, done);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Call call = logoutUserCall( progressListener, progressRequestListener);
|
||||
apiClient.executeAsync(call, callback);
|
||||
return call;
|
||||
}
|
||||
|
||||
/* Build call for getUserByName */
|
||||
private Call getUserByNameCall(String username) throws ApiException {
|
||||
private Call getUserByNameCall(String username, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
|
||||
Object postBody = null;
|
||||
|
||||
// verify the required parameter 'username' is set
|
||||
@ -340,8 +506,20 @@ public class UserApi {
|
||||
final String contentType = apiClient.selectHeaderContentType(contentTypes);
|
||||
headerParams.put("Content-Type", contentType);
|
||||
|
||||
if(progressListener != null) {
|
||||
apiClient.getHttpClient().networkInterceptors().add(new Interceptor() {
|
||||
@Override
|
||||
public Response intercept(Interceptor.Chain chain) throws IOException {
|
||||
Response originalResponse = chain.proceed(chain.request());
|
||||
return originalResponse.newBuilder()
|
||||
.body(new ProgressResponseBody(originalResponse.body(), progressListener))
|
||||
.build();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
String[] authNames = new String[] { };
|
||||
return apiClient.buildCall(path, "GET", queryParams, postBody, headerParams, formParams, authNames);
|
||||
return apiClient.buildCall(path, "GET", queryParams, postBody, headerParams, formParams, authNames, progressRequestListener);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -351,7 +529,7 @@ public class UserApi {
|
||||
* @return User
|
||||
*/
|
||||
public User getUserByName(String username) throws ApiException {
|
||||
Call call = getUserByNameCall(username);
|
||||
Call call = getUserByNameCall(username, null, null);
|
||||
Type returnType = new TypeToken<User>(){}.getType();
|
||||
return apiClient.execute(call, returnType);
|
||||
}
|
||||
@ -363,15 +541,35 @@ public class UserApi {
|
||||
* @param callback The callback to be executed when the API call finishes
|
||||
* @return The request call
|
||||
*/
|
||||
public Call getUserByNameAsync(String username, ApiCallback<User> callback) throws ApiException {
|
||||
Call call = getUserByNameCall(username);
|
||||
public Call getUserByNameAsync(String username, final ApiCallback<User> callback) throws ApiException {
|
||||
|
||||
ProgressResponseBody.ProgressListener progressListener = null;
|
||||
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
|
||||
|
||||
if(callback != null) {
|
||||
progressListener = new ProgressResponseBody.ProgressListener() {
|
||||
@Override
|
||||
public void update(long bytesRead, long contentLength, boolean done) {
|
||||
callback.onDownloadProgress(bytesRead, contentLength, done);
|
||||
}
|
||||
};
|
||||
|
||||
progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
|
||||
@Override
|
||||
public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
|
||||
callback.onUploadProgress(bytesWritten, contentLength, done);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Call call = getUserByNameCall(username, progressListener, progressRequestListener);
|
||||
Type returnType = new TypeToken<User>(){}.getType();
|
||||
apiClient.executeAsync(call, returnType, callback);
|
||||
return call;
|
||||
}
|
||||
|
||||
/* Build call for updateUser */
|
||||
private Call updateUserCall(String username, User body) throws ApiException {
|
||||
private Call updateUserCall(String username,User body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
|
||||
Object postBody = body;
|
||||
|
||||
// verify the required parameter 'username' is set
|
||||
@ -402,8 +600,20 @@ public class UserApi {
|
||||
final String contentType = apiClient.selectHeaderContentType(contentTypes);
|
||||
headerParams.put("Content-Type", contentType);
|
||||
|
||||
if(progressListener != null) {
|
||||
apiClient.getHttpClient().networkInterceptors().add(new Interceptor() {
|
||||
@Override
|
||||
public Response intercept(Interceptor.Chain chain) throws IOException {
|
||||
Response originalResponse = chain.proceed(chain.request());
|
||||
return originalResponse.newBuilder()
|
||||
.body(new ProgressResponseBody(originalResponse.body(), progressListener))
|
||||
.build();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
String[] authNames = new String[] { };
|
||||
return apiClient.buildCall(path, "PUT", queryParams, postBody, headerParams, formParams, authNames);
|
||||
return apiClient.buildCall(path, "PUT", queryParams, postBody, headerParams, formParams, authNames, progressRequestListener);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -413,7 +623,7 @@ public class UserApi {
|
||||
* @param body Updated user object
|
||||
*/
|
||||
public void updateUser(String username, User body) throws ApiException {
|
||||
Call call = updateUserCall(username, body);
|
||||
Call call = updateUserCall(username,body, null, null);
|
||||
apiClient.execute(call);
|
||||
}
|
||||
|
||||
@ -425,14 +635,34 @@ public class UserApi {
|
||||
* @param callback The callback to be executed when the API call finishes
|
||||
* @return The request call
|
||||
*/
|
||||
public Call updateUserAsync(String username, User body, ApiCallback<Void> callback) throws ApiException {
|
||||
Call call = updateUserCall(username, body);
|
||||
public Call updateUserAsync(String username, User body, final ApiCallback<Void> callback) throws ApiException {
|
||||
|
||||
ProgressResponseBody.ProgressListener progressListener = null;
|
||||
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
|
||||
|
||||
if(callback != null) {
|
||||
progressListener = new ProgressResponseBody.ProgressListener() {
|
||||
@Override
|
||||
public void update(long bytesRead, long contentLength, boolean done) {
|
||||
callback.onDownloadProgress(bytesRead, contentLength, done);
|
||||
}
|
||||
};
|
||||
|
||||
progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
|
||||
@Override
|
||||
public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
|
||||
callback.onUploadProgress(bytesWritten, contentLength, done);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Call call = updateUserCall(username,body, progressListener, progressRequestListener);
|
||||
apiClient.executeAsync(call, callback);
|
||||
return call;
|
||||
}
|
||||
|
||||
/* Build call for deleteUser */
|
||||
private Call deleteUserCall(String username) throws ApiException {
|
||||
private Call deleteUserCall(String username, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
|
||||
Object postBody = null;
|
||||
|
||||
// verify the required parameter 'username' is set
|
||||
@ -463,8 +693,20 @@ public class UserApi {
|
||||
final String contentType = apiClient.selectHeaderContentType(contentTypes);
|
||||
headerParams.put("Content-Type", contentType);
|
||||
|
||||
if(progressListener != null) {
|
||||
apiClient.getHttpClient().networkInterceptors().add(new Interceptor() {
|
||||
@Override
|
||||
public Response intercept(Interceptor.Chain chain) throws IOException {
|
||||
Response originalResponse = chain.proceed(chain.request());
|
||||
return originalResponse.newBuilder()
|
||||
.body(new ProgressResponseBody(originalResponse.body(), progressListener))
|
||||
.build();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
String[] authNames = new String[] { };
|
||||
return apiClient.buildCall(path, "DELETE", queryParams, postBody, headerParams, formParams, authNames);
|
||||
return apiClient.buildCall(path, "DELETE", queryParams, postBody, headerParams, formParams, authNames, progressRequestListener);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -473,7 +715,7 @@ public class UserApi {
|
||||
* @param username The name that needs to be deleted
|
||||
*/
|
||||
public void deleteUser(String username) throws ApiException {
|
||||
Call call = deleteUserCall(username);
|
||||
Call call = deleteUserCall(username, null, null);
|
||||
apiClient.execute(call);
|
||||
}
|
||||
|
||||
@ -484,8 +726,28 @@ public class UserApi {
|
||||
* @param callback The callback to be executed when the API call finishes
|
||||
* @return The request call
|
||||
*/
|
||||
public Call deleteUserAsync(String username, ApiCallback<Void> callback) throws ApiException {
|
||||
Call call = deleteUserCall(username);
|
||||
public Call deleteUserAsync(String username, final ApiCallback<Void> callback) throws ApiException {
|
||||
|
||||
ProgressResponseBody.ProgressListener progressListener = null;
|
||||
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
|
||||
|
||||
if(callback != null) {
|
||||
progressListener = new ProgressResponseBody.ProgressListener() {
|
||||
@Override
|
||||
public void update(long bytesRead, long contentLength, boolean done) {
|
||||
callback.onDownloadProgress(bytesRead, contentLength, done);
|
||||
}
|
||||
};
|
||||
|
||||
progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
|
||||
@Override
|
||||
public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
|
||||
callback.onUploadProgress(bytesWritten, contentLength, done);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Call call = deleteUserCall(username, progressListener, progressRequestListener);
|
||||
apiClient.executeAsync(call, callback);
|
||||
return call;
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import io.swagger.client.Pair;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-20T17:28:54.086+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-29T00:18:08.052+08:00")
|
||||
public class ApiKeyAuth implements Authentication {
|
||||
private final String location;
|
||||
private final String paramName;
|
||||
|
@ -5,7 +5,7 @@ import io.swagger.client.Pair;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-20T11:42:25.339-07:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-29T00:18:08.052+08:00")
|
||||
public interface Authentication {
|
||||
/** Apply authentication settings to header and query params. */
|
||||
void applyToParams(List<Pair> queryParams, Map<String, String> headerParams);
|
||||
|
@ -5,7 +5,7 @@ import io.swagger.client.Pair;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-02T22:14:00.422+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-29T00:18:08.052+08:00")
|
||||
public class OAuth implements Authentication {
|
||||
private String accessToken;
|
||||
|
||||
|
@ -2,8 +2,8 @@ package io.swagger.client.model;
|
||||
|
||||
import io.swagger.client.StringUtil;
|
||||
import io.swagger.client.model.Category;
|
||||
import java.util.*;
|
||||
import io.swagger.client.model.Tag;
|
||||
import java.util.*;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
|
@ -88,6 +88,16 @@ public class PetApiTest {
|
||||
public void onSuccess(Pet pet, int statusCode, Map<String, List<String>> responseHeaders) {
|
||||
result.put("pet", pet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUploadProgress(long bytesWritten, long contentLength, boolean done) {
|
||||
//empty
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDownloadProgress(long bytesRead, long contentLength, boolean done) {
|
||||
//empty
|
||||
}
|
||||
});
|
||||
// the API call should be executed asynchronously, so result should be empty at the moment
|
||||
assertTrue(result.isEmpty());
|
||||
@ -123,6 +133,16 @@ public class PetApiTest {
|
||||
public void onSuccess(Pet pet, int statusCode, Map<String, List<String>> responseHeaders) {
|
||||
result.put("pet", pet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUploadProgress(long bytesWritten, long contentLength, boolean done) {
|
||||
//empty
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDownloadProgress(long bytesRead, long contentLength, boolean done) {
|
||||
//empty
|
||||
}
|
||||
});
|
||||
// the API call should be executed asynchronously, so result should be empty at the moment
|
||||
assertTrue(result.isEmpty());
|
||||
@ -257,19 +277,25 @@ public class PetApiTest {
|
||||
Pet pet1 = new Pet();
|
||||
Pet pet2 = new Pet();
|
||||
assertTrue(pet1.equals(pet2));
|
||||
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(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(pet1.equals(pet2));
|
||||
assertTrue(pet2.equals(pet1));
|
||||
assertTrue(pet1.hashCode() == pet2.hashCode());
|
||||
assertTrue(pet1.equals(pet1));
|
||||
assertTrue(pet1.hashCode() == pet1.hashCode());
|
||||
}
|
||||
|
||||
|
@ -47,10 +47,10 @@ public class ApiClient {
|
||||
this();
|
||||
for(String authName : authNames) {
|
||||
Interceptor auth;
|
||||
if (authName == "petstore_auth") {
|
||||
auth = new OAuth(OAuthFlow.implicit, "http://petstore.swagger.io/api/oauth/dialog", "", "write:pets, read:pets");
|
||||
} else if (authName == "api_key") {
|
||||
if (authName == "api_key") {
|
||||
auth = new ApiKeyAuth("header", "api_key");
|
||||
} else if (authName == "petstore_auth") {
|
||||
auth = new OAuth(OAuthFlow.implicit, "http://petstore.swagger.io/api/oauth/dialog", "", "write:pets, read:pets");
|
||||
} else {
|
||||
throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names");
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package io.swagger.client;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-20T11:42:31.307-07:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-29T00:18:14.988+08:00")
|
||||
public class StringUtil {
|
||||
/**
|
||||
* Check if the given array contains the given value (with case-insensitive comparison).
|
||||
|
@ -1,15 +1,16 @@
|
||||
package io.swagger.client.api;
|
||||
|
||||
import io.swagger.client.model.*;
|
||||
import io.swagger.client.CollectionFormats.*;
|
||||
|
||||
import retrofit.Callback;
|
||||
import retrofit.http.*;
|
||||
import retrofit.mime.*;
|
||||
import java.util.*;
|
||||
|
||||
import io.swagger.client.model.Pet;
|
||||
import java.io.File;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public interface PetApi {
|
||||
|
||||
/**
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user