Rebuild Java petstore sample

This commit is contained in:
xhh 2015-08-04 18:36:03 +08:00
parent aff21e5e6b
commit 7c16dfcf13
8 changed files with 328 additions and 649 deletions

View File

@ -1,9 +1,7 @@
package io.swagger.client;
import com.fasterxml.jackson.core.JsonGenerator.Feature;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientResponse;
@ -11,7 +9,9 @@ import com.sun.jersey.api.client.config.ClientConfig;
import com.sun.jersey.api.client.config.DefaultClientConfig;
import com.sun.jersey.api.client.filter.LoggingFilter;
import com.sun.jersey.api.client.WebResource.Builder;
import com.sun.jersey.multipart.FormDataMultiPart;
import com.sun.jersey.multipart.file.FileDataBodyPart;
import javax.ws.rs.core.Response.Status.Family;
import javax.ws.rs.core.MediaType;
@ -29,6 +29,7 @@ import java.util.TimeZone;
import java.net.URLEncoder;
import java.io.IOException;
import java.io.File;
import java.io.UnsupportedEncodingException;
import java.text.DateFormat;
@ -45,6 +46,7 @@ public class ApiClient {
private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
private boolean debugging = false;
private String basePath = "http://petstore.swagger.io/v2";
private JSON json = new JSON();
private Map<String, Authentication> authentications;
@ -336,50 +338,38 @@ public class ApiClient {
}
/**
* Deserialize the given JSON string to Java object.
*
* @param json The JSON string
* @param containerType The container type, one of "list", "array" or ""
* @param cls The type of the Java object
* @return The deserialized Java object
* Serialize the given Java object into string according the given
* Content-Type (only JSON is supported for now).
*/
public Object deserialize(String json, String containerType, Class cls) throws ApiException {
if(null != containerType) {
containerType = containerType.toLowerCase();
}
try{
if("list".equals(containerType) || "array".equals(containerType)) {
JavaType typeInfo = JsonUtil.getJsonMapper().getTypeFactory().constructCollectionType(List.class, cls);
List response = (List<?>) JsonUtil.getJsonMapper().readValue(json, typeInfo);
return response;
}
else if(String.class.equals(cls)) {
if(json != null && json.startsWith("\"") && json.endsWith("\"") && json.length() > 1)
return json.substring(1, json.length() - 2);
else
return json;
}
else {
return JsonUtil.getJsonMapper().readValue(json, cls);
}
}
catch (IOException e) {
throw new ApiException(500, e.getMessage(), null, json);
public String serialize(Object obj, String contentType) throws ApiException {
if (contentType.startsWith("application/json")) {
return json.serialize(obj);
} else {
throw new ApiException(400, "can not serialize object into Content-Type: " + contentType);
}
}
/**
* Serialize the given Java object into JSON string.
* Deserialize response body to Java object according to the Content-Type.
*/
public String serialize(Object obj) throws ApiException {
try {
if (obj != null)
return JsonUtil.getJsonMapper().writeValueAsString(obj);
else
return null;
}
catch (Exception e) {
throw new ApiException(500, e.getMessage());
public <T> T deserialize(ClientResponse response, TypeRef returnType) throws ApiException {
String contentType = null;
List<String> contentTypes = response.getHeaders().get("Content-Type");
if (contentTypes != null && !contentTypes.isEmpty())
contentType = contentTypes.get(0);
if (contentType == null)
throw new ApiException(500, "missing Content-Type in response");
String body;
if (response.hasEntity())
body = (String) response.getEntity(String.class);
else
body = "";
if (contentType.startsWith("application/json")) {
return json.deserialize(body, returnType);
} else {
throw new ApiException(500, "can not deserialize Content-Type: " + contentType);
}
}
@ -395,9 +385,10 @@ public class ApiClient {
* @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 String invokeAPI(String path, String method, List<Pair> queryParams, Object body, Map<String, String> headerParams, Map<String, String> formParams, String accept, String contentType, String[] authNames) throws ApiException {
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 {
updateParamsForAuth(authNames, queryParams, headerParams);
Client client = getClient();
@ -423,90 +414,89 @@ public class ApiClient {
else
builder = client.resource(basePath + path + querystring).accept(accept);
for(String key : headerParams.keySet()) {
for (String key : headerParams.keySet()) {
builder = builder.header(key, headerParams.get(key));
}
for(String key : defaultHeaderMap.keySet()) {
if(!headerParams.containsKey(key)) {
for (String key : defaultHeaderMap.keySet()) {
if (!headerParams.containsKey(key)) {
builder = builder.header(key, defaultHeaderMap.get(key));
}
}
String encodedFormParams = null;
if (contentType.startsWith("multipart/form-data")) {
FormDataMultiPart mp = new FormDataMultiPart();
for (Entry<String, Object> param: formParams.entrySet()) {
if (param.getValue() instanceof File) {
File file = (File) param.getValue();
mp.field(param.getKey(), file.getName());
mp.bodyPart(new FileDataBodyPart(param.getKey(), file, MediaType.MULTIPART_FORM_DATA_TYPE));
} else {
mp.field(param.getKey(), parameterToString(param.getValue()), MediaType.MULTIPART_FORM_DATA_TYPE);
}
}
body = mp;
} else if (contentType.startsWith("application/x-www-form-urlencoded")) {
encodedFormParams = this.getXWWWFormUrlencodedParams(formParams);
}
ClientResponse response = null;
if("GET".equals(method)) {
if ("GET".equals(method)) {
response = (ClientResponse) builder.get(ClientResponse.class);
}
else if ("POST".equals(method)) {
if (contentType.startsWith("application/x-www-form-urlencoded")) {
String encodedFormParams = this
.getXWWWFormUrlencodedParams(formParams);
response = builder.type(contentType).post(ClientResponse.class,
encodedFormParams);
} else if ("POST".equals(method)) {
if (encodedFormParams != null) {
response = builder.type(contentType).post(ClientResponse.class, encodedFormParams);
} else if (body == null) {
response = builder.post(ClientResponse.class, null);
} else if(body instanceof FormDataMultiPart) {
} else if (body instanceof FormDataMultiPart) {
response = builder.type(contentType).post(ClientResponse.class, body);
}
else
response = builder.type(contentType).post(ClientResponse.class, serialize(body));
}
else if ("PUT".equals(method)) {
if ("application/x-www-form-urlencoded".equals(contentType)) {
String encodedFormParams = this
.getXWWWFormUrlencodedParams(formParams);
response = builder.type(contentType).put(ClientResponse.class,
encodedFormParams);
} else if(body == null) {
response = builder.put(ClientResponse.class, serialize(body));
} else {
response = builder.type(contentType).put(ClientResponse.class, serialize(body));
response = builder.type(contentType).post(ClientResponse.class, serialize(body, contentType));
}
}
else if ("DELETE".equals(method)) {
if ("application/x-www-form-urlencoded".equals(contentType)) {
String encodedFormParams = this
.getXWWWFormUrlencodedParams(formParams);
response = builder.type(contentType).delete(ClientResponse.class,
encodedFormParams);
} else if ("PUT".equals(method)) {
if (encodedFormParams != null) {
response = builder.type(contentType).put(ClientResponse.class, encodedFormParams);
} else if(body == null) {
response = builder.put(ClientResponse.class, serialize(body, contentType));
} else {
response = builder.type(contentType).put(ClientResponse.class, serialize(body, contentType));
}
} else if ("DELETE".equals(method)) {
if (encodedFormParams != null) {
response = builder.type(contentType).delete(ClientResponse.class, encodedFormParams);
} else if(body == null) {
response = builder.delete(ClientResponse.class);
} else {
response = builder.type(contentType).delete(ClientResponse.class, serialize(body));
response = builder.type(contentType).delete(ClientResponse.class, serialize(body, contentType));
}
}
else {
} else {
throw new ApiException(500, "unknown method type " + method);
}
if(response.getStatusInfo() == ClientResponse.Status.NO_CONTENT) {
if (response.getStatusInfo() == ClientResponse.Status.NO_CONTENT) {
return null;
}
else if(response.getStatusInfo().getFamily() == Family.SUCCESSFUL) {
if(response.hasEntity()) {
return (String) response.getEntity(String.class);
}
else {
return "";
}
}
else {
} else if (response.getStatusInfo().getFamily() == Family.SUCCESSFUL) {
if (returnType == null)
return null;
else
return deserialize(response, returnType);
} else {
String message = "error";
String respBody = null;
if(response.hasEntity()) {
try{
if (response.hasEntity()) {
try {
respBody = String.valueOf(response.getEntity(String.class));
message = respBody;
}
catch (RuntimeException e) {
} catch (RuntimeException e) {
// e.printStackTrace();
}
}
throw new ApiException(
response.getStatusInfo().getStatusCode(),
message,
response.getHeaders(),
respBody);
response.getStatusInfo().getStatusCode(),
message,
response.getHeaders(),
respBody);
}
}
@ -526,15 +516,14 @@ public class ApiClient {
/**
* Encode the given form parameters as request body.
*/
private String getXWWWFormUrlencodedParams(Map<String, String> formParams) {
private String getXWWWFormUrlencodedParams(Map<String, Object> formParams) {
StringBuilder formParamBuilder = new StringBuilder();
for (Entry<String, String> param : formParams.entrySet()) {
String keyStr = parameterToString(param.getKey());
for (Entry<String, Object> param : formParams.entrySet()) {
String keyStr = param.getKey();
String valueStr = parameterToString(param.getValue());
try {
formParamBuilder.append(URLEncoder.encode(keyStr, "utf8"))
formParamBuilder.append(URLEncoder.encode(param.getKey(), "utf8"))
.append("=")
.append(URLEncoder.encode(valueStr, "utf8"));
formParamBuilder.append("&");
@ -542,11 +531,12 @@ public class ApiClient {
// move on to next
}
}
String encodedFormParams = formParamBuilder.toString();
if (encodedFormParams.endsWith("&")) {
encodedFormParams = encodedFormParams.substring(0,
encodedFormParams.length() - 1);
encodedFormParams = encodedFormParams.substring(0, encodedFormParams.length() - 1);
}
return encodedFormParams;
}

View File

@ -0,0 +1,51 @@
package io.swagger.client;
import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.datatype.joda.*;
import java.io.IOException;
public class JSON {
private ObjectMapper mapper;
public JSON() {
mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
mapper.registerModule(new JodaModule());
}
/**
* Serialize the given Java object into JSON string.
*/
public String serialize(Object obj) throws ApiException {
try {
if (obj != null)
return mapper.writeValueAsString(obj);
else
return null;
} catch (Exception e) {
throw new ApiException(400, e.getMessage());
}
}
/**
* Deserialize the given JSON string to Java object.
*
* @param body The JSON string
* @param returnType The type to deserialize inot
* @return The deserialized Java object
*/
public <T> T deserialize(String body, TypeRef returnType) throws ApiException {
JavaType javaType = mapper.constructType(returnType.getType());
try {
return mapper.readValue(body, javaType);
} catch (IOException e) {
if (returnType.getType().equals(String.class))
return (T) body;
else
throw new ApiException(500, e.getMessage(), null, body);
}
}
}

View File

@ -1,23 +0,0 @@
package io.swagger.client;
import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.core.JsonGenerator.Feature;
import com.fasterxml.jackson.datatype.joda.*;
public class JsonUtil {
public static ObjectMapper mapper;
static {
mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
mapper.registerModule(new JodaModule());
}
public static ObjectMapper getJsonMapper() {
return mapper;
}
}

View File

@ -0,0 +1,25 @@
package io.swagger.client;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
public class TypeRef<T> {
private final Type type;
public TypeRef() {
this.type = getGenericType(getClass());
}
private static Type getGenericType(Class<?> klass) {
Type superclass = klass.getGenericSuperclass();
if (superclass instanceof Class) {
throw new RuntimeException("No type parameter provided");
}
ParameterizedType parameterized = (ParameterizedType) superclass;
return parameterized.getActualTypeArguments()[0];
}
public Type getType() {
return type;
}
}

View File

@ -4,6 +4,7 @@ import io.swagger.client.ApiException;
import io.swagger.client.ApiClient;
import io.swagger.client.Configuration;
import io.swagger.client.Pair;
import io.swagger.client.TypeRef;
import io.swagger.client.model.*;
@ -12,11 +13,6 @@ import java.util.*;
import io.swagger.client.model.Pet;
import java.io.File;
import com.sun.jersey.multipart.FormDataMultiPart;
import com.sun.jersey.multipart.file.FileDataBodyPart;
import javax.ws.rs.core.MediaType;
import java.io.File;
import java.util.Map;
import java.util.HashMap;
@ -57,7 +53,9 @@ public class PetApi {
// query params
List<Pair> queryParams = new ArrayList<Pair>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> formParams = new HashMap<String, String>();
Map<String, Object> formParams = new HashMap<String, Object>();
@ -73,29 +71,10 @@ public class PetApi {
};
final String contentType = apiClient.selectHeaderContentType(contentTypes);
if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
FormDataMultiPart mp = new FormDataMultiPart();
if(hasFields)
postBody = mp;
}
else {
}
try {
String[] authNames = new String[] { "petstore_auth" };
String response = apiClient.invokeAPI(path, "PUT", queryParams, postBody, headerParams, formParams, accept, contentType, authNames);
if(response != null){
return ;
}
else {
return ;
}
} catch (ApiException ex) {
throw ex;
}
String[] authNames = new String[] { "petstore_auth" };
apiClient.invokeAPI(path, "PUT", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null);
}
/**
@ -114,7 +93,9 @@ public class PetApi {
// query params
List<Pair> queryParams = new ArrayList<Pair>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> formParams = new HashMap<String, String>();
Map<String, Object> formParams = new HashMap<String, Object>();
@ -130,29 +111,10 @@ public class PetApi {
};
final String contentType = apiClient.selectHeaderContentType(contentTypes);
if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
FormDataMultiPart mp = new FormDataMultiPart();
if(hasFields)
postBody = mp;
}
else {
}
try {
String[] authNames = new String[] { "petstore_auth" };
String response = apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames);
if(response != null){
return ;
}
else {
return ;
}
} catch (ApiException ex) {
throw ex;
}
String[] authNames = new String[] { "petstore_auth" };
apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null);
}
/**
@ -171,7 +133,7 @@ public class PetApi {
// query params
List<Pair> queryParams = new ArrayList<Pair>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> formParams = new HashMap<String, String>();
Map<String, Object> formParams = new HashMap<String, Object>();
queryParams.addAll(apiClient.parameterToPairs("multi", "status", status));
@ -179,6 +141,8 @@ public class PetApi {
final String[] accepts = {
"application/json", "application/xml"
};
@ -189,29 +153,11 @@ public class PetApi {
};
final String contentType = apiClient.selectHeaderContentType(contentTypes);
if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
FormDataMultiPart mp = new FormDataMultiPart();
if(hasFields)
postBody = mp;
}
else {
}
try {
String[] authNames = new String[] { "petstore_auth" };
String response = apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames);
if(response != null){
return (List<Pet>) apiClient.deserialize(response, "array", Pet.class);
}
else {
return null;
}
} catch (ApiException ex) {
throw ex;
}
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);
}
/**
@ -230,7 +176,7 @@ public class PetApi {
// query params
List<Pair> queryParams = new ArrayList<Pair>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> formParams = new HashMap<String, String>();
Map<String, Object> formParams = new HashMap<String, Object>();
queryParams.addAll(apiClient.parameterToPairs("multi", "tags", tags));
@ -238,6 +184,8 @@ public class PetApi {
final String[] accepts = {
"application/json", "application/xml"
};
@ -248,29 +196,11 @@ public class PetApi {
};
final String contentType = apiClient.selectHeaderContentType(contentTypes);
if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
FormDataMultiPart mp = new FormDataMultiPart();
if(hasFields)
postBody = mp;
}
else {
}
try {
String[] authNames = new String[] { "petstore_auth" };
String response = apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames);
if(response != null){
return (List<Pet>) apiClient.deserialize(response, "array", Pet.class);
}
else {
return null;
}
} catch (ApiException ex) {
throw ex;
}
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);
}
/**
@ -295,7 +225,9 @@ public class PetApi {
// query params
List<Pair> queryParams = new ArrayList<Pair>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> formParams = new HashMap<String, String>();
Map<String, Object> formParams = new HashMap<String, Object>();
@ -311,29 +243,11 @@ public class PetApi {
};
final String contentType = apiClient.selectHeaderContentType(contentTypes);
if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
FormDataMultiPart mp = new FormDataMultiPart();
if(hasFields)
postBody = mp;
}
else {
}
try {
String[] authNames = new String[] { "api_key", "petstore_auth" };
String response = apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames);
if(response != null){
return (Pet) apiClient.deserialize(response, "", Pet.class);
}
else {
return null;
}
} catch (ApiException ex) {
throw ex;
}
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);
}
/**
@ -360,12 +274,18 @@ public class PetApi {
// query params
List<Pair> queryParams = new ArrayList<Pair>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> formParams = new HashMap<String, String>();
Map<String, Object> formParams = new HashMap<String, Object>();
if (name != null)
formParams.put("name", name);
if (status != null)
formParams.put("status", status);
final String[] accepts = {
"application/json", "application/xml"
};
@ -376,43 +296,10 @@ public class PetApi {
};
final String contentType = apiClient.selectHeaderContentType(contentTypes);
if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
FormDataMultiPart mp = new FormDataMultiPart();
if (name != null) {
hasFields = true;
mp.field("name", apiClient.parameterToString(name), MediaType.MULTIPART_FORM_DATA_TYPE);
}
if (status != null) {
hasFields = true;
mp.field("status", apiClient.parameterToString(status), MediaType.MULTIPART_FORM_DATA_TYPE);
}
if(hasFields)
postBody = mp;
}
else {
if (name != null)
formParams.put("name", apiClient.parameterToString(name));
if (status != null)
formParams.put("status", apiClient.parameterToString(status));
}
try {
String[] authNames = new String[] { "petstore_auth" };
String response = apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames);
if(response != null){
return ;
}
else {
return ;
}
} catch (ApiException ex) {
throw ex;
}
String[] authNames = new String[] { "petstore_auth" };
apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null);
}
/**
@ -438,7 +325,7 @@ public class PetApi {
// query params
List<Pair> queryParams = new ArrayList<Pair>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> formParams = new HashMap<String, String>();
Map<String, Object> formParams = new HashMap<String, Object>();
@ -446,6 +333,8 @@ public class PetApi {
headerParams.put("api_key", apiClient.parameterToString(apiKey));
final String[] accepts = {
"application/json", "application/xml"
};
@ -456,29 +345,10 @@ public class PetApi {
};
final String contentType = apiClient.selectHeaderContentType(contentTypes);
if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
FormDataMultiPart mp = new FormDataMultiPart();
if(hasFields)
postBody = mp;
}
else {
}
try {
String[] authNames = new String[] { "petstore_auth" };
String response = apiClient.invokeAPI(path, "DELETE", queryParams, postBody, headerParams, formParams, accept, contentType, authNames);
if(response != null){
return ;
}
else {
return ;
}
} catch (ApiException ex) {
throw ex;
}
String[] authNames = new String[] { "petstore_auth" };
apiClient.invokeAPI(path, "DELETE", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null);
}
/**
@ -505,12 +375,18 @@ public class PetApi {
// query params
List<Pair> queryParams = new ArrayList<Pair>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> formParams = new HashMap<String, String>();
Map<String, Object> formParams = new HashMap<String, Object>();
if (additionalMetadata != null)
formParams.put("additionalMetadata", additionalMetadata);
if (file != null)
formParams.put("file", file);
final String[] accepts = {
"application/json", "application/xml"
};
@ -521,43 +397,10 @@ public class PetApi {
};
final String contentType = apiClient.selectHeaderContentType(contentTypes);
if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
FormDataMultiPart mp = new FormDataMultiPart();
if (additionalMetadata != null) {
hasFields = true;
mp.field("additionalMetadata", apiClient.parameterToString(additionalMetadata), MediaType.MULTIPART_FORM_DATA_TYPE);
}
if (file != null) {
hasFields = true;
mp.field("file", file.getName());
mp.bodyPart(new FileDataBodyPart("file", file, MediaType.MULTIPART_FORM_DATA_TYPE));
}
if(hasFields)
postBody = mp;
}
else {
if (additionalMetadata != null)
formParams.put("additionalMetadata", apiClient.parameterToString(additionalMetadata));
}
try {
String[] authNames = new String[] { "petstore_auth" };
String response = apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames);
if(response != null){
return ;
}
else {
return ;
}
} catch (ApiException ex) {
throw ex;
}
String[] authNames = new String[] { "petstore_auth" };
apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null);
}
}

View File

@ -4,6 +4,7 @@ import io.swagger.client.ApiException;
import io.swagger.client.ApiClient;
import io.swagger.client.Configuration;
import io.swagger.client.Pair;
import io.swagger.client.TypeRef;
import io.swagger.client.model.*;
@ -12,11 +13,6 @@ import java.util.*;
import java.util.Map;
import io.swagger.client.model.Order;
import com.sun.jersey.multipart.FormDataMultiPart;
import com.sun.jersey.multipart.file.FileDataBodyPart;
import javax.ws.rs.core.MediaType;
import java.io.File;
import java.util.Map;
import java.util.HashMap;
@ -56,7 +52,9 @@ public class StoreApi {
// query params
List<Pair> queryParams = new ArrayList<Pair>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> formParams = new HashMap<String, String>();
Map<String, Object> formParams = new HashMap<String, Object>();
@ -72,29 +70,11 @@ public class StoreApi {
};
final String contentType = apiClient.selectHeaderContentType(contentTypes);
if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
FormDataMultiPart mp = new FormDataMultiPart();
if(hasFields)
postBody = mp;
}
else {
}
try {
String[] authNames = new String[] { "api_key" };
String response = apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames);
if(response != null){
return (Map<String, Integer>) apiClient.deserialize(response, "map", Map.class);
}
else {
return null;
}
} catch (ApiException ex) {
throw ex;
}
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);
}
/**
@ -113,7 +93,9 @@ public class StoreApi {
// query params
List<Pair> queryParams = new ArrayList<Pair>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> formParams = new HashMap<String, String>();
Map<String, Object> formParams = new HashMap<String, Object>();
@ -129,29 +111,11 @@ public class StoreApi {
};
final String contentType = apiClient.selectHeaderContentType(contentTypes);
if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
FormDataMultiPart mp = new FormDataMultiPart();
if(hasFields)
postBody = mp;
}
else {
}
try {
String[] authNames = new String[] { };
String response = apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames);
if(response != null){
return (Order) apiClient.deserialize(response, "", Order.class);
}
else {
return null;
}
} catch (ApiException ex) {
throw ex;
}
String[] authNames = new String[] { };
TypeRef returnType = new TypeRef<Order>() {};
return apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
}
/**
@ -176,7 +140,9 @@ public class StoreApi {
// query params
List<Pair> queryParams = new ArrayList<Pair>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> formParams = new HashMap<String, String>();
Map<String, Object> formParams = new HashMap<String, Object>();
@ -192,29 +158,11 @@ public class StoreApi {
};
final String contentType = apiClient.selectHeaderContentType(contentTypes);
if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
FormDataMultiPart mp = new FormDataMultiPart();
if(hasFields)
postBody = mp;
}
else {
}
try {
String[] authNames = new String[] { };
String response = apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames);
if(response != null){
return (Order) apiClient.deserialize(response, "", Order.class);
}
else {
return null;
}
} catch (ApiException ex) {
throw ex;
}
String[] authNames = new String[] { };
TypeRef returnType = new TypeRef<Order>() {};
return apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
}
/**
@ -239,7 +187,9 @@ public class StoreApi {
// query params
List<Pair> queryParams = new ArrayList<Pair>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> formParams = new HashMap<String, String>();
Map<String, Object> formParams = new HashMap<String, Object>();
@ -255,29 +205,10 @@ public class StoreApi {
};
final String contentType = apiClient.selectHeaderContentType(contentTypes);
if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
FormDataMultiPart mp = new FormDataMultiPart();
if(hasFields)
postBody = mp;
}
else {
}
try {
String[] authNames = new String[] { };
String response = apiClient.invokeAPI(path, "DELETE", queryParams, postBody, headerParams, formParams, accept, contentType, authNames);
if(response != null){
return ;
}
else {
return ;
}
} catch (ApiException ex) {
throw ex;
}
String[] authNames = new String[] { };
apiClient.invokeAPI(path, "DELETE", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null);
}
}

View File

@ -4,6 +4,7 @@ import io.swagger.client.ApiException;
import io.swagger.client.ApiClient;
import io.swagger.client.Configuration;
import io.swagger.client.Pair;
import io.swagger.client.TypeRef;
import io.swagger.client.model.*;
@ -12,11 +13,6 @@ import java.util.*;
import io.swagger.client.model.User;
import java.util.*;
import com.sun.jersey.multipart.FormDataMultiPart;
import com.sun.jersey.multipart.file.FileDataBodyPart;
import javax.ws.rs.core.MediaType;
import java.io.File;
import java.util.Map;
import java.util.HashMap;
@ -57,7 +53,9 @@ public class UserApi {
// query params
List<Pair> queryParams = new ArrayList<Pair>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> formParams = new HashMap<String, String>();
Map<String, Object> formParams = new HashMap<String, Object>();
@ -73,29 +71,10 @@ public class UserApi {
};
final String contentType = apiClient.selectHeaderContentType(contentTypes);
if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
FormDataMultiPart mp = new FormDataMultiPart();
if(hasFields)
postBody = mp;
}
else {
}
try {
String[] authNames = new String[] { };
String response = apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames);
if(response != null){
return ;
}
else {
return ;
}
} catch (ApiException ex) {
throw ex;
}
String[] authNames = new String[] { };
apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null);
}
/**
@ -114,7 +93,9 @@ public class UserApi {
// query params
List<Pair> queryParams = new ArrayList<Pair>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> formParams = new HashMap<String, String>();
Map<String, Object> formParams = new HashMap<String, Object>();
@ -130,29 +111,10 @@ public class UserApi {
};
final String contentType = apiClient.selectHeaderContentType(contentTypes);
if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
FormDataMultiPart mp = new FormDataMultiPart();
if(hasFields)
postBody = mp;
}
else {
}
try {
String[] authNames = new String[] { };
String response = apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames);
if(response != null){
return ;
}
else {
return ;
}
} catch (ApiException ex) {
throw ex;
}
String[] authNames = new String[] { };
apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null);
}
/**
@ -171,7 +133,9 @@ public class UserApi {
// query params
List<Pair> queryParams = new ArrayList<Pair>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> formParams = new HashMap<String, String>();
Map<String, Object> formParams = new HashMap<String, Object>();
@ -187,29 +151,10 @@ public class UserApi {
};
final String contentType = apiClient.selectHeaderContentType(contentTypes);
if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
FormDataMultiPart mp = new FormDataMultiPart();
if(hasFields)
postBody = mp;
}
else {
}
try {
String[] authNames = new String[] { };
String response = apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames);
if(response != null){
return ;
}
else {
return ;
}
} catch (ApiException ex) {
throw ex;
}
String[] authNames = new String[] { };
apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null);
}
/**
@ -229,7 +174,7 @@ public class UserApi {
// query params
List<Pair> queryParams = new ArrayList<Pair>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> formParams = new HashMap<String, String>();
Map<String, Object> formParams = new HashMap<String, Object>();
queryParams.addAll(apiClient.parameterToPairs("", "username", username));
@ -239,6 +184,8 @@ public class UserApi {
final String[] accepts = {
"application/json", "application/xml"
};
@ -249,29 +196,11 @@ public class UserApi {
};
final String contentType = apiClient.selectHeaderContentType(contentTypes);
if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
FormDataMultiPart mp = new FormDataMultiPart();
if(hasFields)
postBody = mp;
}
else {
}
try {
String[] authNames = new String[] { };
String response = apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames);
if(response != null){
return (String) apiClient.deserialize(response, "", String.class);
}
else {
return null;
}
} catch (ApiException ex) {
throw ex;
}
String[] authNames = new String[] { };
TypeRef returnType = new TypeRef<String>() {};
return apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
}
/**
@ -289,7 +218,9 @@ public class UserApi {
// query params
List<Pair> queryParams = new ArrayList<Pair>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> formParams = new HashMap<String, String>();
Map<String, Object> formParams = new HashMap<String, Object>();
@ -305,29 +236,10 @@ public class UserApi {
};
final String contentType = apiClient.selectHeaderContentType(contentTypes);
if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
FormDataMultiPart mp = new FormDataMultiPart();
if(hasFields)
postBody = mp;
}
else {
}
try {
String[] authNames = new String[] { };
String response = apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames);
if(response != null){
return ;
}
else {
return ;
}
} catch (ApiException ex) {
throw ex;
}
String[] authNames = new String[] { };
apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null);
}
/**
@ -352,7 +264,9 @@ public class UserApi {
// query params
List<Pair> queryParams = new ArrayList<Pair>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> formParams = new HashMap<String, String>();
Map<String, Object> formParams = new HashMap<String, Object>();
@ -368,29 +282,11 @@ public class UserApi {
};
final String contentType = apiClient.selectHeaderContentType(contentTypes);
if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
FormDataMultiPart mp = new FormDataMultiPart();
if(hasFields)
postBody = mp;
}
else {
}
try {
String[] authNames = new String[] { };
String response = apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames);
if(response != null){
return (User) apiClient.deserialize(response, "", User.class);
}
else {
return null;
}
} catch (ApiException ex) {
throw ex;
}
String[] authNames = new String[] { };
TypeRef returnType = new TypeRef<User>() {};
return apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
}
/**
@ -416,7 +312,9 @@ public class UserApi {
// query params
List<Pair> queryParams = new ArrayList<Pair>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> formParams = new HashMap<String, String>();
Map<String, Object> formParams = new HashMap<String, Object>();
@ -432,29 +330,10 @@ public class UserApi {
};
final String contentType = apiClient.selectHeaderContentType(contentTypes);
if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
FormDataMultiPart mp = new FormDataMultiPart();
if(hasFields)
postBody = mp;
}
else {
}
try {
String[] authNames = new String[] { };
String response = apiClient.invokeAPI(path, "PUT", queryParams, postBody, headerParams, formParams, accept, contentType, authNames);
if(response != null){
return ;
}
else {
return ;
}
} catch (ApiException ex) {
throw ex;
}
String[] authNames = new String[] { };
apiClient.invokeAPI(path, "PUT", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null);
}
/**
@ -479,7 +358,9 @@ public class UserApi {
// query params
List<Pair> queryParams = new ArrayList<Pair>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> formParams = new HashMap<String, String>();
Map<String, Object> formParams = new HashMap<String, Object>();
@ -495,29 +376,10 @@ public class UserApi {
};
final String contentType = apiClient.selectHeaderContentType(contentTypes);
if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
FormDataMultiPart mp = new FormDataMultiPart();
if(hasFields)
postBody = mp;
}
else {
}
try {
String[] authNames = new String[] { };
String response = apiClient.invokeAPI(path, "DELETE", queryParams, postBody, headerParams, formParams, accept, contentType, authNames);
if(response != null){
return ;
}
else {
return ;
}
} catch (ApiException ex) {
throw ex;
}
String[] authNames = new String[] { };
apiClient.invokeAPI(path, "DELETE", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null);
}
}

View File

@ -1,8 +1,8 @@
package io.swagger.client.model;
import io.swagger.client.model.Category;
import io.swagger.client.model.Tag;
import java.util.*;
import io.swagger.client.model.Tag;
import io.swagger.annotations.*;
import com.fasterxml.jackson.annotation.JsonProperty;