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

@ -3,7 +3,7 @@
<parent> <parent>
<groupId>io.swagger</groupId> <groupId>io.swagger</groupId>
<artifactId>swagger-codegen-project</artifactId> <artifactId>swagger-codegen-project</artifactId>
<version>2.1.1</version> <version>2.1.2</version>
<relativePath>../..</relativePath> <relativePath>../..</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@ -3,7 +3,7 @@
<parent> <parent>
<groupId>io.swagger</groupId> <groupId>io.swagger</groupId>
<artifactId>swagger-codegen-project</artifactId> <artifactId>swagger-codegen-project</artifactId>
<version>2.1.1</version> <version>2.1.2</version>
<relativePath>../..</relativePath> <relativePath>../..</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@ -4,7 +4,7 @@
<parent> <parent>
<groupId>io.swagger</groupId> <groupId>io.swagger</groupId>
<artifactId>swagger-codegen-project</artifactId> <artifactId>swagger-codegen-project</artifactId>
<version>2.1.1</version> <version>2.1.2</version>
<relativePath>../..</relativePath> <relativePath>../..</relativePath>
</parent> </parent>
<artifactId>swagger-generator</artifactId> <artifactId>swagger-generator</artifactId>

View File

@ -10,7 +10,7 @@
<artifactId>swagger-codegen-project</artifactId> <artifactId>swagger-codegen-project</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>swagger-codegen-project</name> <name>swagger-codegen-project</name>
<version>2.1.1</version> <version>2.1.2</version>
<url>https://github.com/swagger-api/swagger-codegen</url> <url>https://github.com/swagger-api/swagger-codegen</url>
<scm> <scm>
<connection>scm:git:git@github.com:swagger-api/swagger-codegen.git</connection> <connection>scm:git:git@github.com:swagger-api/swagger-codegen.git</connection>

View File

@ -1,85 +1,87 @@
group = 'io.swagger' group = 'io.swagger'
project.version = '1.0.0' project.version = '1.0.0'
buildscript { buildscript {
repositories { repositories {
jcenter() jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:1.2.2' classpath 'com.android.tools.build:gradle:1.2.2'
classpath 'com.github.dcendents:android-maven-plugin:1.2' classpath 'com.github.dcendents:android-maven-plugin:1.2'
}
}
} }
allprojects { allprojects {
repositories { repositories {
jcenter() jcenter()
} }
} }
apply plugin: 'com.android.library' apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven' apply plugin: 'com.github.dcendents.android-maven'
android { android {
compileSdkVersion 22 compileSdkVersion 22
buildToolsVersion '22.0.0' buildToolsVersion '22.0.0'
defaultConfig { defaultConfig {
minSdkVersion 14 minSdkVersion 14
targetSdkVersion 22 targetSdkVersion 22
} }
// Rename the aar correctly // Rename the aar correctly
libraryVariants.all { variant -> libraryVariants.all { variant ->
variant.outputs.each { output -> variant.outputs.each { output ->
def outputFile = output.outputFile def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.aar')) { if (outputFile != null && outputFile.name.endsWith('.aar')) {
def fileName = "${project.name}-${variant.baseName}-${version}.aar" def fileName = "${project.name}-${variant.baseName}-${version}.aar"
output.outputFile = new File(outputFile.parent, fileName) output.outputFile = new File(outputFile.parent, fileName)
} }
} }
} }
} }
ext { ext {
swagger_annotations_version = "1.5.0" swagger_annotations_version = "1.5.0"
gson_version = "2.3.1" gson_version = "2.3.1"
httpclient_version = "4.3.3" httpclient_version = "4.3.3"
junit_version = "4.8.1" junit_version = "4.8.1"
} }
dependencies { dependencies {
compile "io.swagger:swagger-annotations:$swagger_annotations_version" compile "io.swagger:swagger-annotations:$swagger_annotations_version"
compile "com.google.code.gson:gson:$gson_version" compile "com.google.code.gson:gson:$gson_version"
compile "org.apache.httpcomponents:httpcore:$httpclient_version" compile "org.apache.httpcomponents:httpcore:$httpclient_version"
compile "org.apache.httpcomponents:httpclient:$httpclient_version" compile "org.apache.httpcomponents:httpclient:$httpclient_version"
compile ("org.apache.httpcomponents:httpcore:$httpclient_version") { compile ("org.apache.httpcomponents:httpcore:$httpclient_version") {
exclude(group: 'org.apache.httpcomponents', module: 'httpclient') exclude(group: 'org.apache.httpcomponents', module: 'httpclient')
} }
compile ("org.apache.httpcomponents:httpmime:$httpclient_version") { compile ("org.apache.httpcomponents:httpmime:$httpclient_version") {
exclude(group: 'org.apache.httpcomponents', module: 'httpclient') exclude(group: 'org.apache.httpcomponents', module: 'httpclient')
} }
testCompile "junit:junit:$junit_version" testCompile "junit:junit:$junit_version"
} }
afterEvaluate { afterEvaluate {
android.libraryVariants.all { variant -> android.libraryVariants.all { variant ->
def task = project.tasks.create "jar${variant.name.capitalize()}", Jar def task = project.tasks.create "jar${variant.name.capitalize()}", Jar
task.description = "Create jar artifact for ${variant.name}" task.description = "Create jar artifact for ${variant.name}"
task.dependsOn variant.javaCompile task.dependsOn variant.javaCompile
task.from variant.javaCompile.destinationDir task.from variant.javaCompile.destinationDir
task.destinationDir = project.file("${project.buildDir}/outputs/jar") task.destinationDir = project.file("${project.buildDir}/outputs/jar")
task.archiveName = "${project.name}-${variant.baseName}-${version}.jar" task.archiveName = "${project.name}-${variant.baseName}-${version}.jar"
artifacts.add('archives', task); artifacts.add('archives', task);
} }
} }
task sourcesJar(type: Jar) { task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs from android.sourceSets.main.java.srcDirs
classifier = 'sources' classifier = 'sources'
} }
artifacts { artifacts {
archives sourcesJar archives sourcesJar
} }

View File

@ -77,8 +77,7 @@
</goals> </goals>
<configuration> <configuration>
<sources> <sources>
<source> <source>src/main/java</source>
src/main/java</source>
</sources> </sources>
</configuration> </configuration>
</execution> </execution>
@ -90,8 +89,7 @@
</goals> </goals>
<configuration> <configuration>
<sources> <sources>
<source> <source>src/test/java</source>
src/test/java</source>
</sources> </sources>
</configuration> </configuration>
</execution> </execution>
@ -102,8 +100,7 @@
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version> <version>2.3.2</version>
<configuration> <configuration>
<source> <source>1.6</source>
1.6</source>
<target>1.6</target> <target>1.6</target>
</configuration> </configuration>
</plugin> </plugin>

View File

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

View File

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

View File

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

View File

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

View File

@ -17,7 +17,7 @@ import java.util.Map;
import java.util.HashMap; import java.util.HashMap;
import java.io.File; import java.io.File;
public class PetApi { public class PetApi {
String basePath = "http://petstore.swagger.io/v2"; String basePath = "http://petstore.swagger.io/v2";
ApiInvoker apiInvoker = ApiInvoker.getInstance(); ApiInvoker apiInvoker = ApiInvoker.getInstance();
@ -52,17 +52,11 @@ import java.io.File;
String path = "/pet".replaceAll("\\{format\\}","json"); String path = "/pet".replaceAll("\\{format\\}","json");
// query params // query params
Map Map<String, String> queryParams = new HashMap<String, String>();
<String, String> queryParams = new HashMap
<String, String>();
// header params // header params
Map Map<String, String> headerParams = new HashMap<String, String>();
<String, String> headerParams = new HashMap
<String, String>();
// form params // form params
Map Map<String, String> formParams = new HashMap<String, String>();
<String, String> formParams = new HashMap
<String, String>();
@ -112,17 +106,11 @@ import java.io.File;
String path = "/pet".replaceAll("\\{format\\}","json"); String path = "/pet".replaceAll("\\{format\\}","json");
// query params // query params
Map Map<String, String> queryParams = new HashMap<String, String>();
<String, String> queryParams = new HashMap
<String, String>();
// header params // header params
Map Map<String, String> headerParams = new HashMap<String, String>();
<String, String> headerParams = new HashMap
<String, String>();
// form params // form params
Map Map<String, String> formParams = new HashMap<String, String>();
<String, String> formParams = new HashMap
<String, String>();
@ -172,17 +160,11 @@ import java.io.File;
String path = "/pet/findByStatus".replaceAll("\\{format\\}","json"); String path = "/pet/findByStatus".replaceAll("\\{format\\}","json");
// query params // query params
Map Map<String, String> queryParams = new HashMap<String, String>();
<String, String> queryParams = new HashMap
<String, String>();
// header params // header params
Map Map<String, String> headerParams = new HashMap<String, String>();
<String, String> headerParams = new HashMap
<String, String>();
// form params // form params
Map Map<String, String> formParams = new HashMap<String, String>();
<String, String> formParams = new HashMap
<String, String>();
if (status != null) if (status != null)
queryParams.put("status", ApiInvoker.parameterToString(status)); queryParams.put("status", ApiInvoker.parameterToString(status));
@ -234,17 +216,11 @@ import java.io.File;
String path = "/pet/findByTags".replaceAll("\\{format\\}","json"); String path = "/pet/findByTags".replaceAll("\\{format\\}","json");
// query params // query params
Map Map<String, String> queryParams = new HashMap<String, String>();
<String, String> queryParams = new HashMap
<String, String>();
// header params // header params
Map Map<String, String> headerParams = new HashMap<String, String>();
<String, String> headerParams = new HashMap
<String, String>();
// form params // form params
Map Map<String, String> formParams = new HashMap<String, String>();
<String, String> formParams = new HashMap
<String, String>();
if (tags != null) if (tags != null)
queryParams.put("tags", ApiInvoker.parameterToString(tags)); queryParams.put("tags", ApiInvoker.parameterToString(tags));
@ -301,17 +277,11 @@ import java.io.File;
String path = "/pet/{petId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}", apiInvoker.escapeString(petId.toString())); String path = "/pet/{petId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}", apiInvoker.escapeString(petId.toString()));
// query params // query params
Map Map<String, String> queryParams = new HashMap<String, String>();
<String, String> queryParams = new HashMap
<String, String>();
// header params // header params
Map Map<String, String> headerParams = new HashMap<String, String>();
<String, String> headerParams = new HashMap
<String, String>();
// form params // form params
Map Map<String, String> formParams = new HashMap<String, String>();
<String, String> formParams = new HashMap
<String, String>();
@ -368,17 +338,11 @@ import java.io.File;
String path = "/pet/{petId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}", apiInvoker.escapeString(petId.toString())); String path = "/pet/{petId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}", apiInvoker.escapeString(petId.toString()));
// query params // query params
Map Map<String, String> queryParams = new HashMap<String, String>();
<String, String> queryParams = new HashMap
<String, String>();
// header params // header params
Map Map<String, String> headerParams = new HashMap<String, String>();
<String, String> headerParams = new HashMap
<String, String>();
// form params // form params
Map Map<String, String> formParams = new HashMap<String, String>();
<String, String> formParams = new HashMap
<String, String>();
@ -444,17 +408,11 @@ import java.io.File;
String path = "/pet/{petId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}", apiInvoker.escapeString(petId.toString())); String path = "/pet/{petId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}", apiInvoker.escapeString(petId.toString()));
// query params // query params
Map Map<String, String> queryParams = new HashMap<String, String>();
<String, String> queryParams = new HashMap
<String, String>();
// header params // header params
Map Map<String, String> headerParams = new HashMap<String, String>();
<String, String> headerParams = new HashMap
<String, String>();
// form params // form params
Map Map<String, String> formParams = new HashMap<String, String>();
<String, String> formParams = new HashMap
<String, String>();
@ -512,17 +470,11 @@ import java.io.File;
String path = "/pet/{petId}/uploadImage".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}", apiInvoker.escapeString(petId.toString())); String path = "/pet/{petId}/uploadImage".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}", apiInvoker.escapeString(petId.toString()));
// query params // query params
Map Map<String, String> queryParams = new HashMap<String, String>();
<String, String> queryParams = new HashMap
<String, String>();
// header params // header params
Map Map<String, String> headerParams = new HashMap<String, String>();
<String, String> headerParams = new HashMap
<String, String>();
// form params // form params
Map Map<String, String> formParams = new HashMap<String, String>();
<String, String> formParams = new HashMap
<String, String>();
@ -568,4 +520,4 @@ import java.io.File;
} }
} }
} }

View File

@ -17,7 +17,7 @@ import java.util.Map;
import java.util.HashMap; import java.util.HashMap;
import java.io.File; import java.io.File;
public class StoreApi { public class StoreApi {
String basePath = "http://petstore.swagger.io/v2"; String basePath = "http://petstore.swagger.io/v2";
ApiInvoker apiInvoker = ApiInvoker.getInstance(); ApiInvoker apiInvoker = ApiInvoker.getInstance();
@ -51,17 +51,11 @@ import java.io.File;
String path = "/store/inventory".replaceAll("\\{format\\}","json"); String path = "/store/inventory".replaceAll("\\{format\\}","json");
// query params // query params
Map Map<String, String> queryParams = new HashMap<String, String>();
<String, String> queryParams = new HashMap
<String, String>();
// header params // header params
Map Map<String, String> headerParams = new HashMap<String, String>();
<String, String> headerParams = new HashMap
<String, String>();
// form params // form params
Map Map<String, String> formParams = new HashMap<String, String>();
<String, String> formParams = new HashMap
<String, String>();
@ -111,17 +105,11 @@ import java.io.File;
String path = "/store/order".replaceAll("\\{format\\}","json"); String path = "/store/order".replaceAll("\\{format\\}","json");
// query params // query params
Map Map<String, String> queryParams = new HashMap<String, String>();
<String, String> queryParams = new HashMap
<String, String>();
// header params // header params
Map Map<String, String> headerParams = new HashMap<String, String>();
<String, String> headerParams = new HashMap
<String, String>();
// form params // form params
Map Map<String, String> formParams = new HashMap<String, String>();
<String, String> formParams = new HashMap
<String, String>();
@ -176,17 +164,11 @@ import java.io.File;
String path = "/store/order/{orderId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "orderId" + "\\}", apiInvoker.escapeString(orderId.toString())); String path = "/store/order/{orderId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "orderId" + "\\}", apiInvoker.escapeString(orderId.toString()));
// query params // query params
Map Map<String, String> queryParams = new HashMap<String, String>();
<String, String> queryParams = new HashMap
<String, String>();
// header params // header params
Map Map<String, String> headerParams = new HashMap<String, String>();
<String, String> headerParams = new HashMap
<String, String>();
// form params // form params
Map Map<String, String> formParams = new HashMap<String, String>();
<String, String> formParams = new HashMap
<String, String>();
@ -241,17 +223,11 @@ import java.io.File;
String path = "/store/order/{orderId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "orderId" + "\\}", apiInvoker.escapeString(orderId.toString())); String path = "/store/order/{orderId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "orderId" + "\\}", apiInvoker.escapeString(orderId.toString()));
// query params // query params
Map Map<String, String> queryParams = new HashMap<String, String>();
<String, String> queryParams = new HashMap
<String, String>();
// header params // header params
Map Map<String, String> headerParams = new HashMap<String, String>();
<String, String> headerParams = new HashMap
<String, String>();
// form params // form params
Map Map<String, String> formParams = new HashMap<String, String>();
<String, String> formParams = new HashMap
<String, String>();
@ -287,4 +263,4 @@ import java.io.File;
} }
} }
} }

View File

@ -17,7 +17,7 @@ import java.util.Map;
import java.util.HashMap; import java.util.HashMap;
import java.io.File; import java.io.File;
public class UserApi { public class UserApi {
String basePath = "http://petstore.swagger.io/v2"; String basePath = "http://petstore.swagger.io/v2";
ApiInvoker apiInvoker = ApiInvoker.getInstance(); ApiInvoker apiInvoker = ApiInvoker.getInstance();
@ -52,17 +52,11 @@ import java.io.File;
String path = "/user".replaceAll("\\{format\\}","json"); String path = "/user".replaceAll("\\{format\\}","json");
// query params // query params
Map Map<String, String> queryParams = new HashMap<String, String>();
<String, String> queryParams = new HashMap
<String, String>();
// header params // header params
Map Map<String, String> headerParams = new HashMap<String, String>();
<String, String> headerParams = new HashMap
<String, String>();
// form params // form params
Map Map<String, String> formParams = new HashMap<String, String>();
<String, String> formParams = new HashMap
<String, String>();
@ -112,17 +106,11 @@ import java.io.File;
String path = "/user/createWithArray".replaceAll("\\{format\\}","json"); String path = "/user/createWithArray".replaceAll("\\{format\\}","json");
// query params // query params
Map Map<String, String> queryParams = new HashMap<String, String>();
<String, String> queryParams = new HashMap
<String, String>();
// header params // header params
Map Map<String, String> headerParams = new HashMap<String, String>();
<String, String> headerParams = new HashMap
<String, String>();
// form params // form params
Map Map<String, String> formParams = new HashMap<String, String>();
<String, String> formParams = new HashMap
<String, String>();
@ -172,17 +160,11 @@ import java.io.File;
String path = "/user/createWithList".replaceAll("\\{format\\}","json"); String path = "/user/createWithList".replaceAll("\\{format\\}","json");
// query params // query params
Map Map<String, String> queryParams = new HashMap<String, String>();
<String, String> queryParams = new HashMap
<String, String>();
// header params // header params
Map Map<String, String> headerParams = new HashMap<String, String>();
<String, String> headerParams = new HashMap
<String, String>();
// form params // form params
Map Map<String, String> formParams = new HashMap<String, String>();
<String, String> formParams = new HashMap
<String, String>();
@ -233,17 +215,11 @@ import java.io.File;
String path = "/user/login".replaceAll("\\{format\\}","json"); String path = "/user/login".replaceAll("\\{format\\}","json");
// query params // query params
Map Map<String, String> queryParams = new HashMap<String, String>();
<String, String> queryParams = new HashMap
<String, String>();
// header params // header params
Map Map<String, String> headerParams = new HashMap<String, String>();
<String, String> headerParams = new HashMap
<String, String>();
// form params // form params
Map Map<String, String> formParams = new HashMap<String, String>();
<String, String> formParams = new HashMap
<String, String>();
if (username != null) if (username != null)
queryParams.put("username", ApiInvoker.parameterToString(username)); queryParams.put("username", ApiInvoker.parameterToString(username));
@ -296,17 +272,11 @@ import java.io.File;
String path = "/user/logout".replaceAll("\\{format\\}","json"); String path = "/user/logout".replaceAll("\\{format\\}","json");
// query params // query params
Map Map<String, String> queryParams = new HashMap<String, String>();
<String, String> queryParams = new HashMap
<String, String>();
// header params // header params
Map Map<String, String> headerParams = new HashMap<String, String>();
<String, String> headerParams = new HashMap
<String, String>();
// form params // form params
Map Map<String, String> formParams = new HashMap<String, String>();
<String, String> formParams = new HashMap
<String, String>();
@ -361,17 +331,11 @@ import java.io.File;
String path = "/user/{username}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "username" + "\\}", apiInvoker.escapeString(username.toString())); String path = "/user/{username}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "username" + "\\}", apiInvoker.escapeString(username.toString()));
// query params // query params
Map Map<String, String> queryParams = new HashMap<String, String>();
<String, String> queryParams = new HashMap
<String, String>();
// header params // header params
Map Map<String, String> headerParams = new HashMap<String, String>();
<String, String> headerParams = new HashMap
<String, String>();
// form params // form params
Map Map<String, String> formParams = new HashMap<String, String>();
<String, String> formParams = new HashMap
<String, String>();
@ -427,17 +391,11 @@ import java.io.File;
String path = "/user/{username}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "username" + "\\}", apiInvoker.escapeString(username.toString())); String path = "/user/{username}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "username" + "\\}", apiInvoker.escapeString(username.toString()));
// query params // query params
Map Map<String, String> queryParams = new HashMap<String, String>();
<String, String> queryParams = new HashMap
<String, String>();
// header params // header params
Map Map<String, String> headerParams = new HashMap<String, String>();
<String, String> headerParams = new HashMap
<String, String>();
// form params // form params
Map Map<String, String> formParams = new HashMap<String, String>();
<String, String> formParams = new HashMap
<String, String>();
@ -492,17 +450,11 @@ import java.io.File;
String path = "/user/{username}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "username" + "\\}", apiInvoker.escapeString(username.toString())); String path = "/user/{username}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "username" + "\\}", apiInvoker.escapeString(username.toString()));
// query params // query params
Map Map<String, String> queryParams = new HashMap<String, String>();
<String, String> queryParams = new HashMap
<String, String>();
// header params // header params
Map Map<String, String> headerParams = new HashMap<String, String>();
<String, String> headerParams = new HashMap
<String, String>();
// form params // form params
Map Map<String, String> formParams = new HashMap<String, String>();
<String, String> formParams = new HashMap
<String, String>();
@ -538,4 +490,4 @@ import java.io.File;
} }
} }
} }

View File

@ -5,8 +5,8 @@ import io.swagger.annotations.*;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
@ApiModel(description = "") @ApiModel(description = "")
public class Category { public class Category {
@SerializedName("id") @SerializedName("id")
private Long id = null; private Long id = null;
@ -47,5 +47,4 @@ import com.google.gson.annotations.SerializedName;
sb.append("}\n"); sb.append("}\n");
return sb.toString(); return sb.toString();
} }
} }

View File

@ -6,8 +6,8 @@ import io.swagger.annotations.*;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
@ApiModel(description = "") @ApiModel(description = "")
public class Order { public class Order {
@SerializedName("id") @SerializedName("id")
private Long id = null; private Long id = null;
@ -108,5 +108,4 @@ import com.google.gson.annotations.SerializedName;
sb.append("}\n"); sb.append("}\n");
return sb.toString(); return sb.toString();
} }
} }

View File

@ -1,15 +1,15 @@
package io.swagger.client.model; package io.swagger.client.model;
import io.swagger.client.model.Category; import io.swagger.client.model.Category;
import io.swagger.client.model.Tag;
import java.util.*; import java.util.*;
import io.swagger.client.model.Tag;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
@ApiModel(description = "") @ApiModel(description = "")
public class Pet { public class Pet {
@SerializedName("id") @SerializedName("id")
private Long id = null; private Long id = null;
@ -110,5 +110,4 @@ import com.google.gson.annotations.SerializedName;
sb.append("}\n"); sb.append("}\n");
return sb.toString(); return sb.toString();
} }
} }

View File

@ -5,8 +5,8 @@ import io.swagger.annotations.*;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
@ApiModel(description = "") @ApiModel(description = "")
public class Tag { public class Tag {
@SerializedName("id") @SerializedName("id")
private Long id = null; private Long id = null;
@ -47,5 +47,4 @@ import com.google.gson.annotations.SerializedName;
sb.append("}\n"); sb.append("}\n");
return sb.toString(); return sb.toString();
} }
} }

View File

@ -5,8 +5,8 @@ import io.swagger.annotations.*;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
@ApiModel(description = "") @ApiModel(description = "")
public class User { public class User {
@SerializedName("id") @SerializedName("id")
private Long id = null; private Long id = null;
@ -132,5 +132,4 @@ import com.google.gson.annotations.SerializedName;
sb.append("}\n"); sb.append("}\n");
return sb.toString(); return sb.toString();
} }
} }

View File

