updated versions

This commit is contained in:
fehguy
2015-06-09 00:25:09 -07:00
parent 33c2b1b623
commit 3d2f09a693
180 changed files with 22318 additions and 26364 deletions

View File

@@ -1,3 +1,3 @@
<manifest package="io.swagger.client">
<application/>
<application />
</manifest>

View File

@@ -1,29 +1,29 @@
package io.swagger.client;
public class ApiException extends Exception {
int code = 0;
String message = null;
int code = 0;
String message = null;
public ApiException() {}
public ApiException() {}
public ApiException(int code, String message) {
this.code = code;
this.message = message;
}
public ApiException(int code, String message) {
this.code = code;
this.message = message;
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}

View File

@@ -52,345 +52,338 @@ import javax.net.ssl.X509TrustManager;
import com.google.gson.JsonParseException;
public class ApiInvoker {
private static ApiInvoker INSTANCE = new ApiInvoker();
private Map
<String, String> defaultHeaderMap = new HashMap
<String, String>();
private static ApiInvoker INSTANCE = new ApiInvoker();
private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
private HttpClient client = null;
private HttpClient client = null;
private boolean ignoreSSLCertificates = false;
private boolean ignoreSSLCertificates = false;
private ClientConnectionManager ignoreSSLConnectionManager;
private ClientConnectionManager ignoreSSLConnectionManager;
/** Content type "text/plain" with UTF-8 encoding. */
public static final ContentType TEXT_PLAIN_UTF8 = ContentType.create("text/plain", Consts.UTF_8);
/** Content type "text/plain" with UTF-8 encoding. */
public static final ContentType TEXT_PLAIN_UTF8 = ContentType.create("text/plain", Consts.UTF_8);
/**
* ISO 8601 date time format.
* @see https://en.wikipedia.org/wiki/ISO_8601
*/
public static final SimpleDateFormat DATE_TIME_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
/**
* ISO 8601 date time format.
* @see https://en.wikipedia.org/wiki/ISO_8601
*/
public static final SimpleDateFormat DATE_TIME_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
/**
* ISO 8601 date format.
* @see https://en.wikipedia.org/wiki/ISO_8601
*/
public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd");
/**
* ISO 8601 date format.
* @see https://en.wikipedia.org/wiki/ISO_8601
*/
public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd");
static {
// Use UTC as the default time zone.
DATE_TIME_FORMAT.setTimeZone(TimeZone.getTimeZone("UTC"));
DATE_FORMAT.setTimeZone(TimeZone.getTimeZone("UTC"));
static {
// Use UTC as the default time zone.
DATE_TIME_FORMAT.setTimeZone(TimeZone.getTimeZone("UTC"));
DATE_FORMAT.setTimeZone(TimeZone.getTimeZone("UTC"));
// Set default User-Agent.
setUserAgent("Android-Java-Swagger");
}
// Set default User-Agent.
setUserAgent("Android-Java-Swagger");
}
public static void setUserAgent(String userAgent) {
INSTANCE.addDefaultHeader("User-Agent", userAgent);
}
public static void setUserAgent(String userAgent) {
INSTANCE.addDefaultHeader("User-Agent", userAgent);
}
public static Date parseDateTime(String str) {
try {
return DATE_TIME_FORMAT.parse(str);
} catch (java.text.ParseException e) {
throw new RuntimeException(e);
}
}
public static Date parseDateTime(String str) {
try {
return DATE_TIME_FORMAT.parse(str);
} catch (java.text.ParseException e) {
throw new RuntimeException(e);
}
}
public static Date parseDate(String str) {
try {
return DATE_FORMAT.parse(str);
} catch (java.text.ParseException e) {
throw new RuntimeException(e);
}
}
public static Date parseDate(String str) {
try {
return DATE_FORMAT.parse(str);
} catch (java.text.ParseException e) {
throw new RuntimeException(e);
}
}
public static String formatDateTime(Date datetime) {
return DATE_TIME_FORMAT.format(datetime);
}
public static String formatDateTime(Date datetime) {
return DATE_TIME_FORMAT.format(datetime);
}
public static String formatDate(Date date) {
return DATE_FORMAT.format(date);
}
public static String formatDate(Date date) {
return DATE_FORMAT.format(date);
}
public static String parameterToString(Object param) {
if (param == null) {
return "";
} else if (param instanceof Date) {
return formatDateTime((Date) param);
} else if (param instanceof Collection) {
StringBuilder b = new StringBuilder();
for(Object o : (Collection)param) {
if(b.length() > 0) {
b.append(",");
}
b.append(String.valueOf(o));
}
return b.toString();
} else {
return String.valueOf(param);
}
}
public static String parameterToString(Object param) {
if (param == null) {
return "";
} else if (param instanceof Date) {
return formatDateTime((Date) param);
} else if (param instanceof Collection) {
StringBuilder b = new StringBuilder();
for(Object o : (Collection)param) {
if(b.length() > 0) {
b.append(",");
}
b.append(String.valueOf(o));
}
return b.toString();
} else {
return String.valueOf(param);
}
}
public ApiInvoker() {
initConnectionManager();
}
public ApiInvoker() {
initConnectionManager();
}
public static ApiInvoker getInstance() {
return INSTANCE;
}
public static ApiInvoker getInstance() {
return INSTANCE;
}
public void ignoreSSLCertificates(boolean ignoreSSLCertificates) {
this.ignoreSSLCertificates = ignoreSSLCertificates;
}
public void ignoreSSLCertificates(boolean ignoreSSLCertificates) {
this.ignoreSSLCertificates = ignoreSSLCertificates;
}
public void addDefaultHeader(String key, String value) {
defaultHeaderMap.put(key, value);
}
public void addDefaultHeader(String key, String value) {
defaultHeaderMap.put(key, value);
}
public String escapeString(String str) {
return str;
}
public String escapeString(String str) {
return str;
}
public static Object deserialize(String json, String containerType, Class cls) throws ApiException {
try{
if("list".equalsIgnoreCase(containerType) || "array".equalsIgnoreCase(containerType)) {
return JsonUtil.deserializeToList(json, cls);
}
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.deserializeToObject(json, cls);
}
}
catch (JsonParseException e) {
throw new ApiException(500, e.getMessage());
}
}
public static Object deserialize(String json, String containerType, Class cls) throws ApiException {
try{
if("list".equalsIgnoreCase(containerType) || "array".equalsIgnoreCase(containerType)) {
return JsonUtil.deserializeToList(json, cls);
}
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.deserializeToObject(json, cls);
}
}
catch (JsonParseException e) {
throw new ApiException(500, e.getMessage());
}
}
public static String serialize(Object obj) throws ApiException {
try {
if (obj != null)
return JsonUtil.serialize(obj);
else
return null;
}
catch (Exception e) {
throw new ApiException(500, e.getMessage());
}
}
public static String serialize(Object obj) throws ApiException {
try {
if (obj != null)
return JsonUtil.serialize(obj);
else
return null;
}
catch (Exception e) {
throw new ApiException(500, e.getMessage());
}
}
public String invokeAPI(String host, String path, String method, Map
<String, String> queryParams, Object body, Map
<String, String> headerParams, Map
<String, String> formParams, String contentType) throws ApiException {
HttpClient client = getClient(host);
public String invokeAPI(String host, String path, String method, Map<String, String> queryParams, Object body, Map<String, String> headerParams, Map<String, String> formParams, String contentType) throws ApiException {
HttpClient client = getClient(host);
StringBuilder b = new StringBuilder();
for(String key : queryParams.keySet()) {
String value = queryParams.get(key);
if (value != null){
if(b.toString().length() == 0)
b.append("?");
else
b.append("&");
b.append(escapeString(key)).append("=").append(escapeString(value));
}
}
String url = host + path + b.toString();
StringBuilder b = new StringBuilder();
for(String key : queryParams.keySet()) {
String value = queryParams.get(key);
if (value != null){
if(b.toString().length() == 0)
b.append("?");
else
b.append("&");
b.append(escapeString(key)).append("=").append(escapeString(value));
}
}
String url = host + path + b.toString();
HashMap
<String, String> headers = new HashMap
<String, String>();
HashMap<String, String> headers = new HashMap<String, String>();
for(String key : headerParams.keySet()) {
headers.put(key, headerParams.get(key));
}
for(String key : headerParams.keySet()) {
headers.put(key, headerParams.get(key));
}
for(String key : defaultHeaderMap.keySet()) {
if(!headerParams.containsKey(key)) {
headers.put(key, defaultHeaderMap.get(key));
}
}
headers.put("Accept", "application/json");
for(String key : defaultHeaderMap.keySet()) {
if(!headerParams.containsKey(key)) {
headers.put(key, defaultHeaderMap.get(key));
}
}
headers.put("Accept", "application/json");
// URL encoded string from form parameters
String formParamStr = null;
// URL encoded string from form parameters
String formParamStr = null;
// for form data
if ("application/x-www-form-urlencoded".equals(contentType)) {
StringBuilder formParamBuilder = new StringBuilder();
// for form data
if ("application/x-www-form-urlencoded".equals(contentType)) {
StringBuilder formParamBuilder = new StringBuilder();
// encode the form params
for (String key : formParams.keySet()) {
String value = formParams.get(key);
if (value != null && !"".equals(value.trim())) {
if (formParamBuilder.length() > 0) {
formParamBuilder.append("&");
}
try {
formParamBuilder.append(URLEncoder.encode(key, "utf8")).append("=").append(URLEncoder.encode(value, "utf8"));
}
catch (Exception e) {
// move on to next
}
}
}
formParamStr = formParamBuilder.toString();
}
// encode the form params
for (String key : formParams.keySet()) {
String value = formParams.get(key);
if (value != null && !"".equals(value.trim())) {
if (formParamBuilder.length() > 0) {
formParamBuilder.append("&");
}
try {
formParamBuilder.append(URLEncoder.encode(key, "utf8")).append("=").append(URLEncoder.encode(value, "utf8"));
}
catch (Exception e) {
// move on to next
}
}
}
formParamStr = formParamBuilder.toString();
}
HttpResponse response = null;
try {
if ("GET".equals(method)) {
HttpGet get = new HttpGet(url);
get.addHeader("Accept", "application/json");
for(String key : headers.keySet()) {
get.setHeader(key, headers.get(key));
}
response = client.execute(get);
}
else if ("POST".equals(method)) {
HttpPost post = new HttpPost(url);
if (formParamStr != null) {
post.setHeader("Content-Type", contentType);
post.setEntity(new StringEntity(formParamStr, "UTF-8"));
} else if (body != null) {
if (body instanceof HttpEntity) {
// this is for file uploading
post.setEntity((HttpEntity) body);
} else {
post.setHeader("Content-Type", contentType);
post.setEntity(new StringEntity(serialize(body), "UTF-8"));
}
}
for(String key : headers.keySet()) {
post.setHeader(key, headers.get(key));
}
response = client.execute(post);
}
else if ("PUT".equals(method)) {
HttpPut put = new HttpPut(url);
if (formParamStr != null) {
put.setHeader("Content-Type", contentType);
put.setEntity(new StringEntity(formParamStr, "UTF-8"));
} else if (body != null) {
put.setHeader("Content-Type", contentType);
put.setEntity(new StringEntity(serialize(body), "UTF-8"));
}
for(String key : headers.keySet()) {
put.setHeader(key, headers.get(key));
}
response = client.execute(put);
}
else if ("DELETE".equals(method)) {
HttpDelete delete = new HttpDelete(url);
for(String key : headers.keySet()) {
delete.setHeader(key, headers.get(key));
}
response = client.execute(delete);
}
else if ("PATCH".equals(method)) {
HttpPatch patch = new HttpPatch(url);
if (formParamStr != null) {
patch.setHeader("Content-Type", contentType);
patch.setEntity(new StringEntity(formParamStr, "UTF-8"));
} else if (body != null) {
patch.setHeader("Content-Type", contentType);
patch.setEntity(new StringEntity(serialize(body), "UTF-8"));
}
for(String key : headers.keySet()) {
patch.setHeader(key, headers.get(key));
}
response = client.execute(patch);
}
HttpResponse response = null;
try {
if ("GET".equals(method)) {
HttpGet get = new HttpGet(url);
get.addHeader("Accept", "application/json");
for(String key : headers.keySet()) {
get.setHeader(key, headers.get(key));
}
response = client.execute(get);
}
else if ("POST".equals(method)) {
HttpPost post = new HttpPost(url);
if (formParamStr != null) {
post.setHeader("Content-Type", contentType);
post.setEntity(new StringEntity(formParamStr, "UTF-8"));
} else if (body != null) {
if (body instanceof HttpEntity) {
// this is for file uploading
post.setEntity((HttpEntity) body);
} else {
post.setHeader("Content-Type", contentType);
post.setEntity(new StringEntity(serialize(body), "UTF-8"));
}
}
for(String key : headers.keySet()) {
post.setHeader(key, headers.get(key));
}
response = client.execute(post);
}
else if ("PUT".equals(method)) {
HttpPut put = new HttpPut(url);
if (formParamStr != null) {
put.setHeader("Content-Type", contentType);
put.setEntity(new StringEntity(formParamStr, "UTF-8"));
} else if (body != null) {
put.setHeader("Content-Type", contentType);
put.setEntity(new StringEntity(serialize(body), "UTF-8"));
}
for(String key : headers.keySet()) {
put.setHeader(key, headers.get(key));
}
response = client.execute(put);
}
else if ("DELETE".equals(method)) {
HttpDelete delete = new HttpDelete(url);
for(String key : headers.keySet()) {
delete.setHeader(key, headers.get(key));
}
response = client.execute(delete);
}
else if ("PATCH".equals(method)) {
HttpPatch patch = new HttpPatch(url);
if (formParamStr != null) {
patch.setHeader("Content-Type", contentType);
patch.setEntity(new StringEntity(formParamStr, "UTF-8"));
} else if (body != null) {
patch.setHeader("Content-Type", contentType);
patch.setEntity(new StringEntity(serialize(body), "UTF-8"));
}
for(String key : headers.keySet()) {
patch.setHeader(key, headers.get(key));
}
response = client.execute(patch);
}
int code = response.getStatusLine().getStatusCode();
String responseString = null;
if(code == 204)
responseString = "";
else if(code >= 200 && code < 300) {
if(response.getEntity() != null) {
HttpEntity resEntity = response.getEntity();
responseString = EntityUtils.toString(resEntity);
}
return responseString;
}
else {
if(response.getEntity() != null) {
HttpEntity resEntity = response.getEntity();
responseString = EntityUtils.toString(resEntity);
}
else
responseString = "no data";
}
throw new ApiException(code, responseString);
}
catch(IOException e) {
throw new ApiException(500, e.getMessage());
}
}
int code = response.getStatusLine().getStatusCode();
String responseString = null;
if(code == 204)
responseString = "";
else if(code >= 200 && code < 300) {
if(response.getEntity() != null) {
HttpEntity resEntity = response.getEntity();
responseString = EntityUtils.toString(resEntity);
}
return responseString;
}
else {
if(response.getEntity() != null) {
HttpEntity resEntity = response.getEntity();
responseString = EntityUtils.toString(resEntity);
}
else
responseString = "no data";
}
throw new ApiException(code, responseString);
}
catch(IOException e) {
throw new ApiException(500, e.getMessage());
}
}
private HttpClient getClient(String host) {
if (client == null) {
if (ignoreSSLCertificates && ignoreSSLConnectionManager != null) {
// Trust self signed certificates
client = new DefaultHttpClient(ignoreSSLConnectionManager, new BasicHttpParams());
} else {
client = new DefaultHttpClient();
}
}
return client;
}
private HttpClient getClient(String host) {
if (client == null) {
if (ignoreSSLCertificates && ignoreSSLConnectionManager != null) {
// Trust self signed certificates
client = new DefaultHttpClient(ignoreSSLConnectionManager, new BasicHttpParams());
} else {
client = new DefaultHttpClient();
}
}
return client;
}
private void initConnectionManager() {
try {
final SSLContext sslContext = SSLContext.getInstance("SSL");
private void initConnectionManager() {
try {
final SSLContext sslContext = SSLContext.getInstance("SSL");
// set up a TrustManager that trusts everything
TrustManager[] trustManagers = new TrustManager[] {
new X509TrustManager() {
public X509Certificate[] getAcceptedIssuers() {
return null;
}
public void checkClientTrusted(X509Certificate[] certs, String authType) {}
public void checkServerTrusted(X509Certificate[] certs, String authType) {}
}};
sslContext.init(null, trustManagers, new SecureRandom());
SSLSocketFactory sf = new SSLSocketFactory((KeyStore)null) {
private javax.net.ssl.SSLSocketFactory sslFactory = sslContext.getSocketFactory();
public Socket createSocket(Socket socket, String host, int port, boolean autoClose)
throws IOException, UnknownHostException {
return sslFactory.createSocket(socket, host, port, autoClose);
}
public Socket createSocket() throws IOException {
return sslFactory.createSocket();
}
};
sf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
Scheme httpsScheme = new Scheme("https", sf, 443);
SchemeRegistry schemeRegistry = new SchemeRegistry();
schemeRegistry.register(httpsScheme);
schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
ignoreSSLConnectionManager = new ThreadSafeClientConnManager(new BasicHttpParams(), schemeRegistry);
} catch (NoSuchAlgorithmException e) {
// This will only be thrown if SSL isn't available for some reason.
} catch (KeyManagementException e) {
// This might be thrown when passing a key into init(), but no key is being passed.
} catch (GeneralSecurityException e) {
// This catches anything else that might go wrong.
// If anything goes wrong we default to the standard connection manager.
}
}
// set up a TrustManager that trusts everything
TrustManager[] trustManagers = new TrustManager[] {
new X509TrustManager() {
public X509Certificate[] getAcceptedIssuers() {
return null;
}
public void checkClientTrusted(X509Certificate[] certs, String authType) {}
public void checkServerTrusted(X509Certificate[] certs, String authType) {}
}};
sslContext.init(null, trustManagers, new SecureRandom());
SSLSocketFactory sf = new SSLSocketFactory((KeyStore)null) {
private javax.net.ssl.SSLSocketFactory sslFactory = sslContext.getSocketFactory();
public Socket createSocket(Socket socket, String host, int port, boolean autoClose)
throws IOException, UnknownHostException {
return sslFactory.createSocket(socket, host, port, autoClose);
}
public Socket createSocket() throws IOException {
return sslFactory.createSocket();
}
};
sf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
Scheme httpsScheme = new Scheme("https", sf, 443);
SchemeRegistry schemeRegistry = new SchemeRegistry();
schemeRegistry.register(httpsScheme);
schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
ignoreSSLConnectionManager = new ThreadSafeClientConnManager(new BasicHttpParams(), schemeRegistry);
} catch (NoSuchAlgorithmException e) {
// This will only be thrown if SSL isn't available for some reason.
} catch (KeyManagementException e) {
// This might be thrown when passing a key into init(), but no key is being passed.
} catch (GeneralSecurityException e) {
// This catches anything else that might go wrong.
// If anything goes wrong we default to the standard connection manager.
}
}
}

