forked from loafle/openapi-generator-original
Merge pull request #1215 from xhh/java-last-resp-info
[Java jersey2 okhttp-gson] Fix compilation error, record status code and response headers of last request
This commit is contained in:
commit
46f78f2180
@ -53,6 +53,9 @@ public class ApiClient {
|
||||
|
||||
private Map<String, Authentication> authentications;
|
||||
|
||||
private int statusCode;
|
||||
private Map<String, List<String>> responseHeaders;
|
||||
|
||||
private DateFormat dateFormat;
|
||||
|
||||
public ApiClient() {
|
||||
@ -84,6 +87,20 @@ public class ApiClient {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the status code of the previous request
|
||||
*/
|
||||
public int getStatusCode() {
|
||||
return statusCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the response headers of the previous request
|
||||
*/
|
||||
public Map<String, List<String>> getResponseHeaders() {
|
||||
return responseHeaders;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get authentications (key: authentication name, value: authentication).
|
||||
*/
|
||||
@ -484,6 +501,9 @@ public class ApiClient {
|
||||
throw new ApiException(500, "unknown method type " + method);
|
||||
}
|
||||
|
||||
statusCode = response.getStatusInfo().getStatusCode();
|
||||
responseHeaders = buildResponseHeaders(response);
|
||||
|
||||
if (response.getStatus() == Status.NO_CONTENT.getStatusCode()) {
|
||||
return null;
|
||||
} else if (response.getStatusInfo().getFamily().equals(Status.Family.SUCCESSFUL)) {
|
||||
@ -502,21 +522,25 @@ public class ApiClient {
|
||||
// e.printStackTrace();
|
||||
}
|
||||
}
|
||||
throw new ApiException(
|
||||
response.getStatus(),
|
||||
message,
|
||||
buildResponseHeaders(response),
|
||||
respBody);
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, List<String>> buildResponseHeaders(Response response) {
|
||||
Map<String, List<String>> responseHeaders = new HashMap<String, List<String>>();
|
||||
for (String key: response.getHeaders().keySet()) {
|
||||
List<Object> values = response.getHeaders().get(key);
|
||||
for (Entry<String, List<Object>> entry: response.getHeaders().entrySet()) {
|
||||
List<Object> values = entry.getValue();
|
||||
List<String> headers = new ArrayList<String>();
|
||||
for (Object o : values) {
|
||||
headers.add(String.valueOf(o));
|
||||
}
|
||||
responseHeaders.put(key, headers);
|
||||
}
|
||||
throw new ApiException(
|
||||
response.getStatus(),
|
||||
message,
|
||||
responseHeaders,
|
||||
respBody);
|
||||
responseHeaders.put(entry.getKey(), headers);
|
||||
}
|
||||
return responseHeaders;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -0,0 +1,98 @@
|
||||
package {{package}};
|
||||
|
||||
import {{invokerPackage}}.ApiException;
|
||||
import {{invokerPackage}}.ApiClient;
|
||||
import {{invokerPackage}}.Configuration;
|
||||
import {{invokerPackage}}.Pair;
|
||||
import {{invokerPackage}}.TypeRef;
|
||||
|
||||
import {{modelPackage}}.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
{{#imports}}import {{import}};
|
||||
{{/imports}}
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
{{#operations}}
|
||||
public class {{classname}} {
|
||||
private ApiClient {{localVariablePrefix}}apiClient;
|
||||
|
||||
public {{classname}}() {
|
||||
this(Configuration.getDefaultApiClient());
|
||||
}
|
||||
|
||||
public {{classname}}(ApiClient apiClient) {
|
||||
this.{{localVariablePrefix}}apiClient = apiClient;
|
||||
}
|
||||
|
||||
public ApiClient getApiClient() {
|
||||
return {{localVariablePrefix}}apiClient;
|
||||
}
|
||||
|
||||
public void setApiClient(ApiClient apiClient) {
|
||||
this.{{localVariablePrefix}}apiClient = apiClient;
|
||||
}
|
||||
|
||||
{{#operation}}
|
||||
/**
|
||||
* {{summary}}
|
||||
* {{notes}}
|
||||
{{#allParams}} * @param {{paramName}} {{description}}
|
||||
{{/allParams}} * @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}
|
||||
*/
|
||||
public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{nickname}} ({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) throws ApiException {
|
||||
Object {{localVariablePrefix}}postBody = {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}};
|
||||
{{#allParams}}{{#required}}
|
||||
// verify the required parameter '{{paramName}}' is set
|
||||
if ({{paramName}} == null) {
|
||||
throw new ApiException(400, "Missing the required parameter '{{paramName}}' when calling {{nickname}}");
|
||||
}
|
||||
{{/required}}{{/allParams}}
|
||||
// create path and map variables
|
||||
String {{localVariablePrefix}}path = "{{{path}}}".replaceAll("\\{format\\}","json"){{#pathParams}}
|
||||
.replaceAll("\\{" + "{{baseName}}" + "\\}", {{localVariablePrefix}}apiClient.escapeString({{{paramName}}}.toString())){{/pathParams}};
|
||||
|
||||
// query params
|
||||
List<Pair> {{localVariablePrefix}}queryParams = new ArrayList<Pair>();
|
||||
Map<String, String> {{localVariablePrefix}}headerParams = new HashMap<String, String>();
|
||||
Map<String, Object> {{localVariablePrefix}}formParams = new HashMap<String, Object>();
|
||||
|
||||
{{#queryParams}}
|
||||
{{localVariablePrefix}}queryParams.addAll({{localVariablePrefix}}apiClient.parameterToPairs("{{#collectionFormat}}{{{collectionFormat}}}{{/collectionFormat}}", "{{baseName}}", {{paramName}}));
|
||||
{{/queryParams}}
|
||||
|
||||
{{#headerParams}}if ({{paramName}} != null)
|
||||
{{localVariablePrefix}}headerParams.put("{{baseName}}", {{localVariablePrefix}}apiClient.parameterToString({{paramName}}));
|
||||
{{/headerParams}}
|
||||
|
||||
{{#formParams}}if ({{paramName}} != null)
|
||||
{{localVariablePrefix}}formParams.put("{{baseName}}", {{paramName}});
|
||||
{{/formParams}}
|
||||
|
||||
final String[] {{localVariablePrefix}}accepts = {
|
||||
{{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}}
|
||||
};
|
||||
final String {{localVariablePrefix}}accept = {{localVariablePrefix}}apiClient.selectHeaderAccept({{localVariablePrefix}}accepts);
|
||||
|
||||
final String[] {{localVariablePrefix}}contentTypes = {
|
||||
{{#consumes}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/consumes}}
|
||||
};
|
||||
final String {{localVariablePrefix}}contentType = {{localVariablePrefix}}apiClient.selectHeaderContentType({{localVariablePrefix}}contentTypes);
|
||||
|
||||
String[] {{localVariablePrefix}}authNames = new String[] { {{#authMethods}}"{{name}}"{{#hasMore}}, {{/hasMore}}{{/authMethods}} };
|
||||
|
||||
{{#returnType}}
|
||||
TypeRef {{localVariablePrefix}}returnType = new TypeRef<{{{returnType}}}>() {};
|
||||
return {{localVariablePrefix}}apiClient.invokeAPI({{localVariablePrefix}}path, "{{httpMethod}}", {{localVariablePrefix}}queryParams, {{localVariablePrefix}}postBody, {{localVariablePrefix}}headerParams, {{localVariablePrefix}}formParams, {{localVariablePrefix}}accept, {{localVariablePrefix}}contentType, {{localVariablePrefix}}authNames, {{localVariablePrefix}}returnType);
|
||||
{{/returnType}}{{^returnType}}
|
||||
{{localVariablePrefix}}apiClient.invokeAPI({{localVariablePrefix}}path, "{{httpMethod}}", {{localVariablePrefix}}queryParams, {{localVariablePrefix}}postBody, {{localVariablePrefix}}headerParams, {{localVariablePrefix}}formParams, {{localVariablePrefix}}accept, {{localVariablePrefix}}contentType, {{localVariablePrefix}}authNames, null);
|
||||
{{/returnType}}
|
||||
}
|
||||
{{/operation}}
|
||||
}
|
||||
{{/operations}}
|
@ -2,6 +2,9 @@ package {{invokerPackage}};
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Callback for asynchronous API call.
|
||||
*
|
||||
@ -10,13 +13,19 @@ import java.io.IOException;
|
||||
public interface ApiCallback<T> {
|
||||
/**
|
||||
* This is called when the API call fails.
|
||||
*
|
||||
* @param e The exception causing the failure
|
||||
* @param statusCode Status code of the response if available, otherwise it would be 0
|
||||
* @param responseHeaders Headers of the response if available, otherwise it would be null
|
||||
*/
|
||||
void onFailure(ApiException e);
|
||||
void onFailure(ApiException e, int statusCode, Map<String, List<String>> responseHeaders);
|
||||
|
||||
/**
|
||||
* This is called when the API call succeeded.
|
||||
*
|
||||
* @param result The result deserialized from response
|
||||
* @param statusCode Status code of the response
|
||||
* @param responseHeaders Headers of the response
|
||||
*/
|
||||
void onSuccess(T result);
|
||||
void onSuccess(T result, int statusCode, Map<String, List<String>> responseHeaders);
|
||||
}
|
||||
|
@ -48,6 +48,9 @@ public class ApiClient {
|
||||
|
||||
private Map<String, Authentication> authentications;
|
||||
|
||||
private int statusCode;
|
||||
private Map<String, List<String>> responseHeaders;
|
||||
|
||||
private String dateFormat;
|
||||
private DateFormat dateFormatter;
|
||||
private int dateLength;
|
||||
@ -107,6 +110,24 @@ public class ApiClient {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the status code of the previous request.
|
||||
* NOTE: Status code of last async response is not recorded here, it is
|
||||
* passed to the callback methods instead.
|
||||
*/
|
||||
public int getStatusCode() {
|
||||
return statusCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the response headers of the previous request.
|
||||
* NOTE: Headers of last async response is not recorded here, it is passed
|
||||
* to callback methods instead.
|
||||
*/
|
||||
public Map<String, List<String>> getResponseHeaders() {
|
||||
return responseHeaders;
|
||||
}
|
||||
|
||||
public String getDateFormat() {
|
||||
return dateFormat;
|
||||
}
|
||||
@ -534,6 +555,8 @@ public class ApiClient {
|
||||
public <T> T execute(Call call, Type returnType) throws ApiException {
|
||||
try {
|
||||
Response response = call.execute();
|
||||
this.statusCode = response.code();
|
||||
this.responseHeaders = response.headers().toMultimap();
|
||||
return handleResponse(response, returnType);
|
||||
} catch (IOException e) {
|
||||
throw new ApiException(e);
|
||||
@ -557,7 +580,7 @@ public class ApiClient {
|
||||
call.enqueue(new Callback() {
|
||||
@Override
|
||||
public void onFailure(Request request, IOException e) {
|
||||
callback.onFailure(new ApiException(e));
|
||||
callback.onFailure(new ApiException(e), 0, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -566,10 +589,10 @@ public class ApiClient {
|
||||
try {
|
||||
result = (T) handleResponse(response, returnType);
|
||||
} catch (ApiException e) {
|
||||
callback.onFailure(e);
|
||||
callback.onFailure(e, response.code(), response.headers().toMultimap());
|
||||
return;
|
||||
}
|
||||
callback.onSuccess(result);
|
||||
callback.onSuccess(result, response.code(), response.headers().toMultimap());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ import java.net.URLEncoder;
|
||||
import java.io.IOException;
|
||||
import java.io.File;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.io.DataInputStream;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
@ -38,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-08-24T11:46:58.447+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-11T11:35:58.351+08:00")
|
||||
public class ApiClient {
|
||||
private Map<String, Client> hostMap = new HashMap<String, Client>();
|
||||
private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
|
||||
@ -48,6 +49,9 @@ public class ApiClient {
|
||||
|
||||
private Map<String, Authentication> authentications;
|
||||
|
||||
private int statusCode;
|
||||
private Map<String, List<String>> responseHeaders;
|
||||
|
||||
private DateFormat dateFormat;
|
||||
|
||||
public ApiClient() {
|
||||
@ -78,6 +82,20 @@ public class ApiClient {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the status code of the previous request
|
||||
*/
|
||||
public int getStatusCode() {
|
||||
return statusCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the response headers of the previous request
|
||||
*/
|
||||
public Map<String, List<String>> getResponseHeaders() {
|
||||
return responseHeaders;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get authentications (key: authentication name, value: authentication).
|
||||
*/
|
||||
@ -371,22 +389,12 @@ public class ApiClient {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke API by sending HTTP request with the given options.
|
||||
*
|
||||
* @param path The sub-path of the HTTP URL
|
||||
* @param method The request method, one of "GET", "POST", "PUT", and "DELETE"
|
||||
* @param queryParams The query parameters
|
||||
* @param body The request body object
|
||||
* @param headerParams The header parameters
|
||||
* @param formParams The form parameters
|
||||
* @param accept The request's Accept header
|
||||
* @param contentType The request's Content-Type header
|
||||
* @param authNames The authentications to apply
|
||||
* @param returnType The return type into which to deserialize the response
|
||||
* @return The response body in type of string
|
||||
*/
|
||||
public <T> T invokeAPI(String path, String method, List<Pair> queryParams, Object body, Map<String, String> headerParams, Map<String, Object> formParams, String accept, String contentType, String[] authNames, TypeRef returnType) throws ApiException {
|
||||
private ClientResponse getAPIResponse(String path, String method, List<Pair> queryParams, Object body, byte[] binaryBody, Map<String, String> headerParams, Map<String, Object> formParams, String accept, String contentType, String[] authNames) throws ApiException {
|
||||
|
||||
if (body != null && binaryBody != null){
|
||||
throw new ApiException(500, "either body or binaryBody must be null");
|
||||
}
|
||||
|
||||
updateParamsForAuth(authNames, queryParams, headerParams);
|
||||
|
||||
Client client = getClient();
|
||||
@ -446,7 +454,10 @@ public class ApiClient {
|
||||
if (encodedFormParams != null) {
|
||||
response = builder.type(contentType).post(ClientResponse.class, encodedFormParams);
|
||||
} else if (body == null) {
|
||||
if(binaryBody == null)
|
||||
response = builder.post(ClientResponse.class, null);
|
||||
else
|
||||
response = builder.type(contentType).post(ClientResponse.class, binaryBody);
|
||||
} else if (body instanceof FormDataMultiPart) {
|
||||
response = builder.type(contentType).post(ClientResponse.class, body);
|
||||
} else {
|
||||
@ -456,7 +467,10 @@ public class ApiClient {
|
||||
if (encodedFormParams != null) {
|
||||
response = builder.type(contentType).put(ClientResponse.class, encodedFormParams);
|
||||
} else if(body == null) {
|
||||
response = builder.put(ClientResponse.class, serialize(body, contentType));
|
||||
if(binaryBody == null)
|
||||
response = builder.put(ClientResponse.class, null);
|
||||
else
|
||||
response = builder.type(contentType).put(ClientResponse.class, binaryBody);
|
||||
} else {
|
||||
response = builder.type(contentType).put(ClientResponse.class, serialize(body, contentType));
|
||||
}
|
||||
@ -464,13 +478,40 @@ public class ApiClient {
|
||||
if (encodedFormParams != null) {
|
||||
response = builder.type(contentType).delete(ClientResponse.class, encodedFormParams);
|
||||
} else if(body == null) {
|
||||
if(binaryBody == null)
|
||||
response = builder.delete(ClientResponse.class);
|
||||
else
|
||||
response = builder.type(contentType).delete(ClientResponse.class, binaryBody);
|
||||
} else {
|
||||
response = builder.type(contentType).delete(ClientResponse.class, serialize(body, contentType));
|
||||
}
|
||||
} else {
|
||||
throw new ApiException(500, "unknown method type " + method);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke API by sending HTTP request with the given options.
|
||||
*
|
||||
* @param path The sub-path of the HTTP URL
|
||||
* @param method The request method, one of "GET", "POST", "PUT", and "DELETE"
|
||||
* @param queryParams The query parameters
|
||||
* @param body The request body object - if it is not binary, otherwise null
|
||||
* @param binaryBody The request body object - if it is binary, otherwise null
|
||||
* @param headerParams The header parameters
|
||||
* @param formParams The form parameters
|
||||
* @param accept The request's Accept header
|
||||
* @param contentType The request's Content-Type header
|
||||
* @param authNames The authentications to apply
|
||||
* @return The response body in type of string
|
||||
*/
|
||||
public <T> T invokeAPI(String path, String method, List<Pair> queryParams, Object body, byte[] binaryBody, Map<String, String> headerParams, Map<String, Object> formParams, String accept, String contentType, String[] authNames, TypeRef returnType) throws ApiException {
|
||||
|
||||
ClientResponse response = getAPIResponse(path, method, queryParams, body, binaryBody, headerParams, formParams, accept, contentType, authNames);
|
||||
|
||||
statusCode = response.getStatusInfo().getStatusCode();
|
||||
responseHeaders = response.getHeaders();
|
||||
|
||||
if(response.getStatusInfo() == ClientResponse.Status.NO_CONTENT) {
|
||||
return null;
|
||||
@ -497,6 +538,58 @@ public class ApiClient {
|
||||
respBody);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Invoke API by sending HTTP request with the given options - return binary result
|
||||
*
|
||||
* @param path The sub-path of the HTTP URL
|
||||
* @param method The request method, one of "GET", "POST", "PUT", and "DELETE"
|
||||
* @param queryParams The query parameters
|
||||
* @param body The request body object - if it is not binary, otherwise null
|
||||
* @param binaryBody The request body object - if it is binary, otherwise null
|
||||
* @param headerParams The header parameters
|
||||
* @param formParams The form parameters
|
||||
* @param accept The request's Accept header
|
||||
* @param contentType The request's Content-Type header
|
||||
* @param authNames The authentications to apply
|
||||
* @return The response body in type of string
|
||||
*/
|
||||
public byte[] invokeBinaryAPI(String path, String method, List<Pair> queryParams, Object body, byte[] binaryBody, Map<String, String> headerParams, Map<String, Object> formParams, String accept, String contentType, String[]authNames) throws ApiException {
|
||||
|
||||
ClientResponse response = getAPIResponse(path, method, queryParams, body, binaryBody, headerParams, formParams, accept, contentType, authNames);
|
||||
|
||||
if(response.getStatusInfo() == ClientResponse.Status.NO_CONTENT) {
|
||||
return null;
|
||||
}
|
||||
else if(response.getStatusInfo().getFamily() == Family.SUCCESSFUL) {
|
||||
if(response.hasEntity()) {
|
||||
DataInputStream stream = new DataInputStream(response.getEntityInputStream());
|
||||
byte[] data = new byte[response.getLength()];
|
||||
try {
|
||||
stream.readFully(data);
|
||||
} catch (IOException ex) {
|
||||
throw new ApiException(500, "Error obtaining binary response data");
|
||||
}
|
||||
return data;
|
||||
}
|
||||
else {
|
||||
return new byte[0];
|
||||
}
|
||||
}
|
||||
else {
|
||||
String message = "error";
|
||||
if(response.hasEntity()) {
|
||||
try{
|
||||
message = String.valueOf(response.getEntity(String.class));
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
// e.printStackTrace();
|
||||
}
|
||||
}
|
||||
throw new ApiException(
|
||||
response.getStatusInfo().getStatusCode(),
|
||||
message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update query and header parameters based on authentication settings.
|
||||
|
@ -3,23 +3,48 @@ package io.swagger.client;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-24T11:46:58.447+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-11T11:35:58.351+08:00")
|
||||
public class ApiException extends Exception {
|
||||
private int code = 0;
|
||||
private String message = null;
|
||||
private Map<String, List<String>> responseHeaders = null;
|
||||
private String responseBody = null;
|
||||
|
||||
public ApiException() {}
|
||||
|
||||
public ApiException(int code, String message) {
|
||||
public ApiException(Throwable throwable) {
|
||||
super(throwable);
|
||||
}
|
||||
|
||||
public ApiException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public ApiException(String message, Throwable throwable, int code, Map<String, List<String>> responseHeaders, String responseBody) {
|
||||
super(message, throwable);
|
||||
this.code = code;
|
||||
this.responseHeaders = responseHeaders;
|
||||
this.responseBody = responseBody;
|
||||
}
|
||||
|
||||
public ApiException(String message, int code, Map<String, List<String>> responseHeaders, String responseBody) {
|
||||
this(message, (Throwable) null, code, responseHeaders, responseBody);
|
||||
}
|
||||
|
||||
public ApiException(String message, Throwable throwable, int code, Map<String, List<String>> responseHeaders) {
|
||||
this(message, throwable, code, responseHeaders, null);
|
||||
}
|
||||
|
||||
public ApiException(int code, Map<String, List<String>> responseHeaders, String responseBody) {
|
||||
this((String) null, (Throwable) null, code, responseHeaders, responseBody);
|
||||
}
|
||||
|
||||
public ApiException(int code, String message) {
|
||||
super(message);
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public ApiException(int code, String message, Map<String, List<String>> responseHeaders, String responseBody) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
this(code, message);
|
||||
this.responseHeaders = responseHeaders;
|
||||
this.responseBody = responseBody;
|
||||
}
|
||||
@ -28,10 +53,6 @@ public class ApiException extends Exception {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the HTTP response headers.
|
||||
*/
|
||||
|
@ -1,6 +1,6 @@
|
||||
package io.swagger.client;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-24T11:46:58.447+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-11T11:35:58.351+08:00")
|
||||
public class Configuration {
|
||||
private static ApiClient defaultApiClient = new ApiClient();
|
||||
|
||||
|
@ -6,7 +6,7 @@ import com.fasterxml.jackson.datatype.joda.*;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-24T18:19:30.060+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-11T11:35:58.351+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-08-24T11:46:58.447+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-11T11:35:58.351+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-08-24T11:46:58.447+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-11T11:35:58.351+08:00")
|
||||
public class StringUtil {
|
||||
/**
|
||||
* Check if the given array contains the given value (with case-insensitive comparison).
|
||||
@ -39,4 +39,13 @@ public class StringUtil {
|
||||
}
|
||||
return out.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces
|
||||
* (except the first line).
|
||||
*/
|
||||
public static String toIndentedString(Object o) {
|
||||
if (o == null) return "null";
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
||||
|
@ -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-08-24T11:46:58.447+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-11T11:35:58.351+08:00")
|
||||
public class TypeRef<T> {
|
||||
private final Type type;
|
||||
|
||||
|
@ -17,7 +17,7 @@ import java.io.File;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-24T11:46:58.447+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-11T11:35:58.351+08:00")
|
||||
public class PetApi {
|
||||
private ApiClient apiClient;
|
||||
|
||||
@ -46,7 +46,7 @@ public class PetApi {
|
||||
*/
|
||||
public void updatePet (Pet body) throws ApiException {
|
||||
Object postBody = body;
|
||||
|
||||
byte[] postBinaryBody = null;
|
||||
|
||||
// create path and map variables
|
||||
String path = "/pet".replaceAll("\\{format\\}","json");
|
||||
@ -74,7 +74,14 @@ public class PetApi {
|
||||
|
||||
String[] authNames = new String[] { "petstore_auth" };
|
||||
|
||||
apiClient.invokeAPI(path, "PUT", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null);
|
||||
|
||||
|
||||
|
||||
|
||||
apiClient.invokeAPI(path, "PUT", queryParams, postBody, postBinaryBody, headerParams, formParams, accept, contentType, authNames, null);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -86,7 +93,7 @@ public class PetApi {
|
||||
*/
|
||||
public void addPet (Pet body) throws ApiException {
|
||||
Object postBody = body;
|
||||
|
||||
byte[] postBinaryBody = null;
|
||||
|
||||
// create path and map variables
|
||||
String path = "/pet".replaceAll("\\{format\\}","json");
|
||||
@ -114,7 +121,14 @@ public class PetApi {
|
||||
|
||||
String[] authNames = new String[] { "petstore_auth" };
|
||||
|
||||
apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null);
|
||||
|
||||
|
||||
|
||||
|
||||
apiClient.invokeAPI(path, "POST", queryParams, postBody, postBinaryBody, headerParams, formParams, accept, contentType, authNames, null);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -126,7 +140,7 @@ public class PetApi {
|
||||
*/
|
||||
public List<Pet> findPetsByStatus (List<String> status) throws ApiException {
|
||||
Object postBody = null;
|
||||
|
||||
byte[] postBinaryBody = null;
|
||||
|
||||
// create path and map variables
|
||||
String path = "/pet/findByStatus".replaceAll("\\{format\\}","json");
|
||||
@ -156,8 +170,15 @@ public class PetApi {
|
||||
|
||||
String[] authNames = new String[] { "petstore_auth" };
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
TypeRef returnType = new TypeRef<List<Pet>>() {};
|
||||
return apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
|
||||
return apiClient.invokeAPI(path, "GET", queryParams, postBody, postBinaryBody, headerParams, formParams, accept, contentType, authNames, returnType);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -169,7 +190,7 @@ public class PetApi {
|
||||
*/
|
||||
public List<Pet> findPetsByTags (List<String> tags) throws ApiException {
|
||||
Object postBody = null;
|
||||
|
||||
byte[] postBinaryBody = null;
|
||||
|
||||
// create path and map variables
|
||||
String path = "/pet/findByTags".replaceAll("\\{format\\}","json");
|
||||
@ -199,8 +220,15 @@ public class PetApi {
|
||||
|
||||
String[] authNames = new String[] { "petstore_auth" };
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
TypeRef returnType = new TypeRef<List<Pet>>() {};
|
||||
return apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
|
||||
return apiClient.invokeAPI(path, "GET", queryParams, postBody, postBinaryBody, headerParams, formParams, accept, contentType, authNames, returnType);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -212,13 +240,13 @@ public class PetApi {
|
||||
*/
|
||||
public Pet getPetById (Long petId) throws ApiException {
|
||||
Object postBody = null;
|
||||
byte[] postBinaryBody = null;
|
||||
|
||||
// verify the required parameter 'petId' is set
|
||||
if (petId == null) {
|
||||
throw new ApiException(400, "Missing the required parameter 'petId' when calling getPetById");
|
||||
}
|
||||
|
||||
|
||||
// create path and map variables
|
||||
String path = "/pet/{petId}".replaceAll("\\{format\\}","json")
|
||||
.replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString()));
|
||||
@ -244,10 +272,17 @@ public class PetApi {
|
||||
};
|
||||
final String contentType = apiClient.selectHeaderContentType(contentTypes);
|
||||
|
||||
String[] authNames = new String[] { "api_key", "petstore_auth" };
|
||||
String[] authNames = new String[] { "petstore_auth", "api_key" };
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
TypeRef returnType = new TypeRef<Pet>() {};
|
||||
return apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
|
||||
return apiClient.invokeAPI(path, "GET", queryParams, postBody, postBinaryBody, headerParams, formParams, accept, contentType, authNames, returnType);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -261,13 +296,13 @@ public class PetApi {
|
||||
*/
|
||||
public void updatePetWithForm (String petId, String name, String status) throws ApiException {
|
||||
Object postBody = null;
|
||||
byte[] postBinaryBody = null;
|
||||
|
||||
// verify the required parameter 'petId' is set
|
||||
if (petId == null) {
|
||||
throw new ApiException(400, "Missing the required parameter 'petId' when calling updatePetWithForm");
|
||||
}
|
||||
|
||||
|
||||
// create path and map variables
|
||||
String path = "/pet/{petId}".replaceAll("\\{format\\}","json")
|
||||
.replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString()));
|
||||
@ -299,7 +334,14 @@ public class PetApi {
|
||||
|
||||
String[] authNames = new String[] { "petstore_auth" };
|
||||
|
||||
apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null);
|
||||
|
||||
|
||||
|
||||
|
||||
apiClient.invokeAPI(path, "POST", queryParams, postBody, postBinaryBody, headerParams, formParams, accept, contentType, authNames, null);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -312,13 +354,13 @@ public class PetApi {
|
||||
*/
|
||||
public void deletePet (Long petId, String apiKey) throws ApiException {
|
||||
Object postBody = null;
|
||||
byte[] postBinaryBody = null;
|
||||
|
||||
// verify the required parameter 'petId' is set
|
||||
if (petId == null) {
|
||||
throw new ApiException(400, "Missing the required parameter 'petId' when calling deletePet");
|
||||
}
|
||||
|
||||
|
||||
// create path and map variables
|
||||
String path = "/pet/{petId}".replaceAll("\\{format\\}","json")
|
||||
.replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString()));
|
||||
@ -348,7 +390,14 @@ public class PetApi {
|
||||
|
||||
String[] authNames = new String[] { "petstore_auth" };
|
||||
|
||||
apiClient.invokeAPI(path, "DELETE", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null);
|
||||
|
||||
|
||||
|
||||
|
||||
apiClient.invokeAPI(path, "DELETE", queryParams, postBody, postBinaryBody, headerParams, formParams, accept, contentType, authNames, null);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -362,13 +411,13 @@ public class PetApi {
|
||||
*/
|
||||
public void uploadFile (Long petId, String additionalMetadata, File file) throws ApiException {
|
||||
Object postBody = null;
|
||||
byte[] postBinaryBody = null;
|
||||
|
||||
// verify the required parameter 'petId' is set
|
||||
if (petId == null) {
|
||||
throw new ApiException(400, "Missing the required parameter 'petId' when calling uploadFile");
|
||||
}
|
||||
|
||||
|
||||
// create path and map variables
|
||||
String path = "/pet/{petId}/uploadImage".replaceAll("\\{format\\}","json")
|
||||
.replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString()));
|
||||
@ -400,7 +449,14 @@ public class PetApi {
|
||||
|
||||
String[] authNames = new String[] { "petstore_auth" };
|
||||
|
||||
apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null);
|
||||
|
||||
|
||||
|
||||
|
||||
apiClient.invokeAPI(path, "POST", queryParams, postBody, postBinaryBody, headerParams, formParams, accept, contentType, authNames, null);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ import java.io.File;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-24T11:46:58.447+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-11T11:35:58.351+08:00")
|
||||
public class StoreApi {
|
||||
private ApiClient apiClient;
|
||||
|
||||
@ -45,7 +45,7 @@ public class StoreApi {
|
||||
*/
|
||||
public Map<String, Integer> getInventory () throws ApiException {
|
||||
Object postBody = null;
|
||||
|
||||
byte[] postBinaryBody = null;
|
||||
|
||||
// create path and map variables
|
||||
String path = "/store/inventory".replaceAll("\\{format\\}","json");
|
||||
@ -73,8 +73,15 @@ public class StoreApi {
|
||||
|
||||
String[] authNames = new String[] { "api_key" };
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
TypeRef returnType = new TypeRef<Map<String, Integer>>() {};
|
||||
return apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
|
||||
return apiClient.invokeAPI(path, "GET", queryParams, postBody, postBinaryBody, headerParams, formParams, accept, contentType, authNames, returnType);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -86,7 +93,7 @@ public class StoreApi {
|
||||
*/
|
||||
public Order placeOrder (Order body) throws ApiException {
|
||||
Object postBody = body;
|
||||
|
||||
byte[] postBinaryBody = null;
|
||||
|
||||
// create path and map variables
|
||||
String path = "/store/order".replaceAll("\\{format\\}","json");
|
||||
@ -114,8 +121,15 @@ public class StoreApi {
|
||||
|
||||
String[] authNames = new String[] { };
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
TypeRef returnType = new TypeRef<Order>() {};
|
||||
return apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
|
||||
return apiClient.invokeAPI(path, "POST", queryParams, postBody, postBinaryBody, headerParams, formParams, accept, contentType, authNames, returnType);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -127,13 +141,13 @@ public class StoreApi {
|
||||
*/
|
||||
public Order getOrderById (String orderId) throws ApiException {
|
||||
Object postBody = null;
|
||||
byte[] postBinaryBody = null;
|
||||
|
||||
// verify the required parameter 'orderId' is set
|
||||
if (orderId == null) {
|
||||
throw new ApiException(400, "Missing the required parameter 'orderId' when calling getOrderById");
|
||||
}
|
||||
|
||||
|
||||
// create path and map variables
|
||||
String path = "/store/order/{orderId}".replaceAll("\\{format\\}","json")
|
||||
.replaceAll("\\{" + "orderId" + "\\}", apiClient.escapeString(orderId.toString()));
|
||||
@ -161,8 +175,15 @@ public class StoreApi {
|
||||
|
||||
String[] authNames = new String[] { };
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
TypeRef returnType = new TypeRef<Order>() {};
|
||||
return apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
|
||||
return apiClient.invokeAPI(path, "GET", queryParams, postBody, postBinaryBody, headerParams, formParams, accept, contentType, authNames, returnType);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -174,13 +195,13 @@ public class StoreApi {
|
||||
*/
|
||||
public void deleteOrder (String orderId) throws ApiException {
|
||||
Object postBody = null;
|
||||
byte[] postBinaryBody = null;
|
||||
|
||||
// verify the required parameter 'orderId' is set
|
||||
if (orderId == null) {
|
||||
throw new ApiException(400, "Missing the required parameter 'orderId' when calling deleteOrder");
|
||||
}
|
||||
|
||||
|
||||
// create path and map variables
|
||||
String path = "/store/order/{orderId}".replaceAll("\\{format\\}","json")
|
||||
.replaceAll("\\{" + "orderId" + "\\}", apiClient.escapeString(orderId.toString()));
|
||||
@ -208,7 +229,14 @@ public class StoreApi {
|
||||
|
||||
String[] authNames = new String[] { };
|
||||
|
||||
apiClient.invokeAPI(path, "DELETE", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null);
|
||||
|
||||
|
||||
|
||||
|
||||
apiClient.invokeAPI(path, "DELETE", queryParams, postBody, postBinaryBody, headerParams, formParams, accept, contentType, authNames, null);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ import java.io.File;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-24T11:46:58.447+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-11T11:35:58.351+08:00")
|
||||
public class UserApi {
|
||||
private ApiClient apiClient;
|
||||
|
||||
@ -46,7 +46,7 @@ public class UserApi {
|
||||
*/
|
||||
public void createUser (User body) throws ApiException {
|
||||
Object postBody = body;
|
||||
|
||||
byte[] postBinaryBody = null;
|
||||
|
||||
// create path and map variables
|
||||
String path = "/user".replaceAll("\\{format\\}","json");
|
||||
@ -74,7 +74,14 @@ public class UserApi {
|
||||
|
||||
String[] authNames = new String[] { };
|
||||
|
||||
apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null);
|
||||
|
||||
|
||||
|
||||
|
||||
apiClient.invokeAPI(path, "POST", queryParams, postBody, postBinaryBody, headerParams, formParams, accept, contentType, authNames, null);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -86,7 +93,7 @@ public class UserApi {
|
||||
*/
|
||||
public void createUsersWithArrayInput (List<User> body) throws ApiException {
|
||||
Object postBody = body;
|
||||
|
||||
byte[] postBinaryBody = null;
|
||||
|
||||
// create path and map variables
|
||||
String path = "/user/createWithArray".replaceAll("\\{format\\}","json");
|
||||
@ -114,7 +121,14 @@ public class UserApi {
|
||||
|
||||
String[] authNames = new String[] { };
|
||||
|
||||
apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null);
|
||||
|
||||
|
||||
|
||||
|
||||
apiClient.invokeAPI(path, "POST", queryParams, postBody, postBinaryBody, headerParams, formParams, accept, contentType, authNames, null);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -126,7 +140,7 @@ public class UserApi {
|
||||
*/
|
||||
public void createUsersWithListInput (List<User> body) throws ApiException {
|
||||
Object postBody = body;
|
||||
|
||||
byte[] postBinaryBody = null;
|
||||
|
||||
// create path and map variables
|
||||
String path = "/user/createWithList".replaceAll("\\{format\\}","json");
|
||||
@ -154,7 +168,14 @@ public class UserApi {
|
||||
|
||||
String[] authNames = new String[] { };
|
||||
|
||||
apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null);
|
||||
|
||||
|
||||
|
||||
|
||||
apiClient.invokeAPI(path, "POST", queryParams, postBody, postBinaryBody, headerParams, formParams, accept, contentType, authNames, null);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -167,7 +188,7 @@ public class UserApi {
|
||||
*/
|
||||
public String loginUser (String username, String password) throws ApiException {
|
||||
Object postBody = null;
|
||||
|
||||
byte[] postBinaryBody = null;
|
||||
|
||||
// create path and map variables
|
||||
String path = "/user/login".replaceAll("\\{format\\}","json");
|
||||
@ -199,8 +220,15 @@ public class UserApi {
|
||||
|
||||
String[] authNames = new String[] { };
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
TypeRef returnType = new TypeRef<String>() {};
|
||||
return apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
|
||||
return apiClient.invokeAPI(path, "GET", queryParams, postBody, postBinaryBody, headerParams, formParams, accept, contentType, authNames, returnType);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -211,7 +239,7 @@ public class UserApi {
|
||||
*/
|
||||
public void logoutUser () throws ApiException {
|
||||
Object postBody = null;
|
||||
|
||||
byte[] postBinaryBody = null;
|
||||
|
||||
// create path and map variables
|
||||
String path = "/user/logout".replaceAll("\\{format\\}","json");
|
||||
@ -239,7 +267,14 @@ public class UserApi {
|
||||
|
||||
String[] authNames = new String[] { };
|
||||
|
||||
apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null);
|
||||
|
||||
|
||||
|
||||
|
||||
apiClient.invokeAPI(path, "GET", queryParams, postBody, postBinaryBody, headerParams, formParams, accept, contentType, authNames, null);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -251,13 +286,13 @@ public class UserApi {
|
||||
*/
|
||||
public User getUserByName (String username) throws ApiException {
|
||||
Object postBody = null;
|
||||
byte[] postBinaryBody = null;
|
||||
|
||||
// verify the required parameter 'username' is set
|
||||
if (username == null) {
|
||||
throw new ApiException(400, "Missing the required parameter 'username' when calling getUserByName");
|
||||
}
|
||||
|
||||
|
||||
// create path and map variables
|
||||
String path = "/user/{username}".replaceAll("\\{format\\}","json")
|
||||
.replaceAll("\\{" + "username" + "\\}", apiClient.escapeString(username.toString()));
|
||||
@ -285,8 +320,15 @@ public class UserApi {
|
||||
|
||||
String[] authNames = new String[] { };
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
TypeRef returnType = new TypeRef<User>() {};
|
||||
return apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
|
||||
return apiClient.invokeAPI(path, "GET", queryParams, postBody, postBinaryBody, headerParams, formParams, accept, contentType, authNames, returnType);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -299,13 +341,13 @@ public class UserApi {
|
||||
*/
|
||||
public void updateUser (String username, User body) throws ApiException {
|
||||
Object postBody = body;
|
||||
byte[] postBinaryBody = null;
|
||||
|
||||
// verify the required parameter 'username' is set
|
||||
if (username == null) {
|
||||
throw new ApiException(400, "Missing the required parameter 'username' when calling updateUser");
|
||||
}
|
||||
|
||||
|
||||
// create path and map variables
|
||||
String path = "/user/{username}".replaceAll("\\{format\\}","json")
|
||||
.replaceAll("\\{" + "username" + "\\}", apiClient.escapeString(username.toString()));
|
||||
@ -333,7 +375,14 @@ public class UserApi {
|
||||
|
||||
String[] authNames = new String[] { };
|
||||
|
||||
apiClient.invokeAPI(path, "PUT", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null);
|
||||
|
||||
|
||||
|
||||
|
||||
apiClient.invokeAPI(path, "PUT", queryParams, postBody, postBinaryBody, headerParams, formParams, accept, contentType, authNames, null);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -345,13 +394,13 @@ public class UserApi {
|
||||
*/
|
||||
public void deleteUser (String username) throws ApiException {
|
||||
Object postBody = null;
|
||||
byte[] postBinaryBody = null;
|
||||
|
||||
// verify the required parameter 'username' is set
|
||||
if (username == null) {
|
||||
throw new ApiException(400, "Missing the required parameter 'username' when calling deleteUser");
|
||||
}
|
||||
|
||||
|
||||
// create path and map variables
|
||||
String path = "/user/{username}".replaceAll("\\{format\\}","json")
|
||||
.replaceAll("\\{" + "username" + "\\}", apiClient.escapeString(username.toString()));
|
||||
@ -379,7 +428,14 @@ public class UserApi {
|
||||
|
||||
String[] authNames = new String[] { };
|
||||
|
||||
apiClient.invokeAPI(path, "DELETE", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null);
|
||||
|
||||
|
||||
|
||||
|
||||
apiClient.invokeAPI(path, "DELETE", queryParams, postBody, postBinaryBody, headerParams, formParams, accept, contentType, authNames, null);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -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-08-24T11:46:58.447+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-11T11:35:58.351+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-08-24T11:46:58.447+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-11T11:35:58.351+08:00")
|
||||
public interface Authentication {
|
||||
/** Apply authentication settings to header and query params. */
|
||||
void applyToParams(List<Pair> queryParams, Map<String, String> headerParams);
|
||||
|
@ -8,7 +8,7 @@ import java.util.List;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import javax.xml.bind.DatatypeConverter;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-24T11:46:58.447+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-11T11:35:58.351+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-08-24T11:46:58.447+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-11T11:35:58.351+08:00")
|
||||
public class OAuth implements Authentication {
|
||||
@Override
|
||||
public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams) {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package io.swagger.client.model;
|
||||
|
||||
import io.swagger.client.StringUtil;
|
||||
|
||||
|
||||
|
||||
@ -8,7 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
|
||||
@ApiModel(description = "")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-24T11:46:58.447+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-11T11:35:58.351+08:00")
|
||||
public class Category {
|
||||
|
||||
private Long id = null;
|
||||
@ -45,9 +46,9 @@ public class Category {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class Category {\n");
|
||||
|
||||
sb.append(" id: ").append(id).append("\n");
|
||||
sb.append(" name: ").append(name).append("\n");
|
||||
sb.append("}\n");
|
||||
sb.append(" id: ").append(StringUtil.toIndentedString(id)).append("\n");
|
||||
sb.append(" name: ").append(StringUtil.toIndentedString(name)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package io.swagger.client.model;
|
||||
|
||||
import io.swagger.client.StringUtil;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@ -9,7 +10,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
|
||||
@ApiModel(description = "")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-24T18:19:30.060+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-11T11:35:58.351+08:00")
|
||||
public class Order {
|
||||
|
||||
private Long id = null;
|
||||
@ -115,13 +116,13 @@ public enum StatusEnum {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class Order {\n");
|
||||
|
||||
sb.append(" id: ").append(id).append("\n");
|
||||
sb.append(" petId: ").append(petId).append("\n");
|
||||
sb.append(" quantity: ").append(quantity).append("\n");
|
||||
sb.append(" shipDate: ").append(shipDate).append("\n");
|
||||
sb.append(" status: ").append(status).append("\n");
|
||||
sb.append(" complete: ").append(complete).append("\n");
|
||||
sb.append("}\n");
|
||||
sb.append(" id: ").append(StringUtil.toIndentedString(id)).append("\n");
|
||||
sb.append(" petId: ").append(StringUtil.toIndentedString(petId)).append("\n");
|
||||
sb.append(" quantity: ").append(StringUtil.toIndentedString(quantity)).append("\n");
|
||||
sb.append(" shipDate: ").append(StringUtil.toIndentedString(shipDate)).append("\n");
|
||||
sb.append(" status: ").append(StringUtil.toIndentedString(status)).append("\n");
|
||||
sb.append(" complete: ").append(StringUtil.toIndentedString(complete)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
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;
|
||||
@ -11,7 +12,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
|
||||
@ApiModel(description = "")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-24T18:19:30.060+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-11T11:35:58.351+08:00")
|
||||
public class Pet {
|
||||
|
||||
private Long id = null;
|
||||
@ -117,13 +118,13 @@ public enum StatusEnum {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class Pet {\n");
|
||||
|
||||
sb.append(" id: ").append(id).append("\n");
|
||||
sb.append(" category: ").append(category).append("\n");
|
||||
sb.append(" name: ").append(name).append("\n");
|
||||
sb.append(" photoUrls: ").append(photoUrls).append("\n");
|
||||
sb.append(" tags: ").append(tags).append("\n");
|
||||
sb.append(" status: ").append(status).append("\n");
|
||||
sb.append("}\n");
|
||||
sb.append(" id: ").append(StringUtil.toIndentedString(id)).append("\n");
|
||||
sb.append(" category: ").append(StringUtil.toIndentedString(category)).append("\n");
|
||||
sb.append(" name: ").append(StringUtil.toIndentedString(name)).append("\n");
|
||||
sb.append(" photoUrls: ").append(StringUtil.toIndentedString(photoUrls)).append("\n");
|
||||
sb.append(" tags: ").append(StringUtil.toIndentedString(tags)).append("\n");
|
||||
sb.append(" status: ").append(StringUtil.toIndentedString(status)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package io.swagger.client.model;
|
||||
|
||||
import io.swagger.client.StringUtil;
|
||||
|
||||
|
||||
|
||||
@ -8,7 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
|
||||
@ApiModel(description = "")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-24T11:46:58.447+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-11T11:35:58.351+08:00")
|
||||
public class Tag {
|
||||
|
||||
private Long id = null;
|
||||
@ -45,9 +46,9 @@ public class Tag {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class Tag {\n");
|
||||
|
||||
sb.append(" id: ").append(id).append("\n");
|
||||
sb.append(" name: ").append(name).append("\n");
|
||||
sb.append("}\n");
|
||||
sb.append(" id: ").append(StringUtil.toIndentedString(id)).append("\n");
|
||||
sb.append(" name: ").append(StringUtil.toIndentedString(name)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package io.swagger.client.model;
|
||||
|
||||
import io.swagger.client.StringUtil;
|
||||
|
||||
|
||||
|
||||
@ -8,7 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
|
||||
@ApiModel(description = "")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-24T11:46:58.447+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-11T11:35:58.351+08:00")
|
||||
public class User {
|
||||
|
||||
private Long id = null;
|
||||
@ -124,15 +125,15 @@ public class User {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class User {\n");
|
||||
|
||||
sb.append(" id: ").append(id).append("\n");
|
||||
sb.append(" username: ").append(username).append("\n");
|
||||
sb.append(" firstName: ").append(firstName).append("\n");
|
||||
sb.append(" lastName: ").append(lastName).append("\n");
|
||||
sb.append(" email: ").append(email).append("\n");
|
||||
sb.append(" password: ").append(password).append("\n");
|
||||
sb.append(" phone: ").append(phone).append("\n");
|
||||
sb.append(" userStatus: ").append(userStatus).append("\n");
|
||||
sb.append("}\n");
|
||||
sb.append(" id: ").append(StringUtil.toIndentedString(id)).append("\n");
|
||||
sb.append(" username: ").append(StringUtil.toIndentedString(username)).append("\n");
|
||||
sb.append(" firstName: ").append(StringUtil.toIndentedString(firstName)).append("\n");
|
||||
sb.append(" lastName: ").append(StringUtil.toIndentedString(lastName)).append("\n");
|
||||
sb.append(" email: ").append(StringUtil.toIndentedString(email)).append("\n");
|
||||
sb.append(" password: ").append(StringUtil.toIndentedString(password)).append("\n");
|
||||
sb.append(" phone: ").append(StringUtil.toIndentedString(phone)).append("\n");
|
||||
sb.append(" userStatus: ").append(StringUtil.toIndentedString(userStatus)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
1
samples/client/petstore/java/jersey2/hello.txt
Normal file
1
samples/client/petstore/java/jersey2/hello.txt
Normal file
@ -0,0 +1 @@
|
||||
Hello world!
|
@ -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-08-22T21:47:05.989+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-11T11:35:51.678+08:00")
|
||||
public class ApiClient {
|
||||
private Map<String, Client> hostMap = new HashMap<String, Client>();
|
||||
private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
|
||||
@ -53,6 +53,9 @@ public class ApiClient {
|
||||
|
||||
private Map<String, Authentication> authentications;
|
||||
|
||||
private int statusCode;
|
||||
private Map<String, List<String>> responseHeaders;
|
||||
|
||||
private DateFormat dateFormat;
|
||||
|
||||
public ApiClient() {
|
||||
@ -83,6 +86,20 @@ public class ApiClient {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the status code of the previous request
|
||||
*/
|
||||
public int getStatusCode() {
|
||||
return statusCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the response headers of the previous request
|
||||
*/
|
||||
public Map<String, List<String>> getResponseHeaders() {
|
||||
return responseHeaders;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get authentications (key: authentication name, value: authentication).
|
||||
*/
|
||||
@ -483,6 +500,9 @@ public class ApiClient {
|
||||
throw new ApiException(500, "unknown method type " + method);
|
||||
}
|
||||
|
||||
statusCode = response.getStatusInfo().getStatusCode();
|
||||
responseHeaders = buildResponseHeaders(response);
|
||||
|
||||
if (response.getStatus() == Status.NO_CONTENT.getStatusCode()) {
|
||||
return null;
|
||||
} else if (response.getStatusInfo().getFamily().equals(Status.Family.SUCCESSFUL)) {
|
||||
@ -501,21 +521,25 @@ public class ApiClient {
|
||||
// e.printStackTrace();
|
||||
}
|
||||
}
|
||||
throw new ApiException(
|
||||
response.getStatus(),
|
||||
message,
|
||||
buildResponseHeaders(response),
|
||||
respBody);
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, List<String>> buildResponseHeaders(Response response) {
|
||||
Map<String, List<String>> responseHeaders = new HashMap<String, List<String>>();
|
||||
for (String key: response.getHeaders().keySet()) {
|
||||
List<Object> values = response.getHeaders().get(key);
|
||||
for (Entry<String, List<Object>> entry: response.getHeaders().entrySet()) {
|
||||
List<Object> values = entry.getValue();
|
||||
List<String> headers = new ArrayList<String>();
|
||||
for (Object o : values) {
|
||||
headers.add(String.valueOf(o));
|
||||
}
|
||||
responseHeaders.put(key, headers);
|
||||
}
|
||||
throw new ApiException(
|
||||
response.getStatus(),
|
||||
message,
|
||||
responseHeaders,
|
||||
respBody);
|
||||
responseHeaders.put(entry.getKey(), headers);
|
||||
}
|
||||
return responseHeaders;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3,23 +3,48 @@ package io.swagger.client;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:05.989+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-11T11:35:51.678+08:00")
|
||||
public class ApiException extends Exception {
|
||||
private int code = 0;
|
||||
private String message = null;
|
||||
private Map<String, List<String>> responseHeaders = null;
|
||||
private String responseBody = null;
|
||||
|
||||
public ApiException() {}
|
||||
|
||||
public ApiException(int code, String message) {
|
||||
public ApiException(Throwable throwable) {
|
||||
super(throwable);
|
||||
}
|
||||
|
||||
public ApiException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public ApiException(String message, Throwable throwable, int code, Map<String, List<String>> responseHeaders, String responseBody) {
|
||||
super(message, throwable);
|
||||
this.code = code;
|
||||
this.responseHeaders = responseHeaders;
|
||||
this.responseBody = responseBody;
|
||||
}
|
||||
|
||||
public ApiException(String message, int code, Map<String, List<String>> responseHeaders, String responseBody) {
|
||||
this(message, (Throwable) null, code, responseHeaders, responseBody);
|
||||
}
|
||||
|
||||
public ApiException(String message, Throwable throwable, int code, Map<String, List<String>> responseHeaders) {
|
||||
this(message, throwable, code, responseHeaders, null);
|
||||
}
|
||||
|
||||
public ApiException(int code, Map<String, List<String>> responseHeaders, String responseBody) {
|
||||
this((String) null, (Throwable) null, code, responseHeaders, responseBody);
|
||||
}
|
||||
|
||||
public ApiException(int code, String message) {
|
||||
super(message);
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public ApiException(int code, String message, Map<String, List<String>> responseHeaders, String responseBody) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
this(code, message);
|
||||
this.responseHeaders = responseHeaders;
|
||||
this.responseBody = responseBody;
|
||||
}
|
||||
@ -28,10 +53,6 @@ public class ApiException extends Exception {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the HTTP response headers.
|
||||
*/
|
||||
|
@ -1,6 +1,6 @@
|
||||
package io.swagger.client;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:05.989+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-11T11:35:51.678+08:00")
|
||||
public class Configuration {
|
||||
private static ApiClient defaultApiClient = new ApiClient();
|
||||
|
||||
|
@ -6,7 +6,7 @@ import com.fasterxml.jackson.datatype.joda.*;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-24T16:42:49.539+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-11T11:35:51.678+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-08-22T21:47:05.989+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-11T11:35:51.678+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-08-22T21:47:05.989+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-11T11:35:51.678+08:00")
|
||||
public class StringUtil {
|
||||
/**
|
||||
* Check if the given array contains the given value (with case-insensitive comparison).
|
||||
@ -39,4 +39,13 @@ public class StringUtil {
|
||||
}
|
||||
return out.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces
|
||||
* (except the first line).
|
||||
*/
|
||||
public static String toIndentedString(Object o) {
|
||||
if (o == null) return "null";
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
||||
|
@ -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-08-22T21:47:05.989+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-11T11:35:51.678+08:00")
|
||||
public class TypeRef<T> {
|
||||
private final Type type;
|
||||
|
||||
|
@ -17,7 +17,7 @@ import java.io.File;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:05.989+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-11T11:35:51.678+08:00")
|
||||
public class PetApi {
|
||||
private ApiClient apiClient;
|
||||
|
||||
@ -47,7 +47,6 @@ public class PetApi {
|
||||
public void updatePet (Pet body) throws ApiException {
|
||||
Object postBody = body;
|
||||
|
||||
|
||||
// create path and map variables
|
||||
String path = "/pet".replaceAll("\\{format\\}","json");
|
||||
|
||||
@ -74,6 +73,7 @@ public class PetApi {
|
||||
|
||||
String[] authNames = new String[] { "petstore_auth" };
|
||||
|
||||
|
||||
apiClient.invokeAPI(path, "PUT", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null);
|
||||
|
||||
}
|
||||
@ -87,7 +87,6 @@ public class PetApi {
|
||||
public void addPet (Pet body) throws ApiException {
|
||||
Object postBody = body;
|
||||
|
||||
|
||||
// create path and map variables
|
||||
String path = "/pet".replaceAll("\\{format\\}","json");
|
||||
|
||||
@ -114,6 +113,7 @@ public class PetApi {
|
||||
|
||||
String[] authNames = new String[] { "petstore_auth" };
|
||||
|
||||
|
||||
apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null);
|
||||
|
||||
}
|
||||
@ -127,7 +127,6 @@ public class PetApi {
|
||||
public List<Pet> findPetsByStatus (List<String> status) throws ApiException {
|
||||
Object postBody = null;
|
||||
|
||||
|
||||
// create path and map variables
|
||||
String path = "/pet/findByStatus".replaceAll("\\{format\\}","json");
|
||||
|
||||
@ -156,6 +155,7 @@ public class PetApi {
|
||||
|
||||
String[] authNames = new String[] { "petstore_auth" };
|
||||
|
||||
|
||||
TypeRef returnType = new TypeRef<List<Pet>>() {};
|
||||
return apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
|
||||
|
||||
@ -170,7 +170,6 @@ public class PetApi {
|
||||
public List<Pet> findPetsByTags (List<String> tags) throws ApiException {
|
||||
Object postBody = null;
|
||||
|
||||
|
||||
// create path and map variables
|
||||
String path = "/pet/findByTags".replaceAll("\\{format\\}","json");
|
||||
|
||||
@ -199,6 +198,7 @@ public class PetApi {
|
||||
|
||||
String[] authNames = new String[] { "petstore_auth" };
|
||||
|
||||
|
||||
TypeRef returnType = new TypeRef<List<Pet>>() {};
|
||||
return apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
|
||||
|
||||
@ -218,7 +218,6 @@ public class PetApi {
|
||||
throw new ApiException(400, "Missing the required parameter 'petId' when calling getPetById");
|
||||
}
|
||||
|
||||
|
||||
// create path and map variables
|
||||
String path = "/pet/{petId}".replaceAll("\\{format\\}","json")
|
||||
.replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString()));
|
||||
@ -246,6 +245,7 @@ public class PetApi {
|
||||
|
||||
String[] authNames = new String[] { "petstore_auth", "api_key" };
|
||||
|
||||
|
||||
TypeRef returnType = new TypeRef<Pet>() {};
|
||||
return apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
|
||||
|
||||
@ -267,7 +267,6 @@ public class PetApi {
|
||||
throw new ApiException(400, "Missing the required parameter 'petId' when calling updatePetWithForm");
|
||||
}
|
||||
|
||||
|
||||
// create path and map variables
|
||||
String path = "/pet/{petId}".replaceAll("\\{format\\}","json")
|
||||
.replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString()));
|
||||
@ -299,6 +298,7 @@ public class PetApi {
|
||||
|
||||
String[] authNames = new String[] { "petstore_auth" };
|
||||
|
||||
|
||||
apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null);
|
||||
|
||||
}
|
||||
@ -318,7 +318,6 @@ public class PetApi {
|
||||
throw new ApiException(400, "Missing the required parameter 'petId' when calling deletePet");
|
||||
}
|
||||
|
||||
|
||||
// create path and map variables
|
||||
String path = "/pet/{petId}".replaceAll("\\{format\\}","json")
|
||||
.replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString()));
|
||||
@ -348,6 +347,7 @@ public class PetApi {
|
||||
|
||||
String[] authNames = new String[] { "petstore_auth" };
|
||||
|
||||
|
||||
apiClient.invokeAPI(path, "DELETE", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null);
|
||||
|
||||
}
|
||||
@ -368,7 +368,6 @@ public class PetApi {
|
||||
throw new ApiException(400, "Missing the required parameter 'petId' when calling uploadFile");
|
||||
}
|
||||
|
||||
|
||||
// create path and map variables
|
||||
String path = "/pet/{petId}/uploadImage".replaceAll("\\{format\\}","json")
|
||||
.replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString()));
|
||||
@ -400,6 +399,7 @@ public class PetApi {
|
||||
|
||||
String[] authNames = new String[] { "petstore_auth" };
|
||||
|
||||
|
||||
apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null);
|
||||
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ import java.io.File;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:05.989+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-11T11:35:51.678+08:00")
|
||||
public class StoreApi {
|
||||
private ApiClient apiClient;
|
||||
|
||||
@ -46,7 +46,6 @@ public class StoreApi {
|
||||
public Map<String, Integer> getInventory () throws ApiException {
|
||||
Object postBody = null;
|
||||
|
||||
|
||||
// create path and map variables
|
||||
String path = "/store/inventory".replaceAll("\\{format\\}","json");
|
||||
|
||||
@ -73,6 +72,7 @@ public class StoreApi {
|
||||
|
||||
String[] authNames = new String[] { "api_key" };
|
||||
|
||||
|
||||
TypeRef returnType = new TypeRef<Map<String, Integer>>() {};
|
||||
return apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
|
||||
|
||||
@ -87,7 +87,6 @@ public class StoreApi {
|
||||
public Order placeOrder (Order body) throws ApiException {
|
||||
Object postBody = body;
|
||||
|
||||
|
||||
// create path and map variables
|
||||
String path = "/store/order".replaceAll("\\{format\\}","json");
|
||||
|
||||
@ -114,6 +113,7 @@ public class StoreApi {
|
||||
|
||||
String[] authNames = new String[] { };
|
||||
|
||||
|
||||
TypeRef returnType = new TypeRef<Order>() {};
|
||||
return apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
|
||||
|
||||
@ -133,7 +133,6 @@ public class StoreApi {
|
||||
throw new ApiException(400, "Missing the required parameter 'orderId' when calling getOrderById");
|
||||
}
|
||||
|
||||
|
||||
// create path and map variables
|
||||
String path = "/store/order/{orderId}".replaceAll("\\{format\\}","json")
|
||||
.replaceAll("\\{" + "orderId" + "\\}", apiClient.escapeString(orderId.toString()));
|
||||
@ -161,6 +160,7 @@ public class StoreApi {
|
||||
|
||||
String[] authNames = new String[] { };
|
||||
|
||||
|
||||
TypeRef returnType = new TypeRef<Order>() {};
|
||||
return apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
|
||||
|
||||
@ -180,7 +180,6 @@ public class StoreApi {
|
||||
throw new ApiException(400, "Missing the required parameter 'orderId' when calling deleteOrder");
|
||||
}
|
||||
|
||||
|
||||
// create path and map variables
|
||||
String path = "/store/order/{orderId}".replaceAll("\\{format\\}","json")
|
||||
.replaceAll("\\{" + "orderId" + "\\}", apiClient.escapeString(orderId.toString()));
|
||||
@ -208,6 +207,7 @@ public class StoreApi {
|
||||
|
||||
String[] authNames = new String[] { };
|
||||
|
||||
|
||||
apiClient.invokeAPI(path, "DELETE", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null);
|
||||
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ import java.io.File;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:05.989+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-11T11:35:51.678+08:00")
|
||||
public class UserApi {
|
||||
private ApiClient apiClient;
|
||||
|
||||
@ -47,7 +47,6 @@ public class UserApi {
|
||||
public void createUser (User body) throws ApiException {
|
||||
Object postBody = body;
|
||||
|
||||
|
||||
// create path and map variables
|
||||
String path = "/user".replaceAll("\\{format\\}","json");
|
||||
|
||||
@ -74,6 +73,7 @@ public class UserApi {
|
||||
|
||||
String[] authNames = new String[] { };
|
||||
|
||||
|
||||
apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null);
|
||||
|
||||
}
|
||||
@ -87,7 +87,6 @@ public class UserApi {
|
||||
public void createUsersWithArrayInput (List<User> body) throws ApiException {
|
||||
Object postBody = body;
|
||||
|
||||
|
||||
// create path and map variables
|
||||
String path = "/user/createWithArray".replaceAll("\\{format\\}","json");
|
||||
|
||||
@ -114,6 +113,7 @@ public class UserApi {
|
||||
|
||||
String[] authNames = new String[] { };
|
||||
|
||||
|
||||
apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null);
|
||||
|
||||
}
|
||||
@ -127,7 +127,6 @@ public class UserApi {
|
||||
public void createUsersWithListInput (List<User> body) throws ApiException {
|
||||
Object postBody = body;
|
||||
|
||||
|
||||
// create path and map variables
|
||||
String path = "/user/createWithList".replaceAll("\\{format\\}","json");
|
||||
|
||||
@ -154,6 +153,7 @@ public class UserApi {
|
||||
|
||||
String[] authNames = new String[] { };
|
||||
|
||||
|
||||
apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null);
|
||||
|
||||
}
|
||||
@ -168,7 +168,6 @@ public class UserApi {
|
||||
public String loginUser (String username, String password) throws ApiException {
|
||||
Object postBody = null;
|
||||
|
||||
|
||||
// create path and map variables
|
||||
String path = "/user/login".replaceAll("\\{format\\}","json");
|
||||
|
||||
@ -199,6 +198,7 @@ public class UserApi {
|
||||
|
||||
String[] authNames = new String[] { };
|
||||
|
||||
|
||||
TypeRef returnType = new TypeRef<String>() {};
|
||||
return apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
|
||||
|
||||
@ -212,7 +212,6 @@ public class UserApi {
|
||||
public void logoutUser () throws ApiException {
|
||||
Object postBody = null;
|
||||
|
||||
|
||||
// create path and map variables
|
||||
String path = "/user/logout".replaceAll("\\{format\\}","json");
|
||||
|
||||
@ -239,6 +238,7 @@ public class UserApi {
|
||||
|
||||
String[] authNames = new String[] { };
|
||||
|
||||
|
||||
apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null);
|
||||
|
||||
}
|
||||
@ -257,7 +257,6 @@ public class UserApi {
|
||||
throw new ApiException(400, "Missing the required parameter 'username' when calling getUserByName");
|
||||
}
|
||||
|
||||
|
||||
// create path and map variables
|
||||
String path = "/user/{username}".replaceAll("\\{format\\}","json")
|
||||
.replaceAll("\\{" + "username" + "\\}", apiClient.escapeString(username.toString()));
|
||||
@ -285,6 +284,7 @@ public class UserApi {
|
||||
|
||||
String[] authNames = new String[] { };
|
||||
|
||||
|
||||
TypeRef returnType = new TypeRef<User>() {};
|
||||
return apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
|
||||
|
||||
@ -305,7 +305,6 @@ public class UserApi {
|
||||
throw new ApiException(400, "Missing the required parameter 'username' when calling updateUser");
|
||||
}
|
||||
|
||||
|
||||
// create path and map variables
|
||||
String path = "/user/{username}".replaceAll("\\{format\\}","json")
|
||||
.replaceAll("\\{" + "username" + "\\}", apiClient.escapeString(username.toString()));
|
||||
@ -333,6 +332,7 @@ public class UserApi {
|
||||
|
||||
String[] authNames = new String[] { };
|
||||
|
||||
|
||||
apiClient.invokeAPI(path, "PUT", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null);
|
||||
|
||||
}
|
||||
@ -351,7 +351,6 @@ public class UserApi {
|
||||
throw new ApiException(400, "Missing the required parameter 'username' when calling deleteUser");
|
||||
}
|
||||
|
||||
|
||||
// create path and map variables
|
||||
String path = "/user/{username}".replaceAll("\\{format\\}","json")
|
||||
.replaceAll("\\{" + "username" + "\\}", apiClient.escapeString(username.toString()));
|
||||
@ -379,6 +378,7 @@ public class UserApi {
|
||||
|
||||
String[] authNames = new String[] { };
|
||||
|
||||
|
||||
apiClient.invokeAPI(path, "DELETE", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null);
|
||||
|
||||
}
|
||||
|
@ -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-08-22T21:47:05.989+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-11T11:35:51.678+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-08-22T21:47:05.989+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-11T11:35:51.678+08:00")
|
||||
public interface Authentication {
|
||||
/** Apply authentication settings to header and query params. */
|
||||
void applyToParams(List<Pair> queryParams, Map<String, String> headerParams);
|
||||
|
@ -8,7 +8,7 @@ import java.util.List;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import javax.xml.bind.DatatypeConverter;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:05.989+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-11T11:35:51.678+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-08-22T21:47:05.989+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-11T11:35:51.678+08:00")
|
||||
public class OAuth implements Authentication {
|
||||
@Override
|
||||
public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams) {
|
||||
|
@ -1,12 +1,15 @@
|
||||
package io.swagger.client.model;
|
||||
|
||||
import io.swagger.client.StringUtil;
|
||||
|
||||
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
|
||||
@ApiModel(description = "")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:05.989+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-11T11:35:51.678+08:00")
|
||||
public class Category {
|
||||
|
||||
private Long id = null;
|
||||
@ -43,9 +46,9 @@ public class Category {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class Category {\n");
|
||||
|
||||
sb.append(" id: ").append(id).append("\n");
|
||||
sb.append(" name: ").append(name).append("\n");
|
||||
sb.append("}\n");
|
||||
sb.append(" id: ").append(StringUtil.toIndentedString(id)).append("\n");
|
||||
sb.append(" name: ").append(StringUtil.toIndentedString(name)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package io.swagger.client.model;
|
||||
|
||||
import io.swagger.client.StringUtil;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@ -9,7 +10,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
|
||||
@ApiModel(description = "")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-24T16:42:49.539+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-11T11:35:51.678+08:00")
|
||||
public class Order {
|
||||
|
||||
private Long id = null;
|
||||
@ -115,13 +116,13 @@ public enum StatusEnum {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class Order {\n");
|
||||
|
||||
sb.append(" id: ").append(id).append("\n");
|
||||
sb.append(" petId: ").append(petId).append("\n");
|
||||
sb.append(" quantity: ").append(quantity).append("\n");
|
||||
sb.append(" shipDate: ").append(shipDate).append("\n");
|
||||
sb.append(" status: ").append(status).append("\n");
|
||||
sb.append(" complete: ").append(complete).append("\n");
|
||||
sb.append("}\n");
|
||||
sb.append(" id: ").append(StringUtil.toIndentedString(id)).append("\n");
|
||||
sb.append(" petId: ").append(StringUtil.toIndentedString(petId)).append("\n");
|
||||
sb.append(" quantity: ").append(StringUtil.toIndentedString(quantity)).append("\n");
|
||||
sb.append(" shipDate: ").append(StringUtil.toIndentedString(shipDate)).append("\n");
|
||||
sb.append(" status: ").append(StringUtil.toIndentedString(status)).append("\n");
|
||||
sb.append(" complete: ").append(StringUtil.toIndentedString(complete)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
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;
|
||||
@ -11,7 +12,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
|
||||
@ApiModel(description = "")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-24T16:42:49.539+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-11T11:35:51.678+08:00")
|
||||
public class Pet {
|
||||
|
||||
private Long id = null;
|
||||
@ -117,13 +118,13 @@ public enum StatusEnum {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class Pet {\n");
|
||||
|
||||
sb.append(" id: ").append(id).append("\n");
|
||||
sb.append(" category: ").append(category).append("\n");
|
||||
sb.append(" name: ").append(name).append("\n");
|
||||
sb.append(" photoUrls: ").append(photoUrls).append("\n");
|
||||
sb.append(" tags: ").append(tags).append("\n");
|
||||
sb.append(" status: ").append(status).append("\n");
|
||||
sb.append("}\n");
|
||||
sb.append(" id: ").append(StringUtil.toIndentedString(id)).append("\n");
|
||||
sb.append(" category: ").append(StringUtil.toIndentedString(category)).append("\n");
|
||||
sb.append(" name: ").append(StringUtil.toIndentedString(name)).append("\n");
|
||||
sb.append(" photoUrls: ").append(StringUtil.toIndentedString(photoUrls)).append("\n");
|
||||
sb.append(" tags: ").append(StringUtil.toIndentedString(tags)).append("\n");
|
||||
sb.append(" status: ").append(StringUtil.toIndentedString(status)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,15 @@
|
||||
package io.swagger.client.model;
|
||||
|
||||
import io.swagger.client.StringUtil;
|
||||
|
||||
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
|
||||
@ApiModel(description = "")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:05.989+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-11T11:35:51.678+08:00")
|
||||
public class Tag {
|
||||
|
||||
private Long id = null;
|
||||
@ -43,9 +46,9 @@ public class Tag {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class Tag {\n");
|
||||
|
||||
sb.append(" id: ").append(id).append("\n");
|
||||
sb.append(" name: ").append(name).append("\n");
|
||||
sb.append("}\n");
|
||||
sb.append(" id: ").append(StringUtil.toIndentedString(id)).append("\n");
|
||||
sb.append(" name: ").append(StringUtil.toIndentedString(name)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,15 @@
|
||||
package io.swagger.client.model;
|
||||
|
||||
import io.swagger.client.StringUtil;
|
||||
|
||||
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
|
||||
@ApiModel(description = "")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:05.989+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-11T11:35:51.678+08:00")
|
||||
public class User {
|
||||
|
||||
private Long id = null;
|
||||
@ -122,15 +125,15 @@ public class User {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class User {\n");
|
||||
|
||||
sb.append(" id: ").append(id).append("\n");
|
||||
sb.append(" username: ").append(username).append("\n");
|
||||
sb.append(" firstName: ").append(firstName).append("\n");
|
||||
sb.append(" lastName: ").append(lastName).append("\n");
|
||||
sb.append(" email: ").append(email).append("\n");
|
||||
sb.append(" password: ").append(password).append("\n");
|
||||
sb.append(" phone: ").append(phone).append("\n");
|
||||
sb.append(" userStatus: ").append(userStatus).append("\n");
|
||||
sb.append("}\n");
|
||||
sb.append(" id: ").append(StringUtil.toIndentedString(id)).append("\n");
|
||||
sb.append(" username: ").append(StringUtil.toIndentedString(username)).append("\n");
|
||||
sb.append(" firstName: ").append(StringUtil.toIndentedString(firstName)).append("\n");
|
||||
sb.append(" lastName: ").append(StringUtil.toIndentedString(lastName)).append("\n");
|
||||
sb.append(" email: ").append(StringUtil.toIndentedString(email)).append("\n");
|
||||
sb.append(" password: ").append(StringUtil.toIndentedString(password)).append("\n");
|
||||
sb.append(" phone: ").append(StringUtil.toIndentedString(phone)).append("\n");
|
||||
sb.append(" userStatus: ").append(StringUtil.toIndentedString(userStatus)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,9 @@ package io.swagger.client;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Callback for asynchronous API call.
|
||||
*
|
||||
@ -10,13 +13,19 @@ import java.io.IOException;
|
||||
public interface ApiCallback<T> {
|
||||
/**
|
||||
* This is called when the API call fails.
|
||||
*
|
||||
* @param e The exception causing the failure
|
||||
* @param statusCode Status code of the response if available, otherwise it would be 0
|
||||
* @param responseHeaders Headers of the response if available, otherwise it would be null
|
||||
*/
|
||||
void onFailure(ApiException e);
|
||||
void onFailure(ApiException e, int statusCode, Map<String, List<String>> responseHeaders);
|
||||
|
||||
/**
|
||||
* This is called when the API call succeeded.
|
||||
*
|
||||
* @param result The result deserialized from response
|
||||
* @param statusCode Status code of the response
|
||||
* @param responseHeaders Headers of the response
|
||||
*/
|
||||
void onSuccess(T result);
|
||||
void onSuccess(T result, int statusCode, Map<String, List<String>> responseHeaders);
|
||||
}
|
||||
|
@ -48,6 +48,9 @@ public class ApiClient {
|
||||
|
||||
private Map<String, Authentication> authentications;
|
||||
|
||||
private int statusCode;
|
||||
private Map<String, List<String>> responseHeaders;
|
||||
|
||||
private String dateFormat;
|
||||
private DateFormat dateFormatter;
|
||||
private int dateLength;
|
||||
@ -106,6 +109,24 @@ public class ApiClient {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the status code of the previous request.
|
||||
* NOTE: Status code of last async response is not recorded here, it is
|
||||
* passed to the callback methods instead.
|
||||
*/
|
||||
public int getStatusCode() {
|
||||
return statusCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the response headers of the previous request.
|
||||
* NOTE: Headers of last async response is not recorded here, it is passed
|
||||
* to callback methods instead.
|
||||
*/
|
||||
public Map<String, List<String>> getResponseHeaders() {
|
||||
return responseHeaders;
|
||||
}
|
||||
|
||||
public String getDateFormat() {
|
||||
return dateFormat;
|
||||
}
|
||||
@ -533,6 +554,8 @@ public class ApiClient {
|
||||
public <T> T execute(Call call, Type returnType) throws ApiException {
|
||||
try {
|
||||
Response response = call.execute();
|
||||
this.statusCode = response.code();
|
||||
this.responseHeaders = response.headers().toMultimap();
|
||||
return handleResponse(response, returnType);
|
||||
} catch (IOException e) {
|
||||
throw new ApiException(e);
|
||||
@ -556,7 +579,7 @@ public class ApiClient {
|
||||
call.enqueue(new Callback() {
|
||||
@Override
|
||||
public void onFailure(Request request, IOException e) {
|
||||
callback.onFailure(new ApiException(e));
|
||||
callback.onFailure(new ApiException(e), 0, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -565,10 +588,10 @@ public class ApiClient {
|
||||
try {
|
||||
result = (T) handleResponse(response, returnType);
|
||||
} catch (ApiException e) {
|
||||
callback.onFailure(e);
|
||||
callback.onFailure(e, response.code(), response.headers().toMultimap());
|
||||
return;
|
||||
}
|
||||
callback.onSuccess(result);
|
||||
callback.onSuccess(result, response.code(), response.headers().toMultimap());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -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-08-31T19:27:38.337+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-11T13:13:26.059+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-08-31T19:27:38.337+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-11T13:13:26.059+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-08-31T19:27:38.337+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-11T13:13:26.059+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-08-31T19:27:38.337+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-11T13:13:26.059+08:00")
|
||||
public class StringUtil {
|
||||
/**
|
||||
* Check if the given array contains the given value (with case-insensitive comparison).
|
||||
|
@ -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-08-31T19:27:38.337+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-11T13:13:26.059+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-08-31T19:27:38.337+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-11T13:13:26.059+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-08-31T19:27:38.337+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-11T13:13:26.059+08:00")
|
||||
public class OAuth implements Authentication {
|
||||
@Override
|
||||
public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams) {
|
||||
|
@ -4,6 +4,7 @@ import io.swagger.client.ApiClient;
|
||||
import io.swagger.client.ApiException;
|
||||
import io.swagger.client.Configuration;
|
||||
|
||||
import io.swagger.client.ApiCallback;
|
||||
import io.swagger.client.api.*;
|
||||
import io.swagger.client.auth.*;
|
||||
import io.swagger.client.model.*;
|
||||
@ -13,7 +14,9 @@ import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.*;
|
||||
import static org.junit.Assert.*;
|
||||
@ -68,6 +71,81 @@ public class PetApiTest {
|
||||
assertEquals(fetched.getCategory().getName(), pet.getCategory().getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateAndGetPetAsync() throws Exception {
|
||||
Pet pet = createRandomPet();
|
||||
api.addPet(pet);
|
||||
// to store returned Pet or error message/exception
|
||||
final Map<String, Object> result = new HashMap<String, Object>();
|
||||
|
||||
api.getPetByIdAsync(pet.getId(), new ApiCallback<Pet>() {
|
||||
@Override
|
||||
public void onFailure(ApiException e, int statusCode, Map<String, List<String>> responseHeaders) {
|
||||
result.put("error", e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(Pet pet, int statusCode, Map<String, List<String>> responseHeaders) {
|
||||
result.put("pet", pet);
|
||||
}
|
||||
});
|
||||
// the API call should be executed asynchronously, so result should be empty at the moment
|
||||
assertTrue(result.isEmpty());
|
||||
|
||||
// wait for the asynchronous call to finish (at most 10 seconds)
|
||||
final int maxTry = 10;
|
||||
int tryCount = 1;
|
||||
Pet fetched = null;
|
||||
do {
|
||||
if (tryCount > maxTry) fail("have not got result of getPetByIdAsync after 10 seconds");
|
||||
Thread.sleep(1000);
|
||||
tryCount += 1;
|
||||
if (result.get("error") != null) fail((String) result.get("error"));
|
||||
if (result.get("pet") != null) {
|
||||
fetched = (Pet) result.get("pet");
|
||||
break;
|
||||
}
|
||||
} while (result.isEmpty());
|
||||
assertNotNull(fetched);
|
||||
assertEquals(pet.getId(), fetched.getId());
|
||||
assertNotNull(fetched.getCategory());
|
||||
assertEquals(fetched.getCategory().getName(), pet.getCategory().getName());
|
||||
|
||||
// test getting a nonexistent pet
|
||||
result.clear();
|
||||
api.getPetByIdAsync(new Long(-10000), new ApiCallback<Pet>() {
|
||||
@Override
|
||||
public void onFailure(ApiException e, int statusCode, Map<String, List<String>> responseHeaders) {
|
||||
result.put("exception", e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(Pet pet, int statusCode, Map<String, List<String>> responseHeaders) {
|
||||
result.put("pet", pet);
|
||||
}
|
||||
});
|
||||
// the API call should be executed asynchronously, so result should be empty at the moment
|
||||
assertTrue(result.isEmpty());
|
||||
|
||||
// wait for the asynchronous call to finish (at most 10 seconds)
|
||||
tryCount = 1;
|
||||
ApiException exception = null;
|
||||
do {
|
||||
if (tryCount > maxTry) fail("have not got result of getPetByIdAsync after 10 seconds");
|
||||
Thread.sleep(1000);
|
||||
tryCount += 1;
|
||||
if (result.get("pet") != null) fail("expected an error");
|
||||
if (result.get("exception") != null) {
|
||||
exception = (ApiException) result.get("exception");
|
||||
break;
|
||||
}
|
||||
} while (result.isEmpty());
|
||||
assertNotNull(exception);
|
||||
assertEquals(404, exception.getCode());
|
||||
assertEquals("Not Found", exception.getMessage());
|
||||
assertEquals("application/json", exception.getResponseHeaders().get("Content-Type").get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdatePet() throws Exception {
|
||||
Pet pet = createRandomPet();
|
||||
|
Loading…
x
Reference in New Issue
Block a user