@ -500,7 +500,7 @@ namespace IO.Swagger.Api {
// authentication setting, if any // authentication setting, if any
String[] authSettings = new String[] { "api_key", "petstore_auth" }; String[] authSettings = new String[] { "petstore_auth", "api_key" };
// make the HTTP request // make the HTTP request
IRestResponse response = (IRestResponse) apiClient.CallApi(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings); IRestResponse response = (IRestResponse) apiClient.CallApi(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
@ -540,7 +540,7 @@ namespace IO.Swagger.Api {
// authentication setting, if any // authentication setting, if any
String[] authSettings = new String[] { "api_key", "petstore_auth" }; String[] authSettings = new String[] { "petstore_auth", "api_key" };
// make the HTTP request // make the HTTP request
IRestResponse response = (IRestResponse) await apiClient.CallApiAsync(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings); IRestResponse response = (IRestResponse) await apiClient.CallApiAsync(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings);

View File

@ -77,8 +77,7 @@
</goals> </goals>
<configuration> <configuration>
<sources> <sources>
<source> <source>src/main/java</source>
src/main/java</source>
</sources> </sources>
</configuration> </configuration>
</execution> </execution>
@ -90,8 +89,7 @@
</goals> </goals>
<configuration> <configuration>
<sources> <sources>
<source> <source>src/test/java</source>
src/test/java</source>
</sources> </sources>
</configuration> </configuration>
</execution> </execution>
@ -102,8 +100,7 @@
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version> <version>2.3.2</version>
<configuration> <configuration>
<source> <source>1.6</source>
1.6</source>
<target>1.6</target> <target>1.6</target>
</configuration> </configuration>
</plugin> </plugin>

View File

@ -40,481 +40,467 @@ import io.swagger.client.auth.ApiKeyAuth;
import io.swagger.client.auth.OAuth; import io.swagger.client.auth.OAuth;
public class ApiClient { public class ApiClient {
private Map private Map<String, Client> hostMap = new HashMap<String, Client>();
<String, Client> hostMap = new HashMap private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
<String, Client>(); private boolean debugging = false;
private Map private String basePath = "http://petstore.swagger.io/v2";
<String, String> defaultHeaderMap = new HashMap
<String, String>();
private boolean debugging = false;
private String basePath = "http://petstore.swagger.io/v2";
private Map private Map<String, Authentication> authentications;
<String, Authentication> authentications;
private DateFormat dateFormat; private DateFormat dateFormat;
public ApiClient() { public ApiClient() {
// Use ISO 8601 format for date and datetime. // Use ISO 8601 format for date and datetime.
// See https://en.wikipedia.org/wiki/ISO_8601 // See https://en.wikipedia.org/wiki/ISO_8601
this.dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); this.dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
// Use UTC as the default time zone. // Use UTC as the default time zone.
this.dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); this.dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
// Set default User-Agent. // Set default User-Agent.
setUserAgent("Java-Swagger"); setUserAgent("Java-Swagger");
// Setup authentications (key: authentication name, value: authentication). // Setup authentications (key: authentication name, value: authentication).
authentications = new HashMap authentications = new HashMap<String, Authentication>();
<String, Authentication>();
authentications.put("api_key", new ApiKeyAuth("header", "api_key")); authentications.put("api_key", new ApiKeyAuth("header", "api_key"));
authentications.put("petstore_auth", new OAuth()); authentications.put("petstore_auth", new OAuth());
// Prevent the authentications from being modified. // Prevent the authentications from being modified.
authentications = Collections.unmodifiableMap(authentications); authentications = Collections.unmodifiableMap(authentications);
} }
public String getBasePath() { public String getBasePath() {
return basePath; return basePath;
} }
public ApiClient setBasePath(String basePath) { public ApiClient setBasePath(String basePath) {
this.basePath = basePath; this.basePath = basePath;
return this; return this;
} }
/** /**
* Get authentications (key: authentication name, value: authentication). * Get authentications (key: authentication name, value: authentication).
*/ */
public Map public Map<String, Authentication> getAuthentications() {
<String, Authentication> getAuthentications() { return authentications;
return authentications; }
}
/** /**
* Get authentication for the given name. * Get authentication for the given name.
* *
* @param authName The authentication name * @param authName The authentication name
* @return The authentication, null if not found * @return The authentication, null if not found
*/ */
public Authentication getAuthentication(String authName) { public Authentication getAuthentication(String authName) {
return authentications.get(authName); return authentications.get(authName);
} }
/** /**
* Helper method to set username for the first HTTP basic authentication. * Helper method to set username for the first HTTP basic authentication.
*/ */
public void setUsername(String username) { public void setUsername(String username) {
for (Authentication auth : authentications.values()) { for (Authentication auth : authentications.values()) {
if (auth instanceof HttpBasicAuth) { if (auth instanceof HttpBasicAuth) {
((HttpBasicAuth) auth).setUsername(username); ((HttpBasicAuth) auth).setUsername(username);
return; return;
} }
} }
throw new RuntimeException("No HTTP basic authentication configured!"); throw new RuntimeException("No HTTP basic authentication configured!");
} }
/** /**
* Helper method to set password for the first HTTP basic authentication. * Helper method to set password for the first HTTP basic authentication.
*/ */
public void setPassword(String password) { public void setPassword(String password) {
for (Authentication auth : authentications.values()) { for (Authentication auth : authentications.values()) {
if (auth instanceof HttpBasicAuth) { if (auth instanceof HttpBasicAuth) {
((HttpBasicAuth) auth).setPassword(password); ((HttpBasicAuth) auth).setPassword(password);
return; return;
} }
} }
throw new RuntimeException("No HTTP basic authentication configured!"); throw new RuntimeException("No HTTP basic authentication configured!");
} }
/** /**
* Helper method to set API key value for the first API key authentication. * Helper method to set API key value for the first API key authentication.
*/ */
public void setApiKey(String apiKey) { public void setApiKey(String apiKey) {
for (Authentication auth : authentications.values()) { for (Authentication auth : authentications.values()) {
if (auth instanceof ApiKeyAuth) { if (auth instanceof ApiKeyAuth) {
((ApiKeyAuth) auth).setApiKey(apiKey); ((ApiKeyAuth) auth).setApiKey(apiKey);
return; return;
} }
} }
throw new RuntimeException("No API key authentication configured!"); throw new RuntimeException("No API key authentication configured!");
} }
/** /**
* Helper method to set API key prefix for the first API key authentication. * Helper method to set API key prefix for the first API key authentication.
*/ */
public void setApiKeyPrefix(String apiKeyPrefix) { public void setApiKeyPrefix(String apiKeyPrefix) {
for (Authentication auth : authentications.values()) { for (Authentication auth : authentications.values()) {
if (auth instanceof ApiKeyAuth) { if (auth instanceof ApiKeyAuth) {
((ApiKeyAuth) auth).setApiKeyPrefix(apiKeyPrefix); ((ApiKeyAuth) auth).setApiKeyPrefix(apiKeyPrefix);
return; return;
} }
} }
throw new RuntimeException("No API key authentication configured!"); throw new RuntimeException("No API key authentication configured!");
} }
/** /**
* Set the User-Agent header's value (by adding to the default header map). * Set the User-Agent header's value (by adding to the default header map).
*/ */
public ApiClient setUserAgent(String userAgent) { public ApiClient setUserAgent(String userAgent) {
addDefaultHeader("User-Agent", userAgent); addDefaultHeader("User-Agent", userAgent);
return this; return this;
} }
/** /**
* Add a default header. * Add a default header.
* *
* @param key The header's key * @param key The header's key
* @param value The header's value * @param value The header's value
*/ */
public ApiClient addDefaultHeader(String key, String value) { public ApiClient addDefaultHeader(String key, String value) {
defaultHeaderMap.put(key, value); defaultHeaderMap.put(key, value);
return this; return this;
} }
/** /**
* Check that whether debugging is enabled for this API client. * Check that whether debugging is enabled for this API client.
*/ */
public boolean isDebugging() { public boolean isDebugging() {
return debugging; return debugging;
} }
/** /**
* Enable/disable debugging for this API client. * Enable/disable debugging for this API client.
* *
* @param debugging To enable (true) or disable (false) debugging * @param debugging To enable (true) or disable (false) debugging
*/ */
public ApiClient setDebugging(boolean debugging) { public ApiClient setDebugging(boolean debugging) {
this.debugging = debugging; this.debugging = debugging;
return this; return this;
} }
/** /**
* Get the date format used to parse/format date parameters. * Get the date format used to parse/format date parameters.
*/ */
public DateFormat getDateFormat() { public DateFormat getDateFormat() {
return dateFormat; return dateFormat;
} }
/** /**
* Set the date format used to parse/format date parameters. * Set the date format used to parse/format date parameters.
*/ */
public ApiClient getDateFormat(DateFormat dateFormat) { public ApiClient getDateFormat(DateFormat dateFormat) {
this.dateFormat = dateFormat; this.dateFormat = dateFormat;
return this; return this;
} }
/** /**
* Parse the given string into Date object. * Parse the given string into Date object.
*/ */
public Date parseDate(String str) { public Date parseDate(String str) {
try { try {
return dateFormat.parse(str); return dateFormat.parse(str);
} catch (java.text.ParseException e) { } catch (java.text.ParseException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }
/** /**
* Format the given Date object into string. * Format the given Date object into string.
*/ */
public String formatDate(Date date) { public String formatDate(Date date) {
return dateFormat.format(date); return dateFormat.format(date);
} }
/** /**
* Format the given parameter object into string. * Format the given parameter object into string.
*/ */
public String parameterToString(Object param) { public String parameterToString(Object param) {
if (param == null) { if (param == null) {
return ""; return "";
} else if (param instanceof Date) { } else if (param instanceof Date) {
return formatDate((Date) param); return formatDate((Date) param);
} else if (param instanceof Collection) { } else if (param instanceof Collection) {
StringBuilder b = new StringBuilder(); StringBuilder b = new StringBuilder();
for(Object o : (Collection)param) { for(Object o : (Collection)param) {
if(b.length() > 0) { if(b.length() > 0) {
b.append(","); b.append(",");
} }
b.append(String.valueOf(o)); b.append(String.valueOf(o));
} }
return b.toString(); return b.toString();
} else { } else {
return String.valueOf(param); return String.valueOf(param);
} }
} }
/** /**
* Select the Accept header's value from the given accepts array: * Select the Accept header's value from the given accepts array:
* if JSON exists in the given array, use it; * if JSON exists in the given array, use it;
* otherwise use all of them (joining into a string) * otherwise use all of them (joining into a string)
* *
* @param accepts The accepts array to select from * @param accepts The accepts array to select from
* @return The Accept header to use. If the given array is empty, * @return The Accept header to use. If the given array is empty,
* null will be returned (not to set the Accept header explicitly). * null will be returned (not to set the Accept header explicitly).
*/ */
public String selectHeaderAccept(String[] accepts) { public String selectHeaderAccept(String[] accepts) {
if (accepts.length == 0) return null; if (accepts.length == 0) return null;
if (StringUtil.containsIgnoreCase(accepts, "application/json")) return "application/json"; if (StringUtil.containsIgnoreCase(accepts, "application/json")) return "application/json";
return StringUtil.join(accepts, ","); return StringUtil.join(accepts, ",");
} }
/** /**
* Select the Content-Type header's value from the given array: * Select the Content-Type header's value from the given array:
* if JSON exists in the given array, use it; * if JSON exists in the given array, use it;
* otherwise use the first one of the array. * otherwise use the first one of the array.
* *
* @param contentTypes The Content-Type array to select from * @param contentTypes The Content-Type array to select from
* @return The Content-Type header to use. If the given array is empty, * @return The Content-Type header to use. If the given array is empty,
* JSON will be used. * JSON will be used.
*/ */
public String selectHeaderContentType(String[] contentTypes) { public String selectHeaderContentType(String[] contentTypes) {
if (contentTypes.length == 0) return "application/json"; if (contentTypes.length == 0) return "application/json";
if (StringUtil.containsIgnoreCase(contentTypes, "application/json")) return "application/json"; if (StringUtil.containsIgnoreCase(contentTypes, "application/json")) return "application/json";
return contentTypes[0]; return contentTypes[0];
} }
/** /**
* Escape the given string to be used as URL query value. * Escape the given string to be used as URL query value.
*/ */
public String escapeString(String str) { public String escapeString(String str) {
try { try {
return URLEncoder.encode(str, "utf8").replaceAll("\\+", "%20"); return URLEncoder.encode(str, "utf8").replaceAll("\\+", "%20");
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
return str; return str;
} }
} }
/** /**
* Deserialize the given JSON string to Java object. * Deserialize the given JSON string to Java object.
* *
* @param json The JSON string * @param json The JSON string
* @param containerType The container type, one of "list", "array" or "" * @param containerType The container type, one of "list", "array" or ""
* @param cls The type of the Java object * @param cls The type of the Java object
* @return The deserialized Java object * @return The deserialized Java object
*/ */
public Object deserialize(String json, String containerType, Class cls) throws ApiException { public Object deserialize(String json, String containerType, Class cls) throws ApiException {
if(null != containerType) { if(null != containerType) {
containerType = containerType.toLowerCase(); containerType = containerType.toLowerCase();
} }
try{ try{
if("list".equals(containerType) || "array".equals(containerType)) { if("list".equals(containerType) || "array".equals(containerType)) {
JavaType typeInfo = JsonUtil.getJsonMapper().getTypeFactory().constructCollectionType(List.class, cls); JavaType typeInfo = JsonUtil.getJsonMapper().getTypeFactory().constructCollectionType(List.class, cls);
List response = (List<?>) JsonUtil.getJsonMapper().readValue(json, typeInfo); List response = (List<?>) JsonUtil.getJsonMapper().readValue(json, typeInfo);
return response; return response;
} }
else if(String.class.equals(cls)) { else if(String.class.equals(cls)) {
if(json != null && json.startsWith("\"") && json.endsWith("\"") && json.length() > 1) if(json != null && json.startsWith("\"") && json.endsWith("\"") && json.length() > 1)
return json.substring(1, json.length() - 2); return json.substring(1, json.length() - 2);
else else
return json; return json;
} }
else { else {
return JsonUtil.getJsonMapper().readValue(json, cls); return JsonUtil.getJsonMapper().readValue(json, cls);
} }
} }
catch (IOException e) { catch (IOException e) {
throw new ApiException(500, e.getMessage(), null, json); throw new ApiException(500, e.getMessage(), null, json);
} }
} }
/** /**
* Serialize the given Java object into JSON string. * Serialize the given Java object into JSON string.
*/ */
public String serialize(Object obj) throws ApiException { public String serialize(Object obj) throws ApiException {
try { try {
if (obj != null) if (obj != null)
return JsonUtil.getJsonMapper().writeValueAsString(obj); return JsonUtil.getJsonMapper().writeValueAsString(obj);
else else
return null; return null;
} }
catch (Exception e) { catch (Exception e) {
throw new ApiException(500, e.getMessage()); throw new ApiException(500, e.getMessage());
} }
} }
/** /**
* Invoke API by sending HTTP request with the given options. * Invoke API by sending HTTP request with the given options.
* *
* @param path The sub-path of the HTTP URL * @param path The sub-path of the HTTP URL
* @param method The request method, one of "GET", "POST", "PUT", and "DELETE" * @param method The request method, one of "GET", "POST", "PUT", and "DELETE"
* @param queryParams The query parameters * @param queryParams The query parameters
* @param body The request body object * @param body The request body object
* @param headerParams The header parameters * @param headerParams The header parameters
* @param formParams The form parameters * @param formParams The form parameters
* @param accept The request's Accept header * @param accept The request's Accept header
* @param contentType The request's Content-Type header * @param contentType The request's Content-Type header
* @param authNames The authentications to apply * @param authNames The authentications to apply
* @return The response body in type of string * @return The response body in type of string
*/ */
public String invokeAPI(String path, String method, Map public String invokeAPI(String path, String method, Map<String, String> queryParams, Object body, Map<String, String> headerParams, Map<String, String> formParams, String accept, String contentType, String[] authNames) throws ApiException {
<String, String> queryParams, Object body, Map updateParamsForAuth(authNames, queryParams, headerParams);
<String, String> headerParams, Map
<String, String> formParams, String accept, String contentType, String[] authNames) throws ApiException {
updateParamsForAuth(authNames, queryParams, headerParams);
Client client = getClient(); Client client = getClient();
StringBuilder b = new StringBuilder(); StringBuilder b = new StringBuilder();
for(String key : queryParams.keySet()) { for(String key : queryParams.keySet()) {
String value = queryParams.get(key); String value = queryParams.get(key);
if (value != null){ if (value != null){
if(b.toString().length() == 0) if(b.toString().length() == 0)
b.append("?"); b.append("?");
else else
b.append("&"); b.append("&");
b.append(escapeString(key)).append("=").append(escapeString(value)); b.append(escapeString(key)).append("=").append(escapeString(value));
} }
} }
String querystring = b.toString(); String querystring = b.toString();
Builder builder; Builder builder;
if (accept == null) if (accept == null)
builder = client.resource(basePath + path + querystring).getRequestBuilder(); builder = client.resource(basePath + path + querystring).getRequestBuilder();
else else
builder = client.resource(basePath + path + querystring).accept(accept); 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)); builder = builder.header(key, headerParams.get(key));
} }
for(String key : defaultHeaderMap.keySet()) { for(String key : defaultHeaderMap.keySet()) {
if(!headerParams.containsKey(key)) { if(!headerParams.containsKey(key)) {
builder = builder.header(key, defaultHeaderMap.get(key)); builder = builder.header(key, defaultHeaderMap.get(key));
} }
} }
ClientResponse response = null; ClientResponse response = null;
if("GET".equals(method)) { if("GET".equals(method)) {
response = (ClientResponse) builder.get(ClientResponse.class); response = (ClientResponse) builder.get(ClientResponse.class);
} }
else if ("POST".equals(method)) { else if ("POST".equals(method)) {
if (contentType.startsWith("application/x-www-form-urlencoded")) { if (contentType.startsWith("application/x-www-form-urlencoded")) {
String encodedFormParams = this String encodedFormParams = this
.getXWWWFormUrlencodedParams(formParams); .getXWWWFormUrlencodedParams(formParams);
response = builder.type(contentType).post(ClientResponse.class, response = builder.type(contentType).post(ClientResponse.class,
encodedFormParams); encodedFormParams);
} else if (body == null) { } else if (body == null) {
response = builder.post(ClientResponse.class, 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); response = builder.type(contentType).post(ClientResponse.class, body);
} }
else else
response = builder.type(contentType).post(ClientResponse.class, serialize(body)); response = builder.type(contentType).post(ClientResponse.class, serialize(body));
} }
else if ("PUT".equals(method)) { else if ("PUT".equals(method)) {
if ("application/x-www-form-urlencoded".equals(contentType)) { if ("application/x-www-form-urlencoded".equals(contentType)) {
String encodedFormParams = this String encodedFormParams = this
.getXWWWFormUrlencodedParams(formParams); .getXWWWFormUrlencodedParams(formParams);
response = builder.type(contentType).put(ClientResponse.class, response = builder.type(contentType).put(ClientResponse.class,
encodedFormParams); encodedFormParams);
} else if(body == null) { } else if(body == null) {
response = builder.put(ClientResponse.class, serialize(body)); response = builder.put(ClientResponse.class, serialize(body));
} else { } else {
response = builder.type(contentType).put(ClientResponse.class, serialize(body)); response = builder.type(contentType).put(ClientResponse.class, serialize(body));
} }
} }
else if ("DELETE".equals(method)) { else if ("DELETE".equals(method)) {
if ("application/x-www-form-urlencoded".equals(contentType)) { if ("application/x-www-form-urlencoded".equals(contentType)) {
String encodedFormParams = this String encodedFormParams = this
.getXWWWFormUrlencodedParams(formParams); .getXWWWFormUrlencodedParams(formParams);
response = builder.type(contentType).delete(ClientResponse.class, response = builder.type(contentType).delete(ClientResponse.class,
encodedFormParams); encodedFormParams);
} else if(body == null) { } else if(body == null) {
response = builder.delete(ClientResponse.class); response = builder.delete(ClientResponse.class);
} else { } else {
response = builder.type(contentType).delete(ClientResponse.class, serialize(body)); response = builder.type(contentType).delete(ClientResponse.class, serialize(body));
} }
} }
else { else {
throw new ApiException(500, "unknown method type " + method); throw new ApiException(500, "unknown method type " + method);
} }
if(response.getClientResponseStatus() == ClientResponse.Status.NO_CONTENT) { if(response.getClientResponseStatus() == ClientResponse.Status.NO_CONTENT) {
return null; return null;
} }
else if(response.getClientResponseStatus().getFamily() == Family.SUCCESSFUL) { else if(response.getClientResponseStatus().getFamily() == Family.SUCCESSFUL) {
if(response.hasEntity()) { if(response.hasEntity()) {
return (String) response.getEntity(String.class); return (String) response.getEntity(String.class);
} }
else { else {
return ""; return "";
} }
} }
else { else {
String message = "error"; String message = "error";
String respBody = null; String respBody = null;
if(response.hasEntity()) { if(response.hasEntity()) {
try{ try{
respBody = String.valueOf(response.getEntity(String.class)); respBody = String.valueOf(response.getEntity(String.class));
message = respBody; message = respBody;
} }
catch (RuntimeException e) { catch (RuntimeException e) {
// e.printStackTrace(); // e.printStackTrace();
} }
} }
throw new ApiException( throw new ApiException(
response.getClientResponseStatus().getStatusCode(), response.getClientResponseStatus().getStatusCode(),
message, message,
response.getHeaders(), response.getHeaders(),
respBody); respBody);
} }
} }
/** /**
* Update query and header parameters based on authentication settings. * Update query and header parameters based on authentication settings.
* *
* @param authNames The authentications to apply * @param authNames The authentications to apply
*/ */
private void updateParamsForAuth(String[] authNames, Map private void updateParamsForAuth(String[] authNames, Map<String, String> queryParams, Map<String, String> headerParams) {
<String, String> queryParams, Map for (String authName : authNames) {
<String, String> headerParams) { Authentication auth = authentications.get(authName);
for (String authName : authNames) { if (auth == null) throw new RuntimeException("Authentication undefined: " + authName);
Authentication auth = authentications.get(authName); auth.applyToParams(queryParams, headerParams);
if (auth == null) throw new RuntimeException("Authentication undefined: " + authName); }
auth.applyToParams(queryParams, headerParams); }
}
}
/** /**
* Encode the given form parameters as request body. * Encode the given form parameters as request body.
*/ */
private String getXWWWFormUrlencodedParams(Map private String getXWWWFormUrlencodedParams(Map<String, String> formParams) {
<String, String> formParams) { StringBuilder formParamBuilder = new StringBuilder();
StringBuilder formParamBuilder = new StringBuilder();
for (Entry for (Entry<String, String> param : formParams.entrySet()) {
<String, String> param : formParams.entrySet()) { String keyStr = parameterToString(param.getKey());
String keyStr = parameterToString(param.getKey()); String valueStr = parameterToString(param.getValue());
String valueStr = parameterToString(param.getValue());
try { try {
formParamBuilder.append(URLEncoder.encode(keyStr, "utf8")) formParamBuilder.append(URLEncoder.encode(keyStr, "utf8"))
.append("=") .append("=")
.append(URLEncoder.encode(valueStr, "utf8")); .append(URLEncoder.encode(valueStr, "utf8"));
formParamBuilder.append("&"); formParamBuilder.append("&");
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
// move on to next // move on to next
} }
} }
String encodedFormParams = formParamBuilder.toString(); String encodedFormParams = formParamBuilder.toString();
if (encodedFormParams.endsWith("&")) { if (encodedFormParams.endsWith("&")) {
encodedFormParams = encodedFormParams.substring(0, encodedFormParams = encodedFormParams.substring(0,
encodedFormParams.length() - 1); encodedFormParams.length() - 1);
} }
return encodedFormParams; return encodedFormParams;
} }
/** /**
* Get an existing client or create a new client to handle HTTP request. * Get an existing client or create a new client to handle HTTP request.
*/ */
private Client getClient() { private Client getClient() {
if(!hostMap.containsKey(basePath)) { if(!hostMap.containsKey(basePath)) {
Client client = Client.create(); Client client = Client.create();
if (debugging) if (debugging)
client.addFilter(new LoggingFilter()); client.addFilter(new LoggingFilter());
hostMap.put(basePath, client); hostMap.put(basePath, client);
} }
return hostMap.get(basePath); return hostMap.get(basePath);
} }
} }

View File

@ -4,11 +4,9 @@ import java.util.Map;
import java.util.List; import java.util.List;
public class ApiException extends Exception { public class ApiException extends Exception {
private int code = 0; private int code = 0;
private String message = null; private String message = null;
private Map private Map<String, List<String>> responseHeaders = null;
<String, List
<String>> responseHeaders = null;
private String responseBody = null; private String responseBody = null;
public ApiException() {} public ApiException() {}
@ -18,10 +16,7 @@ private Map
this.message = message; this.message = message;
} }
public ApiException(int code, String message, Map public ApiException(int code, String message, Map<String, List<String>> responseHeaders, String responseBody) {
<String
, List
<String>> responseHeaders, String responseBody) {
this.code = code; this.code = code;
this.message = message; this.message = message;
this.responseHeaders = responseHeaders; this.responseHeaders = responseHeaders;
@ -39,10 +34,7 @@ private Map
/** /**
* Get the HTTP response headers. * Get the HTTP response headers.
*/ */
public Map public Map<String, List<String>> getResponseHeaders() {
<String
, List
<String>> getResponseHeaders() {
return responseHeaders; return responseHeaders;
} }
@ -52,4 +44,4 @@ private Map
public String getResponseBody() { public String getResponseBody() {
return responseBody; return responseBody;
} }
} }

View File

@ -1,21 +1,21 @@
package io.swagger.client; package io.swagger.client;
public class Configuration { public class Configuration {
private static ApiClient defaultApiClient = new ApiClient(); private static ApiClient defaultApiClient = new ApiClient();
/** /**
* Get the default API client, which would be used when creating API * Get the default API client, which would be used when creating API
* instances without providing an API client. * instances without providing an API client.
*/ */
public static ApiClient getDefaultApiClient() { public static ApiClient getDefaultApiClient() {
return defaultApiClient; return defaultApiClient;
} }
/** /**
* Set the default API client, which would be used when creating API * Set the default API client, which would be used when creating API
* instances without providing an API client. * instances without providing an API client.
*/ */
public static void setDefaultApiClient(ApiClient apiClient) { public static void setDefaultApiClient(ApiClient apiClient) {
defaultApiClient = apiClient; defaultApiClient = apiClient;
} }
} }

View File

@ -8,16 +8,16 @@ import com.fasterxml.jackson.core.JsonGenerator.Feature;
import com.fasterxml.jackson.datatype.joda.*; import com.fasterxml.jackson.datatype.joda.*;
public class JsonUtil { public class JsonUtil {
public static ObjectMapper mapper; public static ObjectMapper mapper;
static { static {
mapper = new ObjectMapper(); mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
mapper.registerModule(new JodaModule()); mapper.registerModule(new JodaModule());
} }
public static ObjectMapper getJsonMapper() { public static ObjectMapper getJsonMapper() {
return mapper; return mapper;
} }
} }

View File

@ -1,41 +1,41 @@
package io.swagger.client; package io.swagger.client;
public class StringUtil { public class StringUtil {
/** /**
* Check if the given array contains the given value (with case-insensitive comparison). * Check if the given array contains the given value (with case-insensitive comparison).
* *
* @param array The array * @param array The array
* @param value The value to search * @param value The value to search
* @return true if the array contains the value * @return true if the array contains the value
*/ */
public static boolean containsIgnoreCase(String[] array, String value) { public static boolean containsIgnoreCase(String[] array, String value) {
for (String str : array) { for (String str : array) {
if (value == null && str == null) return true; if (value == null && str == null) return true;
if (value != null && value.equalsIgnoreCase(str)) return true; if (value != null && value.equalsIgnoreCase(str)) return true;
} }
return false; return false;
} }
/** /**
* Join an array of strings with the given separator. * Join an array of strings with the given separator.
* <p> * <p>
* Note: This might be replaced by utility method from commons-lang or guava someday * Note: This might be replaced by utility method from commons-lang or guava someday
* if one of those libraries is added as dependency. * if one of those libraries is added as dependency.
* </p> * </p>
* *
* @param array The array of strings * @param array The array of strings
* @param separator The separator * @param separator The separator
* @return the resulting string * @return the resulting string
*/ */
public static String join(String[] array, String separator) { public static String join(String[] array, String separator) {
int len = array.length; int len = array.length;
if (len == 0) return ""; if (len == 0) return "";
StringBuilder out = new StringBuilder(); StringBuilder out = new StringBuilder();
out.append(array[0]); out.append(array[0]);
for (int i = 1; i < len; i++) { for (int i = 1; i < len; i++) {
out.append(separator).append(array[i]); out.append(separator).append(array[i]);
} }
return out.toString(); return out.toString();
} }
} }

View File

@ -20,7 +20,7 @@ import java.io.File;
import java.util.Map; import java.util.Map;
import java.util.HashMap; import java.util.HashMap;
public class PetApi { public class PetApi {
private ApiClient apiClient; private ApiClient apiClient;
public PetApi() { public PetApi() {
@ -54,15 +54,9 @@ import java.util.HashMap;
String path = "/pet".replaceAll("\\{format\\}","json"); String path = "/pet".replaceAll("\\{format\\}","json");
// query params // query params
Map Map<String, String> queryParams = new HashMap<String, String>();
<String, String> queryParams = new HashMap Map<String, String> headerParams = new HashMap<String, String>();
<String, String>(); Map<String, String> formParams = new HashMap<String, String>();
Map
<String, String> headerParams = new HashMap
<String, String>();
Map
<String, String> formParams = new HashMap
<String, String>();
@ -117,15 +111,9 @@ import java.util.HashMap;
String path = "/pet".replaceAll("\\{format\\}","json"); String path = "/pet".replaceAll("\\{format\\}","json");
// query params // query params
Map Map<String, String> queryParams = new HashMap<String, String>();
<String, String> queryParams = new HashMap Map<String, String> headerParams = new HashMap<String, String>();
<String, String>(); Map<String, String> formParams = new HashMap<String, String>();
Map
<String, String> headerParams = new HashMap
<String, String>();
Map
<String, String> formParams = new HashMap
<String, String>();
@ -180,15 +168,9 @@ import java.util.HashMap;
String path = "/pet/findByStatus".replaceAll("\\{format\\}","json"); String path = "/pet/findByStatus".replaceAll("\\{format\\}","json");
// query params // query params
Map Map<String, String> queryParams = new HashMap<String, String>();
<String, String> queryParams = new HashMap Map<String, String> headerParams = new HashMap<String, String>();
<String, String>(); Map<String, String> formParams = new HashMap<String, String>();
Map
<String, String> headerParams = new HashMap
<String, String>();
Map
<String, String> formParams = new HashMap
<String, String>();
if (status != null) if (status != null)
queryParams.put("status", apiClient.parameterToString(status)); queryParams.put("status", apiClient.parameterToString(status));
@ -245,15 +227,9 @@ import java.util.HashMap;
String path = "/pet/findByTags".replaceAll("\\{format\\}","json"); String path = "/pet/findByTags".replaceAll("\\{format\\}","json");
// query params // query params
Map Map<String, String> queryParams = new HashMap<String, String>();
<String, String> queryParams = new HashMap Map<String, String> headerParams = new HashMap<String, String>();
<String, String>(); Map<String, String> formParams = new HashMap<String, String>();
Map
<String, String> headerParams = new HashMap
<String, String>();
Map
<String, String> formParams = new HashMap
<String, String>();
if (tags != null) if (tags != null)
queryParams.put("tags", apiClient.parameterToString(tags)); queryParams.put("tags", apiClient.parameterToString(tags));
@ -316,15 +292,9 @@ import java.util.HashMap;
.replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString()));
// query params // query params
Map Map<String, String> queryParams = new HashMap<String, String>();
<String, String> queryParams = new HashMap Map<String, String> headerParams = new HashMap<String, String>();
<String, String>(); Map<String, String> formParams = new HashMap<String, String>();
Map
<String, String> headerParams = new HashMap
<String, String>();
Map
<String, String> formParams = new HashMap
<String, String>();
@ -352,7 +322,7 @@ import java.util.HashMap;
} }
try { try {
String[] authNames = new String[] { "api_key", "petstore_auth" }; String[] authNames = new String[] { "petstore_auth", "api_key" };
String response = apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames); String response = apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames);
if(response != null){ if(response != null){
return (Pet) apiClient.deserialize(response, "", Pet.class); return (Pet) apiClient.deserialize(response, "", Pet.class);
@ -387,15 +357,9 @@ import java.util.HashMap;
.replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString()));
// query params // query params
Map Map<String, String> queryParams = new HashMap<String, String>();
<String, String> queryParams = new HashMap Map<String, String> headerParams = new HashMap<String, String>();
<String, String>(); Map<String, String> formParams = new HashMap<String, String>();
Map
<String, String> headerParams = new HashMap
<String, String>();
Map
<String, String> formParams = new HashMap
<String, String>();
@ -471,15 +435,9 @@ import java.util.HashMap;
.replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString()));
// query params // query params
Map Map<String, String> queryParams = new HashMap<String, String>();
<String, String> queryParams = new HashMap Map<String, String> headerParams = new HashMap<String, String>();
<String, String>(); Map<String, String> formParams = new HashMap<String, String>();
Map
<String, String> headerParams = new HashMap
<String, String>();
Map
<String, String> formParams = new HashMap
<String, String>();
@ -544,15 +502,9 @@ import java.util.HashMap;
.replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString()));
// query params // query params
Map Map<String, String> queryParams = new HashMap<String, String>();
<String, String> queryParams = new HashMap Map<String, String> headerParams = new HashMap<String, String>();
<String, String>(); Map<String, String> formParams = new HashMap<String, String>();
Map
<String, String> headerParams = new HashMap
<String, String>();
Map
<String, String> formParams = new HashMap
<String, String>();
@ -607,4 +559,4 @@ import java.util.HashMap;
} }
} }
} }