View File

@@ -3,14 +3,14 @@ package io.swagger.client;
import org.apache.http.client.methods.*;
public class HttpPatch extends HttpPost {
public static final String METHOD_PATCH = "PATCH";
public static final String METHOD_PATCH = "PATCH";
public HttpPatch(final String url) {
super(url);
}
public HttpPatch(final String url) {
super(url);
}
@Override
public String getMethod() {
return METHOD_PATCH;
}
@Override
public String getMethod() {
return METHOD_PATCH;
}
}

View File

@@ -8,95 +8,80 @@ import java.util.List;
import io.swagger.client.model.*;
public class JsonUtil {
public static GsonBuilder gsonBuilder;
public static GsonBuilder gsonBuilder;
static {
gsonBuilder = new GsonBuilder();
gsonBuilder.serializeNulls();
gsonBuilder.setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
}
static {
gsonBuilder = new GsonBuilder();
gsonBuilder.serializeNulls();
gsonBuilder.setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
}
public static Gson getGson() {
return gsonBuilder.create();
}
public static Gson getGson() {
return gsonBuilder.create();
}
public static String serialize(Object obj){
return getGson().toJson(obj);
}
public static String serialize(Object obj){
return getGson().toJson(obj);
}
public static
<T> T deserializeToList(String jsonString, Class cls){
public static <T> T deserializeToList(String jsonString, Class cls){
return getGson().fromJson(jsonString, getListTypeForDeserialization(cls));
}
public static <T> T deserializeToObject(String jsonString, Class cls){
return getGson().fromJson(jsonString, getTypeForDeserialization(cls));
}
public static Type getListTypeForDeserialization(Class cls) {
String className = cls.getSimpleName();
if ("User".equalsIgnoreCase(className)) {
return new TypeToken<List<User>>(){}.getType();
}
if ("Category".equalsIgnoreCase(className)) {
return new TypeToken<List<Category>>(){}.getType();
}
if ("Pet".equalsIgnoreCase(className)) {
return new TypeToken<List<Pet>>(){}.getType();
}
if ("Tag".equalsIgnoreCase(className)) {
return new TypeToken<List<Tag>>(){}.getType();
}
if ("Order".equalsIgnoreCase(className)) {
return new TypeToken<List<Order>>(){}.getType();
}
return new TypeToken<List<Object>>(){}.getType();
}
public static
<T> T deserializeToObject(String jsonString, Class cls){
return getGson().fromJson(jsonString, getTypeForDeserialization(cls));
}
public static Type getTypeForDeserialization(Class cls) {
String className = cls.getSimpleName();
if ("User".equalsIgnoreCase(className)) {
return new TypeToken<User>(){}.getType();
}
if ("Category".equalsIgnoreCase(className)) {
return new TypeToken<Category>(){}.getType();
}
if ("Pet".equalsIgnoreCase(className)) {
return new TypeToken<Pet>(){}.getType();
}
if ("Tag".equalsIgnoreCase(className)) {
return new TypeToken<Tag>(){}.getType();
}
if ("Order".equalsIgnoreCase(className)) {
return new TypeToken<Order>(){}.getType();
}
return new TypeToken<Object>(){}.getType();
}
public static Type getListTypeForDeserialization(Class cls) {
String className = cls.getSimpleName();
if ("User".equalsIgnoreCase(className)) {
return new TypeToken
<List
<User>>(){}.getType();
}
if ("Category".equalsIgnoreCase(className)) {
return new TypeToken
<List
<Category>>(){}.getType();
}
if ("Pet".equalsIgnoreCase(className)) {
return new TypeToken
<List
<Pet>>(){}.getType();
}
if ("Tag".equalsIgnoreCase(className)) {
return new TypeToken
<List
<Tag>>(){}.getType();
}
if ("Order".equalsIgnoreCase(className)) {
return new TypeToken
<List
<Order>>(){}.getType();
}
return new TypeToken
<List
<Object>>(){}.getType();
}
public static Type getTypeForDeserialization(Class cls) {
String className = cls.getSimpleName();
if ("User".equalsIgnoreCase(className)) {
return new TypeToken<User>(){}.getType();
}
if ("Category".equalsIgnoreCase(className)) {
return new TypeToken<Category>(){}.getType();
}
if ("Pet".equalsIgnoreCase(className)) {
return new TypeToken<Pet>(){}.getType();
}
if ("Tag".equalsIgnoreCase(className)) {
return new TypeToken<Tag>(){}.getType();
}
if ("Order".equalsIgnoreCase(className)) {
return new TypeToken<Order>(){}.getType();
}
return new TypeToken
<Object>(){}.getType();
}
};
};

View File

@@ -17,274 +17,250 @@ import java.util.Map;
import java.util.HashMap;
import java.io.File;
public class StoreApi {
String basePath = "http://petstore.swagger.io/v2";
ApiInvoker apiInvoker = ApiInvoker.getInstance();
public class StoreApi {
String basePath = "http://petstore.swagger.io/v2";
ApiInvoker apiInvoker = ApiInvoker.getInstance();
public void addHeader(String key, String value) {
public void addHeader(String key, String value) {
getInvoker().addDefaultHeader(key, value);
}
}
public ApiInvoker getInvoker() {
public ApiInvoker getInvoker() {
return apiInvoker;
}
}
public void setBasePath(String basePath) {
public void setBasePath(String basePath) {
this.basePath = basePath;
}
}
public String getBasePath() {
public String getBasePath() {
return basePath;
}
}
/**
* Returns pet inventories by status
* Returns a map of status codes to quantities
* @return Map<String, Integer>
*/
public Map<String, Integer> getInventory () throws ApiException {
Object postBody = null;
// create path and map variables
String path = "/store/inventory".replaceAll("\\{format\\}","json");
// query params
Map<String, String> queryParams = new HashMap<String, String>();
// header params
Map<String, String> headerParams = new HashMap<String, String>();
// form params
Map<String, String> formParams = new HashMap<String, String>();
/**
* Returns pet inventories by status
* Returns a map of status codes to quantities
* @return Map<String, Integer>
*/
public Map<String, Integer> getInventory () throws ApiException {
Object postBody = null;
// create path and map variables
String path = "/store/inventory".replaceAll("\\{format\\}","json");
// query params
Map
<String, String> queryParams = new HashMap
<String, String>();
// header params
Map
<String, String> headerParams = new HashMap
<String, String>();
// form params
Map
<String, String> formParams = new HashMap
<String, String>();
String[] contentTypes = {
};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if (contentType.startsWith("multipart/form-data")) {
// file uploading
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
HttpEntity httpEntity = builder.build();
postBody = httpEntity;
} else {
// normal form params
}
String[] contentTypes = {
};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if (contentType.startsWith("multipart/form-data")) {
// file uploading
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
HttpEntity httpEntity = builder.build();
postBody = httpEntity;
} else {
// normal form params
}
try {
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType);
if(response != null){
try {
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType);
if(response != null){
return (Map<String, Integer>) ApiInvoker.deserialize(response, "map", Map.class);
}
else {
}
else {
return null;
}
} catch (ApiException ex) {
throw ex;
}
}
/**
* Place an order for a pet
*
* @param body order placed for purchasing the pet
* @return Order
*/
public Order placeOrder (Order body) throws ApiException {
Object postBody = body;
// create path and map variables
String path = "/store/order".replaceAll("\\{format\\}","json");
// query params
Map
<String, String> queryParams = new HashMap
<String, String>();
// header params
Map
<String, String> headerParams = new HashMap
<String, String>();
// form params
Map
<String, String> formParams = new HashMap
<String, String>();
String[] contentTypes = {
};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if (contentType.startsWith("multipart/form-data")) {
// file uploading
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
HttpEntity httpEntity = builder.build();
postBody = httpEntity;
} else {
// normal form params
}
try {
String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, postBody, headerParams, formParams, contentType);
if(response != null){
return (Order) ApiInvoker.deserialize(response, "", Order.class);
}
else {
return null;
}
} catch (ApiException ex) {
throw ex;
}
}
/**
* Find purchase order by ID
* For valid response try integer IDs with value &lt;= 5 or &gt; 10. Other values will generated exceptions
* @param orderId ID of pet that needs to be fetched
* @return Order
*/
public Order getOrderById (String orderId) throws ApiException {
Object postBody = 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" + "\\}", apiInvoker.escapeString(orderId.toString()));
// query params
Map
<String, String> queryParams = new HashMap
<String, String>();
// header params
Map
<String, String> headerParams = new HashMap
<String, String>();
// form params
Map
<String, String> formParams = new HashMap
<String, String>();
String[] contentTypes = {
};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if (contentType.startsWith("multipart/form-data")) {
// file uploading
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
HttpEntity httpEntity = builder.build();
postBody = httpEntity;
} else {
// normal form params
}
try {
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType);
if(response != null){
return (Order) ApiInvoker.deserialize(response, "", Order.class);
}
else {
return null;
}
} catch (ApiException ex) {
throw ex;
}
}
/**
* Delete purchase order by ID
* For valid response try integer IDs with value &lt; 1000. Anything above 1000 or nonintegers will generate API errors
* @param orderId ID of the order that needs to be deleted
* @return void
*/
public void deleteOrder (String orderId) throws ApiException {
Object postBody = 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" + "\\}", apiInvoker.escapeString(orderId.toString()));
// query params
Map
<String, String> queryParams = new HashMap
<String, String>();
// header params
Map
<String, String> headerParams = new HashMap
<String, String>();
// form params
Map
<String, String> formParams = new HashMap
<String, String>();
String[] contentTypes = {
};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if (contentType.startsWith("multipart/form-data")) {
// file uploading
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
HttpEntity httpEntity = builder.build();
postBody = httpEntity;
} else {
// normal form params
}
try {
String response = apiInvoker.invokeAPI(basePath, path, "DELETE", queryParams, postBody, headerParams, formParams, contentType);
if(response != null){
return ;
}
else {
return ;
}
} catch (ApiException ex) {
throw ex;
}
}
}
} catch (ApiException ex) {
throw ex;
}
}
/**
* Place an order for a pet
*
* @param body order placed for purchasing the pet
* @return Order
*/
public Order placeOrder (Order body) throws ApiException {
Object postBody = body;
// create path and map variables
String path = "/store/order".replaceAll("\\{format\\}","json");
// query params
Map<String, String> queryParams = new HashMap<String, String>();
// header params
Map<String, String> headerParams = new HashMap<String, String>();
// form params
Map<String, String> formParams = new HashMap<String, String>();
String[] contentTypes = {
};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if (contentType.startsWith("multipart/form-data")) {
// file uploading
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
HttpEntity httpEntity = builder.build();
postBody = httpEntity;
} else {
// normal form params
}
try {
String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, postBody, headerParams, formParams, contentType);
if(response != null){
return (Order) ApiInvoker.deserialize(response, "", Order.class);
}
else {
return null;
}
} catch (ApiException ex) {
throw ex;
}
}
/**
* Find purchase order by ID
* For valid response try integer IDs with value &lt;= 5 or &gt; 10. Other values will generated exceptions
* @param orderId ID of pet that needs to be fetched
* @return Order
*/
public Order getOrderById (String orderId) throws ApiException {
Object postBody = 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" + "\\}", apiInvoker.escapeString(orderId.toString()));
// query params
Map<String, String> queryParams = new HashMap<String, String>();
// header params
Map<String, String> headerParams = new HashMap<String, String>();
// form params
Map<String, String> formParams = new HashMap<String, String>();
String[] contentTypes = {
};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if (contentType.startsWith("multipart/form-data")) {
// file uploading
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
HttpEntity httpEntity = builder.build();
postBody = httpEntity;
} else {
// normal form params
}
try {
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType);
if(response != null){
return (Order) ApiInvoker.deserialize(response, "", Order.class);
}
else {
return null;
}
} catch (ApiException ex) {
throw ex;
}
}
/**
* Delete purchase order by ID
* For valid response try integer IDs with value &lt; 1000. Anything above 1000 or nonintegers will generate API errors
* @param orderId ID of the order that needs to be deleted
* @return void
*/
public void deleteOrder (String orderId) throws ApiException {
Object postBody = 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" + "\\}", apiInvoker.escapeString(orderId.toString()));
// query params
Map<String, String> queryParams = new HashMap<String, String>();
// header params
Map<String, String> headerParams = new HashMap<String, String>();
// form params
Map<String, String> formParams = new HashMap<String, String>();
String[] contentTypes = {
};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if (contentType.startsWith("multipart/form-data")) {
// file uploading
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
HttpEntity httpEntity = builder.build();
postBody = httpEntity;
} else {
// normal form params
}
try {
String response = apiInvoker.invokeAPI(basePath, path, "DELETE", queryParams, postBody, headerParams, formParams, contentType);
if(response != null){
return ;
}
else {
return ;
}
} catch (ApiException ex) {
throw ex;
}
}
}