View File

@ -20,7 +20,7 @@ import java.io.File;
import java.util.Map; import java.util.Map;
import java.util.HashMap; import java.util.HashMap;
public class StoreApi { public class StoreApi {
private ApiClient apiClient; private ApiClient apiClient;
public StoreApi() { public StoreApi() {
@ -53,15 +53,9 @@ import java.util.HashMap;
String path = "/store/inventory".replaceAll("\\{format\\}","json"); String path = "/store/inventory".replaceAll("\\{format\\}","json");
// query params // query params
Map Map<String, String> queryParams = new HashMap<String, String>();
<String, String> queryParams = new HashMap Map<String, String> headerParams = new HashMap<String, String>();
<String, String>(); Map<String, String> formParams = new HashMap<String, String>();
Map
<String, String> headerParams = new HashMap
<String, String>();
Map
<String, String> formParams = new HashMap
<String, String>();
@ -116,15 +110,9 @@ import java.util.HashMap;
String path = "/store/order".replaceAll("\\{format\\}","json"); String path = "/store/order".replaceAll("\\{format\\}","json");
// query params // query params
Map Map<String, String> queryParams = new HashMap<String, String>();
<String, String> queryParams = new HashMap Map<String, String> headerParams = new HashMap<String, String>();
<String, String>(); Map<String, String> formParams = new HashMap<String, String>();
Map
<String, String> headerParams = new HashMap
<String, String>();
Map
<String, String> formParams = new HashMap
<String, String>();
@ -185,15 +173,9 @@ import java.util.HashMap;
.replaceAll("\\{" + "orderId" + "\\}", apiClient.escapeString(orderId.toString())); .replaceAll("\\{" + "orderId" + "\\}", apiClient.escapeString(orderId.toString()));
// query params // query params
Map Map<String, String> queryParams = new HashMap<String, String>();
<String, String> queryParams = new HashMap Map<String, String> headerParams = new HashMap<String, String>();
<String, String>(); Map<String, String> formParams = new HashMap<String, String>();
Map
<String, String> headerParams = new HashMap
<String, String>();
Map
<String, String> formParams = new HashMap
<String, String>();
@ -254,15 +236,9 @@ import java.util.HashMap;
.replaceAll("\\{" + "orderId" + "\\}", apiClient.escapeString(orderId.toString())); .replaceAll("\\{" + "orderId" + "\\}", apiClient.escapeString(orderId.toString()));
// query params // query params
Map Map<String, String> queryParams = new HashMap<String, String>();
<String, String> queryParams = new HashMap Map<String, String> headerParams = new HashMap<String, String>();
<String, String>(); Map<String, String> formParams = new HashMap<String, String>();
Map
<String, String> headerParams = new HashMap
<String, String>();
Map
<String, String> formParams = new HashMap
<String, String>();
@ -303,4 +279,4 @@ import java.util.HashMap;
} }
} }
} }

View File

@ -20,7 +20,7 @@ import java.io.File;
import java.util.Map; import java.util.Map;
import java.util.HashMap; import java.util.HashMap;
public class UserApi { public class UserApi {
private ApiClient apiClient; private ApiClient apiClient;
public UserApi() { public UserApi() {
@ -54,15 +54,9 @@ import java.util.HashMap;
String path = "/user".replaceAll("\\{format\\}","json"); String path = "/user".replaceAll("\\{format\\}","json");
// query params // query params
Map Map<String, String> queryParams = new HashMap<String, String>();
<String, String> queryParams = new HashMap Map<String, String> headerParams = new HashMap<String, String>();
<String, String>(); Map<String, String> formParams = new HashMap<String, String>();
Map
<String, String> headerParams = new HashMap
<String, String>();
Map
<String, String> formParams = new HashMap
<String, String>();
@ -117,15 +111,9 @@ import java.util.HashMap;
String path = "/user/createWithArray".replaceAll("\\{format\\}","json"); String path = "/user/createWithArray".replaceAll("\\{format\\}","json");
// query params // query params
Map Map<String, String> queryParams = new HashMap<String, String>();
<String, String> queryParams = new HashMap Map<String, String> headerParams = new HashMap<String, String>();
<String, String>(); Map<String, String> formParams = new HashMap<String, String>();
Map
<String, String> headerParams = new HashMap
<String, String>();
Map
<String, String> formParams = new HashMap
<String, String>();
@ -180,15 +168,9 @@ import java.util.HashMap;
String path = "/user/createWithList".replaceAll("\\{format\\}","json"); String path = "/user/createWithList".replaceAll("\\{format\\}","json");
// query params // query params
Map Map<String, String> queryParams = new HashMap<String, String>();
<String, String> queryParams = new HashMap Map<String, String> headerParams = new HashMap<String, String>();
<String, String>(); Map<String, String> formParams = new HashMap<String, String>();
Map
<String, String> headerParams = new HashMap
<String, String>();
Map
<String, String> formParams = new HashMap
<String, String>();
@ -244,15 +226,9 @@ import java.util.HashMap;
String path = "/user/login".replaceAll("\\{format\\}","json"); String path = "/user/login".replaceAll("\\{format\\}","json");
// query params // query params
Map Map<String, String> queryParams = new HashMap<String, String>();
<String, String> queryParams = new HashMap Map<String, String> headerParams = new HashMap<String, String>();
<String, String>(); Map<String, String> formParams = new HashMap<String, String>();
Map
<String, String> headerParams = new HashMap
<String, String>();
Map
<String, String> formParams = new HashMap
<String, String>();
if (username != null) if (username != null)
queryParams.put("username", apiClient.parameterToString(username)); queryParams.put("username", apiClient.parameterToString(username));
@ -310,15 +286,9 @@ import java.util.HashMap;
String path = "/user/logout".replaceAll("\\{format\\}","json"); String path = "/user/logout".replaceAll("\\{format\\}","json");
// query params // query params
Map Map<String, String> queryParams = new HashMap<String, String>();
<String, String> queryParams = new HashMap Map<String, String> headerParams = new HashMap<String, String>();
<String, String>(); Map<String, String> formParams = new HashMap<String, String>();
Map
<String, String> headerParams = new HashMap
<String, String>();
Map
<String, String> formParams = new HashMap
<String, String>();
@ -379,15 +349,9 @@ import java.util.HashMap;
.replaceAll("\\{" + "username" + "\\}", apiClient.escapeString(username.toString())); .replaceAll("\\{" + "username" + "\\}", apiClient.escapeString(username.toString()));
// query params // query params
Map Map<String, String> queryParams = new HashMap<String, String>();
<String, String> queryParams = new HashMap Map<String, String> headerParams = new HashMap<String, String>();
<String, String>(); Map<String, String> formParams = new HashMap<String, String>();
Map
<String, String> headerParams = new HashMap
<String, String>();
Map
<String, String> formParams = new HashMap
<String, String>();
@ -449,15 +413,9 @@ import java.util.HashMap;
.replaceAll("\\{" + "username" + "\\}", apiClient.escapeString(username.toString())); .replaceAll("\\{" + "username" + "\\}", apiClient.escapeString(username.toString()));
// query params // query params
Map Map<String, String> queryParams = new HashMap<String, String>();
<String, String> queryParams = new HashMap Map<String, String> headerParams = new HashMap<String, String>();
<String, String>(); Map<String, String> formParams = new HashMap<String, String>();
Map
<String, String> headerParams = new HashMap
<String, String>();
Map
<String, String> formParams = new HashMap
<String, String>();
@ -518,15 +476,9 @@ import java.util.HashMap;
.replaceAll("\\{" + "username" + "\\}", apiClient.escapeString(username.toString())); .replaceAll("\\{" + "username" + "\\}", apiClient.escapeString(username.toString()));
// query params // query params
Map Map<String, String> queryParams = new HashMap<String, String>();
<String, String> queryParams = new HashMap Map<String, String> headerParams = new HashMap<String, String>();
<String, String>(); Map<String, String> formParams = new HashMap<String, String>();
Map
<String, String> headerParams = new HashMap
<String, String>();
Map
<String, String> formParams = new HashMap
<String, String>();
@ -567,4 +519,4 @@ import java.util.HashMap;
} }
} }
} }

View File

@ -3,55 +3,53 @@ package io.swagger.client.auth;
import java.util.Map; import java.util.Map;
public class ApiKeyAuth implements Authentication { public class ApiKeyAuth implements Authentication {
private final String location; private final String location;
private final String paramName; private final String paramName;
private String apiKey; private String apiKey;
private String apiKeyPrefix; private String apiKeyPrefix;
public ApiKeyAuth(String location, String paramName) { public ApiKeyAuth(String location, String paramName) {
this.location = location; this.location = location;
this.paramName = paramName; this.paramName = paramName;
} }
public String getLocation() { public String getLocation() {
return location; return location;
} }
public String getParamName() { public String getParamName() {
return paramName; return paramName;
} }
public String getApiKey() { public String getApiKey() {
return apiKey; return apiKey;
} }
public void setApiKey(String apiKey) { public void setApiKey(String apiKey) {
this.apiKey = apiKey; this.apiKey = apiKey;
} }
public String getApiKeyPrefix() { public String getApiKeyPrefix() {
return apiKeyPrefix; return apiKeyPrefix;
} }
public void setApiKeyPrefix(String apiKeyPrefix) { public void setApiKeyPrefix(String apiKeyPrefix) {
this.apiKeyPrefix = apiKeyPrefix; this.apiKeyPrefix = apiKeyPrefix;
} }
@Override @Override
public void applyToParams(Map public void applyToParams(Map<String, String> queryParams, Map<String, String> headerParams) {
<String, String> queryParams, Map String value;
<String, String> headerParams) { if (apiKeyPrefix != null) {
String value; value = apiKeyPrefix + " " + apiKey;
if (apiKeyPrefix != null) { } else {
value = apiKeyPrefix + " " + apiKey; value = apiKey;
} else { }
value = apiKey; if (location == "query") {
} queryParams.put(paramName, value);
if (location == "query") { } else if (location == "header") {
queryParams.put(paramName, value); headerParams.put(paramName, value);
} else if (location == "header") { }
headerParams.put(paramName, value); }
}
}
} }

View File

@ -3,8 +3,6 @@ package io.swagger.client.auth;
import java.util.Map; import java.util.Map;
public interface Authentication { public interface Authentication {
/** Apply authentication settings to header and query params. */ /** Apply authentication settings to header and query params. */
void applyToParams(Map void applyToParams(Map<String, String> queryParams, Map<String, String> headerParams);
<String, String> queryParams, Map
<String, String> headerParams);
} }

View File

@ -6,34 +6,32 @@ import java.io.UnsupportedEncodingException;
import javax.xml.bind.DatatypeConverter; import javax.xml.bind.DatatypeConverter;
public class HttpBasicAuth implements Authentication { public class HttpBasicAuth implements Authentication {
private String username; private String username;
private String password; private String password;
public String getUsername() { public String getUsername() {
return username; return username;
} }
public void setUsername(String username) { public void setUsername(String username) {
this.username = username; this.username = username;
} }
public String getPassword() { public String getPassword() {
return password; return password;
} }
public void setPassword(String password) { public void setPassword(String password) {
this.password = password; this.password = password;
} }
@Override @Override
public void applyToParams(Map public void applyToParams(Map<String, String> queryParams, Map<String, String> headerParams) {
<String, String> queryParams, Map String str = (username == null ? "" : username) + ":" + (password == null ? "" : password);
<String, String> headerParams) { try {
String str = (username == null ? "" : username) + ":" + (password == null ? "" : password); headerParams.put("Authorization", "Basic " + DatatypeConverter.printBase64Binary(str.getBytes("UTF-8")));
try { } catch (UnsupportedEncodingException e) {
headerParams.put("Authorization", "Basic " + DatatypeConverter.printBase64Binary(str.getBytes("UTF-8"))); throw new RuntimeException(e);
} catch (UnsupportedEncodingException e) { }
throw new RuntimeException(e); }
}
}
} }

View File

@ -3,10 +3,8 @@ package io.swagger.client.auth;
import java.util.Map; import java.util.Map;
public class OAuth implements Authentication { public class OAuth implements Authentication {
@Override @Override
public void applyToParams(Map public void applyToParams(Map<String, String> queryParams, Map<String, String> headerParams) {
<String, String> queryParams, Map // TODO: support oauth
<String, String> headerParams) { }
// TODO: support oauth
}
} }

View File

@ -5,8 +5,8 @@ import io.swagger.annotations.*;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
@ApiModel(description = "") @ApiModel(description = "")
public class Category { public class Category {
private Long id = null; private Long id = null;
private String name = null; private String name = null;
@ -47,5 +47,4 @@ import com.fasterxml.jackson.annotation.JsonProperty;
sb.append("}\n"); sb.append("}\n");
return sb.toString(); return sb.toString();
} }
} }

View File

@ -6,8 +6,8 @@ import io.swagger.annotations.*;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
@ApiModel(description = "") @ApiModel(description = "")
public class Order { public class Order {
private Long id = null; private Long id = null;
private Long petId = null; private Long petId = null;
@ -108,5 +108,4 @@ import com.fasterxml.jackson.annotation.JsonProperty;
sb.append("}\n"); sb.append("}\n");
return sb.toString(); return sb.toString();
} }
} }

View File

@ -1,15 +1,15 @@
package io.swagger.client.model; package io.swagger.client.model;
import io.swagger.client.model.Category; import io.swagger.client.model.Category;
import io.swagger.client.model.Tag;
import java.util.*; import java.util.*;
import io.swagger.client.model.Tag;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
@ApiModel(description = "") @ApiModel(description = "")
public class Pet { public class Pet {
private Long id = null; private Long id = null;
private Category category = null; private Category category = null;
@ -110,5 +110,4 @@ import com.fasterxml.jackson.annotation.JsonProperty;
sb.append("}\n"); sb.append("}\n");
return sb.toString(); return sb.toString();
} }
} }

View File

@ -5,8 +5,8 @@ import io.swagger.annotations.*;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
@ApiModel(description = "") @ApiModel(description = "")
public class Tag { public class Tag {
private Long id = null; private Long id = null;
private String name = null; private String name = null;
@ -47,5 +47,4 @@ import com.fasterxml.jackson.annotation.JsonProperty;
sb.append("}\n"); sb.append("}\n");
return sb.toString(); return sb.toString();
} }
} }

View File

@ -5,8 +5,8 @@ import io.swagger.annotations.*;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
@ApiModel(description = "") @ApiModel(description = "")
public class User { public class User {
private Long id = null; private Long id = null;
private String username = null; private String username = null;
@ -132,5 +132,4 @@ import com.fasterxml.jackson.annotation.JsonProperty;
sb.append("}\n"); sb.append("}\n");
return sb.toString(); return sb.toString();
} }
} }

View File

@ -1,5 +1,5 @@
platform :ios, '6.0' platform :ios, '6.0'
xcodeproj 'PetstoreClient/PetstoreClient.xcodeproj' xcodeproj 'swaggerClient/swaggerClient.xcodeproj'
pod 'AFNetworking', '~> 2.1' pod 'AFNetworking', '~> 2.1'
pod 'JSONModel', '~> 1.0' pod 'JSONModel', '~> 1.0'
pod 'ISO8601' pod 'ISO8601'

View File

@ -1,21 +1,15 @@
#import #import <Foundation/Foundation.h>
<Foundation/Foundation.h>
#import "SWGObject.h" #import "SWGObject.h"
@protocol SWGCategory
@end
@protocol SWGCategory @interface SWGCategory : SWGObject
@end
@interface SWGCategory : SWGObject
@property(nonatomic) NSNumber* _id;
@property(nonatomic) NSNumber* _id; @property(nonatomic) NSString* name;
@property(nonatomic) NSString* name;
@end
@end

View File