View File

@@ -17,525 +17,477 @@ import java.util.Map;
import java.util.HashMap;
import java.io.File;
public class UserApi {
String basePath = "http://petstore.swagger.io/v2";
ApiInvoker apiInvoker = ApiInvoker.getInstance();
public class UserApi {
String basePath = "http://petstore.swagger.io/v2";
ApiInvoker apiInvoker = ApiInvoker.getInstance();
public void addHeader(String key, String value) {
public void addHeader(String key, String value) {
getInvoker().addDefaultHeader(key, value);
}
}
public ApiInvoker getInvoker() {
public ApiInvoker getInvoker() {
return apiInvoker;
}
}
public void setBasePath(String basePath) {
public void setBasePath(String basePath) {
this.basePath = basePath;
}
}
public String getBasePath() {
public String getBasePath() {
return basePath;
}
/**
* Create user
* This can only be done by the logged in user.
* @param body Created user object
* @return void
*/
public void createUser (User body) throws ApiException {
Object postBody = body;
// create path and map variables
String path = "/user".replaceAll("\\{format\\}","json");
// query params
Map<String, String> queryParams = new HashMap<String, String>();
// header params
Map<String, String> headerParams = new HashMap<String, String>();
// form params
Map<String, String> formParams = new HashMap<String, String>();
String[] contentTypes = {
};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if (contentType.startsWith("multipart/form-data")) {
// file uploading
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
HttpEntity httpEntity = builder.build();
postBody = httpEntity;
} else {
// normal form params
}
try {
String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, postBody, headerParams, formParams, contentType);
if(response != null){
return ;
}
else {
return ;
}
} catch (ApiException ex) {
throw ex;
}
}
/**
* Creates list of users with given input array
*
* @param body List of user object
* @return void
*/
public void createUsersWithArrayInput (List<User> body) throws ApiException {
Object postBody = body;
/**
* Create user
* This can only be done by the logged in user.
* @param body Created user object
* @return void
*/
public void createUser (User body) throws ApiException {
Object postBody = body;
// create path and map variables
String path = "/user".replaceAll("\\{format\\}","json");
// create path and map variables
String path = "/user/createWithArray".replaceAll("\\{format\\}","json");
// query params
Map
<String, String> queryParams = new HashMap
<String, String>();
// header params
Map
<String, String> headerParams = new HashMap
<String, String>();
// form params
Map
<String, String> formParams = new HashMap
<String, String>();
// query params
Map<String, String> queryParams = new HashMap<String, String>();
// header params
Map<String, String> headerParams = new HashMap<String, String>();
// form params
Map<String, String> formParams = new HashMap<String, String>();
String[] contentTypes = {
};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if (contentType.startsWith("multipart/form-data")) {
// file uploading
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
HttpEntity httpEntity = builder.build();
postBody = httpEntity;
} else {
// normal form params
}
try {
String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, postBody, headerParams, formParams, contentType);
if(response != null){
return ;
}
else {
return ;
}
} catch (ApiException ex) {
throw ex;
}
}
/**
* Creates list of users with given input array
*
* @param body List of user object
* @return void
*/
public void createUsersWithArrayInput (List<User> body) throws ApiException {
Object postBody = body;
// create path and map variables
String path = "/user/createWithArray".replaceAll("\\{format\\}","json");
// query params
Map
<String, String> queryParams = new HashMap
<String, String>();
// header params
Map
<String, String> headerParams = new HashMap
<String, String>();
// form params
Map
<String, String> formParams = new HashMap
<String, String>();
String[] contentTypes = {
};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if (contentType.startsWith("multipart/form-data")) {
// file uploading
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
HttpEntity httpEntity = builder.build();
postBody = httpEntity;
} else {
// normal form params
}
try {
String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, postBody, headerParams, formParams, contentType);
if(response != null){
return ;
}
else {
return ;
}
} catch (ApiException ex) {
throw ex;
}
}
/**
* Creates list of users with given input array
*
* @param body List of user object
* @return void
*/
public void createUsersWithListInput (List<User> body) throws ApiException {
Object postBody = body;
// create path and map variables
String path = "/user/createWithList".replaceAll("\\{format\\}","json");
String[] contentTypes = {
};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
// query params
Map
<String, String> queryParams = new HashMap
<String, String>();
// header params
Map
<String, String> headerParams = new HashMap
<String, String>();
// form params
Map
<String, String> formParams = new HashMap
<String, String>();
if (contentType.startsWith("multipart/form-data")) {
// file uploading
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
HttpEntity httpEntity = builder.build();
postBody = httpEntity;
} else {
// normal form params
}
String[] contentTypes = {
};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if (contentType.startsWith("multipart/form-data")) {
// file uploading
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
HttpEntity httpEntity = builder.build();
postBody = httpEntity;
} else {
// normal form params
}
try {
String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, postBody, headerParams, formParams, contentType);
if(response != null){
try {
String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, postBody, headerParams, formParams, contentType);
if(response != null){
return ;
}
else {
}
else {
return ;
}
} catch (ApiException ex) {
throw ex;
}
}
}
} catch (ApiException ex) {
throw ex;
}
}
/**
* Creates list of users with given input array
*
* @param body List of user object
* @return void
*/
public void createUsersWithListInput (List<User> body) throws ApiException {
Object postBody = body;
/**
* Logs user into the system
*
* @param username The user name for login
* @param password The password for login in clear text
* @return String
*/
public String loginUser (String username, String password) throws ApiException {
Object postBody = null;
// create path and map variables
String path = "/user/login".replaceAll("\\{format\\}","json");
// create path and map variables
String path = "/user/createWithList".replaceAll("\\{format\\}","json");
// query params
Map
<String, String> queryParams = new HashMap
<String, String>();
// header params
Map
<String, String> headerParams = new HashMap
<String, String>();
// form params
Map
<String, String> formParams = new HashMap
<String, String>();
// query params
Map<String, String> queryParams = new HashMap<String, String>();
// header params
Map<String, String> headerParams = new HashMap<String, String>();
// form params
Map<String, String> formParams = new HashMap<String, String>();
if (username != null)
queryParams.put("username", ApiInvoker.parameterToString(username));
if (password != null)
queryParams.put("password", ApiInvoker.parameterToString(password));
String[] contentTypes = {
};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
String[] contentTypes = {
};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if (contentType.startsWith("multipart/form-data")) {
// file uploading
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
if (contentType.startsWith("multipart/form-data")) {
// file uploading
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
HttpEntity httpEntity = builder.build();
postBody = httpEntity;
} else {
// normal form params
}
HttpEntity httpEntity = builder.build();
postBody = httpEntity;
} else {
// normal form params
}
try {
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType);
if(response != null){
try {
String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, postBody, headerParams, formParams, contentType);
if(response != null){
return ;
}
else {
return ;
}
} catch (ApiException ex) {
throw ex;
}
}
/**
* Logs user into the system
*
* @param username The user name for login
* @param password The password for login in clear text
* @return String
*/
public String loginUser (String username, String password) throws ApiException {
Object postBody = null;
// create path and map variables
String path = "/user/login".replaceAll("\\{format\\}","json");
// query params
Map<String, String> queryParams = new HashMap<String, String>();
// header params
Map<String, String> headerParams = new HashMap<String, String>();
// form params
Map<String, String> formParams = new HashMap<String, String>();
if (username != null)
queryParams.put("username", ApiInvoker.parameterToString(username));
if (password != null)
queryParams.put("password", ApiInvoker.parameterToString(password));
String[] contentTypes = {
};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if (contentType.startsWith("multipart/form-data")) {
// file uploading
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
HttpEntity httpEntity = builder.build();
postBody = httpEntity;
} else {
// normal form params
}
try {
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType);
if(response != null){
return (String) ApiInvoker.deserialize(response, "", String.class);
}
else {
}
else {
return null;
}
} catch (ApiException ex) {
throw ex;
}
}
/**
* Logs out current logged in user session
*
* @return void
*/
public void logoutUser () throws ApiException {
Object postBody = null;
// create path and map variables
String path = "/user/logout".replaceAll("\\{format\\}","json");
// query params
Map
<String, String> queryParams = new HashMap
<String, String>();
// header params
Map
<String, String> headerParams = new HashMap
<String, String>();
// form params
Map
<String, String> formParams = new HashMap
<String, String>();
String[] contentTypes = {
};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if (contentType.startsWith("multipart/form-data")) {
// file uploading
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
HttpEntity httpEntity = builder.build();
postBody = httpEntity;
} else {
// normal form params
}
try {
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType);
if(response != null){
return ;
}
else {
return ;
}
} catch (ApiException ex) {
throw ex;
}
}
/**
* Get user by user name
*
* @param username The name that needs to be fetched. Use user1 for testing.
* @return User
*/
public User getUserByName (String username) throws ApiException {
Object postBody = 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" + "\\}", apiInvoker.escapeString(username.toString()));
// query params
Map
<String, String> queryParams = new HashMap
<String, String>();
// header params
Map
<String, String> headerParams = new HashMap
<String, String>();
// form params
Map
<String, String> formParams = new HashMap
<String, String>();
String[] contentTypes = {
};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if (contentType.startsWith("multipart/form-data")) {
// file uploading
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
HttpEntity httpEntity = builder.build();
postBody = httpEntity;
} else {
// normal form params
}
try {
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType);
if(response != null){
return (User) ApiInvoker.deserialize(response, "", User.class);
}
else {
return null;
}
} catch (ApiException ex) {
throw ex;
}
}
/**
* Updated user
* This can only be done by the logged in user.
* @param username name that need to be deleted
* @param body Updated user object
* @return void
*/
public void updateUser (String username, User body) throws ApiException {
Object postBody = body;
// 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" + "\\}", apiInvoker.escapeString(username.toString()));
// query params
Map
<String, String> queryParams = new HashMap
<String, String>();
// header params
Map
<String, String> headerParams = new HashMap
<String, String>();
// form params
Map
<String, String> formParams = new HashMap
<String, String>();
String[] contentTypes = {
};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if (contentType.startsWith("multipart/form-data")) {
// file uploading
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
HttpEntity httpEntity = builder.build();
postBody = httpEntity;
} else {
// normal form params
}
try {
String response = apiInvoker.invokeAPI(basePath, path, "PUT", queryParams, postBody, headerParams, formParams, contentType);
if(response != null){
return ;
}
else {
return ;
}
} catch (ApiException ex) {
throw ex;
}
}
/**
* Delete user
* This can only be done by the logged in user.
* @param username The name that needs to be deleted
* @return void
*/
public void deleteUser (String username) throws ApiException {
Object postBody = 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" + "\\}", apiInvoker.escapeString(username.toString()));
// query params
Map
<String, String> queryParams = new HashMap
<String, String>();
// header params
Map
<String, String> headerParams = new HashMap
<String, String>();
// form params
Map
<String, String> formParams = new HashMap
<String, String>();
String[] contentTypes = {
};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if (contentType.startsWith("multipart/form-data")) {
// file uploading
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
HttpEntity httpEntity = builder.build();
postBody = httpEntity;
} else {
// normal form params
}
try {
String response = apiInvoker.invokeAPI(basePath, path, "DELETE", queryParams, postBody, headerParams, formParams, contentType);
if(response != null){
return ;
}
else {
return ;
}
} catch (ApiException ex) {
throw ex;
}
}
}
} catch (ApiException ex) {
throw ex;
}
}
/**
* Logs out current logged in user session
*
* @return void
*/
public void logoutUser () throws ApiException {
Object postBody = null;
// create path and map variables
String path = "/user/logout".replaceAll("\\{format\\}","json");
// query params
Map<String, String> queryParams = new HashMap<String, String>();
// header params
Map<String, String> headerParams = new HashMap<String, String>();
// form params
Map<String, String> formParams = new HashMap<String, String>();
String[] contentTypes = {
};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if (contentType.startsWith("multipart/form-data")) {
// file uploading
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
HttpEntity httpEntity = builder.build();
postBody = httpEntity;
} else {
// normal form params
}
try {
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType);
if(response != null){
return ;
}
else {
return ;
}
} catch (ApiException ex) {
throw ex;
}
}
/**
* Get user by user name
*
* @param username The name that needs to be fetched. Use user1 for testing.
* @return User
*/
public User getUserByName (String username) throws ApiException {
Object postBody = 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" + "\\}", apiInvoker.escapeString(username.toString()));
// query params
Map<String, String> queryParams = new HashMap<String, String>();
// header params
Map<String, String> headerParams = new HashMap<String, String>();
// form params
Map<String, String> formParams = new HashMap<String, String>();
String[] contentTypes = {
};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if (contentType.startsWith("multipart/form-data")) {
// file uploading
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
HttpEntity httpEntity = builder.build();
postBody = httpEntity;
} else {
// normal form params
}
try {
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType);
if(response != null){
return (User) ApiInvoker.deserialize(response, "", User.class);
}
else {
return null;
}
} catch (ApiException ex) {
throw ex;
}
}
/**
* Updated user
* This can only be done by the logged in user.
* @param username name that need to be deleted
* @param body Updated user object
* @return void
*/
public void updateUser (String username, User body) throws ApiException {
Object postBody = body;
// 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" + "\\}", apiInvoker.escapeString(username.toString()));
// query params
Map<String, String> queryParams = new HashMap<String, String>();
// header params
Map<String, String> headerParams = new HashMap<String, String>();
// form params
Map<String, String> formParams = new HashMap<String, String>();
String[] contentTypes = {
};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if (contentType.startsWith("multipart/form-data")) {
// file uploading
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
HttpEntity httpEntity = builder.build();
postBody = httpEntity;
} else {
// normal form params
}
try {
String response = apiInvoker.invokeAPI(basePath, path, "PUT", queryParams, postBody, headerParams, formParams, contentType);
if(response != null){
return ;
}
else {
return ;
}
} catch (ApiException ex) {
throw ex;
}
}
/**
* Delete user
* This can only be done by the logged in user.
* @param username The name that needs to be deleted
* @return void
*/
public void deleteUser (String username) throws ApiException {
Object postBody = 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" + "\\}", apiInvoker.escapeString(username.toString()));
// query params
Map<String, String> queryParams = new HashMap<String, String>();
// header params
Map<String, String> headerParams = new HashMap<String, String>();
// form params
Map<String, String> formParams = new HashMap<String, String>();
String[] contentTypes = {
};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if (contentType.startsWith("multipart/form-data")) {
// file uploading
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
HttpEntity httpEntity = builder.build();
postBody = httpEntity;
} else {
// normal form params
}
try {
String response = apiInvoker.invokeAPI(basePath, path, "DELETE", queryParams, postBody, headerParams, formParams, contentType);
if(response != null){
return ;
}
else {
return ;
}
} catch (ApiException ex) {
throw ex;
}
}
}

View File

@@ -4,41 +4,41 @@ package io.swagger.client.model;
import io.swagger.annotations.*;
import com.google.gson.annotations.SerializedName;
@ApiModel(description = "")
public class Category {
@SerializedName("id")
private Long id = null;
@SerializedName("name")
private String name = null;
/**
**/
@ApiModelProperty(value = "")
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
@ApiModel(description = "")
public class Category {
@SerializedName("id")
private Long id = null;
@SerializedName("name")
private String name = null;
/**
**/
@ApiModelProperty(value = "")
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
/**
**/
@ApiModelProperty(value = "")
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
/**
**/
@ApiModelProperty(value = "")
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public String toString() {
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class Category {\n");
@@ -46,6 +46,5 @@ import com.google.gson.annotations.SerializedName;
sb.append(" name: ").append(name).append("\n");
sb.append("}\n");
return sb.toString();
}
}
}
}

View File

@@ -5,97 +5,97 @@ import java.util.Date;
import io.swagger.annotations.*;
import com.google.gson.annotations.SerializedName;
@ApiModel(description = "")
public class Order {
@SerializedName("id")
private Long id = null;
@SerializedName("petId")
private Long petId = null;
@SerializedName("quantity")
private Integer quantity = null;
@SerializedName("shipDate")
private Date shipDate = null;
public enum StatusEnum {
placed, approved, delivered,
};
@SerializedName("status")
private StatusEnum status = null;
@SerializedName("complete")
private Boolean complete = null;
/**
**/
@ApiModelProperty(value = "")
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
@ApiModel(description = "")
public class Order {
@SerializedName("id")
private Long id = null;
@SerializedName("petId")
private Long petId = null;
@SerializedName("quantity")
private Integer quantity = null;
@SerializedName("shipDate")
private Date shipDate = null;
public enum StatusEnum {
placed, approved, delivered,
};
@SerializedName("status")
private StatusEnum status = null;
@SerializedName("complete")
private Boolean complete = null;
/**
**/
@ApiModelProperty(value = "")
public Long getPetId() {
return petId;
}
public void setPetId(Long petId) {
this.petId = petId;
}
/**
**/
@ApiModelProperty(value = "")
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
/**
**/
@ApiModelProperty(value = "")
public Integer getQuantity() {
return quantity;
}
public void setQuantity(Integer quantity) {
this.quantity = quantity;
}
/**
**/
@ApiModelProperty(value = "")
public Long getPetId() {
return petId;
}
public void setPetId(Long petId) {
this.petId = petId;
}
/**
**/
@ApiModelProperty(value = "")
public Date getShipDate() {
return shipDate;
}
public void setShipDate(Date shipDate) {
this.shipDate = shipDate;
}
/**
**/
@ApiModelProperty(value = "")
public Integer getQuantity() {
return quantity;
}
public void setQuantity(Integer quantity) {
this.quantity = quantity;
}
/**
* Order Status
**/
@ApiModelProperty(value = "Order Status")
public StatusEnum getStatus() {
return status;
}
public void setStatus(StatusEnum status) {
this.status = status;
}
/**
**/
@ApiModelProperty(value = "")
public Date getShipDate() {
return shipDate;
}
public void setShipDate(Date shipDate) {
this.shipDate = shipDate;
}
/**
**/
@ApiModelProperty(value = "")
public Boolean getComplete() {
return complete;
}
public void setComplete(Boolean complete) {
this.complete = complete;
}
/**
* Order Status
**/
@ApiModelProperty(value = "Order Status")
public StatusEnum getStatus() {
return status;
}
public void setStatus(StatusEnum status) {
this.status = status;
}
/**
**/
@ApiModelProperty(value = "")
public Boolean getComplete() {
return complete;
}
public void setComplete(Boolean complete) {
this.complete = complete;
}
@Override
public String toString() {
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class Order {\n");
@@ -107,6 +107,5 @@ import com.google.gson.annotations.SerializedName;
sb.append(" complete: ").append(complete).append("\n");
sb.append("}\n");
return sb.toString();
}
}
}
}