@ -1,15 +1,14 @@
#import "SWGCategory.h"
#import "SWGCategory.h" @implementation SWGCategory
@implementation SWGCategory + (JSONKeyMapper *)keyMapper
{
+ (JSONKeyMapper *)keyMapper
{
return [[JSONKeyMapper alloc] initWithDictionary:@{ @"id": @"_id", @"name": @"name" }]; return [[JSONKeyMapper alloc] initWithDictionary:@{ @"id": @"_id", @"name": @"name" }];
} }
+ (BOOL)propertyIsOptional:(NSString *)propertyName + (BOOL)propertyIsOptional:(NSString *)propertyName
{ {
NSArray *optionalProperties = @[@"_id", @"name"]; NSArray *optionalProperties = @[@"_id", @"name"];
if ([optionalProperties containsObject:propertyName]) { if ([optionalProperties containsObject:propertyName]) {
@ -18,7 +17,6 @@
else { else {
return NO; return NO;
} }
} }
@end
@end

View File

@ -1,57 +1,56 @@
#import #import <Foundation/Foundation.h>
<Foundation/Foundation.h>
@interface SWGConfiguration : NSObject @interface SWGConfiguration : NSObject
/** /**
* Api key values for Api Key type Authentication * Api key values for Api Key type Authentication
* *
* To add or remove api key, use `setValue:forApiKeyField:`. * To add or remove api key, use `setValue:forApiKeyField:`.
*/ */
@property (readonly, nonatomic, strong) NSDictionary *apiKey; @property (readonly, nonatomic, strong) NSDictionary *apiKey;
/** /**
* Api key prefix values to be prepend to the respective api key * Api key prefix values to be prepend to the respective api key
* *
* To add or remove prefix, use `setValue:forApiKeyPrefixField:`. * To add or remove prefix, use `setValue:forApiKeyPrefixField:`.
*/ */
@property (readonly, nonatomic, strong) NSDictionary *apiKeyPrefix; @property (readonly, nonatomic, strong) NSDictionary *apiKeyPrefix;
/** /**
* Usename and Password for Basic type Authentication * Usename and Password for Basic type Authentication
*/ */
@property (nonatomic) NSString *username; @property (nonatomic) NSString *username;
@property (nonatomic) NSString *password; @property (nonatomic) NSString *password;
/** /**
* Get configuration singleton instance * Get configuration singleton instance
*/ */
+ (instancetype) sharedConfig; + (instancetype) sharedConfig;
/** /**
* Sets field in `apiKey` * Sets field in `apiKey`
*/ */
- (void) setValue:(NSString *)value forApiKeyField:(NSString*)field; - (void) setValue:(NSString *)value forApiKeyField:(NSString*)field;
/** /**
* Sets field in `apiKeyPrefix` * Sets field in `apiKeyPrefix`
*/ */
- (void) setValue:(NSString *)value forApiKeyPrefixField:(NSString *)field; - (void) setValue:(NSString *)value forApiKeyPrefixField:(NSString *)field;
/** /**
* Get API key (with prefix if set) * Get API key (with prefix if set)
*/ */
- (NSString *) getApiKeyWithPrefix:(NSString *) key; - (NSString *) getApiKeyWithPrefix:(NSString *) key;
/** /**
* Get Basic Auth token * Get Basic Auth token
*/ */
- (NSString *) getBasicAuthToken; - (NSString *) getBasicAuthToken;
/** /**
* Get Authentication Setings * Get Authentication Setings
*/ */
- (NSDictionary *) authSettings; - (NSDictionary *) authSettings;
@end @end

View File

@ -12,73 +12,73 @@
#pragma mark - Singletion Methods #pragma mark - Singletion Methods
+ (instancetype) sharedConfig { + (instancetype) sharedConfig {
static SWGConfiguration *shardConfig = nil; static SWGConfiguration *shardConfig = nil;
static dispatch_once_t onceToken; static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{ dispatch_once(&onceToken, ^{
shardConfig = [[self alloc] init]; shardConfig = [[self alloc] init];
}); });
return shardConfig; return shardConfig;
} }
#pragma mark - Initialize Methods #pragma mark - Initialize Methods
- (instancetype) init { - (instancetype) init {
self = [super init]; self = [super init];
if (self) { if (self) {
self.username = @""; self.username = @"";
self.password = @""; self.password = @"";
self.mutableApiKey = [NSMutableDictionary dictionary]; self.mutableApiKey = [NSMutableDictionary dictionary];
self.mutableApiKeyPrefix = [NSMutableDictionary dictionary]; self.mutableApiKeyPrefix = [NSMutableDictionary dictionary];
} }
return self; return self;
} }
#pragma mark - Instance Methods #pragma mark - Instance Methods
- (NSString *) getApiKeyWithPrefix:(NSString *)key { - (NSString *) getApiKeyWithPrefix:(NSString *)key {
if ([self.apiKeyPrefix objectForKey:key] && [self.apiKey objectForKey:key]) { if ([self.apiKeyPrefix objectForKey:key] && [self.apiKey objectForKey:key]) {
return [NSString stringWithFormat:@"%@ %@", [self.apiKeyPrefix objectForKey:key], [self.apiKey objectForKey:key]]; return [NSString stringWithFormat:@"%@ %@", [self.apiKeyPrefix objectForKey:key], [self.apiKey objectForKey:key]];
} }
else if ([self.apiKey objectForKey:key]) { else if ([self.apiKey objectForKey:key]) {
return [NSString stringWithFormat:@"%@", [self.apiKey objectForKey:key]]; return [NSString stringWithFormat:@"%@", [self.apiKey objectForKey:key]];
} }
else { else {
return @""; return @"";
} }
} }
- (NSString *) getBasicAuthToken { - (NSString *) getBasicAuthToken {
NSString *basicAuthCredentials = [NSString stringWithFormat:@"%@:%@", self.username, self.password]; NSString *basicAuthCredentials = [NSString stringWithFormat:@"%@:%@", self.username, self.password];
NSData *data = [basicAuthCredentials dataUsingEncoding:NSUTF8StringEncoding]; NSData *data = [basicAuthCredentials dataUsingEncoding:NSUTF8StringEncoding];
basicAuthCredentials = [NSString stringWithFormat:@"Basic %@", [data base64EncodedStringWithOptions:0]]; basicAuthCredentials = [NSString stringWithFormat:@"Basic %@", [data base64EncodedStringWithOptions:0]];
return basicAuthCredentials; return basicAuthCredentials;
} }
#pragma mark - Setter Methods #pragma mark - Setter Methods
- (void) setValue:(NSString *)value forApiKeyField:(NSString *)field { - (void) setValue:(NSString *)value forApiKeyField:(NSString *)field {
[self.mutableApiKey setValue:value forKey:field]; [self.mutableApiKey setValue:value forKey:field];
} }
- (void) setValue:(NSString *)value forApiKeyPrefixField:(NSString *)field { - (void) setValue:(NSString *)value forApiKeyPrefixField:(NSString *)field {
[self.mutableApiKeyPrefix setValue:value forKey:field]; [self.mutableApiKeyPrefix setValue:value forKey:field];
} }
#pragma mark - Getter Methods #pragma mark - Getter Methods
- (NSDictionary *) apiKey { - (NSDictionary *) apiKey {
return [NSDictionary dictionaryWithDictionary:self.mutableApiKey]; return [NSDictionary dictionaryWithDictionary:self.mutableApiKey];
} }
- (NSDictionary *) apiKeyPrefix { - (NSDictionary *) apiKeyPrefix {
return [NSDictionary dictionaryWithDictionary:self.mutableApiKeyPrefix]; return [NSDictionary dictionaryWithDictionary:self.mutableApiKeyPrefix];
} }
#pragma mark - #pragma mark -
- (NSDictionary *) authSettings { - (NSDictionary *) authSettings {
return @{ return @{
@"api_key": @{ @"api_key": @{
@"type": @"api_key", @"type": @"api_key",
@"in": @"header", @"in": @"header",
@ -86,7 +86,7 @@ return @{
@"value": [self getApiKeyWithPrefix:@"api_key"] @"value": [self getApiKeyWithPrefix:@"api_key"]
}, },
}; };
} }
@end @end

View File

@ -1,34 +1,24 @@
#import #import <Foundation/Foundation.h>
<Foundation/Foundation.h>
#import "SWGObject.h" #import "SWGObject.h"
@protocol SWGOrder
@end
@protocol SWGOrder @interface SWGOrder : SWGObject
@end
@interface SWGOrder : SWGObject
@property(nonatomic) NSNumber* _id;
@property(nonatomic) NSNumber* _id; @property(nonatomic) NSNumber* petId;
@property(nonatomic) NSNumber* quantity;
@property(nonatomic) NSNumber* petId; @property(nonatomic) NSDate* shipDate;
/* Order Status [optional]
@property(nonatomic) NSNumber* quantity;
@property(nonatomic) NSDate* shipDate;
/* Order Status [optional]
*/ */
@property(nonatomic) NSString* status; @property(nonatomic) NSString* status;
@property(nonatomic) BOOL complete;
@property(nonatomic) BOOL complete; @end
@end

View File

@ -1,15 +1,14 @@
#import "SWGOrder.h"
#import "SWGOrder.h" @implementation SWGOrder
@implementation SWGOrder + (JSONKeyMapper *)keyMapper
{
+ (JSONKeyMapper *)keyMapper
{
return [[JSONKeyMapper alloc] initWithDictionary:@{ @"id": @"_id", @"petId": @"petId", @"quantity": @"quantity", @"shipDate": @"shipDate", @"status": @"status", @"complete": @"complete" }]; return [[JSONKeyMapper alloc] initWithDictionary:@{ @"id": @"_id", @"petId": @"petId", @"quantity": @"quantity", @"shipDate": @"shipDate", @"status": @"status", @"complete": @"complete" }];
} }
+ (BOOL)propertyIsOptional:(NSString *)propertyName + (BOOL)propertyIsOptional:(NSString *)propertyName
{ {
NSArray *optionalProperties = @[@"_id", @"petId", @"quantity", @"shipDate", @"status", @"complete"]; NSArray *optionalProperties = @[@"_id", @"petId", @"quantity", @"shipDate", @"status", @"complete"];
if ([optionalProperties containsObject:propertyName]) { if ([optionalProperties containsObject:propertyName]) {
@ -18,7 +17,6 @@
else { else {
return NO; return NO;
} }
} }
@end
@end

View File

@ -1,36 +1,26 @@
#import #import <Foundation/Foundation.h>
<Foundation/Foundation.h>
#import "SWGObject.h" #import "SWGObject.h"
#import "SWGTag.h"
#import "SWGCategory.h" #import "SWGCategory.h"
#import "SWGTag.h"
@protocol SWGPet
@end
@protocol SWGPet @interface SWGPet : SWGObject
@end
@interface SWGPet : SWGObject
@property(nonatomic) NSNumber* _id;
@property(nonatomic) NSNumber* _id; @property(nonatomic) SWGCategory* category;
@property(nonatomic) NSString* name;
@property(nonatomic) SWGCategory* category; @property(nonatomic) NSArray* photoUrls;
@property(nonatomic) NSArray<SWGTag>* tags;
@property(nonatomic) NSString* name; /* pet status in the store [optional]
@property(nonatomic) NSArray* photoUrls;
@property(nonatomic) NSArray<SWGTag>* tags;
/* pet status in the store [optional]
*/ */
@property(nonatomic) NSString* status; @property(nonatomic) NSString* status;
@end
@end

View File

@ -1,15 +1,14 @@
#import "SWGPet.h"
#import "SWGPet.h" @implementation SWGPet
@implementation SWGPet + (JSONKeyMapper *)keyMapper
{
+ (JSONKeyMapper *)keyMapper
{
return [[JSONKeyMapper alloc] initWithDictionary:@{ @"id": @"_id", @"category": @"category", @"name": @"name", @"photoUrls": @"photoUrls", @"tags": @"tags", @"status": @"status" }]; return [[JSONKeyMapper alloc] initWithDictionary:@{ @"id": @"_id", @"category": @"category", @"name": @"name", @"photoUrls": @"photoUrls", @"tags": @"tags", @"status": @"status" }];
} }
+ (BOOL)propertyIsOptional:(NSString *)propertyName + (BOOL)propertyIsOptional:(NSString *)propertyName
{ {
NSArray *optionalProperties = @[@"_id", @"category", @"tags", @"status"]; NSArray *optionalProperties = @[@"_id", @"category", @"tags", @"status"];
if ([optionalProperties containsObject:propertyName]) { if ([optionalProperties containsObject:propertyName]) {
@ -18,7 +17,6 @@
else { else {
return NO; return NO;
} }
} }
@end
@end

View File

@ -1,23 +1,21 @@
#import #import <Foundation/Foundation.h>
<Foundation/Foundation.h>
#import "SWGPet.h" #import "SWGPet.h"
#import "SWGFile.h" #import "SWGFile.h"
#import "SWGObject.h" #import "SWGObject.h"
#import "SWGApiClient.h" #import "SWGApiClient.h"
@interface SWGPetApi: NSObject @interface SWGPetApi: NSObject
@property(nonatomic, assign)SWGApiClient *apiClient; @property(nonatomic, assign)SWGApiClient *apiClient;
-(instancetype) initWithApiClient:(SWGApiClient *)apiClient; -(instancetype) initWithApiClient:(SWGApiClient *)apiClient;
-(void) addHeader:(NSString*)value forKey:(NSString*)key; -(void) addHeader:(NSString*)value forKey:(NSString*)key;
-(unsigned long) requestQueueSize; -(unsigned long) requestQueueSize;
+(SWGPetApi*) apiWithHeader:(NSString*)headerValue key:(NSString*)key; +(SWGPetApi*) apiWithHeader:(NSString*)headerValue key:(NSString*)key;
+(void) setBasePath:(NSString*)basePath; +(void) setBasePath:(NSString*)basePath;
+(NSString*) getBasePath; +(NSString*) getBasePath;
/**
/**
Update an existing pet Update an existing pet
@ -27,14 +25,13 @@
return type: return type:
*/ */
-(NSNumber*) updatePetWithCompletionBlock :(SWGPet*) body -(NSNumber*) updatePetWithCompletionBlock :(SWGPet*) body
completionHandler: (void (^)(NSError* error))completionBlock; completionHandler: (void (^)(NSError* error))completionBlock;
/**
/**
Add a new pet to the store Add a new pet to the store
@ -44,14 +41,13 @@
return type: return type:
*/ */
-(NSNumber*) addPetWithCompletionBlock :(SWGPet*) body -(NSNumber*) addPetWithCompletionBlock :(SWGPet*) body
completionHandler: (void (^)(NSError* error))completionBlock; completionHandler: (void (^)(NSError* error))completionBlock;
/**
/**
Finds Pets by status Finds Pets by status
Multiple status values can be provided with comma seperated strings Multiple status values can be provided with comma seperated strings
@ -61,14 +57,13 @@
return type: NSArray<SWGPet>* return type: NSArray<SWGPet>*
*/ */
-(NSNumber*) findPetsByStatusWithCompletionBlock :(NSArray*) status -(NSNumber*) findPetsByStatusWithCompletionBlock :(NSArray*) status
completionHandler: (void (^)(NSArray<SWGPet>* output, NSError* error))completionBlock; completionHandler: (void (^)(NSArray<SWGPet>* output, NSError* error))completionBlock;
/**
/**
Finds Pets by tags Finds Pets by tags
Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.
@ -78,14 +73,13 @@
return type: NSArray<SWGPet>* return type: NSArray<SWGPet>*
*/ */
-(NSNumber*) findPetsByTagsWithCompletionBlock :(NSArray*) tags -(NSNumber*) findPetsByTagsWithCompletionBlock :(NSArray*) tags
completionHandler: (void (^)(NSArray<SWGPet>* output, NSError* error))completionBlock; completionHandler: (void (^)(NSArray<SWGPet>* output, NSError* error))completionBlock;
/**
/**
Find pet by ID Find pet by ID
Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
@ -95,14 +89,13 @@
return type: SWGPet* return type: SWGPet*
*/ */
-(NSNumber*) getPetByIdWithCompletionBlock :(NSNumber*) petId -(NSNumber*) getPetByIdWithCompletionBlock :(NSNumber*) petId
completionHandler: (void (^)(SWGPet* output, NSError* error))completionBlock; completionHandler: (void (^)(SWGPet* output, NSError* error))completionBlock;
/**
/**
Updates a pet in the store with form data Updates a pet in the store with form data
@ -114,7 +107,7 @@
return type: return type:
*/ */
-(NSNumber*) updatePetWithFormWithCompletionBlock :(NSString*) petId -(NSNumber*) updatePetWithFormWithCompletionBlock :(NSString*) petId
name:(NSString*) name name:(NSString*) name
status:(NSString*) status status:(NSString*) status
@ -122,8 +115,7 @@
completionHandler: (void (^)(NSError* error))completionBlock; completionHandler: (void (^)(NSError* error))completionBlock;
/**
/**
Deletes a pet Deletes a pet
@ -134,15 +126,14 @@
return type: return type:
*/ */
-(NSNumber*) deletePetWithCompletionBlock :(NSString*) apiKey -(NSNumber*) deletePetWithCompletionBlock :(NSString*) apiKey
petId:(NSNumber*) petId petId:(NSNumber*) petId
completionHandler: (void (^)(NSError* error))completionBlock; completionHandler: (void (^)(NSError* error))completionBlock;
/**
/**
uploads an image uploads an image
@ -154,7 +145,7 @@
return type: return type:
*/ */
-(NSNumber*) uploadFileWithCompletionBlock :(NSNumber*) petId -(NSNumber*) uploadFileWithCompletionBlock :(NSNumber*) petId
additionalMetadata:(NSString*) additionalMetadata additionalMetadata:(NSString*) additionalMetadata
file:(SWGFile*) file file:(SWGFile*) file
@ -163,5 +154,4 @@
@end @end

View File

@ -1,31 +1,30 @@
#import "SWGPetApi.h" #import "SWGPetApi.h"
#import "SWGFile.h" #import "SWGFile.h"
#import "SWGQueryParamCollection.h" #import "SWGQueryParamCollection.h"
#import "SWGPet.h" #import "SWGPet.h"
#import "SWGFile.h" #import "SWGFile.h"
@interface SWGPetApi ()
@interface SWGPetApi ()
@property (readwrite, nonatomic, strong) NSMutableDictionary *defaultHeaders; @property (readwrite, nonatomic, strong) NSMutableDictionary *defaultHeaders;
@end @end
@implementation SWGPetApi @implementation SWGPetApi
static NSString * basePath = @"http://petstore.swagger.io/v2"; static NSString * basePath = @"http://petstore.swagger.io/v2";
#pragma mark - Initialize methods #pragma mark - Initialize methods
- (id) init { - (id) init {
self = [super init]; self = [super init];
if (self) { if (self) {
self.apiClient = [SWGApiClient sharedClientFromPool:basePath]; self.apiClient = [SWGApiClient sharedClientFromPool:basePath];
self.defaultHeaders = [NSMutableDictionary dictionary]; self.defaultHeaders = [NSMutableDictionary dictionary];
} }
return self; return self;
} }
- (id) initWithApiClient:(SWGApiClient *)apiClient { - (id) initWithApiClient:(SWGApiClient *)apiClient {
self = [super init]; self = [super init];
if (self) { if (self) {
if (apiClient) { if (apiClient) {
@ -37,11 +36,11 @@
self.defaultHeaders = [NSMutableDictionary dictionary]; self.defaultHeaders = [NSMutableDictionary dictionary];
} }
return self; return self;
} }
#pragma mark - #pragma mark -
+(SWGPetApi*) apiWithHeader:(NSString*)headerValue key:(NSString*)key { +(SWGPetApi*) apiWithHeader:(NSString*)headerValue key:(NSString*)key {
static SWGPetApi* singletonAPI = nil; static SWGPetApi* singletonAPI = nil;
if (singletonAPI == nil) { if (singletonAPI == nil) {
@ -49,38 +48,37 @@
[singletonAPI addHeader:headerValue forKey:key]; [singletonAPI addHeader:headerValue forKey:key];
} }
return singletonAPI; return singletonAPI;
} }
+(void) setBasePath:(NSString*)path { +(void) setBasePath:(NSString*)path {
basePath = path; basePath = path;
} }
+(NSString*) getBasePath { +(NSString*) getBasePath {
return basePath; return basePath;
} }
-(void) addHeader:(NSString*)value forKey:(NSString*)key { -(void) addHeader:(NSString*)value forKey:(NSString*)key {
[self.defaultHeaders setValue:value forKey:key]; [self.defaultHeaders setValue:value forKey:key];
} }
-(void) setHeaderValue:(NSString*) value -(void) setHeaderValue:(NSString*) value
forKey:(NSString*)key { forKey:(NSString*)key {
[self.defaultHeaders setValue:value forKey:key]; [self.defaultHeaders setValue:value forKey:key];
} }
-(unsigned long) requestQueueSize { -(unsigned long) requestQueueSize {
return [SWGApiClient requestQueueSize]; return [SWGApiClient requestQueueSize];
} }
/*!
/*!
* Update an existing pet * Update an existing pet
* *
* \param body Pet object that needs to be added to the store * \param body Pet object that needs to be added to the store
* \returns void * \returns void
*/ */
-(NSNumber*) updatePetWithCompletionBlock: (SWGPet*) body -(NSNumber*) updatePetWithCompletionBlock: (SWGPet*) body
completionHandler: (void (^)(NSError* error))completionBlock { completionHandler: (void (^)(NSError* error))completionBlock {
@ -163,32 +161,31 @@
// it's void // it's void
return [self.apiClient stringWithCompletionBlock: requestUrl return [self.apiClient stringWithCompletionBlock: requestUrl
method: @"PUT" method: @"PUT"
queryParams: queryParams queryParams: queryParams
body: bodyDictionary body: bodyDictionary
headerParams: headerParams headerParams: headerParams
authSettings: authSettings authSettings: authSettings
requestContentType: requestContentType requestContentType: requestContentType
responseContentType: responseContentType responseContentType: responseContentType
completionBlock: ^(NSString *data, NSError *error) { completionBlock: ^(NSString *data, NSError *error) {
if (error) { if (error) {
completionBlock(error); completionBlock(error);
return; return;
}
completionBlock(nil);
}];
} }
completionBlock(nil);
}];
/*! }
/*!
* Add a new pet to the store * Add a new pet to the store
* *
* \param body Pet object that needs to be added to the store * \param body Pet object that needs to be added to the store
* \returns void * \returns void
*/ */
-(NSNumber*) addPetWithCompletionBlock: (SWGPet*) body -(NSNumber*) addPetWithCompletionBlock: (SWGPet*) body
completionHandler: (void (^)(NSError* error))completionBlock { completionHandler: (void (^)(NSError* error))completionBlock {
@ -271,32 +268,31 @@ completionBlock(nil);
// it's void // it's void
return [self.apiClient stringWithCompletionBlock: requestUrl return [self.apiClient stringWithCompletionBlock: requestUrl
method: @"POST" method: @"POST"
queryParams: queryParams queryParams: queryParams
body: bodyDictionary body: bodyDictionary
headerParams: headerParams headerParams: headerParams
authSettings: authSettings authSettings: authSettings
requestContentType: requestContentType requestContentType: requestContentType
responseContentType: responseContentType responseContentType: responseContentType
completionBlock: ^(NSString *data, NSError *error) { completionBlock: ^(NSString *data, NSError *error) {
if (error) { if (error) {
completionBlock(error); completionBlock(error);
return; return;
}
completionBlock(nil);
}];
} }
completionBlock(nil);
}];
/*! }
/*!
* Finds Pets by status * Finds Pets by status
* Multiple status values can be provided with comma seperated strings * Multiple status values can be provided with comma seperated strings
* \param status Status values that need to be considered for filter * \param status Status values that need to be considered for filter
* \returns NSArray<SWGPet>* * \returns NSArray<SWGPet>*
*/ */
-(NSNumber*) findPetsByStatusWithCompletionBlock: (NSArray*) status -(NSNumber*) findPetsByStatusWithCompletionBlock: (NSArray*) status
completionHandler: (void (^)(NSArray<SWGPet>* output, NSError* error))completionBlock completionHandler: (void (^)(NSArray<SWGPet>* output, NSError* error))completionBlock
{ {
@ -358,19 +354,19 @@ completionBlock(nil);
// response is in a container // response is in a container
// array container response type // array container response type
return [self.apiClient dictionary: requestUrl return [self.apiClient dictionary: requestUrl
method: @"GET" method: @"GET"
queryParams: queryParams queryParams: queryParams
body: bodyDictionary body: bodyDictionary
headerParams: headerParams headerParams: headerParams
authSettings: authSettings authSettings: authSettings
requestContentType: requestContentType requestContentType: requestContentType
responseContentType: responseContentType responseContentType: responseContentType
completionBlock: ^(NSDictionary *data, NSError *error) { completionBlock: ^(NSDictionary *data, NSError *error) {
if (error) { if (error) {
completionBlock(nil, error); completionBlock(nil, error);
return; return;
} }
if([data isKindOfClass:[NSArray class]]){ if([data isKindOfClass:[NSArray class]]){
NSMutableArray * objs = [[NSMutableArray alloc] initWithCapacity:[data count]]; NSMutableArray * objs = [[NSMutableArray alloc] initWithCapacity:[data count]];
@ -384,23 +380,23 @@ return;
completionBlock((NSArray<SWGPet>*)objs, nil); completionBlock((NSArray<SWGPet>*)objs, nil);
} }
}];
}];
} }
/*!
/*!
* Finds Pets by tags * Finds Pets by tags
* Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. * Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.
* \param tags Tags to filter by * \param tags Tags to filter by
* \returns NSArray<SWGPet>* * \returns NSArray<SWGPet>*
*/ */
-(NSNumber*) findPetsByTagsWithCompletionBlock: (NSArray*) tags -(NSNumber*) findPetsByTagsWithCompletionBlock: (NSArray*) tags
completionHandler: (void (^)(NSArray<SWGPet>* output, NSError* error))completionBlock completionHandler: (void (^)(NSArray<SWGPet>* output, NSError* error))completionBlock
{ {
@ -462,19 +458,19 @@ return;
// response is in a container // response is in a container
// array container response type // array container response type
return [self.apiClient dictionary: requestUrl return [self.apiClient dictionary: requestUrl
method: @"GET" method: @"GET"
queryParams: queryParams queryParams: queryParams
body: bodyDictionary body: bodyDictionary
headerParams: headerParams headerParams: headerParams
authSettings: authSettings authSettings: authSettings
requestContentType: requestContentType requestContentType: requestContentType
responseContentType: responseContentType responseContentType: responseContentType
completionBlock: ^(NSDictionary *data, NSError *error) { completionBlock: ^(NSDictionary *data, NSError *error) {
if (error) { if (error) {
completionBlock(nil, error); completionBlock(nil, error);
return; return;
} }
if([data isKindOfClass:[NSArray class]]){ if([data isKindOfClass:[NSArray class]]){
NSMutableArray * objs = [[NSMutableArray alloc] initWithCapacity:[data count]]; NSMutableArray * objs = [[NSMutableArray alloc] initWithCapacity:[data count]];
@ -488,23 +484,23 @@ return;
completionBlock((NSArray<SWGPet>*)objs, nil); completionBlock((NSArray<SWGPet>*)objs, nil);
} }
}];
}];
} }
/*!
/*!
* Find pet by ID * Find pet by ID
* Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
* \param petId ID of pet that needs to be fetched * \param petId ID of pet that needs to be fetched
* \returns SWGPet* * \returns SWGPet*
*/ */
-(NSNumber*) getPetByIdWithCompletionBlock: (NSNumber*) petId -(NSNumber*) getPetByIdWithCompletionBlock: (NSNumber*) petId
completionHandler: (void (^)(SWGPet* output, NSError* error))completionBlock completionHandler: (void (^)(SWGPet* output, NSError* error))completionBlock
{ {
@ -548,7 +544,7 @@ return;
NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]];
// Authentication setting // Authentication setting
NSArray *authSettings = @[@"api_key", @"petstore_auth"]; NSArray *authSettings = @[@"petstore_auth", @"api_key"];
id bodyDictionary = nil; id bodyDictionary = nil;
@ -570,6 +566,7 @@ return;
// complex response // complex response
// comples response type // comples response type
return [self.apiClient dictionary: requestUrl return [self.apiClient dictionary: requestUrl
method: @"GET" method: @"GET"
@ -596,10 +593,10 @@ return;
}
}
/*! /*!
* Updates a pet in the store with form data * Updates a pet in the store with form data
* *
* \param petId ID of pet that needs to be updated * \param petId ID of pet that needs to be updated
@ -607,7 +604,7 @@ return;
* \param status Updated status of the pet * \param status Updated status of the pet
* \returns void * \returns void
*/ */
-(NSNumber*) updatePetWithFormWithCompletionBlock: (NSString*) petId -(NSNumber*) updatePetWithFormWithCompletionBlock: (NSString*) petId
name: (NSString*) name name: (NSString*) name
status: (NSString*) status status: (NSString*) status
@ -689,33 +686,32 @@ return;
// it's void // it's void
return [self.apiClient stringWithCompletionBlock: requestUrl return [self.apiClient stringWithCompletionBlock: requestUrl
method: @"POST" method: @"POST"
queryParams: queryParams queryParams: queryParams
body: bodyDictionary body: bodyDictionary
headerParams: headerParams headerParams: headerParams
authSettings: authSettings authSettings: authSettings
requestContentType: requestContentType requestContentType: requestContentType
responseContentType: responseContentType responseContentType: responseContentType
completionBlock: ^(NSString *data, NSError *error) { completionBlock: ^(NSString *data, NSError *error) {
if (error) { if (error) {
completionBlock(error); completionBlock(error);
return; return;
}
completionBlock(nil);
}];
} }
completionBlock(nil);
}];
/*! }
/*!
* Deletes a pet * Deletes a pet
* *
* \param apiKey * \param apiKey
* \param petId Pet id to delete * \param petId Pet id to delete
* \returns void * \returns void
*/ */
-(NSNumber*) deletePetWithCompletionBlock: (NSString*) apiKey -(NSNumber*) deletePetWithCompletionBlock: (NSString*) apiKey
petId: (NSNumber*) petId petId: (NSNumber*) petId
@ -782,26 +778,25 @@ completionBlock(nil);
// it's void // it's void
return [self.apiClient stringWithCompletionBlock: requestUrl return [self.apiClient stringWithCompletionBlock: requestUrl
method: @"DELETE" method: @"DELETE"
queryParams: queryParams queryParams: queryParams
body: bodyDictionary body: bodyDictionary
headerParams: headerParams headerParams: headerParams
authSettings: authSettings authSettings: authSettings
requestContentType: requestContentType requestContentType: requestContentType
responseContentType: responseContentType responseContentType: responseContentType
completionBlock: ^(NSString *data, NSError *error) { completionBlock: ^(NSString *data, NSError *error) {
if (error) { if (error) {
completionBlock(error); completionBlock(error);
return; return;
}
completionBlock(nil);
}];
} }
completionBlock(nil);
}];
/*! }
/*!
* uploads an image * uploads an image
* *
* \param petId ID of pet to update * \param petId ID of pet to update
@ -809,7 +804,7 @@ completionBlock(nil);
* \param file file to upload * \param file file to upload
* \returns void * \returns void
*/ */
-(NSNumber*) uploadFileWithCompletionBlock: (NSNumber*) petId -(NSNumber*) uploadFileWithCompletionBlock: (NSNumber*) petId
additionalMetadata: (NSString*) additionalMetadata additionalMetadata: (NSString*) additionalMetadata
file: (SWGFile*) file file: (SWGFile*) file
@ -898,25 +893,24 @@ completionBlock(nil);
// it's void // it's void
return [self.apiClient stringWithCompletionBlock: requestUrl return [self.apiClient stringWithCompletionBlock: requestUrl
method: @"POST" method: @"POST"
queryParams: queryParams queryParams: queryParams
body: bodyDictionary body: bodyDictionary
headerParams: headerParams headerParams: headerParams
authSettings: authSettings authSettings: authSettings
requestContentType: requestContentType requestContentType: requestContentType
responseContentType: responseContentType responseContentType: responseContentType
completionBlock: ^(NSString *data, NSError *error) { completionBlock: ^(NSString *data, NSError *error) {
if (error) { if (error) {
completionBlock(error); completionBlock(error);
return; return;
}
completionBlock(nil);
}];
} }
completionBlock(nil);
}];
}
@end @end

View File

@ -1,22 +1,20 @@
#import #import <Foundation/Foundation.h>
<Foundation/Foundation.h>
#import "SWGOrder.h" #import "SWGOrder.h"
#import "SWGObject.h" #import "SWGObject.h"
#import "SWGApiClient.h" #import "SWGApiClient.h"
@interface SWGStoreApi: NSObject @interface SWGStoreApi: NSObject
@property(nonatomic, assign)SWGApiClient *apiClient; @property(nonatomic, assign)SWGApiClient *apiClient;
-(instancetype) initWithApiClient:(SWGApiClient *)apiClient; -(instancetype) initWithApiClient:(SWGApiClient *)apiClient;
-(void) addHeader:(NSString*)value forKey:(NSString*)key; -(void) addHeader:(NSString*)value forKey:(NSString*)key;
-(unsigned long) requestQueueSize; -(unsigned long) requestQueueSize;
+(SWGStoreApi*) apiWithHeader:(NSString*)headerValue key:(NSString*)key; +(SWGStoreApi*) apiWithHeader:(NSString*)headerValue key:(NSString*)key;
+(void) setBasePath:(NSString*)basePath; +(void) setBasePath:(NSString*)basePath;
+(NSString*) getBasePath; +(NSString*) getBasePath;
/**
/**
Returns pet inventories by status Returns pet inventories by status
Returns a map of status codes to quantities Returns a map of status codes to quantities
@ -25,13 +23,12 @@
return type: NSDictionary* return type: NSDictionary*
*/ */
-(NSNumber*) getInventoryWithCompletionBlock : -(NSNumber*) getInventoryWithCompletionBlock :
(void (^)(NSDictionary* output, NSError* error))completionBlock; (void (^)(NSDictionary* output, NSError* error))completionBlock;
/**
/**
Place an order for a pet Place an order for a pet
@ -41,14 +38,13 @@
return type: SWGOrder* return type: SWGOrder*
*/ */
-(NSNumber*) placeOrderWithCompletionBlock :(SWGOrder*) body -(NSNumber*) placeOrderWithCompletionBlock :(SWGOrder*) body
completionHandler: (void (^)(SWGOrder* output, NSError* error))completionBlock; completionHandler: (void (^)(SWGOrder* output, NSError* error))completionBlock;
/**
/**
Find purchase order by ID Find purchase order by ID
For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
@ -58,14 +54,13 @@
return type: SWGOrder* return type: SWGOrder*
*/ */
-(NSNumber*) getOrderByIdWithCompletionBlock :(NSString*) orderId -(NSNumber*) getOrderByIdWithCompletionBlock :(NSString*) orderId
completionHandler: (void (^)(SWGOrder* output, NSError* error))completionBlock; completionHandler: (void (^)(SWGOrder* output, NSError* error))completionBlock;
/**
/**
Delete purchase order by ID Delete purchase order by ID
For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
@ -75,12 +70,11 @@
return type: return type:
*/ */
-(NSNumber*) deleteOrderWithCompletionBlock :(NSString*) orderId -(NSNumber*) deleteOrderWithCompletionBlock :(NSString*) orderId
completionHandler: (void (^)(NSError* error))completionBlock; completionHandler: (void (^)(NSError* error))completionBlock;
@end @end

View File

@ -1,30 +1,29 @@
#import "SWGStoreApi.h" #import "SWGStoreApi.h"
#import "SWGFile.h" #import "SWGFile.h"
#import "SWGQueryParamCollection.h" #import "SWGQueryParamCollection.h"
#import "SWGOrder.h" #import "SWGOrder.h"
@interface SWGStoreApi ()
@interface SWGStoreApi ()
@property (readwrite, nonatomic, strong) NSMutableDictionary *defaultHeaders; @property (readwrite, nonatomic, strong) NSMutableDictionary *defaultHeaders;
@end @end
@implementation SWGStoreApi @implementation SWGStoreApi
static NSString * basePath = @"http://petstore.swagger.io/v2"; static NSString * basePath = @"http://petstore.swagger.io/v2";
#pragma mark - Initialize methods #pragma mark - Initialize methods
- (id) init { - (id) init {
self = [super init]; self = [super init];
if (self) { if (self) {
self.apiClient = [SWGApiClient sharedClientFromPool:basePath]; self.apiClient = [SWGApiClient sharedClientFromPool:basePath];
self.defaultHeaders = [NSMutableDictionary dictionary]; self.defaultHeaders = [NSMutableDictionary dictionary];
} }
return self; return self;
} }
- (id) initWithApiClient:(SWGApiClient *)apiClient { - (id) initWithApiClient:(SWGApiClient *)apiClient {
self = [super init]; self = [super init];
if (self) { if (self) {
if (apiClient) { if (apiClient) {
@ -36,11 +35,11 @@
self.defaultHeaders = [NSMutableDictionary dictionary]; self.defaultHeaders = [NSMutableDictionary dictionary];
} }
return self; return self;
} }
#pragma mark - #pragma mark -
+(SWGStoreApi*) apiWithHeader:(NSString*)headerValue key:(NSString*)key { +(SWGStoreApi*) apiWithHeader:(NSString*)headerValue key:(NSString*)key {
static SWGStoreApi* singletonAPI = nil; static SWGStoreApi* singletonAPI = nil;
if (singletonAPI == nil) { if (singletonAPI == nil) {
@ -48,37 +47,36 @@
[singletonAPI addHeader:headerValue forKey:key]; [singletonAPI addHeader:headerValue forKey:key];
} }
return singletonAPI; return singletonAPI;
} }
+(void) setBasePath:(NSString*)path { +(void) setBasePath:(NSString*)path {
basePath = path; basePath = path;
} }
+(NSString*) getBasePath { +(NSString*) getBasePath {
return basePath; return basePath;
} }
-(void) addHeader:(NSString*)value forKey:(NSString*)key { -(void) addHeader:(NSString*)value forKey:(NSString*)key {
[self.defaultHeaders setValue:value forKey:key]; [self.defaultHeaders setValue:value forKey:key];
} }
-(void) setHeaderValue:(NSString*) value -(void) setHeaderValue:(NSString*) value
forKey:(NSString*)key { forKey:(NSString*)key {
[self.defaultHeaders setValue:value forKey:key]; [self.defaultHeaders setValue:value forKey:key];
} }
-(unsigned long) requestQueueSize { -(unsigned long) requestQueueSize {
return [SWGApiClient requestQueueSize]; return [SWGApiClient requestQueueSize];
} }
/*!
/*!
* Returns pet inventories by status * Returns pet inventories by status
* Returns a map of status codes to quantities * Returns a map of status codes to quantities
* \returns NSDictionary* * \returns NSDictionary*
*/ */
-(NSNumber*) getInventoryWithCompletionBlock: -(NSNumber*) getInventoryWithCompletionBlock:
(void (^)(NSDictionary* output, NSError* error))completionBlock (void (^)(NSDictionary* output, NSError* error))completionBlock
{ {
@ -133,41 +131,42 @@
// response is in a container // response is in a container
// map container response type // map container response type
return [self.apiClient dictionary: requestUrl return [self.apiClient dictionary: requestUrl
method: @"GET" method: @"GET"
queryParams: queryParams queryParams: queryParams
body: bodyDictionary body: bodyDictionary
headerParams: headerParams headerParams: headerParams
authSettings: authSettings authSettings: authSettings
requestContentType: requestContentType requestContentType: requestContentType
responseContentType: responseContentType responseContentType: responseContentType
completionBlock: ^(NSDictionary *data, NSError *error) { completionBlock: ^(NSDictionary *data, NSError *error) {
if (error) { if (error) {
completionBlock(nil, error); completionBlock(nil, error);
return; return;
} }
NSDictionary *result = nil; NSDictionary *result = nil;
if (data) { if (data) {
result = [[NSDictionary alloc]initWithDictionary: data]; result = [[NSDictionary alloc]initWithDictionary: data];
} }
completionBlock(data, nil); completionBlock(data, nil);
}];
}];
} }
/*!
/*!
* Place an order for a pet * Place an order for a pet
* *
* \param body order placed for purchasing the pet * \param body order placed for purchasing the pet
* \returns SWGOrder* * \returns SWGOrder*
*/ */
-(NSNumber*) placeOrderWithCompletionBlock: (SWGOrder*) body -(NSNumber*) placeOrderWithCompletionBlock: (SWGOrder*) body
completionHandler: (void (^)(SWGOrder* output, NSError* error))completionBlock completionHandler: (void (^)(SWGOrder* output, NSError* error))completionBlock
{ {
@ -252,6 +251,7 @@ return;
// complex response // complex response
// comples response type // comples response type
return [self.apiClient dictionary: requestUrl return [self.apiClient dictionary: requestUrl
method: @"POST" method: @"POST"
@ -278,16 +278,16 @@ return;
}
}
/*! /*!
* Find purchase order by ID * Find purchase order by ID
* For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
* \param orderId ID of pet that needs to be fetched * \param orderId ID of pet that needs to be fetched
* \returns SWGOrder* * \returns SWGOrder*
*/ */
-(NSNumber*) getOrderByIdWithCompletionBlock: (NSString*) orderId -(NSNumber*) getOrderByIdWithCompletionBlock: (NSString*) orderId
completionHandler: (void (^)(SWGOrder* output, NSError* error))completionBlock completionHandler: (void (^)(SWGOrder* output, NSError* error))completionBlock
{ {
@ -353,6 +353,7 @@ return;
// complex response // complex response
// comples response type // comples response type
return [self.apiClient dictionary: requestUrl return [self.apiClient dictionary: requestUrl
method: @"GET" method: @"GET"
@ -379,16 +380,16 @@ return;
}
}
/*! /*!
* Delete purchase order by ID * Delete purchase order by ID
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
* \param orderId ID of the order that needs to be deleted * \param orderId ID of the order that needs to be deleted
* \returns void * \returns void
*/ */
-(NSNumber*) deleteOrderWithCompletionBlock: (NSString*) orderId -(NSNumber*) deleteOrderWithCompletionBlock: (NSString*) orderId
completionHandler: (void (^)(NSError* error))completionBlock { completionHandler: (void (^)(NSError* error))completionBlock {
@ -452,25 +453,24 @@ return;
// it's void // it's void
return [self.apiClient stringWithCompletionBlock: requestUrl return [self.apiClient stringWithCompletionBlock: requestUrl
method: @"DELETE" method: @"DELETE"
queryParams: queryParams queryParams: queryParams
body: bodyDictionary body: bodyDictionary
headerParams: headerParams headerParams: headerParams
authSettings: authSettings authSettings: authSettings
requestContentType: requestContentType requestContentType: requestContentType
responseContentType: responseContentType responseContentType: responseContentType
completionBlock: ^(NSString *data, NSError *error) { completionBlock: ^(NSString *data, NSError *error) {
if (error) { if (error) {
completionBlock(error); completionBlock(error);
return; return;
}
completionBlock(nil);
}];
} }
completionBlock(nil);
}];
}
@end @end

View File

@ -1,21 +1,15 @@
#import #import <Foundation/Foundation.h>
<Foundation/Foundation.h>
#import "SWGObject.h" #import "SWGObject.h"
@protocol SWGTag
@end
@protocol SWGTag @interface SWGTag : SWGObject
@end
@interface SWGTag : SWGObject
@property(nonatomic) NSNumber* _id;
@property(nonatomic) NSNumber* _id; @property(nonatomic) NSString* name;
@property(nonatomic) NSString* name;
@end
@end

View File

@ -1,15 +1,14 @@
#import "SWGTag.h"
#import "SWGTag.h" @implementation SWGTag
@implementation SWGTag + (JSONKeyMapper *)keyMapper
{
+ (JSONKeyMapper *)keyMapper
{
return [[JSONKeyMapper alloc] initWithDictionary:@{ @"id": @"_id", @"name": @"name" }]; return [[JSONKeyMapper alloc] initWithDictionary:@{ @"id": @"_id", @"name": @"name" }];
} }
+ (BOOL)propertyIsOptional:(NSString *)propertyName + (BOOL)propertyIsOptional:(NSString *)propertyName
{ {
NSArray *optionalProperties = @[@"_id", @"name"]; NSArray *optionalProperties = @[@"_id", @"name"];
if ([optionalProperties containsObject:propertyName]) { if ([optionalProperties containsObject:propertyName]) {
@ -18,7 +17,6 @@
else { else {
return NO; return NO;
} }
} }
@end
@end

View File

@ -1,40 +1,28 @@
#import #import <Foundation/Foundation.h>
<Foundation/Foundation.h>
#import "SWGObject.h" #import "SWGObject.h"
@protocol SWGUser
@end
@protocol SWGUser @interface SWGUser : SWGObject
@end
@interface SWGUser : SWGObject
@property(nonatomic) NSNumber* _id;
@property(nonatomic) NSNumber* _id; @property(nonatomic) NSString* username;
@property(nonatomic) NSString* firstName;
@property(nonatomic) NSString* username; @property(nonatomic) NSString* lastName;
@property(nonatomic) NSString* email;
@property(nonatomic) NSString* firstName; @property(nonatomic) NSString* password;
@property(nonatomic) NSString* phone;
@property(nonatomic) NSString* lastName; /* User Status [optional]
@property(nonatomic) NSString* email;
@property(nonatomic) NSString* password;
@property(nonatomic) NSString* phone;
/* User Status [optional]
*/ */
@property(nonatomic) NSNumber* userStatus; @property(nonatomic) NSNumber* userStatus;
@end
@end

View File

@ -1,15 +1,14 @@
#import "SWGUser.h"
#import "SWGUser.h" @implementation SWGUser
@implementation SWGUser + (JSONKeyMapper *)keyMapper
{
+ (JSONKeyMapper *)keyMapper
{
return [[JSONKeyMapper alloc] initWithDictionary:@{ @"id": @"_id", @"username": @"username", @"firstName": @"firstName", @"lastName": @"lastName", @"email": @"email", @"password": @"password", @"phone": @"phone", @"userStatus": @"userStatus" }]; return [[JSONKeyMapper alloc] initWithDictionary:@{ @"id": @"_id", @"username": @"username", @"firstName": @"firstName", @"lastName": @"lastName", @"email": @"email", @"password": @"password", @"phone": @"phone", @"userStatus": @"userStatus" }];
} }
+ (BOOL)propertyIsOptional:(NSString *)propertyName + (BOOL)propertyIsOptional:(NSString *)propertyName
{ {
NSArray *optionalProperties = @[@"_id", @"username", @"firstName", @"lastName", @"email", @"password", @"phone", @"userStatus"]; NSArray *optionalProperties = @[@"_id", @"username", @"firstName", @"lastName", @"email", @"password", @"phone", @"userStatus"];
if ([optionalProperties containsObject:propertyName]) { if ([optionalProperties containsObject:propertyName]) {
@ -18,7 +17,6 @@
else { else {
return NO; return NO;
} }
} }
@end
@end

View File

@ -1,22 +1,20 @@
#import #import <Foundation/Foundation.h>
<Foundation/Foundation.h>
#import "SWGUser.h" #import "SWGUser.h"
#import "SWGObject.h" #import "SWGObject.h"
#import "SWGApiClient.h" #import "SWGApiClient.h"
@interface SWGUserApi: NSObject @interface SWGUserApi: NSObject
@property(nonatomic, assign)SWGApiClient *apiClient; @property(nonatomic, assign)SWGApiClient *apiClient;
-(instancetype) initWithApiClient:(SWGApiClient *)apiClient; -(instancetype) initWithApiClient:(SWGApiClient *)apiClient;
-(void) addHeader:(NSString*)value forKey:(NSString*)key; -(void) addHeader:(NSString*)value forKey:(NSString*)key;
-(unsigned long) requestQueueSize; -(unsigned long) requestQueueSize;
+(SWGUserApi*) apiWithHeader:(NSString*)headerValue key:(NSString*)key; +(SWGUserApi*) apiWithHeader:(NSString*)headerValue key:(NSString*)key;
+(void) setBasePath:(NSString*)basePath; +(void) setBasePath:(NSString*)basePath;
+(NSString*) getBasePath; +(NSString*) getBasePath;
/**
/**
Create user Create user
This can only be done by the logged in user. This can only be done by the logged in user.
@ -26,14 +24,13 @@
return type: return type:
*/ */
-(NSNumber*) createUserWithCompletionBlock :(SWGUser*) body -(NSNumber*) createUserWithCompletionBlock :(SWGUser*) body
completionHandler: (void (^)(NSError* error))completionBlock; completionHandler: (void (^)(NSError* error))completionBlock;
/**
/**
Creates list of users with given input array Creates list of users with given input array
@ -43,14 +40,13 @@
return type: return type:
*/ */
-(NSNumber*) createUsersWithArrayInputWithCompletionBlock :(NSArray<SWGUser>*) body -(NSNumber*) createUsersWithArrayInputWithCompletionBlock :(NSArray<SWGUser>*) body
completionHandler: (void (^)(NSError* error))completionBlock; completionHandler: (void (^)(NSError* error))completionBlock;
/**
/**
Creates list of users with given input array Creates list of users with given input array
@ -60,14 +56,13 @@
return type: return type:
*/ */
-(NSNumber*) createUsersWithListInputWithCompletionBlock :(NSArray<SWGUser>*) body -(NSNumber*) createUsersWithListInputWithCompletionBlock :(NSArray<SWGUser>*) body
completionHandler: (void (^)(NSError* error))completionBlock; completionHandler: (void (^)(NSError* error))completionBlock;
/**
/**
Logs user into the system Logs user into the system
@ -78,15 +73,14 @@
return type: NSString* return type: NSString*
*/ */
-(NSNumber*) loginUserWithCompletionBlock :(NSString*) username -(NSNumber*) loginUserWithCompletionBlock :(NSString*) username
password:(NSString*) password password:(NSString*) password
completionHandler: (void (^)(NSString* output, NSError* error))completionBlock; completionHandler: (void (^)(NSString* output, NSError* error))completionBlock;
/**
/**
Logs out current logged in user session Logs out current logged in user session
@ -95,13 +89,12 @@
return type: return type:
*/ */
-(NSNumber*) logoutUserWithCompletionBlock : -(NSNumber*) logoutUserWithCompletionBlock :
(void (^)(NSError* error))completionBlock; (void (^)(NSError* error))completionBlock;
/**
/**
Get user by user name Get user by user name
@ -111,14 +104,13 @@
return type: SWGUser* return type: SWGUser*
*/ */
-(NSNumber*) getUserByNameWithCompletionBlock :(NSString*) username -(NSNumber*) getUserByNameWithCompletionBlock :(NSString*) username
completionHandler: (void (^)(SWGUser* output, NSError* error))completionBlock; completionHandler: (void (^)(SWGUser* output, NSError* error))completionBlock;
/**
/**
Updated user Updated user
This can only be done by the logged in user. This can only be done by the logged in user.
@ -129,15 +121,14 @@
return type: return type:
*/ */
-(NSNumber*) updateUserWithCompletionBlock :(NSString*) username -(NSNumber*) updateUserWithCompletionBlock :(NSString*) username
body:(SWGUser*) body body:(SWGUser*) body
completionHandler: (void (^)(NSError* error))completionBlock; completionHandler: (void (^)(NSError* error))completionBlock;
/**
/**
Delete user Delete user
This can only be done by the logged in user. This can only be done by the logged in user.
@ -147,12 +138,11 @@
return type: return type:
*/ */
-(NSNumber*) deleteUserWithCompletionBlock :(NSString*) username -(NSNumber*) deleteUserWithCompletionBlock :(NSString*) username
completionHandler: (void (^)(NSError* error))completionBlock; completionHandler: (void (^)(NSError* error))completionBlock;
@end @end

View File

@ -1,30 +1,29 @@
#import "SWGUserApi.h" #import "SWGUserApi.h"
#import "SWGFile.h" #import "SWGFile.h"
#import "SWGQueryParamCollection.h" #import "SWGQueryParamCollection.h"
#import "SWGUser.h" #import "SWGUser.h"
@interface SWGUserApi ()
@interface SWGUserApi ()
@property (readwrite, nonatomic, strong) NSMutableDictionary *defaultHeaders; @property (readwrite, nonatomic, strong) NSMutableDictionary *defaultHeaders;
@end @end
@implementation SWGUserApi @implementation SWGUserApi
static NSString * basePath = @"http://petstore.swagger.io/v2"; static NSString * basePath = @"http://petstore.swagger.io/v2";
#pragma mark - Initialize methods #pragma mark - Initialize methods
- (id) init { - (id) init {
self = [super init]; self = [super init];
if (self) { if (self) {
self.apiClient = [SWGApiClient sharedClientFromPool:basePath]; self.apiClient = [SWGApiClient sharedClientFromPool:basePath];
self.defaultHeaders = [NSMutableDictionary dictionary]; self.defaultHeaders = [NSMutableDictionary dictionary];
} }
return self; return self;
} }
- (id) initWithApiClient:(SWGApiClient *)apiClient { - (id) initWithApiClient:(SWGApiClient *)apiClient {
self = [super init]; self = [super init];
if (self) { if (self) {
if (apiClient) { if (apiClient) {
@ -36,11 +35,11 @@
self.defaultHeaders = [NSMutableDictionary dictionary]; self.defaultHeaders = [NSMutableDictionary dictionary];
} }
return self; return self;
} }
#pragma mark - #pragma mark -
+(SWGUserApi*) apiWithHeader:(NSString*)headerValue key:(NSString*)key { +(SWGUserApi*) apiWithHeader:(NSString*)headerValue key:(NSString*)key {
static SWGUserApi* singletonAPI = nil; static SWGUserApi* singletonAPI = nil;
if (singletonAPI == nil) { if (singletonAPI == nil) {
@ -48,38 +47,37 @@
[singletonAPI addHeader:headerValue forKey:key]; [singletonAPI addHeader:headerValue forKey:key];
} }
return singletonAPI; return singletonAPI;
} }
+(void) setBasePath:(NSString*)path { +(void) setBasePath:(NSString*)path {
basePath = path; basePath = path;
} }
+(NSString*) getBasePath { +(NSString*) getBasePath {
return basePath; return basePath;
} }
-(void) addHeader:(NSString*)value forKey:(NSString*)key { -(void) addHeader:(NSString*)value forKey:(NSString*)key {
[self.defaultHeaders setValue:value forKey:key]; [self.defaultHeaders setValue:value forKey:key];
} }
-(void) setHeaderValue:(NSString*) value -(void) setHeaderValue:(NSString*) value
forKey:(NSString*)key { forKey:(NSString*)key {
[self.defaultHeaders setValue:value forKey:key]; [self.defaultHeaders setValue:value forKey:key];
} }
-(unsigned long) requestQueueSize { -(unsigned long) requestQueueSize {
return [SWGApiClient requestQueueSize]; return [SWGApiClient requestQueueSize];
} }
/*!
/*!
* Create user * Create user
* This can only be done by the logged in user. * This can only be done by the logged in user.
* \param body Created user object * \param body Created user object
* \returns void * \returns void
*/ */
-(NSNumber*) createUserWithCompletionBlock: (SWGUser*) body -(NSNumber*) createUserWithCompletionBlock: (SWGUser*) body
completionHandler: (void (^)(NSError* error))completionBlock { completionHandler: (void (^)(NSError* error))completionBlock {
@ -162,32 +160,31 @@
// it's void // it's void
return [self.apiClient stringWithCompletionBlock: requestUrl return [self.apiClient stringWithCompletionBlock: requestUrl
method: @"POST" method: @"POST"
queryParams: queryParams queryParams: queryParams
body: bodyDictionary body: bodyDictionary
headerParams: headerParams headerParams: headerParams
authSettings: authSettings authSettings: authSettings
requestContentType: requestContentType requestContentType: requestContentType
responseContentType: responseContentType responseContentType: responseContentType
completionBlock: ^(NSString *data, NSError *error) { completionBlock: ^(NSString *data, NSError *error) {
if (error) { if (error) {
completionBlock(error); completionBlock(error);
return; return;
}
completionBlock(nil);
}];
} }
completionBlock(nil);
}];
/*! }
/*!
* Creates list of users with given input array * Creates list of users with given input array
* *
* \param body List of user object * \param body List of user object
* \returns void * \returns void
*/ */
-(NSNumber*) createUsersWithArrayInputWithCompletionBlock: (NSArray<SWGUser>*) body -(NSNumber*) createUsersWithArrayInputWithCompletionBlock: (NSArray<SWGUser>*) body
completionHandler: (void (^)(NSError* error))completionBlock { completionHandler: (void (^)(NSError* error))completionBlock {
@ -270,32 +267,31 @@ completionBlock(nil);
// it's void // it's void
return [self.apiClient stringWithCompletionBlock: requestUrl return [self.apiClient stringWithCompletionBlock: requestUrl
method: @"POST" method: @"POST"
queryParams: queryParams queryParams: queryParams
body: bodyDictionary body: bodyDictionary
headerParams: headerParams headerParams: headerParams
authSettings: authSettings authSettings: authSettings
requestContentType: requestContentType requestContentType: requestContentType
responseContentType: responseContentType responseContentType: responseContentType
completionBlock: ^(NSString *data, NSError *error) { completionBlock: ^(NSString *data, NSError *error) {
if (error) { if (error) {
completionBlock(error); completionBlock(error);
return; return;
}
completionBlock(nil);
}];
} }
completionBlock(nil);
}];
/*! }
/*!
* Creates list of users with given input array * Creates list of users with given input array
* *
* \param body List of user object * \param body List of user object
* \returns void * \returns void
*/ */
-(NSNumber*) createUsersWithListInputWithCompletionBlock: (NSArray<SWGUser>*) body -(NSNumber*) createUsersWithListInputWithCompletionBlock: (NSArray<SWGUser>*) body
completionHandler: (void (^)(NSError* error))completionBlock { completionHandler: (void (^)(NSError* error))completionBlock {
@ -378,33 +374,32 @@ completionBlock(nil);
// it's void // it's void
return [self.apiClient stringWithCompletionBlock: requestUrl return [self.apiClient stringWithCompletionBlock: requestUrl
method: @"POST" method: @"POST"
queryParams: queryParams queryParams: queryParams
body: bodyDictionary body: bodyDictionary
headerParams: headerParams headerParams: headerParams
authSettings: authSettings authSettings: authSettings
requestContentType: requestContentType requestContentType: requestContentType
responseContentType: responseContentType responseContentType: responseContentType
completionBlock: ^(NSString *data, NSError *error) { completionBlock: ^(NSString *data, NSError *error) {
if (error) { if (error) {
completionBlock(error); completionBlock(error);
return; return;
}
completionBlock(nil);
}];
} }
completionBlock(nil);
}];
/*! }
/*!
* Logs user into the system * Logs user into the system
* *
* \param username The user name for login * \param username The user name for login
* \param password The password for login in clear text * \param password The password for login in clear text
* \returns NSString* * \returns NSString*
*/ */
-(NSNumber*) loginUserWithCompletionBlock: (NSString*) username -(NSNumber*) loginUserWithCompletionBlock: (NSString*) username
password: (NSString*) password password: (NSString*) password
completionHandler: (void (^)(NSString* output, NSError* error))completionBlock completionHandler: (void (^)(NSString* output, NSError* error))completionBlock
@ -474,22 +469,24 @@ completionBlock(nil);
// primitive response // primitive response
// primitive response type // primitive response type
return [self.apiClient stringWithCompletionBlock: requestUrl return [self.apiClient stringWithCompletionBlock: requestUrl
method: @"GET" method: @"GET"
queryParams: queryParams queryParams: queryParams
body: bodyDictionary body: bodyDictionary
headerParams: headerParams headerParams: headerParams
authSettings: authSettings authSettings: authSettings
requestContentType: requestContentType requestContentType: requestContentType
responseContentType: responseContentType responseContentType: responseContentType
completionBlock: ^(NSString *data, NSError *error) { completionBlock: ^(NSString *data, NSError *error) {
if (error) { if (error) {
completionBlock(nil, error); completionBlock(nil, error);
return; return;
} }
NSString *result = data ? [[NSString alloc]initWithString: data] : nil; NSString *result = data ? [[NSString alloc]initWithString: data] : nil;
completionBlock(result, nil); completionBlock(result, nil);
}]; }];
@ -499,15 +496,15 @@ completionBlock(result, nil);
}
}
/*! /*!
* Logs out current logged in user session * Logs out current logged in user session
* *
* \returns void * \returns void
*/ */
-(NSNumber*) logoutUserWithCompletionBlock: -(NSNumber*) logoutUserWithCompletionBlock:
(void (^)(NSError* error))completionBlock { (void (^)(NSError* error))completionBlock {
@ -566,32 +563,31 @@ completionBlock(result, nil);
// it's void // it's void
return [self.apiClient stringWithCompletionBlock: requestUrl return [self.apiClient stringWithCompletionBlock: requestUrl
method: @"GET" method: @"GET"
queryParams: queryParams queryParams: queryParams
body: bodyDictionary body: bodyDictionary
headerParams: headerParams headerParams: headerParams
authSettings: authSettings authSettings: authSettings
requestContentType: requestContentType requestContentType: requestContentType
responseContentType: responseContentType responseContentType: responseContentType
completionBlock: ^(NSString *data, NSError *error) { completionBlock: ^(NSString *data, NSError *error) {
if (error) { if (error) {
completionBlock(error); completionBlock(error);
return; return;
}
completionBlock(nil);
}];
} }
completionBlock(nil);
}];
/*! }
/*!
* Get user by user name * Get user by user name
* *
* \param username The name that needs to be fetched. Use user1 for testing. * \param username The name that needs to be fetched. Use user1 for testing.
* \returns SWGUser* * \returns SWGUser*
*/ */
-(NSNumber*) getUserByNameWithCompletionBlock: (NSString*) username -(NSNumber*) getUserByNameWithCompletionBlock: (NSString*) username
completionHandler: (void (^)(SWGUser* output, NSError* error))completionBlock completionHandler: (void (^)(SWGUser* output, NSError* error))completionBlock
{ {
@ -657,6 +653,7 @@ completionBlock(nil);
// complex response // complex response
// comples response type // comples response type
return [self.apiClient dictionary: requestUrl return [self.apiClient dictionary: requestUrl
method: @"GET" method: @"GET"
@ -683,17 +680,17 @@ completionBlock(nil);
}
}
/*! /*!
* Updated user * Updated user
* This can only be done by the logged in user. * This can only be done by the logged in user.
* \param username name that need to be deleted * \param username name that need to be deleted
* \param body Updated user object * \param body Updated user object
* \returns void * \returns void
*/ */
-(NSNumber*) updateUserWithCompletionBlock: (NSString*) username -(NSNumber*) updateUserWithCompletionBlock: (NSString*) username
body: (SWGUser*) body body: (SWGUser*) body
@ -781,32 +778,31 @@ completionBlock(nil);
// it's void // it's void
return [self.apiClient stringWithCompletionBlock: requestUrl return [self.apiClient stringWithCompletionBlock: requestUrl
method: @"PUT" method: @"PUT"
queryParams: queryParams queryParams: queryParams
body: bodyDictionary body: bodyDictionary
headerParams: headerParams headerParams: headerParams
authSettings: authSettings authSettings: authSettings
requestContentType: requestContentType requestContentType: requestContentType
responseContentType: responseContentType responseContentType: responseContentType
completionBlock: ^(NSString *data, NSError *error) { completionBlock: ^(NSString *data, NSError *error) {
if (error) { if (error) {
completionBlock(error); completionBlock(error);
return; return;
}
completionBlock(nil);
}];
} }
completionBlock(nil);
}];
/*! }
/*!
* Delete user * Delete user
* This can only be done by the logged in user. * This can only be done by the logged in user.
* \param username The name that needs to be deleted * \param username The name that needs to be deleted
* \returns void * \returns void
*/ */
-(NSNumber*) deleteUserWithCompletionBlock: (NSString*) username -(NSNumber*) deleteUserWithCompletionBlock: (NSString*) username
completionHandler: (void (^)(NSError* error))completionBlock { completionHandler: (void (^)(NSError* error))completionBlock {
@ -870,25 +866,24 @@ completionBlock(nil);
// it's void // it's void
return [self.apiClient stringWithCompletionBlock: requestUrl return [self.apiClient stringWithCompletionBlock: requestUrl
method: @"DELETE" method: @"DELETE"
queryParams: queryParams queryParams: queryParams
body: bodyDictionary body: bodyDictionary
headerParams: headerParams headerParams: headerParams
authSettings: authSettings authSettings: authSettings
requestContentType: requestContentType requestContentType: requestContentType
responseContentType: responseContentType responseContentType: responseContentType
completionBlock: ^(NSString *data, NSError *error) { completionBlock: ^(NSString *data, NSError *error) {
if (error) { if (error) {
completionBlock(error); completionBlock(error);
return; return;
}
completionBlock(nil);
}];
} }
completionBlock(nil);
}];
}
@end @end

View File

@ -317,7 +317,7 @@ sub new {
# authentication setting, if any # authentication setting, if any
my $auth_settings = ['api_key', 'petstore_auth']; my $auth_settings = ['petstore_auth', 'api_key'];
# make the API Call # make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method, my $response = $self->{api_client}->call_api($_resource_path, $_method,

View File

@ -327,7 +327,7 @@ class PetApi {
} }
// authentication setting, if any // authentication setting, if any
$authSettings = array('api_key', 'petstore_auth'); $authSettings = array('petstore_auth', 'api_key');
// make the API Call // make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method, $response = $this->apiClient->callAPI($resourcePath, $method,

View File

@ -9,8 +9,8 @@ from .models.order import Order
# import apis into sdk package # import apis into sdk package
from .apis.user_api import UserApi from .apis.user_api import UserApi
from .apis.pet_api import PetApi
from .apis.store_api import StoreApi from .apis.store_api import StoreApi
from .apis.pet_api import PetApi
# import ApiClient # import ApiClient
from .api_client import ApiClient from .api_client import ApiClient

View File

@ -2,6 +2,6 @@ from __future__ import absolute_import
# import apis into api package # import apis into api package
from .user_api import UserApi from .user_api import UserApi
from .pet_api import PetApi
from .store_api import StoreApi from .store_api import StoreApi
from .pet_api import PetApi

View File

@ -298,7 +298,7 @@ class PetApi(object):
header_params['Content-Type'] = self.api_client.select_header_content_type([]) header_params['Content-Type'] = self.api_client.select_header_content_type([])
# Authentication setting # Authentication setting
auth_settings = ['api_key', 'petstore_auth'] auth_settings = ['petstore_auth', 'api_key']
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params, response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
body=body_params, post_params=form_params, files=files, body=body_params, post_params=form_params, files=files,

View File

@ -1,77 +1,73 @@
#include "SWGCategory.h" #include "SWGCategory.h"
#include "SWGHelpers.h" #include "SWGHelpers.h"
#include #include <QJsonDocument>
<QJsonDocument> #include <QJsonArray>
#include #include <QObject>
<QJsonArray> #include <QDebug>
#include
<QObject>
#include
<QDebug>
namespace Swagger { namespace Swagger {
SWGCategory::SWGCategory(QString* json) { SWGCategory::SWGCategory(QString* json) {
init(); init();
this->fromJson(*json); this->fromJson(*json);
} }
SWGCategory::SWGCategory() { SWGCategory::SWGCategory() {
init(); init();
} }
SWGCategory::~SWGCategory() { SWGCategory::~SWGCategory() {
this->cleanup(); this->cleanup();
} }
void void
SWGCategory::init() { SWGCategory::init() {
id = 0L; id = 0L;
name = new QString(""); name = new QString("");
} }
void void
SWGCategory::cleanup() { SWGCategory::cleanup() {
if(name != NULL) { if(name != NULL) {
delete name; delete name;
} }
} }
SWGCategory* SWGCategory*
SWGCategory::fromJson(QString &json) { SWGCategory::fromJson(QString &json) {
QByteArray array (json.toStdString().c_str()); QByteArray array (json.toStdString().c_str());
QJsonDocument doc = QJsonDocument::fromJson(array); QJsonDocument doc = QJsonDocument::fromJson(array);
QJsonObject jsonObject = doc.object(); QJsonObject jsonObject = doc.object();
this->fromJsonObject(jsonObject); this->fromJsonObject(jsonObject);
return this; return this;
} }
void void
SWGCategory::fromJsonObject(QJsonObject &pJson) { SWGCategory::fromJsonObject(QJsonObject &pJson) {
setValue(&id, pJson["id"], "qint64", ""); setValue(&id, pJson["id"], "qint64", "");
setValue(&name, pJson["name"], "QString", "QString"); setValue(&name, pJson["name"], "QString", "QString");
} }
QString QString
SWGCategory::asJson () SWGCategory::asJson ()
{ {
QJsonObject* obj = this->asJsonObject(); QJsonObject* obj = this->asJsonObject();
QJsonDocument doc(*obj); QJsonDocument doc(*obj);
QByteArray bytes = doc.toJson(); QByteArray bytes = doc.toJson();
return QString(bytes); return QString(bytes);
} }
QJsonObject* QJsonObject*
SWGCategory::asJsonObject() { SWGCategory::asJsonObject() {
QJsonObject* obj = new QJsonObject(); QJsonObject* obj = new QJsonObject();
obj->insert("id", QJsonValue(id)); obj->insert("id", QJsonValue(id));
@ -83,30 +79,27 @@
return obj; return obj;
} }
qint64
qint64 SWGCategory::getId() {
SWGCategory::getId() {
return id; return id;
} }
void void
SWGCategory::setId(qint64 id) { SWGCategory::setId(qint64 id) {
this->id = id; this->id = id;
} }
QString*
QString* SWGCategory::getName() {
SWGCategory::getName() {
return name; return name;
} }
void void
SWGCategory::setName(QString* name) { SWGCategory::setName(QString* name) {
this->name = name; this->name = name;
} }
} /* namespace Swagger */
} /* namespace Swagger */

View File

@ -1,25 +1,24 @@
/* /*
* SWGCategory.h * SWGCategory.h
* *
* *
*/ */
#ifndef SWGCategory_H_ #ifndef SWGCategory_H_
#define SWGCategory_H_ #define SWGCategory_H_
#include #include <QJsonObject>
<QJsonObject>
#include <QString> #include <QString>
#include "SWGObject.h" #include "SWGObject.h"
namespace Swagger { namespace Swagger {
class SWGCategory: public SWGObject { class SWGCategory: public SWGObject {
public: public:
SWGCategory(); SWGCategory();
SWGCategory(QString* json); SWGCategory(QString* json);
virtual ~SWGCategory(); virtual ~SWGCategory();
@ -37,12 +36,12 @@
void setName(QString* name); void setName(QString* name);
private: private:
qint64 id; qint64 id;
QString* name; QString* name;
}; };
} /* namespace Swagger */ } /* namespace Swagger */
#endif /* SWGCategory_H_ */ #endif /* SWGCategory_H_ */

View File

@ -1,43 +1,32 @@
#include "SWGHelpers.h" #include "SWGHelpers.h"
#include "SWGModelFactory.h" #include "SWGModelFactory.h"
#include "SWGObject.h" #include "SWGObject.h"
#import #import <QDebug>
<QDebug> #import <QJsonArray>
#import #import <QJsonValue>
<QJsonArray>
#import
<QJsonValue>
namespace Swagger { namespace Swagger {
void void
setValue(void* value, QJsonValue obj, QString type, QString complexType) { setValue(void* value, QJsonValue obj, QString type, QString complexType) {
if(value == NULL) { if(value == NULL) {
// can't set value with a null pointer // can't set value with a null pointer
return; return;
} }
if(QStringLiteral("bool").compare(type) == 0) { if(QStringLiteral("bool").compare(type) == 0) {
bool * val = static_cast bool * val = static_cast<bool*>(value);
<bool
*>(value);
*val = obj.toBool(); *val = obj.toBool();
} }
else if(QStringLiteral("qint32").compare(type) == 0) { else if(QStringLiteral("qint32").compare(type) == 0) {
qint32 *val = static_cast qint32 *val = static_cast<qint32*>(value);
<qint32
*>(value);
*val = obj.toInt(); *val = obj.toInt();
} }
else if(QStringLiteral("qint64").compare(type) == 0) { else if(QStringLiteral("qint64").compare(type) == 0) {
qint64 *val = static_cast qint64 *val = static_cast<qint64*>(value);
<qint64
*>(value);
*val = obj.toVariant().toLongLong(); *val = obj.toVariant().toLongLong();
} }
else if (QStringLiteral("QString").compare(type) == 0) { else if (QStringLiteral("QString").compare(type) == 0) {
QString **val = static_cast QString **val = static_cast<QString**>(value);
<QString
**>(value);
if(val != NULL) { if(val != NULL) {
if(!obj.isNull()) { if(!obj.isNull()) {
@ -62,20 +51,14 @@
SWGObject * so = (SWGObject*)Swagger::create(type); SWGObject * so = (SWGObject*)Swagger::create(type);
if(so != NULL) { if(so != NULL) {
so->fromJsonObject(jsonObj); so->fromJsonObject(jsonObj);
SWGObject **val = static_cast SWGObject **val = static_cast<SWGObject**>(value);
<SWGObject
**>(value);
delete *val; delete *val;
*val = so; *val = so;
} }
} }
else if(type.startsWith("QList") && QString("").compare(complexType) != 0 && obj.isArray()) { else if(type.startsWith("QList") && QString("").compare(complexType) != 0 && obj.isArray()) {
// list of values // list of values
QList QList<void*>* output = new QList<void*>();
<void
*>* output = new QList
<void
*>();
QJsonArray arr = obj.toArray(); QJsonArray arr = obj.toArray();
foreach (const QJsonValue & jval, arr) { foreach (const QJsonValue & jval, arr) {
if(complexType.startsWith("SWG")) { if(complexType.startsWith("SWG")) {
@ -105,25 +88,19 @@
} }
} }
} }
QList QList<void*> **val = static_cast<QList<void*>**>(value);
<void
*> **val = static_cast
<QList
<void
*>**>(value);
delete *val; delete *val;
*val = output; *val = output;
} }
} }
void void
toJsonValue(QString name, void* value, QJsonObject* output, QString type) { toJsonValue(QString name, void* value, QJsonObject* output, QString type) {
if(value == NULL) { if(value == NULL) {
return; return;
} }
if(type.startsWith("SWG")) { if(type.startsWith("SWG")) {
SWGObject *swgObject = reinterpret_cast SWGObject *swgObject = reinterpret_cast<SWGObject *>(value);
<SWGObject *>(value);
if(swgObject != NULL) { if(swgObject != NULL) {
QJsonObject* o = (*swgObject).asJsonObject(); QJsonObject* o = (*swgObject).asJsonObject();
if(name != NULL) { if(name != NULL) {
@ -139,63 +116,51 @@
} }
} }
else if(QStringLiteral("QString").compare(type) == 0) { else if(QStringLiteral("QString").compare(type) == 0) {
QString* str = static_cast QString* str = static_cast<QString*>(value);
<QString
*>(value);
output->insert(name, QJsonValue(*str)); output->insert(name, QJsonValue(*str));
} }
else if(QStringLiteral("qint32").compare(type) == 0) { else if(QStringLiteral("qint32").compare(type) == 0) {
qint32* str = static_cast qint32* str = static_cast<qint32*>(value);
<qint32
*>(value);
output->insert(name, QJsonValue(*str)); output->insert(name, QJsonValue(*str));
} }
else if(QStringLiteral("qint64").compare(type) == 0) { else if(QStringLiteral("qint64").compare(type) == 0) {
qint64* str = static_cast qint64* str = static_cast<qint64*>(value);
<qint64
*>(value);
output->insert(name, QJsonValue(*str)); output->insert(name, QJsonValue(*str));
} }
else if(QStringLiteral("bool").compare(type) == 0) { else if(QStringLiteral("bool").compare(type) == 0) {
bool* str = static_cast bool* str = static_cast<bool*>(value);
<bool
*>(value);
output->insert(name, QJsonValue(*str)); output->insert(name, QJsonValue(*str));
} }
} }
void void
toJsonArray(QList toJsonArray(QList<void*>* value, QJsonArray* output, QString innerName, QString innerType) {
<void
*>* value, QJsonArray* output, QString innerName, QString innerType) {
foreach(void* obj, *value) { foreach(void* obj, *value) {
QJsonObject element; QJsonObject element;
toJsonValue(NULL, obj, &element, innerType); toJsonValue(NULL, obj, &element, innerType);
output->append(element); output->append(element);
} }
} }
QString QString
stringValue(QString* value) { stringValue(QString* value) {
QString* str = static_cast QString* str = static_cast<QString*>(value);
<QString
*>(value);
return QString(*str); return QString(*str);
} }
QString QString
stringValue(qint32 value) { stringValue(qint32 value) {
return QString::number(value); return QString::number(value);
} }
QString QString
stringValue(qint64 value) { stringValue(qint64 value) {
return QString::number(value); return QString::number(value);
} }
QString QString
stringValue(bool value) { stringValue(bool value) {
return QString(value ? "true" : "false"); return QString(value ? "true" : "false");
} }
} /* namespace Swagger */ } /* namespace Swagger */

View File

@ -1,20 +1,17 @@
#ifndef SWGHELPERS_H #ifndef SWGHELPERS_H
#define SWGHELPERS_H #define SWGHELPERS_H
#include #include <QJsonValue>
<QJsonValue>
namespace Swagger { namespace Swagger {
void setValue(void* value, QJsonValue obj, QString type, QString complexType); void setValue(void* value, QJsonValue obj, QString type, QString complexType);
void toJsonArray(QList void toJsonArray(QList<void*>* value, QJsonArray* output, QString innerName, QString innerType);
<void
*>* value, QJsonArray* output, QString innerName, QString innerType);
void toJsonValue(QString name, void* value, QJsonObject* output, QString type); void toJsonValue(QString name, void* value, QJsonObject* output, QString type);
bool isCompatibleJsonValue(QString type); bool isCompatibleJsonValue(QString type);
QString stringValue(QString* value); QString stringValue(QString* value);
QString stringValue(qint32 value); QString stringValue(qint32 value);
QString stringValue(qint64 value); QString stringValue(qint64 value);
QString stringValue(bool value); QString stringValue(bool value);
} }
#endif // SWGHELPERS_H #endif // SWGHELPERS_H

View File

@ -2,45 +2,44 @@
#define ModelFactory_H_ #define ModelFactory_H_
#include "SWGUser.h" #include "SWGUser.h"
#include "SWGCategory.h" #include "SWGCategory.h"
#include "SWGPet.h" #include "SWGPet.h"
#include "SWGTag.h" #include "SWGTag.h"
#include "SWGOrder.h" #include "SWGOrder.h"
namespace Swagger { namespace Swagger {
inline void* create(QString type) { inline void* create(QString type) {
if(QString("SWGUser").compare(type) == 0) { if(QString("SWGUser").compare(type) == 0) {
return new SWGUser(); return new SWGUser();
} }
if(QString("SWGCategory").compare(type) == 0) { if(QString("SWGCategory").compare(type) == 0) {
return new SWGCategory(); return new SWGCategory();
} }
if(QString("SWGPet").compare(type) == 0) { if(QString("SWGPet").compare(type) == 0) {
return new SWGPet(); return new SWGPet();
} }
if(QString("SWGTag").compare(type) == 0) { if(QString("SWGTag").compare(type) == 0) {
return new SWGTag(); return new SWGTag();
} }
if(QString("SWGOrder").compare(type) == 0) { if(QString("SWGOrder").compare(type) == 0) {
return new SWGOrder(); return new SWGOrder();
} }
return NULL; return NULL;
} }
inline void* create(QString json, QString type) { inline void* create(QString json, QString type) {
void* val = create(type); void* val = create(type);
if(val != NULL) { if(val != NULL) {
SWGObject* obj = static_cast SWGObject* obj = static_cast<SWGObject*>(val);
<SWGObject*>(val); return obj->fromJson(json);
return obj->fromJson(json); }
} if(type.startsWith("QString")) {
if(type.startsWith("QString")) { return new QString();
return new QString(); }
} return NULL;
return NULL; }
}
} /* namespace Swagger */ } /* namespace Swagger */
#endif /* ModelFactory_H_ */ #endif /* ModelFactory_H_ */

View File

@ -1,10 +1,9 @@
#ifndef _SWG_OBJECT_H_ #ifndef _SWG_OBJECT_H_
#define _SWG_OBJECT_H_ #define _SWG_OBJECT_H_
#include #include <QJsonValue>
<QJsonValue>
class SWGObject { class SWGObject {
public: public:
virtual QJsonObject* asJsonObject() { virtual QJsonObject* asJsonObject() {
return NULL; return NULL;
@ -20,6 +19,6 @@
virtual QString asJson() { virtual QString asJson() {
return QString(""); return QString("");
} }
}; };
#endif /* _SWG_OBJECT_H_ */ #endif /* _SWG_OBJECT_H_ */

View File

@ -1,35 +1,31 @@
#include "SWGOrder.h" #include "SWGOrder.h"
#include "SWGHelpers.h" #include "SWGHelpers.h"
#include #include <QJsonDocument>
<QJsonDocument> #include <QJsonArray>
#include #include <QObject>
<QJsonArray> #include <QDebug>
#include
<QObject>
#include
<QDebug>
namespace Swagger { namespace Swagger {
SWGOrder::SWGOrder(QString* json) { SWGOrder::SWGOrder(QString* json) {
init(); init();
this->fromJson(*json); this->fromJson(*json);
} }
SWGOrder::SWGOrder() { SWGOrder::SWGOrder() {
init(); init();
} }
SWGOrder::~SWGOrder() { SWGOrder::~SWGOrder() {
this->cleanup(); this->cleanup();
} }
void void
SWGOrder::init() { SWGOrder::init() {
id = 0L; id = 0L;
petId = 0L; petId = 0L;
quantity = 0; quantity = 0;
@ -37,10 +33,10 @@
status = new QString(""); status = new QString("");
complete = false; complete = false;
} }
void void
SWGOrder::cleanup() { SWGOrder::cleanup() {
@ -52,19 +48,19 @@
} }
} }
SWGOrder* SWGOrder*
SWGOrder::fromJson(QString &json) { SWGOrder::fromJson(QString &json) {
QByteArray array (json.toStdString().c_str()); QByteArray array (json.toStdString().c_str());
QJsonDocument doc = QJsonDocument::fromJson(array); QJsonDocument doc = QJsonDocument::fromJson(array);
QJsonObject jsonObject = doc.object(); QJsonObject jsonObject = doc.object();
this->fromJsonObject(jsonObject); this->fromJsonObject(jsonObject);
return this; return this;
} }
void void
SWGOrder::fromJsonObject(QJsonObject &pJson) { SWGOrder::fromJsonObject(QJsonObject &pJson) {
setValue(&id, pJson["id"], "qint64", ""); setValue(&id, pJson["id"], "qint64", "");
setValue(&petId, pJson["petId"], "qint64", ""); setValue(&petId, pJson["petId"], "qint64", "");
setValue(&quantity, pJson["quantity"], "qint32", ""); setValue(&quantity, pJson["quantity"], "qint32", "");
@ -72,20 +68,20 @@
setValue(&status, pJson["status"], "QString", "QString"); setValue(&status, pJson["status"], "QString", "QString");
setValue(&complete, pJson["complete"], "bool", ""); setValue(&complete, pJson["complete"], "bool", "");
} }
QString QString
SWGOrder::asJson () SWGOrder::asJson ()
{ {
QJsonObject* obj = this->asJsonObject(); QJsonObject* obj = this->asJsonObject();
QJsonDocument doc(*obj); QJsonDocument doc(*obj);
QByteArray bytes = doc.toJson(); QByteArray bytes = doc.toJson();
return QString(bytes); return QString(bytes);
} }
QJsonObject* QJsonObject*
SWGOrder::asJsonObject() { SWGOrder::asJsonObject() {
QJsonObject* obj = new QJsonObject(); QJsonObject* obj = new QJsonObject();
obj->insert("id", QJsonValue(id)); obj->insert("id", QJsonValue(id));
obj->insert("petId", QJsonValue(petId)); obj->insert("petId", QJsonValue(petId));
@ -106,70 +102,63 @@
return obj; return obj;
} }
qint64
qint64 SWGOrder::getId() {
SWGOrder::getId() {
return id; return id;
} }
void void
SWGOrder::setId(qint64 id) { SWGOrder::setId(qint64 id) {
this->id = id; this->id = id;
} }
qint64
qint64 SWGOrder::getPetId() {
SWGOrder::getPetId() {
return petId; return petId;
} }
void void
SWGOrder::setPetId(qint64 petId) { SWGOrder::setPetId(qint64 petId) {
this->petId = petId; this->petId = petId;
} }
qint32
qint32 SWGOrder::getQuantity() {
SWGOrder::getQuantity() {
return quantity; return quantity;
} }
void void
SWGOrder::setQuantity(qint32 quantity) { SWGOrder::setQuantity(qint32 quantity) {
this->quantity = quantity; this->quantity = quantity;
} }
QDateTime*
QDateTime* SWGOrder::getShipDate() {
SWGOrder::getShipDate() {
return shipDate; return shipDate;
} }
void void
SWGOrder::setShipDate(QDateTime* shipDate) { SWGOrder::setShipDate(QDateTime* shipDate) {
this->shipDate = shipDate; this->shipDate = shipDate;
} }
QString*
QString* SWGOrder::getStatus() {
SWGOrder::getStatus() {
return status; return status;
} }
void void
SWGOrder::setStatus(QString* status) { SWGOrder::setStatus(QString* status) {
this->status = status; this->status = status;
} }
bool
bool SWGOrder::getComplete() {
SWGOrder::getComplete() {
return complete; return complete;
} }
void void
SWGOrder::setComplete(bool complete) { SWGOrder::setComplete(bool complete) {
this->complete = complete; this->complete = complete;
} }
} /* namespace Swagger */
} /* namespace Swagger */

View File

@ -1,26 +1,25 @@
/* /*
* SWGOrder.h * SWGOrder.h
* *
* *
*/ */
#ifndef SWGOrder_H_ #ifndef SWGOrder_H_
#define SWGOrder_H_ #define SWGOrder_H_
#include #include <QJsonObject>
<QJsonObject>
#include "QDateTime.h" #include "QDateTime.h"
#include <QString> #include <QString>
#include "SWGObject.h" #include "SWGObject.h"
namespace Swagger { namespace Swagger {
class SWGOrder: public SWGObject { class SWGOrder: public SWGObject {
public: public:
SWGOrder(); SWGOrder();
SWGOrder(QString* json); SWGOrder(QString* json);
virtual ~SWGOrder(); virtual ~SWGOrder();
@ -46,7 +45,7 @@
void setComplete(bool complete); void setComplete(bool complete);
private: private:
qint64 id; qint64 id;
qint64 petId; qint64 petId;
qint32 quantity; qint32 quantity;
@ -54,8 +53,8 @@
QString* status; QString* status;
bool complete; bool complete;
}; };
} /* namespace Swagger */ } /* namespace Swagger */
#endif /* SWGOrder_H_ */ #endif /* SWGOrder_H_ */

View File

@ -1,35 +1,31 @@
#include "SWGPet.h" #include "SWGPet.h"
#include "SWGHelpers.h" #include "SWGHelpers.h"
#include #include <QJsonDocument>
<QJsonDocument> #include <QJsonArray>
#include #include <QObject>
<QJsonArray> #include <QDebug>
#include
<QObject>
#include
<QDebug>
namespace Swagger { namespace Swagger {
SWGPet::SWGPet(QString* json) { SWGPet::SWGPet(QString* json) {
init(); init();
this->fromJson(*json); this->fromJson(*json);
} }
SWGPet::SWGPet() { SWGPet::SWGPet() {
init(); init();
} }
SWGPet::~SWGPet() { SWGPet::~SWGPet() {
this->cleanup(); this->cleanup();
} }
void void
SWGPet::init() { SWGPet::init() {
id = 0L; id = 0L;
category = new SWGCategory(); category = new SWGCategory();
name = new QString(""); name = new QString("");
@ -37,10 +33,10 @@
tags = new QList<SWGTag*>(); tags = new QList<SWGTag*>();
status = new QString(""); status = new QString("");
} }
void void
SWGPet::cleanup() { SWGPet::cleanup() {
if(category != NULL) { if(category != NULL) {
delete category; delete category;
@ -66,19 +62,19 @@
delete status; delete status;
} }
} }
SWGPet* SWGPet*
SWGPet::fromJson(QString &json) { SWGPet::fromJson(QString &json) {
QByteArray array (json.toStdString().c_str()); QByteArray array (json.toStdString().c_str());
QJsonDocument doc = QJsonDocument::fromJson(array); QJsonDocument doc = QJsonDocument::fromJson(array);
QJsonObject jsonObject = doc.object(); QJsonObject jsonObject = doc.object();
this->fromJsonObject(jsonObject); this->fromJsonObject(jsonObject);
return this; return this;
} }
void void
SWGPet::fromJsonObject(QJsonObject &pJson) { SWGPet::fromJsonObject(QJsonObject &pJson) {
setValue(&id, pJson["id"], "qint64", ""); setValue(&id, pJson["id"], "qint64", "");
setValue(&category, pJson["category"], "SWGCategory", "SWGCategory"); setValue(&category, pJson["category"], "SWGCategory", "SWGCategory");
setValue(&name, pJson["name"], "QString", "QString"); setValue(&name, pJson["name"], "QString", "QString");
@ -86,20 +82,20 @@
setValue(&tags, pJson["tags"], "QList", "SWGTag"); setValue(&tags, pJson["tags"], "QList", "SWGTag");
setValue(&status, pJson["status"], "QString", "QString"); setValue(&status, pJson["status"], "QString", "QString");
} }
QString QString
SWGPet::asJson () SWGPet::asJson ()
{ {
QJsonObject* obj = this->asJsonObject(); QJsonObject* obj = this->asJsonObject();
QJsonDocument doc(*obj); QJsonDocument doc(*obj);
QByteArray bytes = doc.toJson(); QByteArray bytes = doc.toJson();
return QString(bytes); return QString(bytes);
} }
QJsonObject* QJsonObject*
SWGPet::asJsonObject() { SWGPet::asJsonObject() {
QJsonObject* obj = new QJsonObject(); QJsonObject* obj = new QJsonObject();
obj->insert("id", QJsonValue(id)); obj->insert("id", QJsonValue(id));
@ -118,8 +114,7 @@
QList<QString*>* photoUrlsList = photoUrls; QList<QString*>* photoUrlsList = photoUrls;
QJsonArray photoUrlsJsonArray; QJsonArray photoUrlsJsonArray;
toJsonArray((QList toJsonArray((QList<void*>*)photoUrls, &photoUrlsJsonArray, "photoUrls", "QString");
<void*>*)photoUrls, &photoUrlsJsonArray, "photoUrls", "QString");
obj->insert("photoUrls", photoUrlsJsonArray); obj->insert("photoUrls", photoUrlsJsonArray);
@ -128,8 +123,7 @@
QList<SWGTag*>* tagsList = tags; QList<SWGTag*>* tagsList = tags;
QJsonArray tagsJsonArray; QJsonArray tagsJsonArray;
toJsonArray((QList toJsonArray((QList<void*>*)tags, &tagsJsonArray, "tags", "SWGTag");
<void*>*)tags, &tagsJsonArray, "tags", "SWGTag");
obj->insert("tags", tagsJsonArray); obj->insert("tags", tagsJsonArray);
@ -143,70 +137,63 @@
return obj; return obj;
} }
qint64
qint64 SWGPet::getId() {
SWGPet::getId() {
return id; return id;
} }
void void
SWGPet::setId(qint64 id) { SWGPet::setId(qint64 id) {
this->id = id; this->id = id;
} }
SWGCategory*
SWGCategory* SWGPet::getCategory() {
SWGPet::getCategory() {
return category; return category;
} }
void void
SWGPet::setCategory(SWGCategory* category) { SWGPet::setCategory(SWGCategory* category) {
this->category = category; this->category = category;
} }
QString*
QString* SWGPet::getName() {
SWGPet::getName() {
return name; return name;
} }
void void
SWGPet::setName(QString* name) { SWGPet::setName(QString* name) {
this->name = name; this->name = name;
} }
QList<QString*>*
QList<QString*>* SWGPet::getPhotoUrls() {
SWGPet::getPhotoUrls() {
return photoUrls; return photoUrls;
} }
void void
SWGPet::setPhotoUrls(QList<QString*>* photoUrls) { SWGPet::setPhotoUrls(QList<QString*>* photoUrls) {
this->photoUrls = photoUrls; this->photoUrls = photoUrls;
} }
QList<SWGTag*>*
QList<SWGTag*>* SWGPet::getTags() {
SWGPet::getTags() {
return tags; return tags;
} }
void void
SWGPet::setTags(QList<SWGTag*>* tags) { SWGPet::setTags(QList<SWGTag*>* tags) {
this->tags = tags; this->tags = tags;
} }
QString*
QString* SWGPet::getStatus() {
SWGPet::getStatus() {
return status; return status;
} }
void void
SWGPet::setStatus(QString* status) { SWGPet::setStatus(QString* status) {
this->status = status; this->status = status;
} }
} /* namespace Swagger */
} /* namespace Swagger */

View File

@ -1,28 +1,27 @@
/* /*
* SWGPet.h * SWGPet.h
* *
* *
*/ */
#ifndef SWGPet_H_ #ifndef SWGPet_H_
#define SWGPet_H_ #define SWGPet_H_
#include #include <QJsonObject>
<QJsonObject>
#include "SWGTag.h"
#include <QList>
#include "SWGCategory.h"
#include <QString> #include <QString>
#include "SWGCategory.h"
#include <QList>
#include "SWGTag.h"
#include "SWGObject.h" #include "SWGObject.h"
namespace Swagger { namespace Swagger {
class SWGPet: public SWGObject { class SWGPet: public SWGObject {
public: public:
SWGPet(); SWGPet();
SWGPet(QString* json); SWGPet(QString* json);
virtual ~SWGPet(); virtual ~SWGPet();
@ -48,7 +47,7 @@
void setStatus(QString* status); void setStatus(QString* status);
private: private:
qint64 id; qint64 id;
SWGCategory* category; SWGCategory* category;
QString* name; QString* name;
@ -56,8 +55,8 @@
QList<SWGTag*>* tags; QList<SWGTag*>* tags;
QString* status; QString* status;
}; };
} /* namespace Swagger */ } /* namespace Swagger */
#endif /* SWGPet_H_ */ #endif /* SWGPet_H_ */

View File

@ -2,25 +2,21 @@
#include "SWGHelpers.h" #include "SWGHelpers.h"
#include "SWGModelFactory.h" #include "SWGModelFactory.h"
#include #include <QJsonArray>
<QJsonArray> #include <QJsonDocument>
#include
<QJsonDocument>
namespace Swagger { namespace Swagger {
SWGPetApi::SWGPetApi() {} SWGPetApi::SWGPetApi() {}
SWGPetApi::~SWGPetApi() {} SWGPetApi::~SWGPetApi() {}
SWGPetApi::SWGPetApi(QString host, QString basePath) { SWGPetApi::SWGPetApi(QString host, QString basePath) {
this->host = host; this->host = host;
this->basePath = basePath; this->basePath = basePath;
} }
void
SWGPetApi::updatePet(SWGPet body) {
void
SWGPetApi::updatePet(SWGPet body) {
QString fullPath; QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/pet"); fullPath.append(this->host).append(this->basePath).append("/pet");
@ -48,10 +44,10 @@
&SWGPetApi::updatePetCallback); &SWGPetApi::updatePetCallback);
worker->execute(&input); worker->execute(&input);
} }
void void
SWGPetApi::updatePetCallback(HttpRequestWorker * worker) { SWGPetApi::updatePetCallback(HttpRequestWorker * worker) {
QString msg; QString msg;
if (worker->error_type == QNetworkReply::NoError) { if (worker->error_type == QNetworkReply::NoError) {
msg = QString("Success! %1 bytes").arg(worker->response.length()); msg = QString("Success! %1 bytes").arg(worker->response.length());
@ -66,10 +62,9 @@
emit updatePetSignal(); emit updatePetSignal();
} }
void
void SWGPetApi::addPet(SWGPet body) {
SWGPetApi::addPet(SWGPet body) {
QString fullPath; QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/pet"); fullPath.append(this->host).append(this->basePath).append("/pet");
@ -97,10 +92,10 @@
&SWGPetApi::addPetCallback); &SWGPetApi::addPetCallback);
worker->execute(&input); worker->execute(&input);
} }
void void
SWGPetApi::addPetCallback(HttpRequestWorker * worker) { SWGPetApi::addPetCallback(HttpRequestWorker * worker) {
QString msg; QString msg;
if (worker->error_type == QNetworkReply::NoError) { if (worker->error_type == QNetworkReply::NoError) {
msg = QString("Success! %1 bytes").arg(worker->response.length()); msg = QString("Success! %1 bytes").arg(worker->response.length());
@ -115,10 +110,9 @@
emit addPetSignal(); emit addPetSignal();
} }
void
void SWGPetApi::findPetsByStatus(QList<QString*>* status) {
SWGPetApi::findPetsByStatus(QList<QString*>* status) {
QString fullPath; QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/pet/findByStatus"); fullPath.append(this->host).append(this->basePath).append("/pet/findByStatus");
@ -187,10 +181,10 @@
&SWGPetApi::findPetsByStatusCallback); &SWGPetApi::findPetsByStatusCallback);
worker->execute(&input); worker->execute(&input);
} }
void void
SWGPetApi::findPetsByStatusCallback(HttpRequestWorker * worker) { SWGPetApi::findPetsByStatusCallback(HttpRequestWorker * worker) {
QString msg; QString msg;
if (worker->error_type == QNetworkReply::NoError) { if (worker->error_type == QNetworkReply::NoError) {
msg = QString("Success! %1 bytes").arg(worker->response.length()); msg = QString("Success! %1 bytes").arg(worker->response.length());
@ -221,10 +215,9 @@
emit findPetsByStatusSignal(output); emit findPetsByStatusSignal(output);
} }
void
void SWGPetApi::findPetsByTags(QList<QString*>* tags) {
SWGPetApi::findPetsByTags(QList<QString*>* tags) {
QString fullPath; QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/pet/findByTags"); fullPath.append(this->host).append(this->basePath).append("/pet/findByTags");
@ -293,10 +286,10 @@
&SWGPetApi::findPetsByTagsCallback); &SWGPetApi::findPetsByTagsCallback);
worker->execute(&input); worker->execute(&input);
} }
void void
SWGPetApi::findPetsByTagsCallback(HttpRequestWorker * worker) { SWGPetApi::findPetsByTagsCallback(HttpRequestWorker * worker) {
QString msg; QString msg;
if (worker->error_type == QNetworkReply::NoError) { if (worker->error_type == QNetworkReply::NoError) {
msg = QString("Success! %1 bytes").arg(worker->response.length()); msg = QString("Success! %1 bytes").arg(worker->response.length());
@ -327,10 +320,9 @@
emit findPetsByTagsSignal(output); emit findPetsByTagsSignal(output);
} }
void
void SWGPetApi::getPetById(qint64 petId) {
SWGPetApi::getPetById(qint64 petId) {
QString fullPath; QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/pet/{petId}"); fullPath.append(this->host).append(this->basePath).append("/pet/{petId}");
@ -356,10 +348,10 @@
&SWGPetApi::getPetByIdCallback); &SWGPetApi::getPetByIdCallback);
worker->execute(&input); worker->execute(&input);
} }
void void
SWGPetApi::getPetByIdCallback(HttpRequestWorker * worker) { SWGPetApi::getPetByIdCallback(HttpRequestWorker * worker) {
QString msg; QString msg;
if (worker->error_type == QNetworkReply::NoError) { if (worker->error_type == QNetworkReply::NoError) {
msg = QString("Success! %1 bytes").arg(worker->response.length()); msg = QString("Success! %1 bytes").arg(worker->response.length());
@ -374,8 +366,7 @@
QString json(worker->response); QString json(worker->response);
SWGPet* output = static_cast<SWGPet*>(create(json, SWGPet* output = static_cast<SWGPet*>(create(json, QString("SWGPet")));
QString("SWGPet")));
@ -384,12 +375,9 @@
emit getPetByIdSignal(output); emit getPetByIdSignal(output);
} }
void
void SWGPetApi::updatePetWithForm(QString* petId, QString* name, QString* status) {
SWGPetApi::updatePetWithForm(QString* petId
, QString* name
, QString* status) {
QString fullPath; QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/pet/{petId}"); fullPath.append(this->host).append(this->basePath).append("/pet/{petId}");
@ -423,10 +411,10 @@
&SWGPetApi::updatePetWithFormCallback); &SWGPetApi::updatePetWithFormCallback);
worker->execute(&input); worker->execute(&input);
} }
void void
SWGPetApi::updatePetWithFormCallback(HttpRequestWorker * worker) { SWGPetApi::updatePetWithFormCallback(HttpRequestWorker * worker) {
QString msg; QString msg;
if (worker->error_type == QNetworkReply::NoError) { if (worker->error_type == QNetworkReply::NoError) {
msg = QString("Success! %1 bytes").arg(worker->response.length()); msg = QString("Success! %1 bytes").arg(worker->response.length());
@ -441,11 +429,9 @@
emit updatePetWithFormSignal(); emit updatePetWithFormSignal();
} }
void
void SWGPetApi::deletePet(QString* apiKey, qint64 petId) {
SWGPetApi::deletePet(QString* apiKey
, qint64 petId) {
QString fullPath; QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/pet/{petId}"); fullPath.append(this->host).append(this->basePath).append("/pet/{petId}");
@ -473,10 +459,10 @@
&SWGPetApi::deletePetCallback); &SWGPetApi::deletePetCallback);
worker->execute(&input); worker->execute(&input);
} }
void void
SWGPetApi::deletePetCallback(HttpRequestWorker * worker) { SWGPetApi::deletePetCallback(HttpRequestWorker * worker) {
QString msg; QString msg;
if (worker->error_type == QNetworkReply::NoError) { if (worker->error_type == QNetworkReply::NoError) {
msg = QString("Success! %1 bytes").arg(worker->response.length()); msg = QString("Success! %1 bytes").arg(worker->response.length());
@ -491,12 +477,9 @@
emit deletePetSignal(); emit deletePetSignal();
} }
void
void SWGPetApi::uploadFile(qint64 petId, QString* additionalMetadata, SWGHttpRequestInputFileElement* file) {
SWGPetApi::uploadFile(qint64 petId
, QString* additionalMetadata
, SWGHttpRequestInputFileElement* file) {
QString fullPath; QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/pet/{petId}/uploadImage"); fullPath.append(this->host).append(this->basePath).append("/pet/{petId}/uploadImage");
@ -526,10 +509,10 @@
&SWGPetApi::uploadFileCallback); &SWGPetApi::uploadFileCallback);
worker->execute(&input); worker->execute(&input);
} }
void void
SWGPetApi::uploadFileCallback(HttpRequestWorker * worker) { SWGPetApi::uploadFileCallback(HttpRequestWorker * worker) {
QString msg; QString msg;
if (worker->error_type == QNetworkReply::NoError) { if (worker->error_type == QNetworkReply::NoError) {
msg = QString("Success! %1 bytes").arg(worker->response.length()); msg = QString("Success! %1 bytes").arg(worker->response.length());
@ -544,7 +527,5 @@
emit uploadFileSignal(); emit uploadFileSignal();
} }
} /* namespace Swagger */
} /* namespace Swagger */

View File

@ -7,15 +7,14 @@
#include <QString> #include <QString>
#include "SWGHttpRequest.h" #include "SWGHttpRequest.h"
#include #include <QObject>
<QObject>
namespace Swagger { namespace Swagger {
class SWGPetApi: public QObject { class SWGPetApi: public QObject {
Q_OBJECT Q_OBJECT
public: public:
SWGPetApi(); SWGPetApi();
SWGPetApi(QString host, QString basePath); SWGPetApi(QString host, QString basePath);
~SWGPetApi(); ~SWGPetApi();
@ -28,16 +27,11 @@
void findPetsByStatus(QList<QString*>* status); void findPetsByStatus(QList<QString*>* status);
void findPetsByTags(QList<QString*>* tags); void findPetsByTags(QList<QString*>* tags);
void getPetById(qint64 petId); void getPetById(qint64 petId);
void updatePetWithForm(QString* petId void updatePetWithForm(QString* petId, QString* name, QString* status);
, QString* name void deletePet(QString* apiKey, qint64 petId);
, QString* status); void uploadFile(qint64 petId, QString* additionalMetadata, SWGHttpRequestInputFileElement* file);
void deletePet(QString* apiKey
, qint64 petId);
void uploadFile(qint64 petId
, QString* additionalMetadata
, SWGHttpRequestInputFileElement* file);
private: private:
void updatePetCallback (HttpRequestWorker * worker); void updatePetCallback (HttpRequestWorker * worker);
void addPetCallback (HttpRequestWorker * worker); void addPetCallback (HttpRequestWorker * worker);
void findPetsByStatusCallback (HttpRequestWorker * worker); void findPetsByStatusCallback (HttpRequestWorker * worker);
@ -47,7 +41,7 @@
void deletePetCallback (HttpRequestWorker * worker); void deletePetCallback (HttpRequestWorker * worker);
void uploadFileCallback (HttpRequestWorker * worker); void uploadFileCallback (HttpRequestWorker * worker);
signals: signals:
void updatePetSignal(); void updatePetSignal();
void addPetSignal(); void addPetSignal();
void findPetsByStatusSignal(QList<SWGPet*>* summary); void findPetsByStatusSignal(QList<SWGPet*>* summary);
@ -57,6 +51,6 @@
void deletePetSignal(); void deletePetSignal();
void uploadFileSignal(); void uploadFileSignal();
}; };
} }
#endif #endif

View File

@ -2,25 +2,21 @@
#include "SWGHelpers.h" #include "SWGHelpers.h"
#include "SWGModelFactory.h" #include "SWGModelFactory.h"
#include #include <QJsonArray>
<QJsonArray> #include <QJsonDocument>
#include
<QJsonDocument>
namespace Swagger { namespace Swagger {
SWGStoreApi::SWGStoreApi() {} SWGStoreApi::SWGStoreApi() {}
SWGStoreApi::~SWGStoreApi() {} SWGStoreApi::~SWGStoreApi() {}
SWGStoreApi::SWGStoreApi(QString host, QString basePath) { SWGStoreApi::SWGStoreApi(QString host, QString basePath) {
this->host = host; this->host = host;
this->basePath = basePath; this->basePath = basePath;
} }
void
SWGStoreApi::getInventory() {
void
SWGStoreApi::getInventory() {
QString fullPath; QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/store/inventory"); fullPath.append(this->host).append(this->basePath).append("/store/inventory");
@ -43,10 +39,10 @@
&SWGStoreApi::getInventoryCallback); &SWGStoreApi::getInventoryCallback);
worker->execute(&input); worker->execute(&input);
} }
void void
SWGStoreApi::getInventoryCallback(HttpRequestWorker * worker) { SWGStoreApi::getInventoryCallback(HttpRequestWorker * worker) {
QString msg; QString msg;
if (worker->error_type == QNetworkReply::NoError) { if (worker->error_type == QNetworkReply::NoError) {
msg = QString("Success! %1 bytes").arg(worker->response.length()); msg = QString("Success! %1 bytes").arg(worker->response.length());
@ -81,10 +77,9 @@
emit getInventorySignal(output); emit getInventorySignal(output);
} }
void
void SWGStoreApi::placeOrder(SWGOrder body) {
SWGStoreApi::placeOrder(SWGOrder body) {
QString fullPath; QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/store/order"); fullPath.append(this->host).append(this->basePath).append("/store/order");
@ -112,10 +107,10 @@
&SWGStoreApi::placeOrderCallback); &SWGStoreApi::placeOrderCallback);
worker->execute(&input); worker->execute(&input);
} }
void void
SWGStoreApi::placeOrderCallback(HttpRequestWorker * worker) { SWGStoreApi::placeOrderCallback(HttpRequestWorker * worker) {
QString msg; QString msg;
if (worker->error_type == QNetworkReply::NoError) { if (worker->error_type == QNetworkReply::NoError) {
msg = QString("Success! %1 bytes").arg(worker->response.length()); msg = QString("Success! %1 bytes").arg(worker->response.length());
@ -130,8 +125,7 @@
QString json(worker->response); QString json(worker->response);
SWGOrder* output = static_cast<SWGOrder*>(create(json, SWGOrder* output = static_cast<SWGOrder*>(create(json, QString("SWGOrder")));
QString("SWGOrder")));
@ -140,10 +134,9 @@
emit placeOrderSignal(output); emit placeOrderSignal(output);
} }
void
void SWGStoreApi::getOrderById(QString* orderId) {
SWGStoreApi::getOrderById(QString* orderId) {
QString fullPath; QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/store/order/{orderId}"); fullPath.append(this->host).append(this->basePath).append("/store/order/{orderId}");
@ -169,10 +162,10 @@
&SWGStoreApi::getOrderByIdCallback); &SWGStoreApi::getOrderByIdCallback);
worker->execute(&input); worker->execute(&input);
} }
void void
SWGStoreApi::getOrderByIdCallback(HttpRequestWorker * worker) { SWGStoreApi::getOrderByIdCallback(HttpRequestWorker * worker) {
QString msg; QString msg;
if (worker->error_type == QNetworkReply::NoError) { if (worker->error_type == QNetworkReply::NoError) {
msg = QString("Success! %1 bytes").arg(worker->response.length()); msg = QString("Success! %1 bytes").arg(worker->response.length());
@ -187,8 +180,7 @@
QString json(worker->response); QString json(worker->response);
SWGOrder* output = static_cast<SWGOrder*>(create(json, SWGOrder* output = static_cast<SWGOrder*>(create(json, QString("SWGOrder")));
QString("SWGOrder")));
@ -197,10 +189,9 @@
emit getOrderByIdSignal(output); emit getOrderByIdSignal(output);
} }
void
void SWGStoreApi::deleteOrder(QString* orderId) {
SWGStoreApi::deleteOrder(QString* orderId) {
QString fullPath; QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/store/order/{orderId}"); fullPath.append(this->host).append(this->basePath).append("/store/order/{orderId}");
@ -226,10 +217,10 @@
&SWGStoreApi::deleteOrderCallback); &SWGStoreApi::deleteOrderCallback);
worker->execute(&input); worker->execute(&input);
} }
void void
SWGStoreApi::deleteOrderCallback(HttpRequestWorker * worker) { SWGStoreApi::deleteOrderCallback(HttpRequestWorker * worker) {
QString msg; QString msg;
if (worker->error_type == QNetworkReply::NoError) { if (worker->error_type == QNetworkReply::NoError) {
msg = QString("Success! %1 bytes").arg(worker->response.length()); msg = QString("Success! %1 bytes").arg(worker->response.length());
@ -244,7 +235,5 @@
emit deleteOrderSignal(); emit deleteOrderSignal();
} }
} /* namespace Swagger */
} /* namespace Swagger */

View File

@ -7,15 +7,14 @@
#include "SWGOrder.h" #include "SWGOrder.h"
#include <QString> #include <QString>
#include #include <QObject>
<QObject>
namespace Swagger { namespace Swagger {
class SWGStoreApi: public QObject { class SWGStoreApi: public QObject {
Q_OBJECT Q_OBJECT
public: public:
SWGStoreApi(); SWGStoreApi();
SWGStoreApi(QString host, QString basePath); SWGStoreApi(QString host, QString basePath);
~SWGStoreApi(); ~SWGStoreApi();
@ -28,18 +27,18 @@
void getOrderById(QString* orderId); void getOrderById(QString* orderId);
void deleteOrder(QString* orderId); void deleteOrder(QString* orderId);
private: private:
void getInventoryCallback (HttpRequestWorker * worker); void getInventoryCallback (HttpRequestWorker * worker);
void placeOrderCallback (HttpRequestWorker * worker); void placeOrderCallback (HttpRequestWorker * worker);
void getOrderByIdCallback (HttpRequestWorker * worker); void getOrderByIdCallback (HttpRequestWorker * worker);
void deleteOrderCallback (HttpRequestWorker * worker); void deleteOrderCallback (HttpRequestWorker * worker);
signals: signals:
void getInventorySignal(QMap<QString, qint32>* summary); void getInventorySignal(QMap<QString, qint32>* summary);
void placeOrderSignal(SWGOrder* summary); void placeOrderSignal(SWGOrder* summary);
void getOrderByIdSignal(SWGOrder* summary); void getOrderByIdSignal(SWGOrder* summary);
void deleteOrderSignal(); void deleteOrderSignal();
}; };
} }
#endif #endif

View File

@ -1,77 +1,73 @@
#include "SWGTag.h" #include "SWGTag.h"
#include "SWGHelpers.h" #include "SWGHelpers.h"
#include #include <QJsonDocument>
<QJsonDocument> #include <QJsonArray>
#include #include <QObject>
<QJsonArray> #include <QDebug>
#include
<QObject>
#include
<QDebug>
namespace Swagger { namespace Swagger {
SWGTag::SWGTag(QString* json) { SWGTag::SWGTag(QString* json) {
init(); init();
this->fromJson(*json); this->fromJson(*json);
} }
SWGTag::SWGTag() { SWGTag::SWGTag() {
init(); init();
} }
SWGTag::~SWGTag() { SWGTag::~SWGTag() {
this->cleanup(); this->cleanup();
} }
void void
SWGTag::init() { SWGTag::init() {
id = 0L; id = 0L;
name = new QString(""); name = new QString("");
} }
void void
SWGTag::cleanup() { SWGTag::cleanup() {
if(name != NULL) { if(name != NULL) {
delete name; delete name;
} }
} }
SWGTag* SWGTag*
SWGTag::fromJson(QString &json) { SWGTag::fromJson(QString &json) {
QByteArray array (json.toStdString().c_str()); QByteArray array (json.toStdString().c_str());
QJsonDocument doc = QJsonDocument::fromJson(array); QJsonDocument doc = QJsonDocument::fromJson(array);
QJsonObject jsonObject = doc.object(); QJsonObject jsonObject = doc.object();
this->fromJsonObject(jsonObject); this->fromJsonObject(jsonObject);
return this; return this;
} }
void void
SWGTag::fromJsonObject(QJsonObject &pJson) { SWGTag::fromJsonObject(QJsonObject &pJson) {
setValue(&id, pJson["id"], "qint64", ""); setValue(&id, pJson["id"], "qint64", "");
setValue(&name, pJson["name"], "QString", "QString"); setValue(&name, pJson["name"], "QString", "QString");
} }
QString QString
SWGTag::asJson () SWGTag::asJson ()
{ {
QJsonObject* obj = this->asJsonObject(); QJsonObject* obj = this->asJsonObject();
QJsonDocument doc(*obj); QJsonDocument doc(*obj);
QByteArray bytes = doc.toJson(); QByteArray bytes = doc.toJson();
return QString(bytes); return QString(bytes);
} }
QJsonObject* QJsonObject*
SWGTag::asJsonObject() { SWGTag::asJsonObject() {
QJsonObject* obj = new QJsonObject(); QJsonObject* obj = new QJsonObject();
obj->insert("id", QJsonValue(id)); obj->insert("id", QJsonValue(id));
@ -83,30 +79,27 @@
return obj; return obj;
} }
qint64
qint64 SWGTag::getId() {
SWGTag::getId() {
return id; return id;
} }
void void
SWGTag::setId(qint64 id) { SWGTag::setId(qint64 id) {
this->id = id; this->id = id;
} }
QString*
QString* SWGTag::getName() {
SWGTag::getName() {
return name; return name;
} }
void void
SWGTag::setName(QString* name) { SWGTag::setName(QString* name) {
this->name = name; this->name = name;
} }
} /* namespace Swagger */
} /* namespace Swagger */

View File

@ -1,25 +1,24 @@
/* /*
* SWGTag.h * SWGTag.h
* *
* *
*/ */
#ifndef SWGTag_H_ #ifndef SWGTag_H_
#define SWGTag_H_ #define SWGTag_H_
#include #include <QJsonObject>
<QJsonObject>
#include <QString> #include <QString>
#include "SWGObject.h" #include "SWGObject.h"
namespace Swagger { namespace Swagger {
class SWGTag: public SWGObject { class SWGTag: public SWGObject {
public: public:
SWGTag(); SWGTag();
SWGTag(QString* json); SWGTag(QString* json);
virtual ~SWGTag(); virtual ~SWGTag();
@ -37,12 +36,12 @@
void setName(QString* name); void setName(QString* name);
private: private:
qint64 id; qint64 id;
QString* name; QString* name;
}; };
} /* namespace Swagger */ } /* namespace Swagger */
#endif /* SWGTag_H_ */ #endif /* SWGTag_H_ */

View File

@ -1,35 +1,31 @@
#include "SWGUser.h" #include "SWGUser.h"
#include "SWGHelpers.h" #include "SWGHelpers.h"
#include #include <QJsonDocument>
<QJsonDocument> #include <QJsonArray>
#include #include <QObject>
<QJsonArray> #include <QDebug>
#include
<QObject>
#include
<QDebug>
namespace Swagger { namespace Swagger {
SWGUser::SWGUser(QString* json) { SWGUser::SWGUser(QString* json) {
init(); init();
this->fromJson(*json); this->fromJson(*json);
} }
SWGUser::SWGUser() { SWGUser::SWGUser() {
init(); init();
} }
SWGUser::~SWGUser() { SWGUser::~SWGUser() {
this->cleanup(); this->cleanup();
} }
void void
SWGUser::init() { SWGUser::init() {
id = 0L; id = 0L;
username = new QString(""); username = new QString("");
firstName = new QString(""); firstName = new QString("");
@ -39,10 +35,10 @@
phone = new QString(""); phone = new QString("");
userStatus = 0; userStatus = 0;
} }
void void
SWGUser::cleanup() { SWGUser::cleanup() {
if(username != NULL) { if(username != NULL) {
delete username; delete username;
@ -64,19 +60,19 @@
} }
} }
SWGUser* SWGUser*
SWGUser::fromJson(QString &json) { SWGUser::fromJson(QString &json) {
QByteArray array (json.toStdString().c_str()); QByteArray array (json.toStdString().c_str());
QJsonDocument doc = QJsonDocument::fromJson(array); QJsonDocument doc = QJsonDocument::fromJson(array);
QJsonObject jsonObject = doc.object(); QJsonObject jsonObject = doc.object();
this->fromJsonObject(jsonObject); this->fromJsonObject(jsonObject);
return this; return this;
} }
void void
SWGUser::fromJsonObject(QJsonObject &pJson) { SWGUser::fromJsonObject(QJsonObject &pJson) {
setValue(&id, pJson["id"], "qint64", ""); setValue(&id, pJson["id"], "qint64", "");
setValue(&username, pJson["username"], "QString", "QString"); setValue(&username, pJson["username"], "QString", "QString");
setValue(&firstName, pJson["firstName"], "QString", "QString"); setValue(&firstName, pJson["firstName"], "QString", "QString");
@ -86,20 +82,20 @@
setValue(&phone, pJson["phone"], "QString", "QString"); setValue(&phone, pJson["phone"], "QString", "QString");
setValue(&userStatus, pJson["userStatus"], "qint32", ""); setValue(&userStatus, pJson["userStatus"], "qint32", "");
} }
QString QString
SWGUser::asJson () SWGUser::asJson ()
{ {
QJsonObject* obj = this->asJsonObject(); QJsonObject* obj = this->asJsonObject();
QJsonDocument doc(*obj); QJsonDocument doc(*obj);
QByteArray bytes = doc.toJson(); QByteArray bytes = doc.toJson();
return QString(bytes); return QString(bytes);
} }
QJsonObject* QJsonObject*
SWGUser::asJsonObject() { SWGUser::asJsonObject() {
QJsonObject* obj = new QJsonObject(); QJsonObject* obj = new QJsonObject();
obj->insert("id", QJsonValue(id)); obj->insert("id", QJsonValue(id));
@ -142,90 +138,81 @@
return obj; return obj;
} }
qint64
qint64 SWGUser::getId() {
SWGUser::getId() {
return id; return id;
} }
void void
SWGUser::setId(qint64 id) { SWGUser::setId(qint64 id) {
this->id = id; this->id = id;
} }
QString*
QString* SWGUser::getUsername() {
SWGUser::getUsername() {
return username; return username;
} }
void void
SWGUser::setUsername(QString* username) { SWGUser::setUsername(QString* username) {
this->username = username; this->username = username;
} }
QString*
QString* SWGUser::getFirstName() {
SWGUser::getFirstName() {
return firstName; return firstName;
} }
void void
SWGUser::setFirstName(QString* firstName) { SWGUser::setFirstName(QString* firstName) {
this->firstName = firstName; this->firstName = firstName;
} }
QString*
QString* SWGUser::getLastName() {
SWGUser::getLastName() {
return lastName; return lastName;
} }
void void
SWGUser::setLastName(QString* lastName) { SWGUser::setLastName(QString* lastName) {
this->lastName = lastName; this->lastName = lastName;
} }
QString*
QString* SWGUser::getEmail() {
SWGUser::getEmail() {
return email; return email;
} }
void void
SWGUser::setEmail(QString* email) { SWGUser::setEmail(QString* email) {
this->email = email; this->email = email;
} }
QString*
QString* SWGUser::getPassword() {
SWGUser::getPassword() {
return password; return password;
} }
void void
SWGUser::setPassword(QString* password) { SWGUser::setPassword(QString* password) {
this->password = password; this->password = password;
} }
QString*
QString* SWGUser::getPhone() {
SWGUser::getPhone() {
return phone; return phone;
} }
void void
SWGUser::setPhone(QString* phone) { SWGUser::setPhone(QString* phone) {
this->phone = phone; this->phone = phone;
} }
qint32
qint32 SWGUser::getUserStatus() {
SWGUser::getUserStatus() {
return userStatus; return userStatus;
} }
void void
SWGUser::setUserStatus(qint32 userStatus) { SWGUser::setUserStatus(qint32 userStatus) {
this->userStatus = userStatus; this->userStatus = userStatus;
} }
} /* namespace Swagger */
} /* namespace Swagger */

View File

@ -1,25 +1,24 @@
/* /*
* SWGUser.h * SWGUser.h
* *
* *
*/ */
#ifndef SWGUser_H_ #ifndef SWGUser_H_
#define SWGUser_H_ #define SWGUser_H_
#include #include <QJsonObject>
<QJsonObject>
#include <QString> #include <QString>
#include "SWGObject.h" #include "SWGObject.h"
namespace Swagger { namespace Swagger {
class SWGUser: public SWGObject { class SWGUser: public SWGObject {
public: public:
SWGUser(); SWGUser();
SWGUser(QString* json); SWGUser(QString* json);
virtual ~SWGUser(); virtual ~SWGUser();
@ -49,7 +48,7 @@
void setUserStatus(qint32 userStatus); void setUserStatus(qint32 userStatus);
private: private:
qint64 id; qint64 id;
QString* username; QString* username;
QString* firstName; QString* firstName;
@ -59,8 +58,8 @@
QString* phone; QString* phone;
qint32 userStatus; qint32 userStatus;
}; };
} /* namespace Swagger */ } /* namespace Swagger */
#endif /* SWGUser_H_ */ #endif /* SWGUser_H_ */

View File

@ -2,25 +2,21 @@
#include "SWGHelpers.h" #include "SWGHelpers.h"
#include "SWGModelFactory.h" #include "SWGModelFactory.h"
#include #include <QJsonArray>
<QJsonArray> #include <QJsonDocument>
#include
<QJsonDocument>
namespace Swagger { namespace Swagger {
SWGUserApi::SWGUserApi() {} SWGUserApi::SWGUserApi() {}
SWGUserApi::~SWGUserApi() {} SWGUserApi::~SWGUserApi() {}
SWGUserApi::SWGUserApi(QString host, QString basePath) { SWGUserApi::SWGUserApi(QString host, QString basePath) {
this->host = host; this->host = host;
this->basePath = basePath; this->basePath = basePath;
} }
void
SWGUserApi::createUser(SWGUser body) {
void
SWGUserApi::createUser(SWGUser body) {
QString fullPath; QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/user"); fullPath.append(this->host).append(this->basePath).append("/user");
@ -48,10 +44,10 @@
&SWGUserApi::createUserCallback); &SWGUserApi::createUserCallback);
worker->execute(&input); worker->execute(&input);
} }
void void
SWGUserApi::createUserCallback(HttpRequestWorker * worker) { SWGUserApi::createUserCallback(HttpRequestWorker * worker) {
QString msg; QString msg;
if (worker->error_type == QNetworkReply::NoError) { if (worker->error_type == QNetworkReply::NoError) {
msg = QString("Success! %1 bytes").arg(worker->response.length()); msg = QString("Success! %1 bytes").arg(worker->response.length());
@ -66,10 +62,9 @@
emit createUserSignal(); emit createUserSignal();
} }
void
void SWGUserApi::createUsersWithArrayInput(QList<SWGUser*>* body) {
SWGUserApi::createUsersWithArrayInput(QList<SWGUser*>* body) {
QString fullPath; QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/user/createWithArray"); fullPath.append(this->host).append(this->basePath).append("/user/createWithArray");
@ -85,9 +80,7 @@
QJsonArray* bodyArray = new QJsonArray(); QJsonArray* bodyArray = new QJsonArray();
toJsonArray((QList toJsonArray((QList<void*>*)body, bodyArray, QString("body"), QString("SWGUser*"));
<void
*>*)body, bodyArray, QString("body"), QString("SWGUser*"));
QJsonDocument doc(*bodyArray); QJsonDocument doc(*bodyArray);
QByteArray bytes = doc.toJson(); QByteArray bytes = doc.toJson();
@ -104,10 +97,10 @@
&SWGUserApi::createUsersWithArrayInputCallback); &SWGUserApi::createUsersWithArrayInputCallback);
worker->execute(&input); worker->execute(&input);
} }
void void
SWGUserApi::createUsersWithArrayInputCallback(HttpRequestWorker * worker) { SWGUserApi::createUsersWithArrayInputCallback(HttpRequestWorker * worker) {
QString msg; QString msg;
if (worker->error_type == QNetworkReply::NoError) { if (worker->error_type == QNetworkReply::NoError) {
msg = QString("Success! %1 bytes").arg(worker->response.length()); msg = QString("Success! %1 bytes").arg(worker->response.length());
@ -122,10 +115,9 @@
emit createUsersWithArrayInputSignal(); emit createUsersWithArrayInputSignal();
} }
void
void SWGUserApi::createUsersWithListInput(QList<SWGUser*>* body) {
SWGUserApi::createUsersWithListInput(QList<SWGUser*>* body) {
QString fullPath; QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/user/createWithList"); fullPath.append(this->host).append(this->basePath).append("/user/createWithList");
@ -141,9 +133,7 @@
QJsonArray* bodyArray = new QJsonArray(); QJsonArray* bodyArray = new QJsonArray();
toJsonArray((QList toJsonArray((QList<void*>*)body, bodyArray, QString("body"), QString("SWGUser*"));
<void
*>*)body, bodyArray, QString("body"), QString("SWGUser*"));
QJsonDocument doc(*bodyArray); QJsonDocument doc(*bodyArray);
QByteArray bytes = doc.toJson(); QByteArray bytes = doc.toJson();
@ -160,10 +150,10 @@
&SWGUserApi::createUsersWithListInputCallback); &SWGUserApi::createUsersWithListInputCallback);
worker->execute(&input); worker->execute(&input);
} }
void void
SWGUserApi::createUsersWithListInputCallback(HttpRequestWorker * worker) { SWGUserApi::createUsersWithListInputCallback(HttpRequestWorker * worker) {
QString msg; QString msg;
if (worker->error_type == QNetworkReply::NoError) { if (worker->error_type == QNetworkReply::NoError) {
msg = QString("Success! %1 bytes").arg(worker->response.length()); msg = QString("Success! %1 bytes").arg(worker->response.length());
@ -178,11 +168,9 @@
emit createUsersWithListInputSignal(); emit createUsersWithListInputSignal();
} }
void
void SWGUserApi::loginUser(QString* username, QString* password) {
SWGUserApi::loginUser(QString* username
, QString* password) {
QString fullPath; QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/user/login"); fullPath.append(this->host).append(this->basePath).append("/user/login");
@ -229,10 +217,10 @@
&SWGUserApi::loginUserCallback); &SWGUserApi::loginUserCallback);
worker->execute(&input); worker->execute(&input);
} }
void void
SWGUserApi::loginUserCallback(HttpRequestWorker * worker) { SWGUserApi::loginUserCallback(HttpRequestWorker * worker) {
QString msg; QString msg;
if (worker->error_type == QNetworkReply::NoError) { if (worker->error_type == QNetworkReply::NoError) {
msg = QString("Success! %1 bytes").arg(worker->response.length()); msg = QString("Success! %1 bytes").arg(worker->response.length());
@ -247,8 +235,7 @@
QString json(worker->response); QString json(worker->response);
QString* output = static_cast<QString*>(create(json, QString* output = static_cast<QString*>(create(json, QString("QString")));
QString("QString")));
@ -257,10 +244,9 @@
emit loginUserSignal(output); emit loginUserSignal(output);
} }
void
void SWGUserApi::logoutUser() {
SWGUserApi::logoutUser() {
QString fullPath; QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/user/logout"); fullPath.append(this->host).append(this->basePath).append("/user/logout");
@ -283,10 +269,10 @@
&SWGUserApi::logoutUserCallback); &SWGUserApi::logoutUserCallback);
worker->execute(&input); worker->execute(&input);
} }
void void
SWGUserApi::logoutUserCallback(HttpRequestWorker * worker) { SWGUserApi::logoutUserCallback(HttpRequestWorker * worker) {
QString msg; QString msg;
if (worker->error_type == QNetworkReply::NoError) { if (worker->error_type == QNetworkReply::NoError) {
msg = QString("Success! %1 bytes").arg(worker->response.length()); msg = QString("Success! %1 bytes").arg(worker->response.length());
@ -301,10 +287,9 @@
emit logoutUserSignal(); emit logoutUserSignal();
} }
void
void SWGUserApi::getUserByName(QString* username) {
SWGUserApi::getUserByName(QString* username) {
QString fullPath; QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/user/{username}"); fullPath.append(this->host).append(this->basePath).append("/user/{username}");
@ -330,10 +315,10 @@
&SWGUserApi::getUserByNameCallback); &SWGUserApi::getUserByNameCallback);
worker->execute(&input); worker->execute(&input);
} }
void void
SWGUserApi::getUserByNameCallback(HttpRequestWorker * worker) { SWGUserApi::getUserByNameCallback(HttpRequestWorker * worker) {
QString msg; QString msg;
if (worker->error_type == QNetworkReply::NoError) { if (worker->error_type == QNetworkReply::NoError) {
msg = QString("Success! %1 bytes").arg(worker->response.length()); msg = QString("Success! %1 bytes").arg(worker->response.length());
@ -348,8 +333,7 @@
QString json(worker->response); QString json(worker->response);
SWGUser* output = static_cast<SWGUser*>(create(json, SWGUser* output = static_cast<SWGUser*>(create(json, QString("SWGUser")));
QString("SWGUser")));
@ -358,11 +342,9 @@
emit getUserByNameSignal(output); emit getUserByNameSignal(output);
} }
void
void SWGUserApi::updateUser(QString* username, SWGUser body) {
SWGUserApi::updateUser(QString* username
, SWGUser body) {
QString fullPath; QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/user/{username}"); fullPath.append(this->host).append(this->basePath).append("/user/{username}");
@ -393,10 +375,10 @@
&SWGUserApi::updateUserCallback); &SWGUserApi::updateUserCallback);
worker->execute(&input); worker->execute(&input);
} }
void void
SWGUserApi::updateUserCallback(HttpRequestWorker * worker) { SWGUserApi::updateUserCallback(HttpRequestWorker * worker) {
QString msg; QString msg;
if (worker->error_type == QNetworkReply::NoError) { if (worker->error_type == QNetworkReply::NoError) {
msg = QString("Success! %1 bytes").arg(worker->response.length()); msg = QString("Success! %1 bytes").arg(worker->response.length());
@ -411,10 +393,9 @@
emit updateUserSignal(); emit updateUserSignal();
} }
void
void SWGUserApi::deleteUser(QString* username) {
SWGUserApi::deleteUser(QString* username) {
QString fullPath; QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/user/{username}"); fullPath.append(this->host).append(this->basePath).append("/user/{username}");
@ -440,10 +421,10 @@
&SWGUserApi::deleteUserCallback); &SWGUserApi::deleteUserCallback);
worker->execute(&input); worker->execute(&input);
} }
void void
SWGUserApi::deleteUserCallback(HttpRequestWorker * worker) { SWGUserApi::deleteUserCallback(HttpRequestWorker * worker) {
QString msg; QString msg;
if (worker->error_type == QNetworkReply::NoError) { if (worker->error_type == QNetworkReply::NoError) {
msg = QString("Success! %1 bytes").arg(worker->response.length()); msg = QString("Success! %1 bytes").arg(worker->response.length());
@ -458,7 +439,5 @@
emit deleteUserSignal(); emit deleteUserSignal();
} }
} /* namespace Swagger */
} /* namespace Swagger */

View File

@ -7,15 +7,14 @@
#include <QList> #include <QList>
#include <QString> #include <QString>
#include #include <QObject>
<QObject>
namespace Swagger { namespace Swagger {
class SWGUserApi: public QObject { class SWGUserApi: public QObject {
Q_OBJECT Q_OBJECT
public: public:
SWGUserApi(); SWGUserApi();
SWGUserApi(QString host, QString basePath); SWGUserApi(QString host, QString basePath);
~SWGUserApi(); ~SWGUserApi();
@ -26,15 +25,13 @@
void createUser(SWGUser body); void createUser(SWGUser body);
void createUsersWithArrayInput(QList<SWGUser*>* body); void createUsersWithArrayInput(QList<SWGUser*>* body);
void createUsersWithListInput(QList<SWGUser*>* body); void createUsersWithListInput(QList<SWGUser*>* body);
void loginUser(QString* username void loginUser(QString* username, QString* password);
, QString* password);
void logoutUser(); void logoutUser();
void getUserByName(QString* username); void getUserByName(QString* username);
void updateUser(QString* username void updateUser(QString* username, SWGUser body);
, SWGUser body);
void deleteUser(QString* username); void deleteUser(QString* username);
private: private:
void createUserCallback (HttpRequestWorker * worker); void createUserCallback (HttpRequestWorker * worker);
void createUsersWithArrayInputCallback (HttpRequestWorker * worker); void createUsersWithArrayInputCallback (HttpRequestWorker * worker);
void createUsersWithListInputCallback (HttpRequestWorker * worker); void createUsersWithListInputCallback (HttpRequestWorker * worker);
@ -44,7 +41,7 @@
void updateUserCallback (HttpRequestWorker * worker); void updateUserCallback (HttpRequestWorker * worker);
void deleteUserCallback (HttpRequestWorker * worker); void deleteUserCallback (HttpRequestWorker * worker);
signals: signals:
void createUserSignal(); void createUserSignal();
void createUsersWithArrayInputSignal(); void createUsersWithArrayInputSignal();
void createUsersWithListInputSignal(); void createUsersWithListInputSignal();
@ -54,6 +51,6 @@
void updateUserSignal(); void updateUserSignal();
void deleteUserSignal(); void deleteUserSignal();
}; };
} }
#endif #endif

View File

@ -77,8 +77,7 @@
</goals> </goals>
<configuration> <configuration>
<sources> <sources>
<source> <source>src/main/java</source>
src/main/java</source>
</sources> </sources>
</configuration> </configuration>
</execution> </execution>
@ -90,8 +89,7 @@
</goals> </goals>
<configuration> <configuration>
<sources> <sources>
<source> <source>src/test/java</source>
src/test/java</source>
</sources> </sources>
</configuration> </configuration>
</execution> </execution>
@ -102,8 +100,7 @@
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version> <version>2.3.2</version>
<configuration> <configuration>
<source> <source>1.6</source>
1.6</source>
<target>1.6</target> <target>1.6</target>
</configuration> </configuration>
</plugin> </plugin>

View File

@ -6,10 +6,10 @@ import retrofit.RestAdapter;
import retrofit.converter.GsonConverter; import retrofit.converter.GsonConverter;
public class ServiceGenerator { public class ServiceGenerator {
// No need to instantiate this class. // No need to instantiate this class.
private ServiceGenerator() { } private ServiceGenerator() { }
public static <S> S createService(Class<S> serviceClass) { public static <S> S createService(Class<S> serviceClass) {
Gson gson = new GsonBuilder() Gson gson = new GsonBuilder()
.setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ") .setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ")
.create(); .create();
@ -20,4 +20,4 @@ public static <S> S createService(Class<S> serviceClass) {
return adapter.create(serviceClass); return adapter.create(serviceClass);
} }
} }

View File

@ -9,7 +9,7 @@ import java.util.*;
import io.swagger.client.model.Pet; import io.swagger.client.model.Pet;
import java.io.File; import java.io.File;
public interface PetApi { public interface PetApi {
/** /**
* Update an existing pet * Update an existing pet
@ -114,4 +114,4 @@ import java.io.File;
@Path("petId") Long petId,@Part("additionalMetadata") String additionalMetadata,@Part("file") TypedFile file @Path("petId") Long petId,@Part("additionalMetadata") String additionalMetadata,@Part("file") TypedFile file
); );
} }

View File

@ -9,7 +9,7 @@ import java.util.*;
import java.util.Map; import java.util.Map;
import io.swagger.client.model.Order; import io.swagger.client.model.Order;
public interface StoreApi { public interface StoreApi {
/** /**
* Returns pet inventories by status * Returns pet inventories by status
@ -57,4 +57,4 @@ import io.swagger.client.model.Order;
@Path("orderId") String orderId @Path("orderId") String orderId
); );
} }

View File

@ -9,7 +9,7 @@ import java.util.*;
import io.swagger.client.model.User; import io.swagger.client.model.User;
import java.util.*; import java.util.*;
public interface UserApi { public interface UserApi {
/** /**
* Create user * Create user
@ -107,4 +107,4 @@ import java.util.*;
@Path("username") String username @Path("username") String username
); );
} }

View File

@ -5,8 +5,8 @@ import io.swagger.annotations.*;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
@ApiModel(description = "") @ApiModel(description = "")
public class Category { public class Category {
/** /**
@ -46,5 +46,4 @@ import com.google.gson.annotations.SerializedName;
sb.append("}\n"); sb.append("}\n");
return sb.toString(); return sb.toString();
} }
} }

View File

@ -6,8 +6,8 @@ import io.swagger.annotations.*;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
@ApiModel(description = "") @ApiModel(description = "")
public class Order { public class Order {
/** /**
@ -107,5 +107,4 @@ import com.google.gson.annotations.SerializedName;
sb.append("}\n"); sb.append("}\n");
return sb.toString(); return sb.toString();
} }
} }

View File

@ -1,15 +1,15 @@
package io.swagger.client.model; package io.swagger.client.model;
import io.swagger.client.model.Category; import io.swagger.client.model.Category;
import io.swagger.client.model.Tag;
import java.util.*; import java.util.*;
import io.swagger.client.model.Tag;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
@ApiModel(description = "") @ApiModel(description = "")
public class Pet { public class Pet {
/** /**
@ -109,5 +109,4 @@ import com.google.gson.annotations.SerializedName;
sb.append("}\n"); sb.append("}\n");
return sb.toString(); return sb.toString();
} }
} }

View File

@ -5,8 +5,8 @@ import io.swagger.annotations.*;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
@ApiModel(description = "") @ApiModel(description = "")
public class Tag { public class Tag {
/** /**
@ -46,5 +46,4 @@ import com.google.gson.annotations.SerializedName;
sb.append("}\n"); sb.append("}\n");
return sb.toString(); return sb.toString();
} }
} }

View File

@ -5,8 +5,8 @@ import io.swagger.annotations.*;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
@ApiModel(description = "") @ApiModel(description = "")
public class User { public class User {
/** /**
@ -131,5 +131,4 @@ import com.google.gson.annotations.SerializedName;
sb.append("}\n"); sb.append("}\n");
return sb.toString(); return sb.toString();
} }
} }

View File

@ -16,8 +16,8 @@ require 'swagger_client/models/order'
# APIs # APIs
require 'swagger_client/api/user_api' require 'swagger_client/api/user_api'
require 'swagger_client/api/pet_api'
require 'swagger_client/api/store_api' require 'swagger_client/api/store_api'
require 'swagger_client/api/pet_api'
module SwaggerClient module SwaggerClient
# Initialize the default configuration # Initialize the default configuration

View File

@ -190,7 +190,7 @@ module SwaggerClient
post_body = nil post_body = nil
auth_names = ['api_key', 'petstore_auth'] auth_names = ['petstore_auth', 'api_key']
response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body, :auth_names => auth_names}).make.body response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body, :auth_names => auth_names}).make.body
obj = Pet.new() and obj.build_from_hash(response) obj = Pet.new() and obj.build_from_hash(response)
end end

View File

@ -81,8 +81,7 @@
</goals> </goals>
<configuration> <configuration>
<sources> <sources>
<source> <source>src/main/java</source>
src/main/java</source>
</sources> </sources>
</configuration> </configuration>
</execution> </execution>
@ -94,8 +93,7 @@
</goals> </goals>
<configuration> <configuration>
<sources> <sources>
<source> <source>src/test/java</source>
src/test/java</source>
</sources> </sources>
</configuration> </configuration>
</execution> </execution>
@ -106,8 +104,7 @@
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version> <version>2.3.2</version>
<configuration> <configuration>
<source> <source>1.6</source>
1.6</source>
<target>1.6</target> <target>1.6</target>
</configuration> </configuration>
</plugin> </plugin>

View File

@ -25,179 +25,179 @@ import com.fasterxml.jackson.annotation._
import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.databind.annotation.JsonSerialize
object ScalaJsonUtil { object ScalaJsonUtil {
def getJsonMapper = { def getJsonMapper = {
val mapper = new ObjectMapper() val mapper = new ObjectMapper()
mapper.registerModule(new DefaultScalaModule()) mapper.registerModule(new DefaultScalaModule())
mapper.registerModule(new JodaModule()); mapper.registerModule(new JodaModule());
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
mapper.setSerializationInclusion(JsonInclude.Include.NON_DEFAULT) mapper.setSerializationInclusion(JsonInclude.Include.NON_DEFAULT)
mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false) mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false)
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY) mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY)
mapper mapper
} }
} }
class ApiInvoker(val mapper: ObjectMapper = ScalaJsonUtil.getJsonMapper, class ApiInvoker(val mapper: ObjectMapper = ScalaJsonUtil.getJsonMapper,
httpHeaders: HashMap[String, String] = HashMap(), httpHeaders: HashMap[String, String] = HashMap(),
hostMap: HashMap[String, Client] = HashMap(), hostMap: HashMap[String, Client] = HashMap(),
asyncHttpClient: Boolean = false, asyncHttpClient: Boolean = false,
authScheme: String = "", authScheme: String = "",
authPreemptive: Boolean = false) { authPreemptive: Boolean = false) {
var defaultHeaders: HashMap[String, String] = httpHeaders var defaultHeaders: HashMap[String, String] = httpHeaders
def escape(value: String): String = { def escape(value: String): String = {
URLEncoder.encode(value, "utf-8").replaceAll("\\+", "%20") URLEncoder.encode(value, "utf-8").replaceAll("\\+", "%20")
} }
def escape(value: Long): String = value.toString def escape(value: Long): String = value.toString
def escape(value: Double): String = value.toString def escape(value: Double): String = value.toString
def escape(value: Float): String = value.toString def escape(value: Float): String = value.toString
def deserialize(json: String, containerType: String, cls: Class[_]) = { def deserialize(json: String, containerType: String, cls: Class[_]) = {
if (cls == classOf[String]) { if (cls == classOf[String]) {
json match { json match {
case s: String => { case s: String => {
if (s.startsWith("\"") && s.endsWith("\"") && s.length > 1) s.substring(1, s.length - 2) if (s.startsWith("\"") && s.endsWith("\"") && s.length > 1) s.substring(1, s.length - 2)
else s else s
} }
case _ => null case _ => null
} }
} else { } else {
containerType.toLowerCase match { containerType.toLowerCase match {
case "array" => { case "array" => {
val typeInfo = mapper.getTypeFactory().constructCollectionType(classOf[java.util.List[_]], cls) val typeInfo = mapper.getTypeFactory().constructCollectionType(classOf[java.util.List[_]], cls)
val response = mapper.readValue(json, typeInfo).asInstanceOf[java.util.List[_]] val response = mapper.readValue(json, typeInfo).asInstanceOf[java.util.List[_]]
response.asScala.toList response.asScala.toList
} }
case "list" => { case "list" => {
val typeInfo = mapper.getTypeFactory().constructCollectionType(classOf[java.util.List[_]], cls) val typeInfo = mapper.getTypeFactory().constructCollectionType(classOf[java.util.List[_]], cls)
val response = mapper.readValue(json, typeInfo).asInstanceOf[java.util.List[_]] val response = mapper.readValue(json, typeInfo).asInstanceOf[java.util.List[_]]
response.asScala.toList response.asScala.toList
} }
case _ => { case _ => {
json match { json match {
case e: String if ("\"\"" == e) => null case e: String if ("\"\"" == e) => null
case _ => mapper.readValue(json, cls) case _ => mapper.readValue(json, cls)
} }
} }
} }
} }
} }
def serialize(obj: AnyRef): String = { def serialize(obj: AnyRef): String = {
if (obj != null) { if (obj != null) {
obj match { obj match {
case e: List[_] => mapper.writeValueAsString(obj.asInstanceOf[List[_]].asJava) case e: List[_] => mapper.writeValueAsString(obj.asInstanceOf[List[_]].asJava)
case _ => mapper.writeValueAsString(obj) case _ => mapper.writeValueAsString(obj)
} }
} else null } else null
} }
def invokeApi(host: String, path: String, method: String, queryParams: Map[String, String], formParams: Map[String, String], body: AnyRef, headerParams: Map[String, String], contentType: String): String = { def invokeApi(host: String, path: String, method: String, queryParams: Map[String, String], formParams: Map[String, String], body: AnyRef, headerParams: Map[String, String], contentType: String): String = {
val client = getClient(host) val client = getClient(host)
val querystring = queryParams.filter(k => k._2 != null).map(k => (escape(k._1) + "=" + escape(k._2))).mkString("?", "&", "") val querystring = queryParams.filter(k => k._2 != null).map(k => (escape(k._1) + "=" + escape(k._2))).mkString("?", "&", "")
val builder = client.resource(host + path + querystring).accept(contentType) val builder = client.resource(host + path + querystring).accept(contentType)
headerParams.map(p => builder.header(p._1, p._2)) headerParams.map(p => builder.header(p._1, p._2))
defaultHeaders.map(p => { defaultHeaders.map(p => {
headerParams.contains(p._1) match { headerParams.contains(p._1) match {
case true => // override default with supplied header case true => // override default with supplied header
case false => if (p._2 != null) builder.header(p._1, p._2) case false => if (p._2 != null) builder.header(p._1, p._2)
} }
}) })
var formData: MultivaluedMapImpl = null var formData: MultivaluedMapImpl = null
if(contentType == "application/x-www-form-urlencoded") { if(contentType == "application/x-www-form-urlencoded") {
formData = new MultivaluedMapImpl() formData = new MultivaluedMapImpl()
formParams.map(p => formData.add(p._1, p._2)) formParams.map(p => formData.add(p._1, p._2))
} }
val response: ClientResponse = method match { val response: ClientResponse = method match {
case "GET" => { case "GET" => {
builder.get(classOf[ClientResponse]).asInstanceOf[ClientResponse] builder.get(classOf[ClientResponse]).asInstanceOf[ClientResponse]
} }
case "POST" => { case "POST" => {
if(formData != null) builder.post(classOf[ClientResponse], formData) if(formData != null) builder.post(classOf[ClientResponse], formData)
else if(body != null && body.isInstanceOf[File]) { else if(body != null && body.isInstanceOf[File]) {
val file = body.asInstanceOf[File] val file = body.asInstanceOf[File]
val form = new FormDataMultiPart() val form = new FormDataMultiPart()
form.field("filename", file.getName()) form.field("filename", file.getName())
form.bodyPart(new FileDataBodyPart("file", file, MediaType.MULTIPART_FORM_DATA_TYPE)) form.bodyPart(new FileDataBodyPart("file", file, MediaType.MULTIPART_FORM_DATA_TYPE))
builder.post(classOf[ClientResponse], form) builder.post(classOf[ClientResponse], form)
} }
else { else {
if(body == null) builder.post(classOf[ClientResponse], serialize(body)) if(body == null) builder.post(classOf[ClientResponse], serialize(body))
else builder.`type`(contentType).post(classOf[ClientResponse], serialize(body)) else builder.`type`(contentType).post(classOf[ClientResponse], serialize(body))
} }
} }
case "PUT" => { case "PUT" => {
if(formData != null) builder.post(classOf[ClientResponse], formData) if(formData != null) builder.post(classOf[ClientResponse], formData)
else if(body == null) builder.put(classOf[ClientResponse], null) else if(body == null) builder.put(classOf[ClientResponse], null)
else builder.`type`(contentType).put(classOf[ClientResponse], serialize(body)) else builder.`type`(contentType).put(classOf[ClientResponse], serialize(body))
} }
case "DELETE" => { case "DELETE" => {
builder.delete(classOf[ClientResponse]) builder.delete(classOf[ClientResponse])
} }
case _ => null case _ => null
} }
response.getClientResponseStatus().getStatusCode() match { response.getClientResponseStatus().getStatusCode() match {
case 204 => "" case 204 => ""
case code: Int if (Range(200, 299).contains(code)) => { case code: Int if (Range(200, 299).contains(code)) => {
response.hasEntity() match { response.hasEntity() match {
case true => response.getEntity(classOf[String]) case true => response.getEntity(classOf[String])
case false => "" case false => ""
} }
} }
case _ => { case _ => {
val entity = response.hasEntity() match { val entity = response.hasEntity() match {
case true => response.getEntity(classOf[String]) case true => response.getEntity(classOf[String])
case false => "no data" case false => "no data"
} }
throw new ApiException( throw new ApiException(
response.getClientResponseStatus().getStatusCode(), response.getClientResponseStatus().getStatusCode(),
entity) entity)
} }
} }
} }
def getClient(host: String): Client = { def getClient(host: String): Client = {
hostMap.contains(host) match { hostMap.contains(host) match {
case true => hostMap(host) case true => hostMap(host)
case false => { case false => {
val client = newClient(host) val client = newClient(host)
// client.addFilter(new LoggingFilter()) // client.addFilter(new LoggingFilter())
hostMap += host -> client hostMap += host -> client
client client
} }
} }
} }
def newClient(host: String): Client = asyncHttpClient match { def newClient(host: String): Client = asyncHttpClient match {
case true => { case true => {
import org.sonatype.spice.jersey.client.ahc.config.DefaultAhcConfig import org.sonatype.spice.jersey.client.ahc.config.DefaultAhcConfig
import org.sonatype.spice.jersey.client.ahc.AhcHttpClient import org.sonatype.spice.jersey.client.ahc.AhcHttpClient
import com.ning.http.client.Realm import com.ning.http.client.Realm
val config: DefaultAhcConfig = new DefaultAhcConfig() val config: DefaultAhcConfig = new DefaultAhcConfig()
if (!authScheme.isEmpty) { if (!authScheme.isEmpty) {
val authSchemeEnum = Realm.AuthScheme.valueOf(authScheme) val authSchemeEnum = Realm.AuthScheme.valueOf(authScheme)
config.getAsyncHttpClientConfigBuilder config.getAsyncHttpClientConfigBuilder
.setRealm(new Realm.RealmBuilder().setScheme(authSchemeEnum) .setRealm(new Realm.RealmBuilder().setScheme(authSchemeEnum)
.setUsePreemptiveAuth(authPreemptive).build) .setUsePreemptiveAuth(authPreemptive).build)
} }
AhcHttpClient.create(config) AhcHttpClient.create(config)
} }
case _ => Client.create() case _ => Client.create()
} }
} }
object ApiInvoker extends ApiInvoker(mapper = ScalaJsonUtil.getJsonMapper, object ApiInvoker extends ApiInvoker(mapper = ScalaJsonUtil.getJsonMapper,
httpHeaders = HashMap(), httpHeaders = HashMap(),
hostMap = HashMap(), hostMap = HashMap(),
asyncHttpClient = false, asyncHttpClient = false,
authScheme = "", authScheme = "",
authPreemptive = false) authPreemptive = false)
class ApiException(val code: Int, msg: String) extends RuntimeException(msg) class ApiException(val code: Int, msg: String) extends RuntimeException(msg)

View File

@ -15,7 +15,7 @@ import java.util.Date
import scala.collection.mutable.HashMap import scala.collection.mutable.HashMap
class PetApi(val defBasePath: String = "http://petstore.swagger.io/v2", class PetApi(val defBasePath: String = "http://petstore.swagger.io/v2",
defApiInvoker: ApiInvoker = ApiInvoker) { defApiInvoker: ApiInvoker = ApiInvoker) {
var basePath = defBasePath var basePath = defBasePath
var apiInvoker = defApiInvoker var apiInvoker = defApiInvoker
@ -431,4 +431,4 @@ import scala.collection.mutable.HashMap
} }
} }
} }

View File

@ -14,7 +14,7 @@ import java.util.Date
import scala.collection.mutable.HashMap import scala.collection.mutable.HashMap
class StoreApi(val defBasePath: String = "http://petstore.swagger.io/v2", class StoreApi(val defBasePath: String = "http://petstore.swagger.io/v2",
defApiInvoker: ApiInvoker = ApiInvoker) { defApiInvoker: ApiInvoker = ApiInvoker) {
var basePath = defBasePath var basePath = defBasePath
var apiInvoker = defApiInvoker var apiInvoker = defApiInvoker
@ -216,4 +216,4 @@ import scala.collection.mutable.HashMap
} }
} }
} }

View File

@ -14,7 +14,7 @@ import java.util.Date
import scala.collection.mutable.HashMap import scala.collection.mutable.HashMap
class UserApi(val defBasePath: String = "http://petstore.swagger.io/v2", class UserApi(val defBasePath: String = "http://petstore.swagger.io/v2",
defApiInvoker: ApiInvoker = ApiInvoker) { defApiInvoker: ApiInvoker = ApiInvoker) {
var basePath = defBasePath var basePath = defBasePath
var apiInvoker = defApiInvoker var apiInvoker = defApiInvoker
@ -409,4 +409,4 @@ import scala.collection.mutable.HashMap
} }
} }
} }

View File

@ -3,9 +3,7 @@ package io.swagger.client.model
case class Category (
case class Category (
id: Long, id: Long,
name: String) name: String)

Some files were not shown because too many files have changed in this diff Show More