View File

@@ -1,103 +1,103 @@
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.google.gson.annotations.SerializedName;
@ApiModel(description = "")
public class Pet {
@SerializedName("id")
private Long id = null;
@SerializedName("category")
private Category category = null;
@SerializedName("name")
private String name = null;
@SerializedName("photoUrls")
private List<String> photoUrls = new ArrayList<String>() ;
@SerializedName("tags")
private List<Tag> tags = new ArrayList<Tag>() ;
public enum StatusEnum {
available, pending, sold,
};
@SerializedName("status")
private StatusEnum status = null;
/**
**/
@ApiModelProperty(value = "")
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
@ApiModel(description = "")
public class Pet {
@SerializedName("id")
private Long id = null;
@SerializedName("category")
private Category category = null;
@SerializedName("name")
private String name = null;
@SerializedName("photoUrls")
private List<String> photoUrls = new ArrayList<String>() ;
@SerializedName("tags")
private List<Tag> tags = new ArrayList<Tag>() ;
public enum StatusEnum {
available, pending, sold,
};
@SerializedName("status")
private StatusEnum status = null;
/**
**/
@ApiModelProperty(value = "")
public Category getCategory() {
return category;
}
public void setCategory(Category category) {
this.category = category;
}
/**
**/
@ApiModelProperty(value = "")
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
/**
**/
@ApiModelProperty(required = true, value = "")
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
/**
**/
@ApiModelProperty(value = "")
public Category getCategory() {
return category;
}
public void setCategory(Category category) {
this.category = category;
}
/**
**/
@ApiModelProperty(required = true, value = "")
public List<String> getPhotoUrls() {
return photoUrls;
}
public void setPhotoUrls(List<String> photoUrls) {
this.photoUrls = photoUrls;
}
/**
**/
@ApiModelProperty(required = true, value = "")
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
/**
**/
@ApiModelProperty(value = "")
public List<Tag> getTags() {
return tags;
}
public void setTags(List<Tag> tags) {
this.tags = tags;
}
/**
**/
@ApiModelProperty(required = true, value = "")
public List<String> getPhotoUrls() {
return photoUrls;
}
public void setPhotoUrls(List<String> photoUrls) {
this.photoUrls = photoUrls;
}
/**
* pet status in the store
**/
@ApiModelProperty(value = "pet status in the store")
public StatusEnum getStatus() {
return status;
}
public void setStatus(StatusEnum status) {
this.status = status;
}
/**
**/
@ApiModelProperty(value = "")
public List<Tag> getTags() {
return tags;
}
public void setTags(List<Tag> tags) {
this.tags = tags;
}
/**
* pet status in the store
**/
@ApiModelProperty(value = "pet status in the store")
public StatusEnum getStatus() {
return status;
}
public void setStatus(StatusEnum status) {
this.status = status;
}
@Override
public String toString() {
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class Pet {\n");
@@ -109,6 +109,5 @@ import com.google.gson.annotations.SerializedName;
sb.append(" status: ").append(status).append("\n");
sb.append("}\n");
return sb.toString();
}
}
}
}

View File

@@ -4,41 +4,41 @@ package io.swagger.client.model;
import io.swagger.annotations.*;
import com.google.gson.annotations.SerializedName;
@ApiModel(description = "")
public class Tag {
@SerializedName("id")
private Long id = null;
@SerializedName("name")
private String name = null;
/**
**/
@ApiModelProperty(value = "")
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
@ApiModel(description = "")
public class Tag {
@SerializedName("id")
private Long id = null;
@SerializedName("name")
private String name = null;
/**
**/
@ApiModelProperty(value = "")
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
/**
**/
@ApiModelProperty(value = "")
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
/**
**/
@ApiModelProperty(value = "")
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public String toString() {
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class Tag {\n");
@@ -46,6 +46,5 @@ import com.google.gson.annotations.SerializedName;
sb.append(" name: ").append(name).append("\n");
sb.append("}\n");
return sb.toString();
}
}
}
}

View File

@@ -4,120 +4,120 @@ package io.swagger.client.model;
import io.swagger.annotations.*;
import com.google.gson.annotations.SerializedName;
@ApiModel(description = "")
public class User {
@SerializedName("id")
private Long id = null;
@SerializedName("username")
private String username = null;
@SerializedName("firstName")
private String firstName = null;
@SerializedName("lastName")
private String lastName = null;
@SerializedName("email")
private String email = null;
@SerializedName("password")
private String password = null;
@SerializedName("phone")
private String phone = null;
@SerializedName("userStatus")
private Integer userStatus = null;
/**
**/
@ApiModelProperty(value = "")
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
@ApiModel(description = "")
public class User {
@SerializedName("id")
private Long id = null;
@SerializedName("username")
private String username = null;
@SerializedName("firstName")
private String firstName = null;
@SerializedName("lastName")
private String lastName = null;
@SerializedName("email")
private String email = null;
@SerializedName("password")
private String password = null;
@SerializedName("phone")
private String phone = null;
@SerializedName("userStatus")
private Integer userStatus = null;
/**
**/
@ApiModelProperty(value = "")
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
/**
**/
@ApiModelProperty(value = "")
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
/**
**/
@ApiModelProperty(value = "")
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
/**
**/
@ApiModelProperty(value = "")
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
/**
**/
@ApiModelProperty(value = "")
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
/**
**/
@ApiModelProperty(value = "")
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
/**
**/
@ApiModelProperty(value = "")
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
/**
**/
@ApiModelProperty(value = "")
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
/**
**/
@ApiModelProperty(value = "")
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
/**
**/
@ApiModelProperty(value = "")
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
/**
**/
@ApiModelProperty(value = "")
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
/**
**/
@ApiModelProperty(value = "")
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
/**
* User Status
**/
@ApiModelProperty(value = "User Status")
public Integer getUserStatus() {
return userStatus;
}
public void setUserStatus(Integer userStatus) {
this.userStatus = userStatus;
}
/**
**/
@ApiModelProperty(value = "")
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
/**
* User Status
**/
@ApiModelProperty(value = "User Status")
public Integer getUserStatus() {
return userStatus;
}
public void setUserStatus(Integer userStatus) {
this.userStatus = userStatus;
}
@Override
public String toString() {
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class User {\n");
@@ -131,6 +131,5 @@ import com.google.gson.annotations.SerializedName;
sb.append(" userStatus: ").append(userStatus).append("\n");
sb.append("}\n");
return sb.toString();
}
}
}
}