forked from loafle/openapi-generator-original
updated versions
This commit is contained in:
parent
33c2b1b623
commit
3d2f09a693
@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-codegen-project</artifactId>
|
||||
<version>2.1.1</version>
|
||||
<version>2.1.2</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-codegen-project</artifactId>
|
||||
<version>2.1.1</version>
|
||||
<version>2.1.2</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-codegen-project</artifactId>
|
||||
<version>2.1.1</version>
|
||||
<version>2.1.2</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<artifactId>swagger-generator</artifactId>
|
||||
|
2
pom.xml
2
pom.xml
@ -10,7 +10,7 @@
|
||||
<artifactId>swagger-codegen-project</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<name>swagger-codegen-project</name>
|
||||
<version>2.1.1</version>
|
||||
<version>2.1.2</version>
|
||||
<url>https://github.com/swagger-api/swagger-codegen</url>
|
||||
<scm>
|
||||
<connection>scm:git:git@github.com:swagger-api/swagger-codegen.git</connection>
|
||||
|
@ -1,85 +1,87 @@
|
||||
group = 'io.swagger'
|
||||
project.version = '1.0.0'
|
||||
group = 'io.swagger'
|
||||
project.version = '1.0.0'
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:1.2.2'
|
||||
repositories {
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:1.2.2'
|
||||
|
||||
classpath 'com.github.dcendents:android-maven-plugin:1.2'
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
jcenter()
|
||||
}
|
||||
repositories {
|
||||
jcenter()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
apply plugin: 'com.android.library'
|
||||
apply plugin: 'com.github.dcendents.android-maven'
|
||||
apply plugin: 'com.github.dcendents.android-maven'
|
||||
|
||||
android {
|
||||
compileSdkVersion 22
|
||||
buildToolsVersion '22.0.0'
|
||||
defaultConfig {
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 22
|
||||
}
|
||||
compileSdkVersion 22
|
||||
buildToolsVersion '22.0.0'
|
||||
defaultConfig {
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 22
|
||||
}
|
||||
|
||||
// Rename the aar correctly
|
||||
libraryVariants.all { variant ->
|
||||
variant.outputs.each { output ->
|
||||
def outputFile = output.outputFile
|
||||
if (outputFile != null && outputFile.name.endsWith('.aar')) {
|
||||
def fileName = "${project.name}-${variant.baseName}-${version}.aar"
|
||||
output.outputFile = new File(outputFile.parent, fileName)
|
||||
}
|
||||
}
|
||||
}
|
||||
// Rename the aar correctly
|
||||
libraryVariants.all { variant ->
|
||||
variant.outputs.each { output ->
|
||||
def outputFile = output.outputFile
|
||||
if (outputFile != null && outputFile.name.endsWith('.aar')) {
|
||||
def fileName = "${project.name}-${variant.baseName}-${version}.aar"
|
||||
output.outputFile = new File(outputFile.parent, fileName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ext {
|
||||
swagger_annotations_version = "1.5.0"
|
||||
gson_version = "2.3.1"
|
||||
httpclient_version = "4.3.3"
|
||||
junit_version = "4.8.1"
|
||||
swagger_annotations_version = "1.5.0"
|
||||
gson_version = "2.3.1"
|
||||
httpclient_version = "4.3.3"
|
||||
junit_version = "4.8.1"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile "io.swagger:swagger-annotations:$swagger_annotations_version"
|
||||
compile "com.google.code.gson:gson:$gson_version"
|
||||
compile "org.apache.httpcomponents:httpcore:$httpclient_version"
|
||||
compile "org.apache.httpcomponents:httpclient:$httpclient_version"
|
||||
compile ("org.apache.httpcomponents:httpcore:$httpclient_version") {
|
||||
exclude(group: 'org.apache.httpcomponents', module: 'httpclient')
|
||||
}
|
||||
compile ("org.apache.httpcomponents:httpmime:$httpclient_version") {
|
||||
exclude(group: 'org.apache.httpcomponents', module: 'httpclient')
|
||||
}
|
||||
testCompile "junit:junit:$junit_version"
|
||||
compile "io.swagger:swagger-annotations:$swagger_annotations_version"
|
||||
compile "com.google.code.gson:gson:$gson_version"
|
||||
compile "org.apache.httpcomponents:httpcore:$httpclient_version"
|
||||
compile "org.apache.httpcomponents:httpclient:$httpclient_version"
|
||||
compile ("org.apache.httpcomponents:httpcore:$httpclient_version") {
|
||||
exclude(group: 'org.apache.httpcomponents', module: 'httpclient')
|
||||
}
|
||||
compile ("org.apache.httpcomponents:httpmime:$httpclient_version") {
|
||||
exclude(group: 'org.apache.httpcomponents', module: 'httpclient')
|
||||
}
|
||||
testCompile "junit:junit:$junit_version"
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
android.libraryVariants.all { variant ->
|
||||
def task = project.tasks.create "jar${variant.name.capitalize()}", Jar
|
||||
task.description = "Create jar artifact for ${variant.name}"
|
||||
task.dependsOn variant.javaCompile
|
||||
task.from variant.javaCompile.destinationDir
|
||||
task.destinationDir = project.file("${project.buildDir}/outputs/jar")
|
||||
task.archiveName = "${project.name}-${variant.baseName}-${version}.jar"
|
||||
artifacts.add('archives', task);
|
||||
}
|
||||
android.libraryVariants.all { variant ->
|
||||
def task = project.tasks.create "jar${variant.name.capitalize()}", Jar
|
||||
task.description = "Create jar artifact for ${variant.name}"
|
||||
task.dependsOn variant.javaCompile
|
||||
task.from variant.javaCompile.destinationDir
|
||||
task.destinationDir = project.file("${project.buildDir}/outputs/jar")
|
||||
task.archiveName = "${project.name}-${variant.baseName}-${version}.jar"
|
||||
artifacts.add('archives', task);
|
||||
}
|
||||
}
|
||||
|
||||
task sourcesJar(type: Jar) {
|
||||
task sourcesJar(type: Jar) {
|
||||
from android.sourceSets.main.java.srcDirs
|
||||
classifier = 'sources'
|
||||
}
|
||||
}
|
||||
|
||||
artifacts {
|
||||
artifacts {
|
||||
archives sourcesJar
|
||||
}
|
||||
}
|
||||
|
@ -77,8 +77,7 @@
|
||||
</goals>
|
||||
<configuration>
|
||||
<sources>
|
||||
<source>
|
||||
src/main/java</source>
|
||||
<source>src/main/java</source>
|
||||
</sources>
|
||||
</configuration>
|
||||
</execution>
|
||||
@ -90,8 +89,7 @@
|
||||
</goals>
|
||||
<configuration>
|
||||
<sources>
|
||||
<source>
|
||||
src/test/java</source>
|
||||
<source>src/test/java</source>
|
||||
</sources>
|
||||
</configuration>
|
||||
</execution>
|
||||
@ -102,8 +100,7 @@
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>2.3.2</version>
|
||||
<configuration>
|
||||
<source>
|
||||
1.6</source>
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
@ -1,3 +1,3 @@
|
||||
<manifest package="io.swagger.client">
|
||||
<application/>
|
||||
<application />
|
||||
</manifest>
|
||||
|
@ -1,29 +1,29 @@
|
||||
package io.swagger.client;
|
||||
|
||||
public class ApiException extends Exception {
|
||||
int code = 0;
|
||||
String message = null;
|
||||
int code = 0;
|
||||
String message = null;
|
||||
|
||||
public ApiException() {}
|
||||
public ApiException() {}
|
||||
|
||||
public ApiException(int code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
public ApiException(int code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
}
|
@ -52,345 +52,338 @@ import javax.net.ssl.X509TrustManager;
|
||||
import com.google.gson.JsonParseException;
|
||||
|
||||
public class ApiInvoker {
|
||||
private static ApiInvoker INSTANCE = new ApiInvoker();
|
||||
private Map
|
||||
<String, String> defaultHeaderMap = new HashMap
|
||||
<String, String>();
|
||||
private static ApiInvoker INSTANCE = new ApiInvoker();
|
||||
private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
|
||||
|
||||
private HttpClient client = null;
|
||||
private HttpClient client = null;
|
||||
|
||||
private boolean ignoreSSLCertificates = false;
|
||||
private boolean ignoreSSLCertificates = false;
|
||||
|
||||
private ClientConnectionManager ignoreSSLConnectionManager;
|
||||
private ClientConnectionManager ignoreSSLConnectionManager;
|
||||
|
||||
/** Content type "text/plain" with UTF-8 encoding. */
|
||||
public static final ContentType TEXT_PLAIN_UTF8 = ContentType.create("text/plain", Consts.UTF_8);
|
||||
/** Content type "text/plain" with UTF-8 encoding. */
|
||||
public static final ContentType TEXT_PLAIN_UTF8 = ContentType.create("text/plain", Consts.UTF_8);
|
||||
|
||||
/**
|
||||
* ISO 8601 date time format.
|
||||
* @see https://en.wikipedia.org/wiki/ISO_8601
|
||||
*/
|
||||
public static final SimpleDateFormat DATE_TIME_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
|
||||
/**
|
||||
* ISO 8601 date time format.
|
||||
* @see https://en.wikipedia.org/wiki/ISO_8601
|
||||
*/
|
||||
public static final SimpleDateFormat DATE_TIME_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
|
||||
|
||||
/**
|
||||
* ISO 8601 date format.
|
||||
* @see https://en.wikipedia.org/wiki/ISO_8601
|
||||
*/
|
||||
public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd");
|
||||
/**
|
||||
* ISO 8601 date format.
|
||||
* @see https://en.wikipedia.org/wiki/ISO_8601
|
||||
*/
|
||||
public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd");
|
||||
|
||||
static {
|
||||
// Use UTC as the default time zone.
|
||||
DATE_TIME_FORMAT.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
DATE_FORMAT.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
static {
|
||||
// Use UTC as the default time zone.
|
||||
DATE_TIME_FORMAT.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
DATE_FORMAT.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
|
||||
// Set default User-Agent.
|
||||
setUserAgent("Android-Java-Swagger");
|
||||
}
|
||||
// Set default User-Agent.
|
||||
setUserAgent("Android-Java-Swagger");
|
||||
}
|
||||
|
||||
public static void setUserAgent(String userAgent) {
|
||||
INSTANCE.addDefaultHeader("User-Agent", userAgent);
|
||||
}
|
||||
public static void setUserAgent(String userAgent) {
|
||||
INSTANCE.addDefaultHeader("User-Agent", userAgent);
|
||||
}
|
||||
|
||||
public static Date parseDateTime(String str) {
|
||||
try {
|
||||
return DATE_TIME_FORMAT.parse(str);
|
||||
} catch (java.text.ParseException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
public static Date parseDateTime(String str) {
|
||||
try {
|
||||
return DATE_TIME_FORMAT.parse(str);
|
||||
} catch (java.text.ParseException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static Date parseDate(String str) {
|
||||
try {
|
||||
return DATE_FORMAT.parse(str);
|
||||
} catch (java.text.ParseException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
public static Date parseDate(String str) {
|
||||
try {
|
||||
return DATE_FORMAT.parse(str);
|
||||
} catch (java.text.ParseException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static String formatDateTime(Date datetime) {
|
||||
return DATE_TIME_FORMAT.format(datetime);
|
||||
}
|
||||
public static String formatDateTime(Date datetime) {
|
||||
return DATE_TIME_FORMAT.format(datetime);
|
||||
}
|
||||
|
||||
public static String formatDate(Date date) {
|
||||
return DATE_FORMAT.format(date);
|
||||
}
|
||||
public static String formatDate(Date date) {
|
||||
return DATE_FORMAT.format(date);
|
||||
}
|
||||
|
||||
public static String parameterToString(Object param) {
|
||||
if (param == null) {
|
||||
return "";
|
||||
} else if (param instanceof Date) {
|
||||
return formatDateTime((Date) param);
|
||||
} else if (param instanceof Collection) {
|
||||
StringBuilder b = new StringBuilder();
|
||||
for(Object o : (Collection)param) {
|
||||
if(b.length() > 0) {
|
||||
b.append(",");
|
||||
}
|
||||
b.append(String.valueOf(o));
|
||||
}
|
||||
return b.toString();
|
||||
} else {
|
||||
return String.valueOf(param);
|
||||
}
|
||||
}
|
||||
public static String parameterToString(Object param) {
|
||||
if (param == null) {
|
||||
return "";
|
||||
} else if (param instanceof Date) {
|
||||
return formatDateTime((Date) param);
|
||||
} else if (param instanceof Collection) {
|
||||
StringBuilder b = new StringBuilder();
|
||||
for(Object o : (Collection)param) {
|
||||
if(b.length() > 0) {
|
||||
b.append(",");
|
||||
}
|
||||
b.append(String.valueOf(o));
|
||||
}
|
||||
return b.toString();
|
||||
} else {
|
||||
return String.valueOf(param);
|
||||
}
|
||||
}
|
||||
|
||||
public ApiInvoker() {
|
||||
initConnectionManager();
|
||||
}
|
||||
public ApiInvoker() {
|
||||
initConnectionManager();
|
||||
}
|
||||
|
||||
public static ApiInvoker getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
public static ApiInvoker getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public void ignoreSSLCertificates(boolean ignoreSSLCertificates) {
|
||||
this.ignoreSSLCertificates = ignoreSSLCertificates;
|
||||
}
|
||||
public void ignoreSSLCertificates(boolean ignoreSSLCertificates) {
|
||||
this.ignoreSSLCertificates = ignoreSSLCertificates;
|
||||
}
|
||||
|
||||
public void addDefaultHeader(String key, String value) {
|
||||
defaultHeaderMap.put(key, value);
|
||||
}
|
||||
public void addDefaultHeader(String key, String value) {
|
||||
defaultHeaderMap.put(key, value);
|
||||
}
|
||||
|
||||
public String escapeString(String str) {
|
||||
return str;
|
||||
}
|
||||
public String escapeString(String str) {
|
||||
return str;
|
||||
}
|
||||
|
||||
public static Object deserialize(String json, String containerType, Class cls) throws ApiException {
|
||||
try{
|
||||
if("list".equalsIgnoreCase(containerType) || "array".equalsIgnoreCase(containerType)) {
|
||||
return JsonUtil.deserializeToList(json, cls);
|
||||
}
|
||||
else if(String.class.equals(cls)) {
|
||||
if(json != null && json.startsWith("\"") && json.endsWith("\"") && json.length() > 1)
|
||||
return json.substring(1, json.length() - 2);
|
||||
else
|
||||
return json;
|
||||
}
|
||||
else {
|
||||
return JsonUtil.deserializeToObject(json, cls);
|
||||
}
|
||||
}
|
||||
catch (JsonParseException e) {
|
||||
throw new ApiException(500, e.getMessage());
|
||||
}
|
||||
}
|
||||
public static Object deserialize(String json, String containerType, Class cls) throws ApiException {
|
||||
try{
|
||||
if("list".equalsIgnoreCase(containerType) || "array".equalsIgnoreCase(containerType)) {
|
||||
return JsonUtil.deserializeToList(json, cls);
|
||||
}
|
||||
else if(String.class.equals(cls)) {
|
||||
if(json != null && json.startsWith("\"") && json.endsWith("\"") && json.length() > 1)
|
||||
return json.substring(1, json.length() - 2);
|
||||
else
|
||||
return json;
|
||||
}
|
||||
else {
|
||||
return JsonUtil.deserializeToObject(json, cls);
|
||||
}
|
||||
}
|
||||
catch (JsonParseException e) {
|
||||
throw new ApiException(500, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public static String serialize(Object obj) throws ApiException {
|
||||
try {
|
||||
if (obj != null)
|
||||
return JsonUtil.serialize(obj);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new ApiException(500, e.getMessage());
|
||||
}
|
||||
}
|
||||
public static String serialize(Object obj) throws ApiException {
|
||||
try {
|
||||
if (obj != null)
|
||||
return JsonUtil.serialize(obj);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new ApiException(500, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public String invokeAPI(String host, String path, String method, Map
|
||||
<String, String> queryParams, Object body, Map
|
||||
<String, String> headerParams, Map
|
||||
<String, String> formParams, String contentType) throws ApiException {
|
||||
HttpClient client = getClient(host);
|
||||
public String invokeAPI(String host, String path, String method, Map<String, String> queryParams, Object body, Map<String, String> headerParams, Map<String, String> formParams, String contentType) throws ApiException {
|
||||
HttpClient client = getClient(host);
|
||||
|
||||
StringBuilder b = new StringBuilder();
|
||||
for(String key : queryParams.keySet()) {
|
||||
String value = queryParams.get(key);
|
||||
if (value != null){
|
||||
if(b.toString().length() == 0)
|
||||
b.append("?");
|
||||
else
|
||||
b.append("&");
|
||||
b.append(escapeString(key)).append("=").append(escapeString(value));
|
||||
}
|
||||
}
|
||||
String url = host + path + b.toString();
|
||||
StringBuilder b = new StringBuilder();
|
||||
for(String key : queryParams.keySet()) {
|
||||
String value = queryParams.get(key);
|
||||
if (value != null){
|
||||
if(b.toString().length() == 0)
|
||||
b.append("?");
|
||||
else
|
||||
b.append("&");
|
||||
b.append(escapeString(key)).append("=").append(escapeString(value));
|
||||
}
|
||||
}
|
||||
String url = host + path + b.toString();
|
||||
|
||||
HashMap
|
||||
<String, String> headers = new HashMap
|
||||
<String, String>();
|
||||
HashMap<String, String> headers = new HashMap<String, String>();
|
||||
|
||||
for(String key : headerParams.keySet()) {
|
||||
headers.put(key, headerParams.get(key));
|
||||
}
|
||||
for(String key : headerParams.keySet()) {
|
||||
headers.put(key, headerParams.get(key));
|
||||
}
|
||||
|
||||
for(String key : defaultHeaderMap.keySet()) {
|
||||
if(!headerParams.containsKey(key)) {
|
||||
headers.put(key, defaultHeaderMap.get(key));
|
||||
}
|
||||
}
|
||||
headers.put("Accept", "application/json");
|
||||
for(String key : defaultHeaderMap.keySet()) {
|
||||
if(!headerParams.containsKey(key)) {
|
||||
headers.put(key, defaultHeaderMap.get(key));
|
||||
}
|
||||
}
|
||||
headers.put("Accept", "application/json");
|
||||
|
||||
// URL encoded string from form parameters
|
||||
String formParamStr = null;
|
||||
// URL encoded string from form parameters
|
||||
String formParamStr = null;
|
||||
|
||||
// for form data
|
||||
if ("application/x-www-form-urlencoded".equals(contentType)) {
|
||||
StringBuilder formParamBuilder = new StringBuilder();
|
||||
// for form data
|
||||
if ("application/x-www-form-urlencoded".equals(contentType)) {
|
||||
StringBuilder formParamBuilder = new StringBuilder();
|
||||
|
||||
// encode the form params
|
||||
for (String key : formParams.keySet()) {
|
||||
String value = formParams.get(key);
|
||||
if (value != null && !"".equals(value.trim())) {
|
||||
if (formParamBuilder.length() > 0) {
|
||||
formParamBuilder.append("&");
|
||||
}
|
||||
try {
|
||||
formParamBuilder.append(URLEncoder.encode(key, "utf8")).append("=").append(URLEncoder.encode(value, "utf8"));
|
||||
}
|
||||
catch (Exception e) {
|
||||
// move on to next
|
||||
}
|
||||
}
|
||||
}
|
||||
formParamStr = formParamBuilder.toString();
|
||||
}
|
||||
// encode the form params
|
||||
for (String key : formParams.keySet()) {
|
||||
String value = formParams.get(key);
|
||||
if (value != null && !"".equals(value.trim())) {
|
||||
if (formParamBuilder.length() > 0) {
|
||||
formParamBuilder.append("&");
|
||||
}
|
||||
try {
|
||||
formParamBuilder.append(URLEncoder.encode(key, "utf8")).append("=").append(URLEncoder.encode(value, "utf8"));
|
||||
}
|
||||
catch (Exception e) {
|
||||
// move on to next
|
||||
}
|
||||
}
|
||||
}
|
||||
formParamStr = formParamBuilder.toString();
|
||||
}
|
||||
|
||||
HttpResponse response = null;
|
||||
try {
|
||||
if ("GET".equals(method)) {
|
||||
HttpGet get = new HttpGet(url);
|
||||
get.addHeader("Accept", "application/json");
|
||||
for(String key : headers.keySet()) {
|
||||
get.setHeader(key, headers.get(key));
|
||||
}
|
||||
response = client.execute(get);
|
||||
}
|
||||
else if ("POST".equals(method)) {
|
||||
HttpPost post = new HttpPost(url);
|
||||
if (formParamStr != null) {
|
||||
post.setHeader("Content-Type", contentType);
|
||||
post.setEntity(new StringEntity(formParamStr, "UTF-8"));
|
||||
} else if (body != null) {
|
||||
if (body instanceof HttpEntity) {
|
||||
// this is for file uploading
|
||||
post.setEntity((HttpEntity) body);
|
||||
} else {
|
||||
post.setHeader("Content-Type", contentType);
|
||||
post.setEntity(new StringEntity(serialize(body), "UTF-8"));
|
||||
}
|
||||
}
|
||||
for(String key : headers.keySet()) {
|
||||
post.setHeader(key, headers.get(key));
|
||||
}
|
||||
response = client.execute(post);
|
||||
}
|
||||
else if ("PUT".equals(method)) {
|
||||
HttpPut put = new HttpPut(url);
|
||||
if (formParamStr != null) {
|
||||
put.setHeader("Content-Type", contentType);
|
||||
put.setEntity(new StringEntity(formParamStr, "UTF-8"));
|
||||
} else if (body != null) {
|
||||
put.setHeader("Content-Type", contentType);
|
||||
put.setEntity(new StringEntity(serialize(body), "UTF-8"));
|
||||
}
|
||||
for(String key : headers.keySet()) {
|
||||
put.setHeader(key, headers.get(key));
|
||||
}
|
||||
response = client.execute(put);
|
||||
}
|
||||
else if ("DELETE".equals(method)) {
|
||||
HttpDelete delete = new HttpDelete(url);
|
||||
for(String key : headers.keySet()) {
|
||||
delete.setHeader(key, headers.get(key));
|
||||
}
|
||||
response = client.execute(delete);
|
||||
}
|
||||
else if ("PATCH".equals(method)) {
|
||||
HttpPatch patch = new HttpPatch(url);
|
||||
if (formParamStr != null) {
|
||||
patch.setHeader("Content-Type", contentType);
|
||||
patch.setEntity(new StringEntity(formParamStr, "UTF-8"));
|
||||
} else if (body != null) {
|
||||
patch.setHeader("Content-Type", contentType);
|
||||
patch.setEntity(new StringEntity(serialize(body), "UTF-8"));
|
||||
}
|
||||
for(String key : headers.keySet()) {
|
||||
patch.setHeader(key, headers.get(key));
|
||||
}
|
||||
response = client.execute(patch);
|
||||
}
|
||||
HttpResponse response = null;
|
||||
try {
|
||||
if ("GET".equals(method)) {
|
||||
HttpGet get = new HttpGet(url);
|
||||
get.addHeader("Accept", "application/json");
|
||||
for(String key : headers.keySet()) {
|
||||
get.setHeader(key, headers.get(key));
|
||||
}
|
||||
response = client.execute(get);
|
||||
}
|
||||
else if ("POST".equals(method)) {
|
||||
HttpPost post = new HttpPost(url);
|
||||
if (formParamStr != null) {
|
||||
post.setHeader("Content-Type", contentType);
|
||||
post.setEntity(new StringEntity(formParamStr, "UTF-8"));
|
||||
} else if (body != null) {
|
||||
if (body instanceof HttpEntity) {
|
||||
// this is for file uploading
|
||||
post.setEntity((HttpEntity) body);
|
||||
} else {
|
||||
post.setHeader("Content-Type", contentType);
|
||||
post.setEntity(new StringEntity(serialize(body), "UTF-8"));
|
||||
}
|
||||
}
|
||||
for(String key : headers.keySet()) {
|
||||
post.setHeader(key, headers.get(key));
|
||||
}
|
||||
response = client.execute(post);
|
||||
}
|
||||
else if ("PUT".equals(method)) {
|
||||
HttpPut put = new HttpPut(url);
|
||||
if (formParamStr != null) {
|
||||
put.setHeader("Content-Type", contentType);
|
||||
put.setEntity(new StringEntity(formParamStr, "UTF-8"));
|
||||
} else if (body != null) {
|
||||
put.setHeader("Content-Type", contentType);
|
||||
put.setEntity(new StringEntity(serialize(body), "UTF-8"));
|
||||
}
|
||||
for(String key : headers.keySet()) {
|
||||
put.setHeader(key, headers.get(key));
|
||||
}
|
||||
response = client.execute(put);
|
||||
}
|
||||
else if ("DELETE".equals(method)) {
|
||||
HttpDelete delete = new HttpDelete(url);
|
||||
for(String key : headers.keySet()) {
|
||||
delete.setHeader(key, headers.get(key));
|
||||
}
|
||||
response = client.execute(delete);
|
||||
}
|
||||
else if ("PATCH".equals(method)) {
|
||||
HttpPatch patch = new HttpPatch(url);
|
||||
if (formParamStr != null) {
|
||||
patch.setHeader("Content-Type", contentType);
|
||||
patch.setEntity(new StringEntity(formParamStr, "UTF-8"));
|
||||
} else if (body != null) {
|
||||
patch.setHeader("Content-Type", contentType);
|
||||
patch.setEntity(new StringEntity(serialize(body), "UTF-8"));
|
||||
}
|
||||
for(String key : headers.keySet()) {
|
||||
patch.setHeader(key, headers.get(key));
|
||||
}
|
||||
response = client.execute(patch);
|
||||
}
|
||||
|
||||
int code = response.getStatusLine().getStatusCode();
|
||||
String responseString = null;
|
||||
if(code == 204)
|
||||
responseString = "";
|
||||
else if(code >= 200 && code < 300) {
|
||||
if(response.getEntity() != null) {
|
||||
HttpEntity resEntity = response.getEntity();
|
||||
responseString = EntityUtils.toString(resEntity);
|
||||
}
|
||||
return responseString;
|
||||
}
|
||||
else {
|
||||
if(response.getEntity() != null) {
|
||||
HttpEntity resEntity = response.getEntity();
|
||||
responseString = EntityUtils.toString(resEntity);
|
||||
}
|
||||
else
|
||||
responseString = "no data";
|
||||
}
|
||||
throw new ApiException(code, responseString);
|
||||
}
|
||||
catch(IOException e) {
|
||||
throw new ApiException(500, e.getMessage());
|
||||
}
|
||||
}
|
||||
int code = response.getStatusLine().getStatusCode();
|
||||
String responseString = null;
|
||||
if(code == 204)
|
||||
responseString = "";
|
||||
else if(code >= 200 && code < 300) {
|
||||
if(response.getEntity() != null) {
|
||||
HttpEntity resEntity = response.getEntity();
|
||||
responseString = EntityUtils.toString(resEntity);
|
||||
}
|
||||
return responseString;
|
||||
}
|
||||
else {
|
||||
if(response.getEntity() != null) {
|
||||
HttpEntity resEntity = response.getEntity();
|
||||
responseString = EntityUtils.toString(resEntity);
|
||||
}
|
||||
else
|
||||
responseString = "no data";
|
||||
}
|
||||
throw new ApiException(code, responseString);
|
||||
}
|
||||
catch(IOException e) {
|
||||
throw new ApiException(500, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private HttpClient getClient(String host) {
|
||||
if (client == null) {
|
||||
if (ignoreSSLCertificates && ignoreSSLConnectionManager != null) {
|
||||
// Trust self signed certificates
|
||||
client = new DefaultHttpClient(ignoreSSLConnectionManager, new BasicHttpParams());
|
||||
} else {
|
||||
client = new DefaultHttpClient();
|
||||
}
|
||||
}
|
||||
return client;
|
||||
}
|
||||
private HttpClient getClient(String host) {
|
||||
if (client == null) {
|
||||
if (ignoreSSLCertificates && ignoreSSLConnectionManager != null) {
|
||||
// Trust self signed certificates
|
||||
client = new DefaultHttpClient(ignoreSSLConnectionManager, new BasicHttpParams());
|
||||
} else {
|
||||
client = new DefaultHttpClient();
|
||||
}
|
||||
}
|
||||
return client;
|
||||
}
|
||||
|
||||
private void initConnectionManager() {
|
||||
try {
|
||||
final SSLContext sslContext = SSLContext.getInstance("SSL");
|
||||
private void initConnectionManager() {
|
||||
try {
|
||||
final SSLContext sslContext = SSLContext.getInstance("SSL");
|
||||
|
||||
// set up a TrustManager that trusts everything
|
||||
TrustManager[] trustManagers = new TrustManager[] {
|
||||
new X509TrustManager() {
|
||||
public X509Certificate[] getAcceptedIssuers() {
|
||||
return null;
|
||||
}
|
||||
public void checkClientTrusted(X509Certificate[] certs, String authType) {}
|
||||
public void checkServerTrusted(X509Certificate[] certs, String authType) {}
|
||||
}};
|
||||
|
||||
sslContext.init(null, trustManagers, new SecureRandom());
|
||||
|
||||
SSLSocketFactory sf = new SSLSocketFactory((KeyStore)null) {
|
||||
private javax.net.ssl.SSLSocketFactory sslFactory = sslContext.getSocketFactory();
|
||||
|
||||
public Socket createSocket(Socket socket, String host, int port, boolean autoClose)
|
||||
throws IOException, UnknownHostException {
|
||||
return sslFactory.createSocket(socket, host, port, autoClose);
|
||||
}
|
||||
|
||||
public Socket createSocket() throws IOException {
|
||||
return sslFactory.createSocket();
|
||||
}
|
||||
};
|
||||
|
||||
sf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
|
||||
Scheme httpsScheme = new Scheme("https", sf, 443);
|
||||
SchemeRegistry schemeRegistry = new SchemeRegistry();
|
||||
schemeRegistry.register(httpsScheme);
|
||||
schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
|
||||
|
||||
ignoreSSLConnectionManager = new ThreadSafeClientConnManager(new BasicHttpParams(), schemeRegistry);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
// This will only be thrown if SSL isn't available for some reason.
|
||||
} catch (KeyManagementException e) {
|
||||
// This might be thrown when passing a key into init(), but no key is being passed.
|
||||
} catch (GeneralSecurityException e) {
|
||||
// This catches anything else that might go wrong.
|
||||
// If anything goes wrong we default to the standard connection manager.
|
||||
}
|
||||
}
|
||||
// set up a TrustManager that trusts everything
|
||||
TrustManager[] trustManagers = new TrustManager[] {
|
||||
new X509TrustManager() {
|
||||
public X509Certificate[] getAcceptedIssuers() {
|
||||
return null;
|
||||
}
|
||||
public void checkClientTrusted(X509Certificate[] certs, String authType) {}
|
||||
public void checkServerTrusted(X509Certificate[] certs, String authType) {}
|
||||
}};
|
||||
|
||||
sslContext.init(null, trustManagers, new SecureRandom());
|
||||
|
||||
SSLSocketFactory sf = new SSLSocketFactory((KeyStore)null) {
|
||||
private javax.net.ssl.SSLSocketFactory sslFactory = sslContext.getSocketFactory();
|
||||
|
||||
public Socket createSocket(Socket socket, String host, int port, boolean autoClose)
|
||||
throws IOException, UnknownHostException {
|
||||
return sslFactory.createSocket(socket, host, port, autoClose);
|
||||
}
|
||||
|
||||
public Socket createSocket() throws IOException {
|
||||
return sslFactory.createSocket();
|
||||
}
|
||||
};
|
||||
|
||||
sf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
|
||||
Scheme httpsScheme = new Scheme("https", sf, 443);
|
||||
SchemeRegistry schemeRegistry = new SchemeRegistry();
|
||||
schemeRegistry.register(httpsScheme);
|
||||
schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
|
||||
|
||||
ignoreSSLConnectionManager = new ThreadSafeClientConnManager(new BasicHttpParams(), schemeRegistry);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
// This will only be thrown if SSL isn't available for some reason.
|
||||
} catch (KeyManagementException e) {
|
||||
// This might be thrown when passing a key into init(), but no key is being passed.
|
||||
} catch (GeneralSecurityException e) {
|
||||
// This catches anything else that might go wrong.
|
||||
// If anything goes wrong we default to the standard connection manager.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,14 +3,14 @@ package io.swagger.client;
|
||||
import org.apache.http.client.methods.*;
|
||||
|
||||
public class HttpPatch extends HttpPost {
|
||||
public static final String METHOD_PATCH = "PATCH";
|
||||
public static final String METHOD_PATCH = "PATCH";
|
||||
|
||||
public HttpPatch(final String url) {
|
||||
super(url);
|
||||
}
|
||||
public HttpPatch(final String url) {
|
||||
super(url);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return METHOD_PATCH;
|
||||
}
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return METHOD_PATCH;
|
||||
}
|
||||
}
|
@ -8,29 +8,27 @@ import java.util.List;
|
||||
import io.swagger.client.model.*;
|
||||
|
||||
public class JsonUtil {
|
||||
public static GsonBuilder gsonBuilder;
|
||||
public static GsonBuilder gsonBuilder;
|
||||
|
||||
static {
|
||||
gsonBuilder = new GsonBuilder();
|
||||
gsonBuilder.serializeNulls();
|
||||
gsonBuilder.setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
|
||||
}
|
||||
static {
|
||||
gsonBuilder = new GsonBuilder();
|
||||
gsonBuilder.serializeNulls();
|
||||
gsonBuilder.setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
|
||||
}
|
||||
|
||||
public static Gson getGson() {
|
||||
return gsonBuilder.create();
|
||||
}
|
||||
public static Gson getGson() {
|
||||
return gsonBuilder.create();
|
||||
}
|
||||
|
||||
public static String serialize(Object obj){
|
||||
return getGson().toJson(obj);
|
||||
}
|
||||
public static String serialize(Object obj){
|
||||
return getGson().toJson(obj);
|
||||
}
|
||||
|
||||
public static
|
||||
<T> T deserializeToList(String jsonString, Class cls){
|
||||
public static <T> T deserializeToList(String jsonString, Class cls){
|
||||
return getGson().fromJson(jsonString, getListTypeForDeserialization(cls));
|
||||
}
|
||||
|
||||
public static
|
||||
<T> T deserializeToObject(String jsonString, Class cls){
|
||||
public static <T> T deserializeToObject(String jsonString, Class cls){
|
||||
return getGson().fromJson(jsonString, getTypeForDeserialization(cls));
|
||||
}
|
||||
|
||||
@ -38,38 +36,26 @@ public static
|
||||
String className = cls.getSimpleName();
|
||||
|
||||
if ("User".equalsIgnoreCase(className)) {
|
||||
return new TypeToken
|
||||
<List
|
||||
<User>>(){}.getType();
|
||||
return new TypeToken<List<User>>(){}.getType();
|
||||
}
|
||||
|
||||
if ("Category".equalsIgnoreCase(className)) {
|
||||
return new TypeToken
|
||||
<List
|
||||
<Category>>(){}.getType();
|
||||
return new TypeToken<List<Category>>(){}.getType();
|
||||
}
|
||||
|
||||
if ("Pet".equalsIgnoreCase(className)) {
|
||||
return new TypeToken
|
||||
<List
|
||||
<Pet>>(){}.getType();
|
||||
return new TypeToken<List<Pet>>(){}.getType();
|
||||
}
|
||||
|
||||
if ("Tag".equalsIgnoreCase(className)) {
|
||||
return new TypeToken
|
||||
<List
|
||||
<Tag>>(){}.getType();
|
||||
return new TypeToken<List<Tag>>(){}.getType();
|
||||
}
|
||||
|
||||
if ("Order".equalsIgnoreCase(className)) {
|
||||
return new TypeToken
|
||||
<List
|
||||
<Order>>(){}.getType();
|
||||
return new TypeToken<List<Order>>(){}.getType();
|
||||
}
|
||||
|
||||
return new TypeToken
|
||||
<List
|
||||
<Object>>(){}.getType();
|
||||
return new TypeToken<List<Object>>(){}.getType();
|
||||
}
|
||||
|
||||
public static Type getTypeForDeserialization(Class cls) {
|
||||
@ -95,8 +81,7 @@ public static
|
||||
return new TypeToken<Order>(){}.getType();
|
||||
}
|
||||
|
||||
return new TypeToken
|
||||
<Object>(){}.getType();
|
||||
return new TypeToken<Object>(){}.getType();
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
|
@ -17,7 +17,7 @@ import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.io.File;
|
||||
|
||||
public class PetApi {
|
||||
public class PetApi {
|
||||
String basePath = "http://petstore.swagger.io/v2";
|
||||
ApiInvoker apiInvoker = ApiInvoker.getInstance();
|
||||
|
||||
@ -52,17 +52,11 @@ import java.io.File;
|
||||
String path = "/pet".replaceAll("\\{format\\}","json");
|
||||
|
||||
// query params
|
||||
Map
|
||||
<String, String> queryParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> queryParams = new HashMap<String, String>();
|
||||
// header params
|
||||
Map
|
||||
<String, String> headerParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> headerParams = new HashMap<String, String>();
|
||||
// form params
|
||||
Map
|
||||
<String, String> formParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> formParams = new HashMap<String, String>();
|
||||
|
||||
|
||||
|
||||
@ -112,17 +106,11 @@ import java.io.File;
|
||||
String path = "/pet".replaceAll("\\{format\\}","json");
|
||||
|
||||
// query params
|
||||
Map
|
||||
<String, String> queryParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> queryParams = new HashMap<String, String>();
|
||||
// header params
|
||||
Map
|
||||
<String, String> headerParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> headerParams = new HashMap<String, String>();
|
||||
// form params
|
||||
Map
|
||||
<String, String> formParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> formParams = new HashMap<String, String>();
|
||||
|
||||
|
||||
|
||||
@ -172,17 +160,11 @@ import java.io.File;
|
||||
String path = "/pet/findByStatus".replaceAll("\\{format\\}","json");
|
||||
|
||||
// query params
|
||||
Map
|
||||
<String, String> queryParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> queryParams = new HashMap<String, String>();
|
||||
// header params
|
||||
Map
|
||||
<String, String> headerParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> headerParams = new HashMap<String, String>();
|
||||
// form params
|
||||
Map
|
||||
<String, String> formParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> formParams = new HashMap<String, String>();
|
||||
|
||||
if (status != null)
|
||||
queryParams.put("status", ApiInvoker.parameterToString(status));
|
||||
@ -234,17 +216,11 @@ import java.io.File;
|
||||
String path = "/pet/findByTags".replaceAll("\\{format\\}","json");
|
||||
|
||||
// query params
|
||||
Map
|
||||
<String, String> queryParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> queryParams = new HashMap<String, String>();
|
||||
// header params
|
||||
Map
|
||||
<String, String> headerParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> headerParams = new HashMap<String, String>();
|
||||
// form params
|
||||
Map
|
||||
<String, String> formParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> formParams = new HashMap<String, String>();
|
||||
|
||||
if (tags != null)
|
||||
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()));
|
||||
|
||||
// query params
|
||||
Map
|
||||
<String, String> queryParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> queryParams = new HashMap<String, String>();
|
||||
// header params
|
||||
Map
|
||||
<String, String> headerParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> headerParams = new HashMap<String, String>();
|
||||
// form params
|
||||
Map
|
||||
<String, String> formParams = new HashMap
|
||||
<String, String>();
|
||||
Map<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()));
|
||||
|
||||
// query params
|
||||
Map
|
||||
<String, String> queryParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> queryParams = new HashMap<String, String>();
|
||||
// header params
|
||||
Map
|
||||
<String, String> headerParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> headerParams = new HashMap<String, String>();
|
||||
// form params
|
||||
Map
|
||||
<String, String> formParams = new HashMap
|
||||
<String, String>();
|
||||
Map<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()));
|
||||
|
||||
// query params
|
||||
Map
|
||||
<String, String> queryParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> queryParams = new HashMap<String, String>();
|
||||
// header params
|
||||
Map
|
||||
<String, String> headerParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> headerParams = new HashMap<String, String>();
|
||||
// form params
|
||||
Map
|
||||
<String, String> formParams = new HashMap
|
||||
<String, String>();
|
||||
Map<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()));
|
||||
|
||||
// query params
|
||||
Map
|
||||
<String, String> queryParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> queryParams = new HashMap<String, String>();
|
||||
// header params
|
||||
Map
|
||||
<String, String> headerParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> headerParams = new HashMap<String, String>();
|
||||
// form params
|
||||
Map
|
||||
<String, String> formParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> formParams = new HashMap<String, String>();
|
||||
|
||||
|
||||
|
||||
@ -568,4 +520,4 @@ import java.io.File;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.io.File;
|
||||
|
||||
public class StoreApi {
|
||||
public class StoreApi {
|
||||
String basePath = "http://petstore.swagger.io/v2";
|
||||
ApiInvoker apiInvoker = ApiInvoker.getInstance();
|
||||
|
||||
@ -51,17 +51,11 @@ import java.io.File;
|
||||
String path = "/store/inventory".replaceAll("\\{format\\}","json");
|
||||
|
||||
// query params
|
||||
Map
|
||||
<String, String> queryParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> queryParams = new HashMap<String, String>();
|
||||
// header params
|
||||
Map
|
||||
<String, String> headerParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> headerParams = new HashMap<String, String>();
|
||||
// form params
|
||||
Map
|
||||
<String, String> formParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> formParams = new HashMap<String, String>();
|
||||
|
||||
|
||||
|
||||
@ -111,17 +105,11 @@ import java.io.File;
|
||||
String path = "/store/order".replaceAll("\\{format\\}","json");
|
||||
|
||||
// query params
|
||||
Map
|
||||
<String, String> queryParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> queryParams = new HashMap<String, String>();
|
||||
// header params
|
||||
Map
|
||||
<String, String> headerParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> headerParams = new HashMap<String, String>();
|
||||
// form params
|
||||
Map
|
||||
<String, String> formParams = new HashMap
|
||||
<String, String>();
|
||||
Map<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()));
|
||||
|
||||
// query params
|
||||
Map
|
||||
<String, String> queryParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> queryParams = new HashMap<String, String>();
|
||||
// header params
|
||||
Map
|
||||
<String, String> headerParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> headerParams = new HashMap<String, String>();
|
||||
// form params
|
||||
Map
|
||||
<String, String> formParams = new HashMap
|
||||
<String, String>();
|
||||
Map<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()));
|
||||
|
||||
// query params
|
||||
Map
|
||||
<String, String> queryParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> queryParams = new HashMap<String, String>();
|
||||
// header params
|
||||
Map
|
||||
<String, String> headerParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> headerParams = new HashMap<String, String>();
|
||||
// form params
|
||||
Map
|
||||
<String, String> formParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> formParams = new HashMap<String, String>();
|
||||
|
||||
|
||||
|
||||
@ -287,4 +263,4 @@ import java.io.File;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.io.File;
|
||||
|
||||
public class UserApi {
|
||||
public class UserApi {
|
||||
String basePath = "http://petstore.swagger.io/v2";
|
||||
ApiInvoker apiInvoker = ApiInvoker.getInstance();
|
||||
|
||||
@ -52,17 +52,11 @@ import java.io.File;
|
||||
String path = "/user".replaceAll("\\{format\\}","json");
|
||||
|
||||
// query params
|
||||
Map
|
||||
<String, String> queryParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> queryParams = new HashMap<String, String>();
|
||||
// header params
|
||||
Map
|
||||
<String, String> headerParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> headerParams = new HashMap<String, String>();
|
||||
// form params
|
||||
Map
|
||||
<String, String> formParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> formParams = new HashMap<String, String>();
|
||||
|
||||
|
||||
|
||||
@ -112,17 +106,11 @@ import java.io.File;
|
||||
String path = "/user/createWithArray".replaceAll("\\{format\\}","json");
|
||||
|
||||
// query params
|
||||
Map
|
||||
<String, String> queryParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> queryParams = new HashMap<String, String>();
|
||||
// header params
|
||||
Map
|
||||
<String, String> headerParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> headerParams = new HashMap<String, String>();
|
||||
// form params
|
||||
Map
|
||||
<String, String> formParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> formParams = new HashMap<String, String>();
|
||||
|
||||
|
||||
|
||||
@ -172,17 +160,11 @@ import java.io.File;
|
||||
String path = "/user/createWithList".replaceAll("\\{format\\}","json");
|
||||
|
||||
// query params
|
||||
Map
|
||||
<String, String> queryParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> queryParams = new HashMap<String, String>();
|
||||
// header params
|
||||
Map
|
||||
<String, String> headerParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> headerParams = new HashMap<String, String>();
|
||||
// form params
|
||||
Map
|
||||
<String, String> formParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> formParams = new HashMap<String, String>();
|
||||
|
||||
|
||||
|
||||
@ -233,17 +215,11 @@ import java.io.File;
|
||||
String path = "/user/login".replaceAll("\\{format\\}","json");
|
||||
|
||||
// query params
|
||||
Map
|
||||
<String, String> queryParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> queryParams = new HashMap<String, String>();
|
||||
// header params
|
||||
Map
|
||||
<String, String> headerParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> headerParams = new HashMap<String, String>();
|
||||
// form params
|
||||
Map
|
||||
<String, String> formParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> formParams = new HashMap<String, String>();
|
||||
|
||||
if (username != null)
|
||||
queryParams.put("username", ApiInvoker.parameterToString(username));
|
||||
@ -296,17 +272,11 @@ import java.io.File;
|
||||
String path = "/user/logout".replaceAll("\\{format\\}","json");
|
||||
|
||||
// query params
|
||||
Map
|
||||
<String, String> queryParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> queryParams = new HashMap<String, String>();
|
||||
// header params
|
||||
Map
|
||||
<String, String> headerParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> headerParams = new HashMap<String, String>();
|
||||
// form params
|
||||
Map
|
||||
<String, String> formParams = new HashMap
|
||||
<String, String>();
|
||||
Map<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()));
|
||||
|
||||
// query params
|
||||
Map
|
||||
<String, String> queryParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> queryParams = new HashMap<String, String>();
|
||||
// header params
|
||||
Map
|
||||
<String, String> headerParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> headerParams = new HashMap<String, String>();
|
||||
// form params
|
||||
Map
|
||||
<String, String> formParams = new HashMap
|
||||
<String, String>();
|
||||
Map<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()));
|
||||
|
||||
// query params
|
||||
Map
|
||||
<String, String> queryParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> queryParams = new HashMap<String, String>();
|
||||
// header params
|
||||
Map
|
||||
<String, String> headerParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> headerParams = new HashMap<String, String>();
|
||||
// form params
|
||||
Map
|
||||
<String, String> formParams = new HashMap
|
||||
<String, String>();
|
||||
Map<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()));
|
||||
|
||||
// query params
|
||||
Map
|
||||
<String, String> queryParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> queryParams = new HashMap<String, String>();
|
||||
// header params
|
||||
Map
|
||||
<String, String> headerParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> headerParams = new HashMap<String, String>();
|
||||
// form params
|
||||
Map
|
||||
<String, String> formParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> formParams = new HashMap<String, String>();
|
||||
|
||||
|
||||
|
||||
@ -538,4 +490,4 @@ import java.io.File;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -5,8 +5,8 @@ import io.swagger.annotations.*;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
|
||||
@ApiModel(description = "")
|
||||
public class Category {
|
||||
@ApiModel(description = "")
|
||||
public class Category {
|
||||
|
||||
@SerializedName("id")
|
||||
private Long id = null;
|
||||
@ -47,5 +47,4 @@ import com.google.gson.annotations.SerializedName;
|
||||
sb.append("}\n");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,8 +6,8 @@ import io.swagger.annotations.*;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
|
||||
@ApiModel(description = "")
|
||||
public class Order {
|
||||
@ApiModel(description = "")
|
||||
public class Order {
|
||||
|
||||
@SerializedName("id")
|
||||
private Long id = null;
|
||||
@ -108,5 +108,4 @@ import com.google.gson.annotations.SerializedName;
|
||||
sb.append("}\n");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,15 +1,15 @@
|
||||
package io.swagger.client.model;
|
||||
|
||||
import io.swagger.client.model.Category;
|
||||
import io.swagger.client.model.Tag;
|
||||
import java.util.*;
|
||||
import io.swagger.client.model.Tag;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
|
||||
@ApiModel(description = "")
|
||||
public class Pet {
|
||||
@ApiModel(description = "")
|
||||
public class Pet {
|
||||
|
||||
@SerializedName("id")
|
||||
private Long id = null;
|
||||
@ -110,5 +110,4 @@ import com.google.gson.annotations.SerializedName;
|
||||
sb.append("}\n");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,8 +5,8 @@ import io.swagger.annotations.*;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
|
||||
@ApiModel(description = "")
|
||||
public class Tag {
|
||||
@ApiModel(description = "")
|
||||
public class Tag {
|
||||
|
||||
@SerializedName("id")
|
||||
private Long id = null;
|
||||
@ -47,5 +47,4 @@ import com.google.gson.annotations.SerializedName;
|
||||
sb.append("}\n");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,8 +5,8 @@ import io.swagger.annotations.*;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
|
||||
@ApiModel(description = "")
|
||||
public class User {
|
||||
@ApiModel(description = "")
|
||||
public class User {
|
||||
|
||||
@SerializedName("id")
|
||||
private Long id = null;
|
||||
@ -132,5 +132,4 @@ import com.google.gson.annotations.SerializedName;
|
||||
sb.append("}\n");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -500,7 +500,7 @@ namespace IO.Swagger.Api {
|
||||
|
||||
|
||||
// authentication setting, if any
|
||||
String[] authSettings = new String[] { "api_key", "petstore_auth" };
|
||||
String[] authSettings = new String[] { "petstore_auth", "api_key" };
|
||||
|
||||
// make the HTTP request
|
||||
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
|
||||
String[] authSettings = new String[] { "api_key", "petstore_auth" };
|
||||
String[] authSettings = new String[] { "petstore_auth", "api_key" };
|
||||
|
||||
// make the HTTP request
|
||||
IRestResponse response = (IRestResponse) await apiClient.CallApiAsync(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||
|
@ -77,8 +77,7 @@
|
||||
</goals>
|
||||
<configuration>
|
||||
<sources>
|
||||
<source>
|
||||
src/main/java</source>
|
||||
<source>src/main/java</source>
|
||||
</sources>
|
||||
</configuration>
|
||||
</execution>
|
||||
@ -90,8 +89,7 @@
|
||||
</goals>
|
||||
<configuration>
|
||||
<sources>
|
||||
<source>
|
||||
src/test/java</source>
|
||||
<source>src/test/java</source>
|
||||
</sources>
|
||||
</configuration>
|
||||
</execution>
|
||||
@ -102,8 +100,7 @@
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>2.3.2</version>
|
||||
<configuration>
|
||||
<source>
|
||||
1.6</source>
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
@ -40,481 +40,467 @@ import io.swagger.client.auth.ApiKeyAuth;
|
||||
import io.swagger.client.auth.OAuth;
|
||||
|
||||
public class ApiClient {
|
||||
private Map
|
||||
<String, Client> hostMap = new HashMap
|
||||
<String, Client>();
|
||||
private Map
|
||||
<String, String> defaultHeaderMap = new HashMap
|
||||
<String, String>();
|
||||
private boolean debugging = false;
|
||||
private String basePath = "http://petstore.swagger.io/v2";
|
||||
private Map<String, Client> hostMap = new HashMap<String, Client>();
|
||||
private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
|
||||
private boolean debugging = false;
|
||||
private String basePath = "http://petstore.swagger.io/v2";
|
||||
|
||||
private Map
|
||||
<String, Authentication> authentications;
|
||||
private Map<String, Authentication> authentications;
|
||||
|
||||
private DateFormat dateFormat;
|
||||
private DateFormat dateFormat;
|
||||
|
||||
public ApiClient() {
|
||||
// Use ISO 8601 format for date and datetime.
|
||||
// See https://en.wikipedia.org/wiki/ISO_8601
|
||||
this.dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
|
||||
public ApiClient() {
|
||||
// Use ISO 8601 format for date and datetime.
|
||||
// See https://en.wikipedia.org/wiki/ISO_8601
|
||||
this.dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
|
||||
|
||||
// Use UTC as the default time zone.
|
||||
this.dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
// Use UTC as the default time zone.
|
||||
this.dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
|
||||
// Set default User-Agent.
|
||||
setUserAgent("Java-Swagger");
|
||||
// Set default User-Agent.
|
||||
setUserAgent("Java-Swagger");
|
||||
|
||||
// Setup authentications (key: authentication name, value: authentication).
|
||||
authentications = new HashMap
|
||||
<String, Authentication>();
|
||||
// Setup authentications (key: authentication name, value: authentication).
|
||||
authentications = new HashMap<String, Authentication>();
|
||||
authentications.put("api_key", new ApiKeyAuth("header", "api_key"));
|
||||
authentications.put("petstore_auth", new OAuth());
|
||||
// Prevent the authentications from being modified.
|
||||
authentications = Collections.unmodifiableMap(authentications);
|
||||
}
|
||||
// Prevent the authentications from being modified.
|
||||
authentications = Collections.unmodifiableMap(authentications);
|
||||
}
|
||||
|
||||
public String getBasePath() {
|
||||
return basePath;
|
||||
}
|
||||
public String getBasePath() {
|
||||
return basePath;
|
||||
}
|
||||
|
||||
public ApiClient setBasePath(String basePath) {
|
||||
this.basePath = basePath;
|
||||
return this;
|
||||
}
|
||||
public ApiClient setBasePath(String basePath) {
|
||||
this.basePath = basePath;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get authentications (key: authentication name, value: authentication).
|
||||
*/
|
||||
public Map
|
||||
<String, Authentication> getAuthentications() {
|
||||
return authentications;
|
||||
}
|
||||
/**
|
||||
* Get authentications (key: authentication name, value: authentication).
|
||||
*/
|
||||
public Map<String, Authentication> getAuthentications() {
|
||||
return authentications;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get authentication for the given name.
|
||||
*
|
||||
* @param authName The authentication name
|
||||
* @return The authentication, null if not found
|
||||
*/
|
||||
public Authentication getAuthentication(String authName) {
|
||||
return authentications.get(authName);
|
||||
}
|
||||
/**
|
||||
* Get authentication for the given name.
|
||||
*
|
||||
* @param authName The authentication name
|
||||
* @return The authentication, null if not found
|
||||
*/
|
||||
public Authentication getAuthentication(String authName) {
|
||||
return authentications.get(authName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to set username for the first HTTP basic authentication.
|
||||
*/
|
||||
public void setUsername(String username) {
|
||||
for (Authentication auth : authentications.values()) {
|
||||
if (auth instanceof HttpBasicAuth) {
|
||||
((HttpBasicAuth) auth).setUsername(username);
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw new RuntimeException("No HTTP basic authentication configured!");
|
||||
}
|
||||
/**
|
||||
* Helper method to set username for the first HTTP basic authentication.
|
||||
*/
|
||||
public void setUsername(String username) {
|
||||
for (Authentication auth : authentications.values()) {
|
||||
if (auth instanceof HttpBasicAuth) {
|
||||
((HttpBasicAuth) auth).setUsername(username);
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw new RuntimeException("No HTTP basic authentication configured!");
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to set password for the first HTTP basic authentication.
|
||||
*/
|
||||
public void setPassword(String password) {
|
||||
for (Authentication auth : authentications.values()) {
|
||||
if (auth instanceof HttpBasicAuth) {
|
||||
((HttpBasicAuth) auth).setPassword(password);
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw new RuntimeException("No HTTP basic authentication configured!");
|
||||
}
|
||||
/**
|
||||
* Helper method to set password for the first HTTP basic authentication.
|
||||
*/
|
||||
public void setPassword(String password) {
|
||||
for (Authentication auth : authentications.values()) {
|
||||
if (auth instanceof HttpBasicAuth) {
|
||||
((HttpBasicAuth) auth).setPassword(password);
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw new RuntimeException("No HTTP basic authentication configured!");
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to set API key value for the first API key authentication.
|
||||
*/
|
||||
public void setApiKey(String apiKey) {
|
||||
for (Authentication auth : authentications.values()) {
|
||||
if (auth instanceof ApiKeyAuth) {
|
||||
((ApiKeyAuth) auth).setApiKey(apiKey);
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw new RuntimeException("No API key authentication configured!");
|
||||
}
|
||||
/**
|
||||
* Helper method to set API key value for the first API key authentication.
|
||||
*/
|
||||
public void setApiKey(String apiKey) {
|
||||
for (Authentication auth : authentications.values()) {
|
||||
if (auth instanceof ApiKeyAuth) {
|
||||
((ApiKeyAuth) auth).setApiKey(apiKey);
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw new RuntimeException("No API key authentication configured!");
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to set API key prefix for the first API key authentication.
|
||||
*/
|
||||
public void setApiKeyPrefix(String apiKeyPrefix) {
|
||||
for (Authentication auth : authentications.values()) {
|
||||
if (auth instanceof ApiKeyAuth) {
|
||||
((ApiKeyAuth) auth).setApiKeyPrefix(apiKeyPrefix);
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw new RuntimeException("No API key authentication configured!");
|
||||
}
|
||||
/**
|
||||
* Helper method to set API key prefix for the first API key authentication.
|
||||
*/
|
||||
public void setApiKeyPrefix(String apiKeyPrefix) {
|
||||
for (Authentication auth : authentications.values()) {
|
||||
if (auth instanceof ApiKeyAuth) {
|
||||
((ApiKeyAuth) auth).setApiKeyPrefix(apiKeyPrefix);
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw new RuntimeException("No API key authentication configured!");
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the User-Agent header's value (by adding to the default header map).
|
||||
*/
|
||||
public ApiClient setUserAgent(String userAgent) {
|
||||
addDefaultHeader("User-Agent", userAgent);
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Set the User-Agent header's value (by adding to the default header map).
|
||||
*/
|
||||
public ApiClient setUserAgent(String userAgent) {
|
||||
addDefaultHeader("User-Agent", userAgent);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a default header.
|
||||
*
|
||||
* @param key The header's key
|
||||
* @param value The header's value
|
||||
*/
|
||||
public ApiClient addDefaultHeader(String key, String value) {
|
||||
defaultHeaderMap.put(key, value);
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Add a default header.
|
||||
*
|
||||
* @param key The header's key
|
||||
* @param value The header's value
|
||||
*/
|
||||
public ApiClient addDefaultHeader(String key, String value) {
|
||||
defaultHeaderMap.put(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that whether debugging is enabled for this API client.
|
||||
*/
|
||||
public boolean isDebugging() {
|
||||
return debugging;
|
||||
}
|
||||
/**
|
||||
* Check that whether debugging is enabled for this API client.
|
||||
*/
|
||||
public boolean isDebugging() {
|
||||
return debugging;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable/disable debugging for this API client.
|
||||
*
|
||||
* @param debugging To enable (true) or disable (false) debugging
|
||||
*/
|
||||
public ApiClient setDebugging(boolean debugging) {
|
||||
this.debugging = debugging;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Enable/disable debugging for this API client.
|
||||
*
|
||||
* @param debugging To enable (true) or disable (false) debugging
|
||||
*/
|
||||
public ApiClient setDebugging(boolean debugging) {
|
||||
this.debugging = debugging;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the date format used to parse/format date parameters.
|
||||
*/
|
||||
public DateFormat getDateFormat() {
|
||||
return dateFormat;
|
||||
}
|
||||
/**
|
||||
* Get the date format used to parse/format date parameters.
|
||||
*/
|
||||
public DateFormat getDateFormat() {
|
||||
return dateFormat;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the date format used to parse/format date parameters.
|
||||
*/
|
||||
public ApiClient getDateFormat(DateFormat dateFormat) {
|
||||
this.dateFormat = dateFormat;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Set the date format used to parse/format date parameters.
|
||||
*/
|
||||
public ApiClient getDateFormat(DateFormat dateFormat) {
|
||||
this.dateFormat = dateFormat;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the given string into Date object.
|
||||
*/
|
||||
public Date parseDate(String str) {
|
||||
try {
|
||||
return dateFormat.parse(str);
|
||||
} catch (java.text.ParseException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Parse the given string into Date object.
|
||||
*/
|
||||
public Date parseDate(String str) {
|
||||
try {
|
||||
return dateFormat.parse(str);
|
||||
} catch (java.text.ParseException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the given Date object into string.
|
||||
*/
|
||||
public String formatDate(Date date) {
|
||||
return dateFormat.format(date);
|
||||
}
|
||||
/**
|
||||
* Format the given Date object into string.
|
||||
*/
|
||||
public String formatDate(Date date) {
|
||||
return dateFormat.format(date);
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the given parameter object into string.
|
||||
*/
|
||||
public String parameterToString(Object param) {
|
||||
if (param == null) {
|
||||
return "";
|
||||
} else if (param instanceof Date) {
|
||||
return formatDate((Date) param);
|
||||
} else if (param instanceof Collection) {
|
||||
StringBuilder b = new StringBuilder();
|
||||
for(Object o : (Collection)param) {
|
||||
if(b.length() > 0) {
|
||||
b.append(",");
|
||||
}
|
||||
b.append(String.valueOf(o));
|
||||
}
|
||||
return b.toString();
|
||||
} else {
|
||||
return String.valueOf(param);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Format the given parameter object into string.
|
||||
*/
|
||||
public String parameterToString(Object param) {
|
||||
if (param == null) {
|
||||
return "";
|
||||
} else if (param instanceof Date) {
|
||||
return formatDate((Date) param);
|
||||
} else if (param instanceof Collection) {
|
||||
StringBuilder b = new StringBuilder();
|
||||
for(Object o : (Collection)param) {
|
||||
if(b.length() > 0) {
|
||||
b.append(",");
|
||||
}
|
||||
b.append(String.valueOf(o));
|
||||
}
|
||||
return b.toString();
|
||||
} else {
|
||||
return String.valueOf(param);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Select the Accept header's value from the given accepts array:
|
||||
* if JSON exists in the given array, use it;
|
||||
* otherwise use all of them (joining into a string)
|
||||
*
|
||||
* @param accepts The accepts array to select from
|
||||
* @return The Accept header to use. If the given array is empty,
|
||||
* null will be returned (not to set the Accept header explicitly).
|
||||
*/
|
||||
public String selectHeaderAccept(String[] accepts) {
|
||||
if (accepts.length == 0) return null;
|
||||
if (StringUtil.containsIgnoreCase(accepts, "application/json")) return "application/json";
|
||||
return StringUtil.join(accepts, ",");
|
||||
}
|
||||
/**
|
||||
* Select the Accept header's value from the given accepts array:
|
||||
* if JSON exists in the given array, use it;
|
||||
* otherwise use all of them (joining into a string)
|
||||
*
|
||||
* @param accepts The accepts array to select from
|
||||
* @return The Accept header to use. If the given array is empty,
|
||||
* null will be returned (not to set the Accept header explicitly).
|
||||
*/
|
||||
public String selectHeaderAccept(String[] accepts) {
|
||||
if (accepts.length == 0) return null;
|
||||
if (StringUtil.containsIgnoreCase(accepts, "application/json")) return "application/json";
|
||||
return StringUtil.join(accepts, ",");
|
||||
}
|
||||
|
||||
/**
|
||||
* Select the Content-Type header's value from the given array:
|
||||
* if JSON exists in the given array, use it;
|
||||
* otherwise use the first one of the array.
|
||||
*
|
||||
* @param contentTypes The Content-Type array to select from
|
||||
* @return The Content-Type header to use. If the given array is empty,
|
||||
* JSON will be used.
|
||||
*/
|
||||
public String selectHeaderContentType(String[] contentTypes) {
|
||||
if (contentTypes.length == 0) return "application/json";
|
||||
if (StringUtil.containsIgnoreCase(contentTypes, "application/json")) return "application/json";
|
||||
return contentTypes[0];
|
||||
}
|
||||
/**
|
||||
* Select the Content-Type header's value from the given array:
|
||||
* if JSON exists in the given array, use it;
|
||||
* otherwise use the first one of the array.
|
||||
*
|
||||
* @param contentTypes The Content-Type array to select from
|
||||
* @return The Content-Type header to use. If the given array is empty,
|
||||
* JSON will be used.
|
||||
*/
|
||||
public String selectHeaderContentType(String[] contentTypes) {
|
||||
if (contentTypes.length == 0) return "application/json";
|
||||
if (StringUtil.containsIgnoreCase(contentTypes, "application/json")) return "application/json";
|
||||
return contentTypes[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Escape the given string to be used as URL query value.
|
||||
*/
|
||||
public String escapeString(String str) {
|
||||
try {
|
||||
return URLEncoder.encode(str, "utf8").replaceAll("\\+", "%20");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
return str;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Escape the given string to be used as URL query value.
|
||||
*/
|
||||
public String escapeString(String str) {
|
||||
try {
|
||||
return URLEncoder.encode(str, "utf8").replaceAll("\\+", "%20");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deserialize the given JSON string to Java object.
|
||||
*
|
||||
* @param json The JSON string
|
||||
* @param containerType The container type, one of "list", "array" or ""
|
||||
* @param cls The type of the Java object
|
||||
* @return The deserialized Java object
|
||||
*/
|
||||
public Object deserialize(String json, String containerType, Class cls) throws ApiException {
|
||||
if(null != containerType) {
|
||||
containerType = containerType.toLowerCase();
|
||||
}
|
||||
try{
|
||||
if("list".equals(containerType) || "array".equals(containerType)) {
|
||||
JavaType typeInfo = JsonUtil.getJsonMapper().getTypeFactory().constructCollectionType(List.class, cls);
|
||||
List response = (List<?>) JsonUtil.getJsonMapper().readValue(json, typeInfo);
|
||||
return response;
|
||||
}
|
||||
else if(String.class.equals(cls)) {
|
||||
if(json != null && json.startsWith("\"") && json.endsWith("\"") && json.length() > 1)
|
||||
return json.substring(1, json.length() - 2);
|
||||
else
|
||||
return json;
|
||||
}
|
||||
else {
|
||||
return JsonUtil.getJsonMapper().readValue(json, cls);
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new ApiException(500, e.getMessage(), null, json);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Deserialize the given JSON string to Java object.
|
||||
*
|
||||
* @param json The JSON string
|
||||
* @param containerType The container type, one of "list", "array" or ""
|
||||
* @param cls The type of the Java object
|
||||
* @return The deserialized Java object
|
||||
*/
|
||||
public Object deserialize(String json, String containerType, Class cls) throws ApiException {
|
||||
if(null != containerType) {
|
||||
containerType = containerType.toLowerCase();
|
||||
}
|
||||
try{
|
||||
if("list".equals(containerType) || "array".equals(containerType)) {
|
||||
JavaType typeInfo = JsonUtil.getJsonMapper().getTypeFactory().constructCollectionType(List.class, cls);
|
||||
List response = (List<?>) JsonUtil.getJsonMapper().readValue(json, typeInfo);
|
||||
return response;
|
||||
}
|
||||
else if(String.class.equals(cls)) {
|
||||
if(json != null && json.startsWith("\"") && json.endsWith("\"") && json.length() > 1)
|
||||
return json.substring(1, json.length() - 2);
|
||||
else
|
||||
return json;
|
||||
}
|
||||
else {
|
||||
return JsonUtil.getJsonMapper().readValue(json, cls);
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new ApiException(500, e.getMessage(), null, json);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize the given Java object into JSON string.
|
||||
*/
|
||||
public String serialize(Object obj) throws ApiException {
|
||||
try {
|
||||
if (obj != null)
|
||||
return JsonUtil.getJsonMapper().writeValueAsString(obj);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new ApiException(500, e.getMessage());
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Serialize the given Java object into JSON string.
|
||||
*/
|
||||
public String serialize(Object obj) throws ApiException {
|
||||
try {
|
||||
if (obj != null)
|
||||
return JsonUtil.getJsonMapper().writeValueAsString(obj);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new ApiException(500, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke API by sending HTTP request with the given options.
|
||||
*
|
||||
* @param path The sub-path of the HTTP URL
|
||||
* @param method The request method, one of "GET", "POST", "PUT", and "DELETE"
|
||||
* @param queryParams The query parameters
|
||||
* @param body The request body object
|
||||
* @param headerParams The header parameters
|
||||
* @param formParams The form parameters
|
||||
* @param accept The request's Accept header
|
||||
* @param contentType The request's Content-Type header
|
||||
* @param authNames The authentications to apply
|
||||
* @return The response body in type of string
|
||||
*/
|
||||
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 {
|
||||
updateParamsForAuth(authNames, queryParams, headerParams);
|
||||
/**
|
||||
* Invoke API by sending HTTP request with the given options.
|
||||
*
|
||||
* @param path The sub-path of the HTTP URL
|
||||
* @param method The request method, one of "GET", "POST", "PUT", and "DELETE"
|
||||
* @param queryParams The query parameters
|
||||
* @param body The request body object
|
||||
* @param headerParams The header parameters
|
||||
* @param formParams The form parameters
|
||||
* @param accept The request's Accept header
|
||||
* @param contentType The request's Content-Type header
|
||||
* @param authNames The authentications to apply
|
||||
* @return The response body in type of string
|
||||
*/
|
||||
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 {
|
||||
updateParamsForAuth(authNames, queryParams, headerParams);
|
||||
|
||||
Client client = getClient();
|
||||
Client client = getClient();
|
||||
|
||||
StringBuilder b = new StringBuilder();
|
||||
for(String key : queryParams.keySet()) {
|
||||
String value = queryParams.get(key);
|
||||
if (value != null){
|
||||
if(b.toString().length() == 0)
|
||||
b.append("?");
|
||||
else
|
||||
b.append("&");
|
||||
b.append(escapeString(key)).append("=").append(escapeString(value));
|
||||
}
|
||||
}
|
||||
String querystring = b.toString();
|
||||
StringBuilder b = new StringBuilder();
|
||||
for(String key : queryParams.keySet()) {
|
||||
String value = queryParams.get(key);
|
||||
if (value != null){
|
||||
if(b.toString().length() == 0)
|
||||
b.append("?");
|
||||
else
|
||||
b.append("&");
|
||||
b.append(escapeString(key)).append("=").append(escapeString(value));
|
||||
}
|
||||
}
|
||||
String querystring = b.toString();
|
||||
|
||||
Builder builder;
|
||||
if (accept == null)
|
||||
builder = client.resource(basePath + path + querystring).getRequestBuilder();
|
||||
else
|
||||
builder = client.resource(basePath + path + querystring).accept(accept);
|
||||
Builder builder;
|
||||
if (accept == null)
|
||||
builder = client.resource(basePath + path + querystring).getRequestBuilder();
|
||||
else
|
||||
builder = client.resource(basePath + path + querystring).accept(accept);
|
||||
|
||||
for(String key : headerParams.keySet()) {
|
||||
builder = builder.header(key, headerParams.get(key));
|
||||
}
|
||||
for(String key : defaultHeaderMap.keySet()) {
|
||||
if(!headerParams.containsKey(key)) {
|
||||
builder = builder.header(key, defaultHeaderMap.get(key));
|
||||
}
|
||||
}
|
||||
for(String key : headerParams.keySet()) {
|
||||
builder = builder.header(key, headerParams.get(key));
|
||||
}
|
||||
for(String key : defaultHeaderMap.keySet()) {
|
||||
if(!headerParams.containsKey(key)) {
|
||||
builder = builder.header(key, defaultHeaderMap.get(key));
|
||||
}
|
||||
}
|
||||
|
||||
ClientResponse response = null;
|
||||
ClientResponse response = null;
|
||||
|
||||
if("GET".equals(method)) {
|
||||
response = (ClientResponse) builder.get(ClientResponse.class);
|
||||
}
|
||||
else if ("POST".equals(method)) {
|
||||
if (contentType.startsWith("application/x-www-form-urlencoded")) {
|
||||
String encodedFormParams = this
|
||||
.getXWWWFormUrlencodedParams(formParams);
|
||||
response = builder.type(contentType).post(ClientResponse.class,
|
||||
encodedFormParams);
|
||||
} else if (body == null) {
|
||||
response = builder.post(ClientResponse.class, null);
|
||||
} else if(body instanceof FormDataMultiPart) {
|
||||
response = builder.type(contentType).post(ClientResponse.class, body);
|
||||
}
|
||||
else
|
||||
response = builder.type(contentType).post(ClientResponse.class, serialize(body));
|
||||
}
|
||||
else if ("PUT".equals(method)) {
|
||||
if ("application/x-www-form-urlencoded".equals(contentType)) {
|
||||
String encodedFormParams = this
|
||||
.getXWWWFormUrlencodedParams(formParams);
|
||||
response = builder.type(contentType).put(ClientResponse.class,
|
||||
encodedFormParams);
|
||||
} else if(body == null) {
|
||||
response = builder.put(ClientResponse.class, serialize(body));
|
||||
} else {
|
||||
response = builder.type(contentType).put(ClientResponse.class, serialize(body));
|
||||
}
|
||||
}
|
||||
else if ("DELETE".equals(method)) {
|
||||
if ("application/x-www-form-urlencoded".equals(contentType)) {
|
||||
String encodedFormParams = this
|
||||
.getXWWWFormUrlencodedParams(formParams);
|
||||
response = builder.type(contentType).delete(ClientResponse.class,
|
||||
encodedFormParams);
|
||||
} else if(body == null) {
|
||||
response = builder.delete(ClientResponse.class);
|
||||
} else {
|
||||
response = builder.type(contentType).delete(ClientResponse.class, serialize(body));
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new ApiException(500, "unknown method type " + method);
|
||||
}
|
||||
if("GET".equals(method)) {
|
||||
response = (ClientResponse) builder.get(ClientResponse.class);
|
||||
}
|
||||
else if ("POST".equals(method)) {
|
||||
if (contentType.startsWith("application/x-www-form-urlencoded")) {
|
||||
String encodedFormParams = this
|
||||
.getXWWWFormUrlencodedParams(formParams);
|
||||
response = builder.type(contentType).post(ClientResponse.class,
|
||||
encodedFormParams);
|
||||
} else if (body == null) {
|
||||
response = builder.post(ClientResponse.class, null);
|
||||
} else if(body instanceof FormDataMultiPart) {
|
||||
response = builder.type(contentType).post(ClientResponse.class, body);
|
||||
}
|
||||
else
|
||||
response = builder.type(contentType).post(ClientResponse.class, serialize(body));
|
||||
}
|
||||
else if ("PUT".equals(method)) {
|
||||
if ("application/x-www-form-urlencoded".equals(contentType)) {
|
||||
String encodedFormParams = this
|
||||
.getXWWWFormUrlencodedParams(formParams);
|
||||
response = builder.type(contentType).put(ClientResponse.class,
|
||||
encodedFormParams);
|
||||
} else if(body == null) {
|
||||
response = builder.put(ClientResponse.class, serialize(body));
|
||||
} else {
|
||||
response = builder.type(contentType).put(ClientResponse.class, serialize(body));
|
||||
}
|
||||
}
|
||||
else if ("DELETE".equals(method)) {
|
||||
if ("application/x-www-form-urlencoded".equals(contentType)) {
|
||||
String encodedFormParams = this
|
||||
.getXWWWFormUrlencodedParams(formParams);
|
||||
response = builder.type(contentType).delete(ClientResponse.class,
|
||||
encodedFormParams);
|
||||
} else if(body == null) {
|
||||
response = builder.delete(ClientResponse.class);
|
||||
} else {
|
||||
response = builder.type(contentType).delete(ClientResponse.class, serialize(body));
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new ApiException(500, "unknown method type " + method);
|
||||
}
|
||||
|
||||
if(response.getClientResponseStatus() == ClientResponse.Status.NO_CONTENT) {
|
||||
return null;
|
||||
}
|
||||
else if(response.getClientResponseStatus().getFamily() == Family.SUCCESSFUL) {
|
||||
if(response.hasEntity()) {
|
||||
return (String) response.getEntity(String.class);
|
||||
}
|
||||
else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
else {
|
||||
String message = "error";
|
||||
String respBody = null;
|
||||
if(response.hasEntity()) {
|
||||
try{
|
||||
respBody = String.valueOf(response.getEntity(String.class));
|
||||
message = respBody;
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
// e.printStackTrace();
|
||||
}
|
||||
}
|
||||
throw new ApiException(
|
||||
response.getClientResponseStatus().getStatusCode(),
|
||||
message,
|
||||
response.getHeaders(),
|
||||
respBody);
|
||||
}
|
||||
}
|
||||
if(response.getClientResponseStatus() == ClientResponse.Status.NO_CONTENT) {
|
||||
return null;
|
||||
}
|
||||
else if(response.getClientResponseStatus().getFamily() == Family.SUCCESSFUL) {
|
||||
if(response.hasEntity()) {
|
||||
return (String) response.getEntity(String.class);
|
||||
}
|
||||
else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
else {
|
||||
String message = "error";
|
||||
String respBody = null;
|
||||
if(response.hasEntity()) {
|
||||
try{
|
||||
respBody = String.valueOf(response.getEntity(String.class));
|
||||
message = respBody;
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
// e.printStackTrace();
|
||||
}
|
||||
}
|
||||
throw new ApiException(
|
||||
response.getClientResponseStatus().getStatusCode(),
|
||||
message,
|
||||
response.getHeaders(),
|
||||
respBody);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update query and header parameters based on authentication settings.
|
||||
*
|
||||
* @param authNames The authentications to apply
|
||||
*/
|
||||
private void updateParamsForAuth(String[] authNames, Map
|
||||
<String, String> queryParams, Map
|
||||
<String, String> headerParams) {
|
||||
for (String authName : authNames) {
|
||||
Authentication auth = authentications.get(authName);
|
||||
if (auth == null) throw new RuntimeException("Authentication undefined: " + authName);
|
||||
auth.applyToParams(queryParams, headerParams);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Update query and header parameters based on authentication settings.
|
||||
*
|
||||
* @param authNames The authentications to apply
|
||||
*/
|
||||
private void updateParamsForAuth(String[] authNames, Map<String, String> queryParams, Map<String, String> headerParams) {
|
||||
for (String authName : authNames) {
|
||||
Authentication auth = authentications.get(authName);
|
||||
if (auth == null) throw new RuntimeException("Authentication undefined: " + authName);
|
||||
auth.applyToParams(queryParams, headerParams);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode the given form parameters as request body.
|
||||
*/
|
||||
private String getXWWWFormUrlencodedParams(Map
|
||||
<String, String> formParams) {
|
||||
StringBuilder formParamBuilder = new StringBuilder();
|
||||
/**
|
||||
* Encode the given form parameters as request body.
|
||||
*/
|
||||
private String getXWWWFormUrlencodedParams(Map<String, String> formParams) {
|
||||
StringBuilder formParamBuilder = new StringBuilder();
|
||||
|
||||
for (Entry
|
||||
<String, String> param : formParams.entrySet()) {
|
||||
String keyStr = parameterToString(param.getKey());
|
||||
String valueStr = parameterToString(param.getValue());
|
||||
for (Entry<String, String> param : formParams.entrySet()) {
|
||||
String keyStr = parameterToString(param.getKey());
|
||||
String valueStr = parameterToString(param.getValue());
|
||||
|
||||
try {
|
||||
formParamBuilder.append(URLEncoder.encode(keyStr, "utf8"))
|
||||
.append("=")
|
||||
.append(URLEncoder.encode(valueStr, "utf8"));
|
||||
formParamBuilder.append("&");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
// move on to next
|
||||
}
|
||||
}
|
||||
String encodedFormParams = formParamBuilder.toString();
|
||||
if (encodedFormParams.endsWith("&")) {
|
||||
encodedFormParams = encodedFormParams.substring(0,
|
||||
encodedFormParams.length() - 1);
|
||||
}
|
||||
return encodedFormParams;
|
||||
}
|
||||
try {
|
||||
formParamBuilder.append(URLEncoder.encode(keyStr, "utf8"))
|
||||
.append("=")
|
||||
.append(URLEncoder.encode(valueStr, "utf8"));
|
||||
formParamBuilder.append("&");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
// move on to next
|
||||
}
|
||||
}
|
||||
String encodedFormParams = formParamBuilder.toString();
|
||||
if (encodedFormParams.endsWith("&")) {
|
||||
encodedFormParams = encodedFormParams.substring(0,
|
||||
encodedFormParams.length() - 1);
|
||||
}
|
||||
return encodedFormParams;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an existing client or create a new client to handle HTTP request.
|
||||
*/
|
||||
private Client getClient() {
|
||||
if(!hostMap.containsKey(basePath)) {
|
||||
Client client = Client.create();
|
||||
if (debugging)
|
||||
client.addFilter(new LoggingFilter());
|
||||
hostMap.put(basePath, client);
|
||||
}
|
||||
return hostMap.get(basePath);
|
||||
}
|
||||
/**
|
||||
* Get an existing client or create a new client to handle HTTP request.
|
||||
*/
|
||||
private Client getClient() {
|
||||
if(!hostMap.containsKey(basePath)) {
|
||||
Client client = Client.create();
|
||||
if (debugging)
|
||||
client.addFilter(new LoggingFilter());
|
||||
hostMap.put(basePath, client);
|
||||
}
|
||||
return hostMap.get(basePath);
|
||||
}
|
||||
}
|
||||
|
@ -4,11 +4,9 @@ import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
public class ApiException extends Exception {
|
||||
private int code = 0;
|
||||
private String message = null;
|
||||
private Map
|
||||
<String, List
|
||||
<String>> responseHeaders = null;
|
||||
private int code = 0;
|
||||
private String message = null;
|
||||
private Map<String, List<String>> responseHeaders = null;
|
||||
private String responseBody = null;
|
||||
|
||||
public ApiException() {}
|
||||
@ -18,10 +16,7 @@ private Map
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public ApiException(int code, String message, Map
|
||||
<String
|
||||
, List
|
||||
<String>> responseHeaders, String responseBody) {
|
||||
public ApiException(int code, String message, Map<String, List<String>> responseHeaders, String responseBody) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
this.responseHeaders = responseHeaders;
|
||||
@ -39,10 +34,7 @@ private Map
|
||||
/**
|
||||
* Get the HTTP response headers.
|
||||
*/
|
||||
public Map
|
||||
<String
|
||||
, List
|
||||
<String>> getResponseHeaders() {
|
||||
public Map<String, List<String>> getResponseHeaders() {
|
||||
return responseHeaders;
|
||||
}
|
||||
|
||||
@ -52,4 +44,4 @@ private Map
|
||||
public String getResponseBody() {
|
||||
return responseBody;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,21 +1,21 @@
|
||||
package io.swagger.client;
|
||||
|
||||
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
|
||||
* instances without providing an API client.
|
||||
*/
|
||||
public static ApiClient getDefaultApiClient() {
|
||||
return defaultApiClient;
|
||||
}
|
||||
/**
|
||||
* Get the default API client, which would be used when creating API
|
||||
* instances without providing an API client.
|
||||
*/
|
||||
public static ApiClient getDefaultApiClient() {
|
||||
return defaultApiClient;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the default API client, which would be used when creating API
|
||||
* instances without providing an API client.
|
||||
*/
|
||||
public static void setDefaultApiClient(ApiClient apiClient) {
|
||||
defaultApiClient = apiClient;
|
||||
}
|
||||
/**
|
||||
* Set the default API client, which would be used when creating API
|
||||
* instances without providing an API client.
|
||||
*/
|
||||
public static void setDefaultApiClient(ApiClient apiClient) {
|
||||
defaultApiClient = apiClient;
|
||||
}
|
||||
}
|
||||
|
@ -8,16 +8,16 @@ import com.fasterxml.jackson.core.JsonGenerator.Feature;
|
||||
import com.fasterxml.jackson.datatype.joda.*;
|
||||
|
||||
public class JsonUtil {
|
||||
public static ObjectMapper mapper;
|
||||
public static ObjectMapper mapper;
|
||||
|
||||
static {
|
||||
mapper = new ObjectMapper();
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
||||
mapper.registerModule(new JodaModule());
|
||||
}
|
||||
static {
|
||||
mapper = new ObjectMapper();
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
||||
mapper.registerModule(new JodaModule());
|
||||
}
|
||||
|
||||
public static ObjectMapper getJsonMapper() {
|
||||
return mapper;
|
||||
}
|
||||
public static ObjectMapper getJsonMapper() {
|
||||
return mapper;
|
||||
}
|
||||
}
|
||||
|
@ -1,41 +1,41 @@
|
||||
package io.swagger.client;
|
||||
|
||||
public class StringUtil {
|
||||
/**
|
||||
* Check if the given array contains the given value (with case-insensitive comparison).
|
||||
*
|
||||
* @param array The array
|
||||
* @param value The value to search
|
||||
* @return true if the array contains the value
|
||||
*/
|
||||
public static boolean containsIgnoreCase(String[] array, String value) {
|
||||
for (String str : array) {
|
||||
if (value == null && str == null) return true;
|
||||
if (value != null && value.equalsIgnoreCase(str)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Check if the given array contains the given value (with case-insensitive comparison).
|
||||
*
|
||||
* @param array The array
|
||||
* @param value The value to search
|
||||
* @return true if the array contains the value
|
||||
*/
|
||||
public static boolean containsIgnoreCase(String[] array, String value) {
|
||||
for (String str : array) {
|
||||
if (value == null && str == null) return true;
|
||||
if (value != null && value.equalsIgnoreCase(str)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Join an array of strings with the given separator.
|
||||
* <p>
|
||||
/**
|
||||
* Join an array of strings with the given separator.
|
||||
* <p>
|
||||
* Note: This might be replaced by utility method from commons-lang or guava someday
|
||||
* if one of those libraries is added as dependency.
|
||||
* </p>
|
||||
*
|
||||
* @param array The array of strings
|
||||
* @param separator The separator
|
||||
* @return the resulting string
|
||||
*/
|
||||
public static String join(String[] array, String separator) {
|
||||
int len = array.length;
|
||||
if (len == 0) return "";
|
||||
*
|
||||
* @param array The array of strings
|
||||
* @param separator The separator
|
||||
* @return the resulting string
|
||||
*/
|
||||
public static String join(String[] array, String separator) {
|
||||
int len = array.length;
|
||||
if (len == 0) return "";
|
||||
|
||||
StringBuilder out = new StringBuilder();
|
||||
out.append(array[0]);
|
||||
for (int i = 1; i < len; i++) {
|
||||
out.append(separator).append(array[i]);
|
||||
}
|
||||
return out.toString();
|
||||
}
|
||||
StringBuilder out = new StringBuilder();
|
||||
out.append(array[0]);
|
||||
for (int i = 1; i < len; i++) {
|
||||
out.append(separator).append(array[i]);
|
||||
}
|
||||
return out.toString();
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ import java.io.File;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class PetApi {
|
||||
public class PetApi {
|
||||
private ApiClient apiClient;
|
||||
|
||||
public PetApi() {
|
||||
@ -54,15 +54,9 @@ import java.util.HashMap;
|
||||
String path = "/pet".replaceAll("\\{format\\}","json");
|
||||
|
||||
// query params
|
||||
Map
|
||||
<String, String> queryParams = new HashMap
|
||||
<String, String>();
|
||||
Map
|
||||
<String, String> headerParams = new HashMap
|
||||
<String, String>();
|
||||
Map
|
||||
<String, String> formParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> queryParams = 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");
|
||||
|
||||
// query params
|
||||
Map
|
||||
<String, String> queryParams = new HashMap
|
||||
<String, String>();
|
||||
Map
|
||||
<String, String> headerParams = new HashMap
|
||||
<String, String>();
|
||||
Map
|
||||
<String, String> formParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> queryParams = 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");
|
||||
|
||||
// query params
|
||||
Map
|
||||
<String, String> queryParams = new HashMap
|
||||
<String, String>();
|
||||
Map
|
||||
<String, String> headerParams = new HashMap
|
||||
<String, String>();
|
||||
Map
|
||||
<String, String> formParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> queryParams = new HashMap<String, String>();
|
||||
Map<String, String> headerParams = new HashMap<String, String>();
|
||||
Map<String, String> formParams = new HashMap<String, String>();
|
||||
|
||||
if (status != null)
|
||||
queryParams.put("status", apiClient.parameterToString(status));
|
||||
@ -245,15 +227,9 @@ import java.util.HashMap;
|
||||
String path = "/pet/findByTags".replaceAll("\\{format\\}","json");
|
||||
|
||||
// query params
|
||||
Map
|
||||
<String, String> queryParams = new HashMap
|
||||
<String, String>();
|
||||
Map
|
||||
<String, String> headerParams = new HashMap
|
||||
<String, String>();
|
||||
Map
|
||||
<String, String> formParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> queryParams = new HashMap<String, String>();
|
||||
Map<String, String> headerParams = new HashMap<String, String>();
|
||||
Map<String, String> formParams = new HashMap<String, String>();
|
||||
|
||||
if (tags != null)
|
||||
queryParams.put("tags", apiClient.parameterToString(tags));
|
||||
@ -316,15 +292,9 @@ import java.util.HashMap;
|
||||
.replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString()));
|
||||
|
||||
// query params
|
||||
Map
|
||||
<String, String> queryParams = new HashMap
|
||||
<String, String>();
|
||||
Map
|
||||
<String, String> headerParams = new HashMap
|
||||
<String, String>();
|
||||
Map
|
||||
<String, String> formParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> queryParams = 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 {
|
||||
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);
|
||||
if(response != null){
|
||||
return (Pet) apiClient.deserialize(response, "", Pet.class);
|
||||
@ -387,15 +357,9 @@ import java.util.HashMap;
|
||||
.replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString()));
|
||||
|
||||
// query params
|
||||
Map
|
||||
<String, String> queryParams = new HashMap
|
||||
<String, String>();
|
||||
Map
|
||||
<String, String> headerParams = new HashMap
|
||||
<String, String>();
|
||||
Map
|
||||
<String, String> formParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> queryParams = 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()));
|
||||
|
||||
// query params
|
||||
Map
|
||||
<String, String> queryParams = new HashMap
|
||||
<String, String>();
|
||||
Map
|
||||
<String, String> headerParams = new HashMap
|
||||
<String, String>();
|
||||
Map
|
||||
<String, String> formParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> queryParams = 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()));
|
||||
|
||||
// query params
|
||||
Map
|
||||
<String, String> queryParams = new HashMap
|
||||
<String, String>();
|
||||
Map
|
||||
<String, String> headerParams = new HashMap
|
||||
<String, String>();
|
||||
Map
|
||||
<String, String> formParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> queryParams = 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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ import java.io.File;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class StoreApi {
|
||||
public class StoreApi {
|
||||
private ApiClient apiClient;
|
||||
|
||||
public StoreApi() {
|
||||
@ -53,15 +53,9 @@ import java.util.HashMap;
|
||||
String path = "/store/inventory".replaceAll("\\{format\\}","json");
|
||||
|
||||
// query params
|
||||
Map
|
||||
<String, String> queryParams = new HashMap
|
||||
<String, String>();
|
||||
Map
|
||||
<String, String> headerParams = new HashMap
|
||||
<String, String>();
|
||||
Map
|
||||
<String, String> formParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> queryParams = 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");
|
||||
|
||||
// query params
|
||||
Map
|
||||
<String, String> queryParams = new HashMap
|
||||
<String, String>();
|
||||
Map
|
||||
<String, String> headerParams = new HashMap
|
||||
<String, String>();
|
||||
Map
|
||||
<String, String> formParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> queryParams = 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()));
|
||||
|
||||
// query params
|
||||
Map
|
||||
<String, String> queryParams = new HashMap
|
||||
<String, String>();
|
||||
Map
|
||||
<String, String> headerParams = new HashMap
|
||||
<String, String>();
|
||||
Map
|
||||
<String, String> formParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> queryParams = 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()));
|
||||
|
||||
// query params
|
||||
Map
|
||||
<String, String> queryParams = new HashMap
|
||||
<String, String>();
|
||||
Map
|
||||
<String, String> headerParams = new HashMap
|
||||
<String, String>();
|
||||
Map
|
||||
<String, String> formParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> queryParams = 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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ import java.io.File;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class UserApi {
|
||||
public class UserApi {
|
||||
private ApiClient apiClient;
|
||||
|
||||
public UserApi() {
|
||||
@ -54,15 +54,9 @@ import java.util.HashMap;
|
||||
String path = "/user".replaceAll("\\{format\\}","json");
|
||||
|
||||
// query params
|
||||
Map
|
||||
<String, String> queryParams = new HashMap
|
||||
<String, String>();
|
||||
Map
|
||||
<String, String> headerParams = new HashMap
|
||||
<String, String>();
|
||||
Map
|
||||
<String, String> formParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> queryParams = 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");
|
||||
|
||||
// query params
|
||||
Map
|
||||
<String, String> queryParams = new HashMap
|
||||
<String, String>();
|
||||
Map
|
||||
<String, String> headerParams = new HashMap
|
||||
<String, String>();
|
||||
Map
|
||||
<String, String> formParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> queryParams = 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");
|
||||
|
||||
// query params
|
||||
Map
|
||||
<String, String> queryParams = new HashMap
|
||||
<String, String>();
|
||||
Map
|
||||
<String, String> headerParams = new HashMap
|
||||
<String, String>();
|
||||
Map
|
||||
<String, String> formParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> queryParams = 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");
|
||||
|
||||
// query params
|
||||
Map
|
||||
<String, String> queryParams = new HashMap
|
||||
<String, String>();
|
||||
Map
|
||||
<String, String> headerParams = new HashMap
|
||||
<String, String>();
|
||||
Map
|
||||
<String, String> formParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> queryParams = new HashMap<String, String>();
|
||||
Map<String, String> headerParams = new HashMap<String, String>();
|
||||
Map<String, String> formParams = new HashMap<String, String>();
|
||||
|
||||
if (username != null)
|
||||
queryParams.put("username", apiClient.parameterToString(username));
|
||||
@ -310,15 +286,9 @@ import java.util.HashMap;
|
||||
String path = "/user/logout".replaceAll("\\{format\\}","json");
|
||||
|
||||
// query params
|
||||
Map
|
||||
<String, String> queryParams = new HashMap
|
||||
<String, String>();
|
||||
Map
|
||||
<String, String> headerParams = new HashMap
|
||||
<String, String>();
|
||||
Map
|
||||
<String, String> formParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> queryParams = 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()));
|
||||
|
||||
// query params
|
||||
Map
|
||||
<String, String> queryParams = new HashMap
|
||||
<String, String>();
|
||||
Map
|
||||
<String, String> headerParams = new HashMap
|
||||
<String, String>();
|
||||
Map
|
||||
<String, String> formParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> queryParams = 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()));
|
||||
|
||||
// query params
|
||||
Map
|
||||
<String, String> queryParams = new HashMap
|
||||
<String, String>();
|
||||
Map
|
||||
<String, String> headerParams = new HashMap
|
||||
<String, String>();
|
||||
Map
|
||||
<String, String> formParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> queryParams = 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()));
|
||||
|
||||
// query params
|
||||
Map
|
||||
<String, String> queryParams = new HashMap
|
||||
<String, String>();
|
||||
Map
|
||||
<String, String> headerParams = new HashMap
|
||||
<String, String>();
|
||||
Map
|
||||
<String, String> formParams = new HashMap
|
||||
<String, String>();
|
||||
Map<String, String> queryParams = 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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -3,55 +3,53 @@ package io.swagger.client.auth;
|
||||
import java.util.Map;
|
||||
|
||||
public class ApiKeyAuth implements Authentication {
|
||||
private final String location;
|
||||
private final String paramName;
|
||||
private final String location;
|
||||
private final String paramName;
|
||||
|
||||
private String apiKey;
|
||||
private String apiKeyPrefix;
|
||||
private String apiKey;
|
||||
private String apiKeyPrefix;
|
||||
|
||||
public ApiKeyAuth(String location, String paramName) {
|
||||
this.location = location;
|
||||
this.paramName = paramName;
|
||||
}
|
||||
public ApiKeyAuth(String location, String paramName) {
|
||||
this.location = location;
|
||||
this.paramName = paramName;
|
||||
}
|
||||
|
||||
public String getLocation() {
|
||||
return location;
|
||||
}
|
||||
public String getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public String getParamName() {
|
||||
return paramName;
|
||||
}
|
||||
public String getParamName() {
|
||||
return paramName;
|
||||
}
|
||||
|
||||
public String getApiKey() {
|
||||
return apiKey;
|
||||
}
|
||||
public String getApiKey() {
|
||||
return apiKey;
|
||||
}
|
||||
|
||||
public void setApiKey(String apiKey) {
|
||||
this.apiKey = apiKey;
|
||||
}
|
||||
public void setApiKey(String apiKey) {
|
||||
this.apiKey = apiKey;
|
||||
}
|
||||
|
||||
public String getApiKeyPrefix() {
|
||||
return apiKeyPrefix;
|
||||
}
|
||||
public String getApiKeyPrefix() {
|
||||
return apiKeyPrefix;
|
||||
}
|
||||
|
||||
public void setApiKeyPrefix(String apiKeyPrefix) {
|
||||
this.apiKeyPrefix = apiKeyPrefix;
|
||||
}
|
||||
public void setApiKeyPrefix(String apiKeyPrefix) {
|
||||
this.apiKeyPrefix = apiKeyPrefix;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyToParams(Map
|
||||
<String, String> queryParams, Map
|
||||
<String, String> headerParams) {
|
||||
String value;
|
||||
if (apiKeyPrefix != null) {
|
||||
value = apiKeyPrefix + " " + apiKey;
|
||||
} else {
|
||||
value = apiKey;
|
||||
}
|
||||
if (location == "query") {
|
||||
queryParams.put(paramName, value);
|
||||
} else if (location == "header") {
|
||||
headerParams.put(paramName, value);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void applyToParams(Map<String, String> queryParams, Map<String, String> headerParams) {
|
||||
String value;
|
||||
if (apiKeyPrefix != null) {
|
||||
value = apiKeyPrefix + " " + apiKey;
|
||||
} else {
|
||||
value = apiKey;
|
||||
}
|
||||
if (location == "query") {
|
||||
queryParams.put(paramName, value);
|
||||
} else if (location == "header") {
|
||||
headerParams.put(paramName, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,8 +3,6 @@ package io.swagger.client.auth;
|
||||
import java.util.Map;
|
||||
|
||||
public interface Authentication {
|
||||
/** Apply authentication settings to header and query params. */
|
||||
void applyToParams(Map
|
||||
<String, String> queryParams, Map
|
||||
<String, String> headerParams);
|
||||
/** Apply authentication settings to header and query params. */
|
||||
void applyToParams(Map<String, String> queryParams, Map<String, String> headerParams);
|
||||
}
|
||||
|
@ -6,34 +6,32 @@ import java.io.UnsupportedEncodingException;
|
||||
import javax.xml.bind.DatatypeConverter;
|
||||
|
||||
public class HttpBasicAuth implements Authentication {
|
||||
private String username;
|
||||
private String password;
|
||||
private String username;
|
||||
private String password;
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyToParams(Map
|
||||
<String, String> queryParams, Map
|
||||
<String, String> headerParams) {
|
||||
String str = (username == null ? "" : username) + ":" + (password == null ? "" : password);
|
||||
try {
|
||||
headerParams.put("Authorization", "Basic " + DatatypeConverter.printBase64Binary(str.getBytes("UTF-8")));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void applyToParams(Map<String, String> queryParams, Map<String, String> headerParams) {
|
||||
String str = (username == null ? "" : username) + ":" + (password == null ? "" : password);
|
||||
try {
|
||||
headerParams.put("Authorization", "Basic " + DatatypeConverter.printBase64Binary(str.getBytes("UTF-8")));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,10 +3,8 @@ package io.swagger.client.auth;
|
||||
import java.util.Map;
|
||||
|
||||
public class OAuth implements Authentication {
|
||||
@Override
|
||||
public void applyToParams(Map
|
||||
<String, String> queryParams, Map
|
||||
<String, String> headerParams) {
|
||||
// TODO: support oauth
|
||||
}
|
||||
@Override
|
||||
public void applyToParams(Map<String, String> queryParams, Map<String, String> headerParams) {
|
||||
// TODO: support oauth
|
||||
}
|
||||
}
|
||||
|
@ -5,8 +5,8 @@ import io.swagger.annotations.*;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
|
||||
@ApiModel(description = "")
|
||||
public class Category {
|
||||
@ApiModel(description = "")
|
||||
public class Category {
|
||||
|
||||
private Long id = null;
|
||||
private String name = null;
|
||||
@ -47,5 +47,4 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
sb.append("}\n");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,8 +6,8 @@ import io.swagger.annotations.*;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
|
||||
@ApiModel(description = "")
|
||||
public class Order {
|
||||
@ApiModel(description = "")
|
||||
public class Order {
|
||||
|
||||
private Long id = null;
|
||||
private Long petId = null;
|
||||
@ -108,5 +108,4 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
sb.append("}\n");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,15 +1,15 @@
|
||||
package io.swagger.client.model;
|
||||
|
||||
import io.swagger.client.model.Category;
|
||||
import io.swagger.client.model.Tag;
|
||||
import java.util.*;
|
||||
import io.swagger.client.model.Tag;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
|
||||
@ApiModel(description = "")
|
||||
public class Pet {
|
||||
@ApiModel(description = "")
|
||||
public class Pet {
|
||||
|
||||
private Long id = null;
|
||||
private Category category = null;
|
||||
@ -110,5 +110,4 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
sb.append("}\n");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,8 +5,8 @@ import io.swagger.annotations.*;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
|
||||
@ApiModel(description = "")
|
||||
public class Tag {
|
||||
@ApiModel(description = "")
|
||||
public class Tag {
|
||||
|
||||
private Long id = null;
|
||||
private String name = null;
|
||||
@ -47,5 +47,4 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
sb.append("}\n");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,8 +5,8 @@ import io.swagger.annotations.*;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
|
||||
@ApiModel(description = "")
|
||||
public class User {
|
||||
@ApiModel(description = "")
|
||||
public class User {
|
||||
|
||||
private Long id = null;
|
||||
private String username = null;
|
||||
@ -132,5 +132,4 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
sb.append("}\n");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
platform :ios, '6.0'
|
||||
xcodeproj 'PetstoreClient/PetstoreClient.xcodeproj'
|
||||
xcodeproj 'swaggerClient/swaggerClient.xcodeproj'
|
||||
pod 'AFNetworking', '~> 2.1'
|
||||
pod 'JSONModel', '~> 1.0'
|
||||
pod 'ISO8601'
|
||||
|
@ -1,21 +1,15 @@
|
||||
#import
|
||||
<Foundation/Foundation.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "SWGObject.h"
|
||||
|
||||
|
||||
@protocol SWGCategory
|
||||
@end
|
||||
|
||||
@protocol SWGCategory
|
||||
@end
|
||||
|
||||
@interface SWGCategory : SWGObject
|
||||
@interface SWGCategory : SWGObject
|
||||
|
||||
|
||||
@property(nonatomic) NSNumber* _id;
|
||||
|
||||
@property(nonatomic) NSNumber* _id;
|
||||
|
||||
|
||||
@property(nonatomic) NSString* name;
|
||||
|
||||
|
||||
@end
|
||||
@property(nonatomic) NSString* name;
|
||||
|
||||
@end
|
||||
|
@ -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" }];
|
||||
}
|
||||
}
|
||||
|
||||
+ (BOOL)propertyIsOptional:(NSString *)propertyName
|
||||
{
|
||||
+ (BOOL)propertyIsOptional:(NSString *)propertyName
|
||||
{
|
||||
NSArray *optionalProperties = @[@"_id", @"name"];
|
||||
|
||||
if ([optionalProperties containsObject:propertyName]) {
|
||||
@ -18,7 +17,6 @@
|
||||
else {
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
@end
|
||||
|
@ -1,57 +1,56 @@
|
||||
#import
|
||||
<Foundation/Foundation.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface SWGConfiguration : NSObject
|
||||
|
||||
|
||||
/**
|
||||
* Api key values for Api Key type Authentication
|
||||
*
|
||||
* To add or remove api key, use `setValue:forApiKeyField:`.
|
||||
*/
|
||||
* Api key values for Api Key type Authentication
|
||||
*
|
||||
* To add or remove api key, use `setValue:forApiKeyField:`.
|
||||
*/
|
||||
@property (readonly, nonatomic, strong) NSDictionary *apiKey;
|
||||
|
||||
/**
|
||||
* Api key prefix values to be prepend to the respective api key
|
||||
*
|
||||
* To add or remove prefix, use `setValue:forApiKeyPrefixField:`.
|
||||
*/
|
||||
* Api key prefix values to be prepend to the respective api key
|
||||
*
|
||||
* To add or remove prefix, use `setValue:forApiKeyPrefixField:`.
|
||||
*/
|
||||
@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 *password;
|
||||
|
||||
/**
|
||||
* Get configuration singleton instance
|
||||
*/
|
||||
* Get configuration singleton instance
|
||||
*/
|
||||
+ (instancetype) sharedConfig;
|
||||
|
||||
/**
|
||||
* Sets field in `apiKey`
|
||||
*/
|
||||
* Sets field in `apiKey`
|
||||
*/
|
||||
- (void) setValue:(NSString *)value forApiKeyField:(NSString*)field;
|
||||
|
||||
/**
|
||||
* Sets field in `apiKeyPrefix`
|
||||
*/
|
||||
* Sets field in `apiKeyPrefix`
|
||||
*/
|
||||
- (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;
|
||||
|
||||
/**
|
||||
* Get Basic Auth token
|
||||
*/
|
||||
* Get Basic Auth token
|
||||
*/
|
||||
- (NSString *) getBasicAuthToken;
|
||||
|
||||
/**
|
||||
* Get Authentication Setings
|
||||
*/
|
||||
* Get Authentication Setings
|
||||
*/
|
||||
- (NSDictionary *) authSettings;
|
||||
|
||||
@end
|
||||
|
@ -12,73 +12,73 @@
|
||||
#pragma mark - Singletion Methods
|
||||
|
||||
+ (instancetype) sharedConfig {
|
||||
static SWGConfiguration *shardConfig = nil;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
shardConfig = [[self alloc] init];
|
||||
});
|
||||
return shardConfig;
|
||||
static SWGConfiguration *shardConfig = nil;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
shardConfig = [[self alloc] init];
|
||||
});
|
||||
return shardConfig;
|
||||
}
|
||||
|
||||
#pragma mark - Initialize Methods
|
||||
|
||||
- (instancetype) init {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self.username = @"";
|
||||
self.password = @"";
|
||||
self.mutableApiKey = [NSMutableDictionary dictionary];
|
||||
self.mutableApiKeyPrefix = [NSMutableDictionary dictionary];
|
||||
}
|
||||
return self;
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self.username = @"";
|
||||
self.password = @"";
|
||||
self.mutableApiKey = [NSMutableDictionary dictionary];
|
||||
self.mutableApiKeyPrefix = [NSMutableDictionary dictionary];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
#pragma mark - Instance Methods
|
||||
|
||||
- (NSString *) getApiKeyWithPrefix:(NSString *)key {
|
||||
if ([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]) {
|
||||
return [NSString stringWithFormat:@"%@", [self.apiKey objectForKey:key]];
|
||||
}
|
||||
else {
|
||||
return @"";
|
||||
}
|
||||
if ([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]) {
|
||||
return [NSString stringWithFormat:@"%@", [self.apiKey objectForKey:key]];
|
||||
}
|
||||
else {
|
||||
return @"";
|
||||
}
|
||||
}
|
||||
|
||||
- (NSString *) getBasicAuthToken {
|
||||
NSString *basicAuthCredentials = [NSString stringWithFormat:@"%@:%@", self.username, self.password];
|
||||
NSData *data = [basicAuthCredentials dataUsingEncoding:NSUTF8StringEncoding];
|
||||
basicAuthCredentials = [NSString stringWithFormat:@"Basic %@", [data base64EncodedStringWithOptions:0]];
|
||||
NSString *basicAuthCredentials = [NSString stringWithFormat:@"%@:%@", self.username, self.password];
|
||||
NSData *data = [basicAuthCredentials dataUsingEncoding:NSUTF8StringEncoding];
|
||||
basicAuthCredentials = [NSString stringWithFormat:@"Basic %@", [data base64EncodedStringWithOptions:0]];
|
||||
|
||||
return basicAuthCredentials;
|
||||
return basicAuthCredentials;
|
||||
}
|
||||
|
||||
#pragma mark - Setter Methods
|
||||
|
||||
- (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 {
|
||||
[self.mutableApiKeyPrefix setValue:value forKey:field];
|
||||
[self.mutableApiKeyPrefix setValue:value forKey:field];
|
||||
}
|
||||
|
||||
#pragma mark - Getter Methods
|
||||
|
||||
- (NSDictionary *) apiKey {
|
||||
return [NSDictionary dictionaryWithDictionary:self.mutableApiKey];
|
||||
return [NSDictionary dictionaryWithDictionary:self.mutableApiKey];
|
||||
}
|
||||
|
||||
- (NSDictionary *) apiKeyPrefix {
|
||||
return [NSDictionary dictionaryWithDictionary:self.mutableApiKeyPrefix];
|
||||
return [NSDictionary dictionaryWithDictionary:self.mutableApiKeyPrefix];
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
- (NSDictionary *) authSettings {
|
||||
return @{
|
||||
return @{
|
||||
@"api_key": @{
|
||||
@"type": @"api_key",
|
||||
@"in": @"header",
|
||||
@ -86,7 +86,7 @@ return @{
|
||||
@"value": [self getApiKeyWithPrefix:@"api_key"]
|
||||
},
|
||||
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -1,34 +1,24 @@
|
||||
#import
|
||||
<Foundation/Foundation.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "SWGObject.h"
|
||||
|
||||
|
||||
@protocol SWGOrder
|
||||
@end
|
||||
|
||||
@protocol SWGOrder
|
||||
@end
|
||||
|
||||
@interface SWGOrder : SWGObject
|
||||
@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) NSNumber* quantity;
|
||||
|
||||
|
||||
@property(nonatomic) NSDate* shipDate;
|
||||
|
||||
/* Order Status [optional]
|
||||
@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
|
||||
|
@ -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" }];
|
||||
}
|
||||
}
|
||||
|
||||
+ (BOOL)propertyIsOptional:(NSString *)propertyName
|
||||
{
|
||||
+ (BOOL)propertyIsOptional:(NSString *)propertyName
|
||||
{
|
||||
NSArray *optionalProperties = @[@"_id", @"petId", @"quantity", @"shipDate", @"status", @"complete"];
|
||||
|
||||
if ([optionalProperties containsObject:propertyName]) {
|
||||
@ -18,7 +17,6 @@
|
||||
else {
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
@end
|
||||
|
@ -1,36 +1,26 @@
|
||||
#import
|
||||
<Foundation/Foundation.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "SWGObject.h"
|
||||
#import "SWGTag.h"
|
||||
#import "SWGCategory.h"
|
||||
#import "SWGTag.h"
|
||||
|
||||
|
||||
@protocol SWGPet
|
||||
@end
|
||||
|
||||
@protocol SWGPet
|
||||
@end
|
||||
|
||||
@interface SWGPet : SWGObject
|
||||
@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) NSString* name;
|
||||
|
||||
|
||||
@property(nonatomic) NSArray* photoUrls;
|
||||
|
||||
|
||||
@property(nonatomic) NSArray<SWGTag>* tags;
|
||||
|
||||
/* pet status in the store [optional]
|
||||
@property(nonatomic) NSArray<SWGTag>* tags;
|
||||
/* pet status in the store [optional]
|
||||
*/
|
||||
@property(nonatomic) NSString* status;
|
||||
|
||||
|
||||
@end
|
||||
@property(nonatomic) NSString* status;
|
||||
|
||||
@end
|
||||
|
@ -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" }];
|
||||
}
|
||||
}
|
||||
|
||||
+ (BOOL)propertyIsOptional:(NSString *)propertyName
|
||||
{
|
||||
+ (BOOL)propertyIsOptional:(NSString *)propertyName
|
||||
{
|
||||
NSArray *optionalProperties = @[@"_id", @"category", @"tags", @"status"];
|
||||
|
||||
if ([optionalProperties containsObject:propertyName]) {
|
||||
@ -18,7 +17,6 @@
|
||||
else {
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
@end
|
||||
|
@ -1,23 +1,21 @@
|
||||
#import
|
||||
<Foundation/Foundation.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "SWGPet.h"
|
||||
#import "SWGFile.h"
|
||||
#import "SWGObject.h"
|
||||
#import "SWGApiClient.h"
|
||||
|
||||
|
||||
@interface SWGPetApi: NSObject
|
||||
@interface SWGPetApi: NSObject
|
||||
|
||||
@property(nonatomic, assign)SWGApiClient *apiClient;
|
||||
@property(nonatomic, assign)SWGApiClient *apiClient;
|
||||
|
||||
-(instancetype) initWithApiClient:(SWGApiClient *)apiClient;
|
||||
-(void) addHeader:(NSString*)value forKey:(NSString*)key;
|
||||
-(unsigned long) requestQueueSize;
|
||||
+(SWGPetApi*) apiWithHeader:(NSString*)headerValue key:(NSString*)key;
|
||||
+(void) setBasePath:(NSString*)basePath;
|
||||
+(NSString*) getBasePath;
|
||||
|
||||
/**
|
||||
-(instancetype) initWithApiClient:(SWGApiClient *)apiClient;
|
||||
-(void) addHeader:(NSString*)value forKey:(NSString*)key;
|
||||
-(unsigned long) requestQueueSize;
|
||||
+(SWGPetApi*) apiWithHeader:(NSString*)headerValue key:(NSString*)key;
|
||||
+(void) setBasePath:(NSString*)basePath;
|
||||
+(NSString*) getBasePath;
|
||||
/**
|
||||
|
||||
Update an existing pet
|
||||
|
||||
@ -27,14 +25,13 @@
|
||||
|
||||
return type:
|
||||
*/
|
||||
-(NSNumber*) updatePetWithCompletionBlock :(SWGPet*) body
|
||||
-(NSNumber*) updatePetWithCompletionBlock :(SWGPet*) body
|
||||
|
||||
|
||||
completionHandler: (void (^)(NSError* error))completionBlock;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
|
||||
Add a new pet to the store
|
||||
|
||||
@ -44,14 +41,13 @@
|
||||
|
||||
return type:
|
||||
*/
|
||||
-(NSNumber*) addPetWithCompletionBlock :(SWGPet*) body
|
||||
-(NSNumber*) addPetWithCompletionBlock :(SWGPet*) body
|
||||
|
||||
|
||||
completionHandler: (void (^)(NSError* error))completionBlock;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
|
||||
Finds Pets by status
|
||||
Multiple status values can be provided with comma seperated strings
|
||||
@ -61,14 +57,13 @@
|
||||
|
||||
return type: NSArray<SWGPet>*
|
||||
*/
|
||||
-(NSNumber*) findPetsByStatusWithCompletionBlock :(NSArray*) status
|
||||
-(NSNumber*) findPetsByStatusWithCompletionBlock :(NSArray*) status
|
||||
|
||||
completionHandler: (void (^)(NSArray<SWGPet>* output, NSError* error))completionBlock;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
|
||||
Finds Pets by tags
|
||||
Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.
|
||||
@ -78,14 +73,13 @@
|
||||
|
||||
return type: NSArray<SWGPet>*
|
||||
*/
|
||||
-(NSNumber*) findPetsByTagsWithCompletionBlock :(NSArray*) tags
|
||||
-(NSNumber*) findPetsByTagsWithCompletionBlock :(NSArray*) tags
|
||||
|
||||
completionHandler: (void (^)(NSArray<SWGPet>* output, NSError* error))completionBlock;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
|
||||
Find pet by ID
|
||||
Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
|
||||
@ -95,14 +89,13 @@
|
||||
|
||||
return type: SWGPet*
|
||||
*/
|
||||
-(NSNumber*) getPetByIdWithCompletionBlock :(NSNumber*) petId
|
||||
-(NSNumber*) getPetByIdWithCompletionBlock :(NSNumber*) petId
|
||||
|
||||
completionHandler: (void (^)(SWGPet* output, NSError* error))completionBlock;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
|
||||
Updates a pet in the store with form data
|
||||
|
||||
@ -114,7 +107,7 @@
|
||||
|
||||
return type:
|
||||
*/
|
||||
-(NSNumber*) updatePetWithFormWithCompletionBlock :(NSString*) petId
|
||||
-(NSNumber*) updatePetWithFormWithCompletionBlock :(NSString*) petId
|
||||
name:(NSString*) name
|
||||
status:(NSString*) status
|
||||
|
||||
@ -122,8 +115,7 @@
|
||||
completionHandler: (void (^)(NSError* error))completionBlock;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
|
||||
Deletes a pet
|
||||
|
||||
@ -134,15 +126,14 @@
|
||||
|
||||
return type:
|
||||
*/
|
||||
-(NSNumber*) deletePetWithCompletionBlock :(NSString*) apiKey
|
||||
-(NSNumber*) deletePetWithCompletionBlock :(NSString*) apiKey
|
||||
petId:(NSNumber*) petId
|
||||
|
||||
|
||||
completionHandler: (void (^)(NSError* error))completionBlock;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
|
||||
uploads an image
|
||||
|
||||
@ -154,7 +145,7 @@
|
||||
|
||||
return type:
|
||||
*/
|
||||
-(NSNumber*) uploadFileWithCompletionBlock :(NSNumber*) petId
|
||||
-(NSNumber*) uploadFileWithCompletionBlock :(NSNumber*) petId
|
||||
additionalMetadata:(NSString*) additionalMetadata
|
||||
file:(SWGFile*) file
|
||||
|
||||
@ -163,5 +154,4 @@
|
||||
|
||||
|
||||
|
||||
|
||||
@end
|
||||
|
@ -1,31 +1,30 @@
|
||||
#import "SWGPetApi.h"
|
||||
#import "SWGFile.h"
|
||||
#import "SWGQueryParamCollection.h"
|
||||
#import "SWGPet.h"
|
||||
#import "SWGFile.h"
|
||||
#import "SWGPetApi.h"
|
||||
#import "SWGFile.h"
|
||||
#import "SWGQueryParamCollection.h"
|
||||
#import "SWGPet.h"
|
||||
#import "SWGFile.h"
|
||||
|
||||
|
||||
|
||||
@interface SWGPetApi ()
|
||||
@interface SWGPetApi ()
|
||||
@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];
|
||||
if (self) {
|
||||
self.apiClient = [SWGApiClient sharedClientFromPool:basePath];
|
||||
self.defaultHeaders = [NSMutableDictionary dictionary];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
}
|
||||
|
||||
- (id) initWithApiClient:(SWGApiClient *)apiClient {
|
||||
- (id) initWithApiClient:(SWGApiClient *)apiClient {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
if (apiClient) {
|
||||
@ -37,11 +36,11 @@
|
||||
self.defaultHeaders = [NSMutableDictionary dictionary];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark -
|
||||
|
||||
+(SWGPetApi*) apiWithHeader:(NSString*)headerValue key:(NSString*)key {
|
||||
+(SWGPetApi*) apiWithHeader:(NSString*)headerValue key:(NSString*)key {
|
||||
static SWGPetApi* singletonAPI = nil;
|
||||
|
||||
if (singletonAPI == nil) {
|
||||
@ -49,38 +48,37 @@
|
||||
[singletonAPI addHeader:headerValue forKey:key];
|
||||
}
|
||||
return singletonAPI;
|
||||
}
|
||||
}
|
||||
|
||||
+(void) setBasePath:(NSString*)path {
|
||||
+(void) setBasePath:(NSString*)path {
|
||||
basePath = path;
|
||||
}
|
||||
}
|
||||
|
||||
+(NSString*) getBasePath {
|
||||
+(NSString*) getBasePath {
|
||||
return basePath;
|
||||
}
|
||||
}
|
||||
|
||||
-(void) addHeader:(NSString*)value forKey:(NSString*)key {
|
||||
-(void) addHeader:(NSString*)value forKey:(NSString*)key {
|
||||
[self.defaultHeaders setValue:value forKey:key];
|
||||
}
|
||||
}
|
||||
|
||||
-(void) setHeaderValue:(NSString*) value
|
||||
-(void) setHeaderValue:(NSString*) value
|
||||
forKey:(NSString*)key {
|
||||
[self.defaultHeaders setValue:value forKey:key];
|
||||
}
|
||||
}
|
||||
|
||||
-(unsigned long) requestQueueSize {
|
||||
-(unsigned long) requestQueueSize {
|
||||
return [SWGApiClient requestQueueSize];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
/*!
|
||||
* Update an existing pet
|
||||
*
|
||||
* \param body Pet object that needs to be added to the store
|
||||
* \returns void
|
||||
*/
|
||||
-(NSNumber*) updatePetWithCompletionBlock: (SWGPet*) body
|
||||
-(NSNumber*) updatePetWithCompletionBlock: (SWGPet*) body
|
||||
|
||||
|
||||
completionHandler: (void (^)(NSError* error))completionBlock {
|
||||
@ -163,32 +161,31 @@
|
||||
|
||||
// it's void
|
||||
return [self.apiClient stringWithCompletionBlock: requestUrl
|
||||
method: @"PUT"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
requestContentType: requestContentType
|
||||
responseContentType: responseContentType
|
||||
completionBlock: ^(NSString *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(error);
|
||||
return;
|
||||
}
|
||||
completionBlock(nil);
|
||||
}];
|
||||
|
||||
|
||||
method: @"PUT"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
requestContentType: requestContentType
|
||||
responseContentType: responseContentType
|
||||
completionBlock: ^(NSString *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(error);
|
||||
return;
|
||||
}
|
||||
completionBlock(nil);
|
||||
}];
|
||||
|
||||
|
||||
/*!
|
||||
}
|
||||
|
||||
/*!
|
||||
* Add a new pet to the store
|
||||
*
|
||||
* \param body Pet object that needs to be added to the store
|
||||
* \returns void
|
||||
*/
|
||||
-(NSNumber*) addPetWithCompletionBlock: (SWGPet*) body
|
||||
-(NSNumber*) addPetWithCompletionBlock: (SWGPet*) body
|
||||
|
||||
|
||||
completionHandler: (void (^)(NSError* error))completionBlock {
|
||||
@ -271,32 +268,31 @@ completionBlock(nil);
|
||||
|
||||
// it's void
|
||||
return [self.apiClient stringWithCompletionBlock: requestUrl
|
||||
method: @"POST"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
requestContentType: requestContentType
|
||||
responseContentType: responseContentType
|
||||
completionBlock: ^(NSString *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(error);
|
||||
return;
|
||||
}
|
||||
completionBlock(nil);
|
||||
}];
|
||||
|
||||
|
||||
method: @"POST"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
requestContentType: requestContentType
|
||||
responseContentType: responseContentType
|
||||
completionBlock: ^(NSString *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(error);
|
||||
return;
|
||||
}
|
||||
completionBlock(nil);
|
||||
}];
|
||||
|
||||
|
||||
/*!
|
||||
}
|
||||
|
||||
/*!
|
||||
* Finds Pets by status
|
||||
* Multiple status values can be provided with comma seperated strings
|
||||
* \param status Status values that need to be considered for filter
|
||||
* \returns NSArray<SWGPet>*
|
||||
*/
|
||||
-(NSNumber*) findPetsByStatusWithCompletionBlock: (NSArray*) status
|
||||
-(NSNumber*) findPetsByStatusWithCompletionBlock: (NSArray*) status
|
||||
|
||||
completionHandler: (void (^)(NSArray<SWGPet>* output, NSError* error))completionBlock
|
||||
{
|
||||
@ -358,19 +354,19 @@ completionBlock(nil);
|
||||
|
||||
// response is in a container
|
||||
// array container response type
|
||||
return [self.apiClient dictionary: requestUrl
|
||||
method: @"GET"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
requestContentType: requestContentType
|
||||
responseContentType: responseContentType
|
||||
completionBlock: ^(NSDictionary *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(nil, error);
|
||||
return;
|
||||
}
|
||||
return [self.apiClient dictionary: requestUrl
|
||||
method: @"GET"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
requestContentType: requestContentType
|
||||
responseContentType: responseContentType
|
||||
completionBlock: ^(NSDictionary *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(nil, error);
|
||||
return;
|
||||
}
|
||||
|
||||
if([data isKindOfClass:[NSArray class]]){
|
||||
NSMutableArray * objs = [[NSMutableArray alloc] initWithCapacity:[data count]];
|
||||
@ -384,23 +380,23 @@ return;
|
||||
completionBlock((NSArray<SWGPet>*)objs, nil);
|
||||
}
|
||||
|
||||
}];
|
||||
|
||||
}];
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
/*!
|
||||
* Finds Pets by tags
|
||||
* Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.
|
||||
* \param tags Tags to filter by
|
||||
* \returns NSArray<SWGPet>*
|
||||
*/
|
||||
-(NSNumber*) findPetsByTagsWithCompletionBlock: (NSArray*) tags
|
||||
-(NSNumber*) findPetsByTagsWithCompletionBlock: (NSArray*) tags
|
||||
|
||||
completionHandler: (void (^)(NSArray<SWGPet>* output, NSError* error))completionBlock
|
||||
{
|
||||
@ -462,19 +458,19 @@ return;
|
||||
|
||||
// response is in a container
|
||||
// array container response type
|
||||
return [self.apiClient dictionary: requestUrl
|
||||
method: @"GET"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
requestContentType: requestContentType
|
||||
responseContentType: responseContentType
|
||||
completionBlock: ^(NSDictionary *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(nil, error);
|
||||
return;
|
||||
}
|
||||
return [self.apiClient dictionary: requestUrl
|
||||
method: @"GET"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
requestContentType: requestContentType
|
||||
responseContentType: responseContentType
|
||||
completionBlock: ^(NSDictionary *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(nil, error);
|
||||
return;
|
||||
}
|
||||
|
||||
if([data isKindOfClass:[NSArray class]]){
|
||||
NSMutableArray * objs = [[NSMutableArray alloc] initWithCapacity:[data count]];
|
||||
@ -488,23 +484,23 @@ return;
|
||||
completionBlock((NSArray<SWGPet>*)objs, nil);
|
||||
}
|
||||
|
||||
}];
|
||||
|
||||
}];
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
/*!
|
||||
* Find pet by ID
|
||||
* 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
|
||||
* \returns SWGPet*
|
||||
*/
|
||||
-(NSNumber*) getPetByIdWithCompletionBlock: (NSNumber*) petId
|
||||
-(NSNumber*) getPetByIdWithCompletionBlock: (NSNumber*) petId
|
||||
|
||||
completionHandler: (void (^)(SWGPet* output, NSError* error))completionBlock
|
||||
{
|
||||
@ -548,7 +544,7 @@ return;
|
||||
NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]];
|
||||
|
||||
// Authentication setting
|
||||
NSArray *authSettings = @[@"api_key", @"petstore_auth"];
|
||||
NSArray *authSettings = @[@"petstore_auth", @"api_key"];
|
||||
|
||||
id bodyDictionary = nil;
|
||||
|
||||
@ -570,6 +566,7 @@ return;
|
||||
|
||||
|
||||
// complex response
|
||||
|
||||
// comples response type
|
||||
return [self.apiClient dictionary: requestUrl
|
||||
method: @"GET"
|
||||
@ -596,10 +593,10 @@ return;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*!
|
||||
/*!
|
||||
* Updates a pet in the store with form data
|
||||
*
|
||||
* \param petId ID of pet that needs to be updated
|
||||
@ -607,7 +604,7 @@ return;
|
||||
* \param status Updated status of the pet
|
||||
* \returns void
|
||||
*/
|
||||
-(NSNumber*) updatePetWithFormWithCompletionBlock: (NSString*) petId
|
||||
-(NSNumber*) updatePetWithFormWithCompletionBlock: (NSString*) petId
|
||||
name: (NSString*) name
|
||||
status: (NSString*) status
|
||||
|
||||
@ -689,33 +686,32 @@ return;
|
||||
|
||||
// it's void
|
||||
return [self.apiClient stringWithCompletionBlock: requestUrl
|
||||
method: @"POST"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
requestContentType: requestContentType
|
||||
responseContentType: responseContentType
|
||||
completionBlock: ^(NSString *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(error);
|
||||
return;
|
||||
}
|
||||
completionBlock(nil);
|
||||
}];
|
||||
|
||||
|
||||
method: @"POST"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
requestContentType: requestContentType
|
||||
responseContentType: responseContentType
|
||||
completionBlock: ^(NSString *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(error);
|
||||
return;
|
||||
}
|
||||
completionBlock(nil);
|
||||
}];
|
||||
|
||||
|
||||
/*!
|
||||
}
|
||||
|
||||
/*!
|
||||
* Deletes a pet
|
||||
*
|
||||
* \param apiKey
|
||||
* \param petId Pet id to delete
|
||||
* \returns void
|
||||
*/
|
||||
-(NSNumber*) deletePetWithCompletionBlock: (NSString*) apiKey
|
||||
-(NSNumber*) deletePetWithCompletionBlock: (NSString*) apiKey
|
||||
petId: (NSNumber*) petId
|
||||
|
||||
|
||||
@ -782,26 +778,25 @@ completionBlock(nil);
|
||||
|
||||
// it's void
|
||||
return [self.apiClient stringWithCompletionBlock: requestUrl
|
||||
method: @"DELETE"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
requestContentType: requestContentType
|
||||
responseContentType: responseContentType
|
||||
completionBlock: ^(NSString *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(error);
|
||||
return;
|
||||
}
|
||||
completionBlock(nil);
|
||||
}];
|
||||
|
||||
|
||||
method: @"DELETE"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
requestContentType: requestContentType
|
||||
responseContentType: responseContentType
|
||||
completionBlock: ^(NSString *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(error);
|
||||
return;
|
||||
}
|
||||
completionBlock(nil);
|
||||
}];
|
||||
|
||||
|
||||
/*!
|
||||
}
|
||||
|
||||
/*!
|
||||
* uploads an image
|
||||
*
|
||||
* \param petId ID of pet to update
|
||||
@ -809,7 +804,7 @@ completionBlock(nil);
|
||||
* \param file file to upload
|
||||
* \returns void
|
||||
*/
|
||||
-(NSNumber*) uploadFileWithCompletionBlock: (NSNumber*) petId
|
||||
-(NSNumber*) uploadFileWithCompletionBlock: (NSNumber*) petId
|
||||
additionalMetadata: (NSString*) additionalMetadata
|
||||
file: (SWGFile*) file
|
||||
|
||||
@ -898,25 +893,24 @@ completionBlock(nil);
|
||||
|
||||
// it's void
|
||||
return [self.apiClient stringWithCompletionBlock: requestUrl
|
||||
method: @"POST"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
requestContentType: requestContentType
|
||||
responseContentType: responseContentType
|
||||
completionBlock: ^(NSString *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(error);
|
||||
return;
|
||||
}
|
||||
completionBlock(nil);
|
||||
}];
|
||||
|
||||
|
||||
method: @"POST"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
requestContentType: requestContentType
|
||||
responseContentType: responseContentType
|
||||
completionBlock: ^(NSString *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(error);
|
||||
return;
|
||||
}
|
||||
completionBlock(nil);
|
||||
}];
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@end
|
||||
|
@ -1,22 +1,20 @@
|
||||
#import
|
||||
<Foundation/Foundation.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "SWGOrder.h"
|
||||
#import "SWGObject.h"
|
||||
#import "SWGApiClient.h"
|
||||
|
||||
|
||||
@interface SWGStoreApi: NSObject
|
||||
@interface SWGStoreApi: NSObject
|
||||
|
||||
@property(nonatomic, assign)SWGApiClient *apiClient;
|
||||
@property(nonatomic, assign)SWGApiClient *apiClient;
|
||||
|
||||
-(instancetype) initWithApiClient:(SWGApiClient *)apiClient;
|
||||
-(void) addHeader:(NSString*)value forKey:(NSString*)key;
|
||||
-(unsigned long) requestQueueSize;
|
||||
+(SWGStoreApi*) apiWithHeader:(NSString*)headerValue key:(NSString*)key;
|
||||
+(void) setBasePath:(NSString*)basePath;
|
||||
+(NSString*) getBasePath;
|
||||
|
||||
/**
|
||||
-(instancetype) initWithApiClient:(SWGApiClient *)apiClient;
|
||||
-(void) addHeader:(NSString*)value forKey:(NSString*)key;
|
||||
-(unsigned long) requestQueueSize;
|
||||
+(SWGStoreApi*) apiWithHeader:(NSString*)headerValue key:(NSString*)key;
|
||||
+(void) setBasePath:(NSString*)basePath;
|
||||
+(NSString*) getBasePath;
|
||||
/**
|
||||
|
||||
Returns pet inventories by status
|
||||
Returns a map of status codes to quantities
|
||||
@ -25,13 +23,12 @@
|
||||
|
||||
return type: NSDictionary*
|
||||
*/
|
||||
-(NSNumber*) getInventoryWithCompletionBlock :
|
||||
-(NSNumber*) getInventoryWithCompletionBlock :
|
||||
(void (^)(NSDictionary* output, NSError* error))completionBlock;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
|
||||
Place an order for a pet
|
||||
|
||||
@ -41,14 +38,13 @@
|
||||
|
||||
return type: SWGOrder*
|
||||
*/
|
||||
-(NSNumber*) placeOrderWithCompletionBlock :(SWGOrder*) body
|
||||
-(NSNumber*) placeOrderWithCompletionBlock :(SWGOrder*) body
|
||||
|
||||
completionHandler: (void (^)(SWGOrder* output, NSError* error))completionBlock;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
|
||||
Find purchase order by ID
|
||||
For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
@ -58,14 +54,13 @@
|
||||
|
||||
return type: SWGOrder*
|
||||
*/
|
||||
-(NSNumber*) getOrderByIdWithCompletionBlock :(NSString*) orderId
|
||||
-(NSNumber*) getOrderByIdWithCompletionBlock :(NSString*) orderId
|
||||
|
||||
completionHandler: (void (^)(SWGOrder* output, NSError* error))completionBlock;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
|
||||
Delete purchase order by ID
|
||||
For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
@ -75,12 +70,11 @@
|
||||
|
||||
return type:
|
||||
*/
|
||||
-(NSNumber*) deleteOrderWithCompletionBlock :(NSString*) orderId
|
||||
-(NSNumber*) deleteOrderWithCompletionBlock :(NSString*) orderId
|
||||
|
||||
|
||||
completionHandler: (void (^)(NSError* error))completionBlock;
|
||||
|
||||
|
||||
|
||||
|
||||
@end
|
||||
|
@ -1,30 +1,29 @@
|
||||
#import "SWGStoreApi.h"
|
||||
#import "SWGFile.h"
|
||||
#import "SWGQueryParamCollection.h"
|
||||
#import "SWGOrder.h"
|
||||
#import "SWGStoreApi.h"
|
||||
#import "SWGFile.h"
|
||||
#import "SWGQueryParamCollection.h"
|
||||
#import "SWGOrder.h"
|
||||
|
||||
|
||||
|
||||
@interface SWGStoreApi ()
|
||||
@interface SWGStoreApi ()
|
||||
@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];
|
||||
if (self) {
|
||||
self.apiClient = [SWGApiClient sharedClientFromPool:basePath];
|
||||
self.defaultHeaders = [NSMutableDictionary dictionary];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
}
|
||||
|
||||
- (id) initWithApiClient:(SWGApiClient *)apiClient {
|
||||
- (id) initWithApiClient:(SWGApiClient *)apiClient {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
if (apiClient) {
|
||||
@ -36,11 +35,11 @@
|
||||
self.defaultHeaders = [NSMutableDictionary dictionary];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark -
|
||||
|
||||
+(SWGStoreApi*) apiWithHeader:(NSString*)headerValue key:(NSString*)key {
|
||||
+(SWGStoreApi*) apiWithHeader:(NSString*)headerValue key:(NSString*)key {
|
||||
static SWGStoreApi* singletonAPI = nil;
|
||||
|
||||
if (singletonAPI == nil) {
|
||||
@ -48,37 +47,36 @@
|
||||
[singletonAPI addHeader:headerValue forKey:key];
|
||||
}
|
||||
return singletonAPI;
|
||||
}
|
||||
}
|
||||
|
||||
+(void) setBasePath:(NSString*)path {
|
||||
+(void) setBasePath:(NSString*)path {
|
||||
basePath = path;
|
||||
}
|
||||
}
|
||||
|
||||
+(NSString*) getBasePath {
|
||||
+(NSString*) getBasePath {
|
||||
return basePath;
|
||||
}
|
||||
}
|
||||
|
||||
-(void) addHeader:(NSString*)value forKey:(NSString*)key {
|
||||
-(void) addHeader:(NSString*)value forKey:(NSString*)key {
|
||||
[self.defaultHeaders setValue:value forKey:key];
|
||||
}
|
||||
}
|
||||
|
||||
-(void) setHeaderValue:(NSString*) value
|
||||
-(void) setHeaderValue:(NSString*) value
|
||||
forKey:(NSString*)key {
|
||||
[self.defaultHeaders setValue:value forKey:key];
|
||||
}
|
||||
}
|
||||
|
||||
-(unsigned long) requestQueueSize {
|
||||
-(unsigned long) requestQueueSize {
|
||||
return [SWGApiClient requestQueueSize];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
/*!
|
||||
* Returns pet inventories by status
|
||||
* Returns a map of status codes to quantities
|
||||
* \returns NSDictionary*
|
||||
*/
|
||||
-(NSNumber*) getInventoryWithCompletionBlock:
|
||||
-(NSNumber*) getInventoryWithCompletionBlock:
|
||||
(void (^)(NSDictionary* output, NSError* error))completionBlock
|
||||
{
|
||||
|
||||
@ -133,41 +131,42 @@
|
||||
|
||||
// response is in a container
|
||||
// map container response type
|
||||
return [self.apiClient dictionary: requestUrl
|
||||
method: @"GET"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
requestContentType: requestContentType
|
||||
responseContentType: responseContentType
|
||||
completionBlock: ^(NSDictionary *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(nil, error);
|
||||
return;
|
||||
}
|
||||
return [self.apiClient dictionary: requestUrl
|
||||
method: @"GET"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
requestContentType: requestContentType
|
||||
responseContentType: responseContentType
|
||||
completionBlock: ^(NSDictionary *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(nil, error);
|
||||
return;
|
||||
}
|
||||
|
||||
NSDictionary *result = nil;
|
||||
if (data) {
|
||||
result = [[NSDictionary alloc]initWithDictionary: data];
|
||||
}
|
||||
completionBlock(data, nil);
|
||||
}];
|
||||
|
||||
}];
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
/*!
|
||||
* Place an order for a pet
|
||||
*
|
||||
* \param body order placed for purchasing the pet
|
||||
* \returns SWGOrder*
|
||||
*/
|
||||
-(NSNumber*) placeOrderWithCompletionBlock: (SWGOrder*) body
|
||||
-(NSNumber*) placeOrderWithCompletionBlock: (SWGOrder*) body
|
||||
|
||||
completionHandler: (void (^)(SWGOrder* output, NSError* error))completionBlock
|
||||
{
|
||||
@ -252,6 +251,7 @@ return;
|
||||
|
||||
|
||||
// complex response
|
||||
|
||||
// comples response type
|
||||
return [self.apiClient dictionary: requestUrl
|
||||
method: @"POST"
|
||||
@ -278,16 +278,16 @@ return;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*!
|
||||
/*!
|
||||
* Find purchase order by ID
|
||||
* 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
|
||||
* \returns SWGOrder*
|
||||
*/
|
||||
-(NSNumber*) getOrderByIdWithCompletionBlock: (NSString*) orderId
|
||||
-(NSNumber*) getOrderByIdWithCompletionBlock: (NSString*) orderId
|
||||
|
||||
completionHandler: (void (^)(SWGOrder* output, NSError* error))completionBlock
|
||||
{
|
||||
@ -353,6 +353,7 @@ return;
|
||||
|
||||
|
||||
// complex response
|
||||
|
||||
// comples response type
|
||||
return [self.apiClient dictionary: requestUrl
|
||||
method: @"GET"
|
||||
@ -379,16 +380,16 @@ return;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*!
|
||||
/*!
|
||||
* Delete purchase order by ID
|
||||
* 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
|
||||
* \returns void
|
||||
*/
|
||||
-(NSNumber*) deleteOrderWithCompletionBlock: (NSString*) orderId
|
||||
-(NSNumber*) deleteOrderWithCompletionBlock: (NSString*) orderId
|
||||
|
||||
|
||||
completionHandler: (void (^)(NSError* error))completionBlock {
|
||||
@ -452,25 +453,24 @@ return;
|
||||
|
||||
// it's void
|
||||
return [self.apiClient stringWithCompletionBlock: requestUrl
|
||||
method: @"DELETE"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
requestContentType: requestContentType
|
||||
responseContentType: responseContentType
|
||||
completionBlock: ^(NSString *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(error);
|
||||
return;
|
||||
}
|
||||
completionBlock(nil);
|
||||
}];
|
||||
|
||||
|
||||
method: @"DELETE"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
requestContentType: requestContentType
|
||||
responseContentType: responseContentType
|
||||
completionBlock: ^(NSString *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(error);
|
||||
return;
|
||||
}
|
||||
completionBlock(nil);
|
||||
}];
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@end
|
||||
|
@ -1,21 +1,15 @@
|
||||
#import
|
||||
<Foundation/Foundation.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "SWGObject.h"
|
||||
|
||||
|
||||
@protocol SWGTag
|
||||
@end
|
||||
|
||||
@protocol SWGTag
|
||||
@end
|
||||
|
||||
@interface SWGTag : SWGObject
|
||||
@interface SWGTag : SWGObject
|
||||
|
||||
|
||||
@property(nonatomic) NSNumber* _id;
|
||||
|
||||
@property(nonatomic) NSNumber* _id;
|
||||
|
||||
|
||||
@property(nonatomic) NSString* name;
|
||||
|
||||
|
||||
@end
|
||||
@property(nonatomic) NSString* name;
|
||||
|
||||
@end
|
||||
|
@ -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" }];
|
||||
}
|
||||
}
|
||||
|
||||
+ (BOOL)propertyIsOptional:(NSString *)propertyName
|
||||
{
|
||||
+ (BOOL)propertyIsOptional:(NSString *)propertyName
|
||||
{
|
||||
NSArray *optionalProperties = @[@"_id", @"name"];
|
||||
|
||||
if ([optionalProperties containsObject:propertyName]) {
|
||||
@ -18,7 +17,6 @@
|
||||
else {
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
@end
|
||||
|
@ -1,40 +1,28 @@
|
||||
#import
|
||||
<Foundation/Foundation.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "SWGObject.h"
|
||||
|
||||
|
||||
@protocol SWGUser
|
||||
@end
|
||||
|
||||
@protocol SWGUser
|
||||
@end
|
||||
|
||||
@interface SWGUser : SWGObject
|
||||
@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* lastName;
|
||||
|
||||
|
||||
@property(nonatomic) NSString* email;
|
||||
|
||||
|
||||
@property(nonatomic) NSString* password;
|
||||
|
||||
|
||||
@property(nonatomic) NSString* phone;
|
||||
|
||||
/* User Status [optional]
|
||||
@property(nonatomic) NSString* phone;
|
||||
/* User Status [optional]
|
||||
*/
|
||||
@property(nonatomic) NSNumber* userStatus;
|
||||
|
||||
|
||||
@end
|
||||
@property(nonatomic) NSNumber* userStatus;
|
||||
|
||||
@end
|
||||
|
@ -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" }];
|
||||
}
|
||||
}
|
||||
|
||||
+ (BOOL)propertyIsOptional:(NSString *)propertyName
|
||||
{
|
||||
+ (BOOL)propertyIsOptional:(NSString *)propertyName
|
||||
{
|
||||
NSArray *optionalProperties = @[@"_id", @"username", @"firstName", @"lastName", @"email", @"password", @"phone", @"userStatus"];
|
||||
|
||||
if ([optionalProperties containsObject:propertyName]) {
|
||||
@ -18,7 +17,6 @@
|
||||
else {
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
@end
|
||||
|
@ -1,22 +1,20 @@
|
||||
#import
|
||||
<Foundation/Foundation.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "SWGUser.h"
|
||||
#import "SWGObject.h"
|
||||
#import "SWGApiClient.h"
|
||||
|
||||
|
||||
@interface SWGUserApi: NSObject
|
||||
@interface SWGUserApi: NSObject
|
||||
|
||||
@property(nonatomic, assign)SWGApiClient *apiClient;
|
||||
@property(nonatomic, assign)SWGApiClient *apiClient;
|
||||
|
||||
-(instancetype) initWithApiClient:(SWGApiClient *)apiClient;
|
||||
-(void) addHeader:(NSString*)value forKey:(NSString*)key;
|
||||
-(unsigned long) requestQueueSize;
|
||||
+(SWGUserApi*) apiWithHeader:(NSString*)headerValue key:(NSString*)key;
|
||||
+(void) setBasePath:(NSString*)basePath;
|
||||
+(NSString*) getBasePath;
|
||||
|
||||
/**
|
||||
-(instancetype) initWithApiClient:(SWGApiClient *)apiClient;
|
||||
-(void) addHeader:(NSString*)value forKey:(NSString*)key;
|
||||
-(unsigned long) requestQueueSize;
|
||||
+(SWGUserApi*) apiWithHeader:(NSString*)headerValue key:(NSString*)key;
|
||||
+(void) setBasePath:(NSString*)basePath;
|
||||
+(NSString*) getBasePath;
|
||||
/**
|
||||
|
||||
Create user
|
||||
This can only be done by the logged in user.
|
||||
@ -26,14 +24,13 @@
|
||||
|
||||
return type:
|
||||
*/
|
||||
-(NSNumber*) createUserWithCompletionBlock :(SWGUser*) body
|
||||
-(NSNumber*) createUserWithCompletionBlock :(SWGUser*) body
|
||||
|
||||
|
||||
completionHandler: (void (^)(NSError* error))completionBlock;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
|
||||
Creates list of users with given input array
|
||||
|
||||
@ -43,14 +40,13 @@
|
||||
|
||||
return type:
|
||||
*/
|
||||
-(NSNumber*) createUsersWithArrayInputWithCompletionBlock :(NSArray<SWGUser>*) body
|
||||
-(NSNumber*) createUsersWithArrayInputWithCompletionBlock :(NSArray<SWGUser>*) body
|
||||
|
||||
|
||||
completionHandler: (void (^)(NSError* error))completionBlock;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
|
||||
Creates list of users with given input array
|
||||
|
||||
@ -60,14 +56,13 @@
|
||||
|
||||
return type:
|
||||
*/
|
||||
-(NSNumber*) createUsersWithListInputWithCompletionBlock :(NSArray<SWGUser>*) body
|
||||
-(NSNumber*) createUsersWithListInputWithCompletionBlock :(NSArray<SWGUser>*) body
|
||||
|
||||
|
||||
completionHandler: (void (^)(NSError* error))completionBlock;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
|
||||
Logs user into the system
|
||||
|
||||
@ -78,15 +73,14 @@
|
||||
|
||||
return type: NSString*
|
||||
*/
|
||||
-(NSNumber*) loginUserWithCompletionBlock :(NSString*) username
|
||||
-(NSNumber*) loginUserWithCompletionBlock :(NSString*) username
|
||||
password:(NSString*) password
|
||||
|
||||
completionHandler: (void (^)(NSString* output, NSError* error))completionBlock;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
|
||||
Logs out current logged in user session
|
||||
|
||||
@ -95,13 +89,12 @@
|
||||
|
||||
return type:
|
||||
*/
|
||||
-(NSNumber*) logoutUserWithCompletionBlock :
|
||||
-(NSNumber*) logoutUserWithCompletionBlock :
|
||||
|
||||
(void (^)(NSError* error))completionBlock;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
|
||||
Get user by user name
|
||||
|
||||
@ -111,14 +104,13 @@
|
||||
|
||||
return type: SWGUser*
|
||||
*/
|
||||
-(NSNumber*) getUserByNameWithCompletionBlock :(NSString*) username
|
||||
-(NSNumber*) getUserByNameWithCompletionBlock :(NSString*) username
|
||||
|
||||
completionHandler: (void (^)(SWGUser* output, NSError* error))completionBlock;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
|
||||
Updated user
|
||||
This can only be done by the logged in user.
|
||||
@ -129,15 +121,14 @@
|
||||
|
||||
return type:
|
||||
*/
|
||||
-(NSNumber*) updateUserWithCompletionBlock :(NSString*) username
|
||||
-(NSNumber*) updateUserWithCompletionBlock :(NSString*) username
|
||||
body:(SWGUser*) body
|
||||
|
||||
|
||||
completionHandler: (void (^)(NSError* error))completionBlock;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
|
||||
Delete user
|
||||
This can only be done by the logged in user.
|
||||
@ -147,12 +138,11 @@
|
||||
|
||||
return type:
|
||||
*/
|
||||
-(NSNumber*) deleteUserWithCompletionBlock :(NSString*) username
|
||||
-(NSNumber*) deleteUserWithCompletionBlock :(NSString*) username
|
||||
|
||||
|
||||
completionHandler: (void (^)(NSError* error))completionBlock;
|
||||
|
||||
|
||||
|
||||
|
||||
@end
|
||||
|
@ -1,30 +1,29 @@
|
||||
#import "SWGUserApi.h"
|
||||
#import "SWGFile.h"
|
||||
#import "SWGQueryParamCollection.h"
|
||||
#import "SWGUser.h"
|
||||
#import "SWGUserApi.h"
|
||||
#import "SWGFile.h"
|
||||
#import "SWGQueryParamCollection.h"
|
||||
#import "SWGUser.h"
|
||||
|
||||
|
||||
|
||||
@interface SWGUserApi ()
|
||||
@interface SWGUserApi ()
|
||||
@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];
|
||||
if (self) {
|
||||
self.apiClient = [SWGApiClient sharedClientFromPool:basePath];
|
||||
self.defaultHeaders = [NSMutableDictionary dictionary];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
}
|
||||
|
||||
- (id) initWithApiClient:(SWGApiClient *)apiClient {
|
||||
- (id) initWithApiClient:(SWGApiClient *)apiClient {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
if (apiClient) {
|
||||
@ -36,11 +35,11 @@
|
||||
self.defaultHeaders = [NSMutableDictionary dictionary];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark -
|
||||
|
||||
+(SWGUserApi*) apiWithHeader:(NSString*)headerValue key:(NSString*)key {
|
||||
+(SWGUserApi*) apiWithHeader:(NSString*)headerValue key:(NSString*)key {
|
||||
static SWGUserApi* singletonAPI = nil;
|
||||
|
||||
if (singletonAPI == nil) {
|
||||
@ -48,38 +47,37 @@
|
||||
[singletonAPI addHeader:headerValue forKey:key];
|
||||
}
|
||||
return singletonAPI;
|
||||
}
|
||||
}
|
||||
|
||||
+(void) setBasePath:(NSString*)path {
|
||||
+(void) setBasePath:(NSString*)path {
|
||||
basePath = path;
|
||||
}
|
||||
}
|
||||
|
||||
+(NSString*) getBasePath {
|
||||
+(NSString*) getBasePath {
|
||||
return basePath;
|
||||
}
|
||||
}
|
||||
|
||||
-(void) addHeader:(NSString*)value forKey:(NSString*)key {
|
||||
-(void) addHeader:(NSString*)value forKey:(NSString*)key {
|
||||
[self.defaultHeaders setValue:value forKey:key];
|
||||
}
|
||||
}
|
||||
|
||||
-(void) setHeaderValue:(NSString*) value
|
||||
-(void) setHeaderValue:(NSString*) value
|
||||
forKey:(NSString*)key {
|
||||
[self.defaultHeaders setValue:value forKey:key];
|
||||
}
|
||||
}
|
||||
|
||||
-(unsigned long) requestQueueSize {
|
||||
-(unsigned long) requestQueueSize {
|
||||
return [SWGApiClient requestQueueSize];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
/*!
|
||||
* Create user
|
||||
* This can only be done by the logged in user.
|
||||
* \param body Created user object
|
||||
* \returns void
|
||||
*/
|
||||
-(NSNumber*) createUserWithCompletionBlock: (SWGUser*) body
|
||||
-(NSNumber*) createUserWithCompletionBlock: (SWGUser*) body
|
||||
|
||||
|
||||
completionHandler: (void (^)(NSError* error))completionBlock {
|
||||
@ -162,32 +160,31 @@
|
||||
|
||||
// it's void
|
||||
return [self.apiClient stringWithCompletionBlock: requestUrl
|
||||
method: @"POST"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
requestContentType: requestContentType
|
||||
responseContentType: responseContentType
|
||||
completionBlock: ^(NSString *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(error);
|
||||
return;
|
||||
}
|
||||
completionBlock(nil);
|
||||
}];
|
||||
|
||||
|
||||
method: @"POST"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
requestContentType: requestContentType
|
||||
responseContentType: responseContentType
|
||||
completionBlock: ^(NSString *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(error);
|
||||
return;
|
||||
}
|
||||
completionBlock(nil);
|
||||
}];
|
||||
|
||||
|
||||
/*!
|
||||
}
|
||||
|
||||
/*!
|
||||
* Creates list of users with given input array
|
||||
*
|
||||
* \param body List of user object
|
||||
* \returns void
|
||||
*/
|
||||
-(NSNumber*) createUsersWithArrayInputWithCompletionBlock: (NSArray<SWGUser>*) body
|
||||
-(NSNumber*) createUsersWithArrayInputWithCompletionBlock: (NSArray<SWGUser>*) body
|
||||
|
||||
|
||||
completionHandler: (void (^)(NSError* error))completionBlock {
|
||||
@ -270,32 +267,31 @@ completionBlock(nil);
|
||||
|
||||
// it's void
|
||||
return [self.apiClient stringWithCompletionBlock: requestUrl
|
||||
method: @"POST"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
requestContentType: requestContentType
|
||||
responseContentType: responseContentType
|
||||
completionBlock: ^(NSString *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(error);
|
||||
return;
|
||||
}
|
||||
completionBlock(nil);
|
||||
}];
|
||||
|
||||
|
||||
method: @"POST"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
requestContentType: requestContentType
|
||||
responseContentType: responseContentType
|
||||
completionBlock: ^(NSString *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(error);
|
||||
return;
|
||||
}
|
||||
completionBlock(nil);
|
||||
}];
|
||||
|
||||
|
||||
/*!
|
||||
}
|
||||
|
||||
/*!
|
||||
* Creates list of users with given input array
|
||||
*
|
||||
* \param body List of user object
|
||||
* \returns void
|
||||
*/
|
||||
-(NSNumber*) createUsersWithListInputWithCompletionBlock: (NSArray<SWGUser>*) body
|
||||
-(NSNumber*) createUsersWithListInputWithCompletionBlock: (NSArray<SWGUser>*) body
|
||||
|
||||
|
||||
completionHandler: (void (^)(NSError* error))completionBlock {
|
||||
@ -378,33 +374,32 @@ completionBlock(nil);
|
||||
|
||||
// it's void
|
||||
return [self.apiClient stringWithCompletionBlock: requestUrl
|
||||
method: @"POST"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
requestContentType: requestContentType
|
||||
responseContentType: responseContentType
|
||||
completionBlock: ^(NSString *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(error);
|
||||
return;
|
||||
}
|
||||
completionBlock(nil);
|
||||
}];
|
||||
|
||||
|
||||
method: @"POST"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
requestContentType: requestContentType
|
||||
responseContentType: responseContentType
|
||||
completionBlock: ^(NSString *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(error);
|
||||
return;
|
||||
}
|
||||
completionBlock(nil);
|
||||
}];
|
||||
|
||||
|
||||
/*!
|
||||
}
|
||||
|
||||
/*!
|
||||
* Logs user into the system
|
||||
*
|
||||
* \param username The user name for login
|
||||
* \param password The password for login in clear text
|
||||
* \returns NSString*
|
||||
*/
|
||||
-(NSNumber*) loginUserWithCompletionBlock: (NSString*) username
|
||||
-(NSNumber*) loginUserWithCompletionBlock: (NSString*) username
|
||||
password: (NSString*) password
|
||||
|
||||
completionHandler: (void (^)(NSString* output, NSError* error))completionBlock
|
||||
@ -474,22 +469,24 @@ completionBlock(nil);
|
||||
|
||||
// primitive response
|
||||
// primitive response type
|
||||
return [self.apiClient stringWithCompletionBlock: requestUrl
|
||||
method: @"GET"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
requestContentType: requestContentType
|
||||
responseContentType: responseContentType
|
||||
completionBlock: ^(NSString *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(nil, error);
|
||||
return;
|
||||
}
|
||||
NSString *result = data ? [[NSString alloc]initWithString: data] : nil;
|
||||
completionBlock(result, nil);
|
||||
}];
|
||||
return [self.apiClient stringWithCompletionBlock: requestUrl
|
||||
method: @"GET"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
requestContentType: requestContentType
|
||||
responseContentType: responseContentType
|
||||
completionBlock: ^(NSString *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(nil, error);
|
||||
return;
|
||||
}
|
||||
NSString *result = data ? [[NSString alloc]initWithString: data] : nil;
|
||||
completionBlock(result, nil);
|
||||
}];
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -499,15 +496,15 @@ completionBlock(result, nil);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*!
|
||||
/*!
|
||||
* Logs out current logged in user session
|
||||
*
|
||||
* \returns void
|
||||
*/
|
||||
-(NSNumber*) logoutUserWithCompletionBlock:
|
||||
-(NSNumber*) logoutUserWithCompletionBlock:
|
||||
|
||||
(void (^)(NSError* error))completionBlock {
|
||||
|
||||
@ -566,32 +563,31 @@ completionBlock(result, nil);
|
||||
|
||||
// it's void
|
||||
return [self.apiClient stringWithCompletionBlock: requestUrl
|
||||
method: @"GET"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
requestContentType: requestContentType
|
||||
responseContentType: responseContentType
|
||||
completionBlock: ^(NSString *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(error);
|
||||
return;
|
||||
}
|
||||
completionBlock(nil);
|
||||
}];
|
||||
|
||||
|
||||
method: @"GET"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
requestContentType: requestContentType
|
||||
responseContentType: responseContentType
|
||||
completionBlock: ^(NSString *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(error);
|
||||
return;
|
||||
}
|
||||
completionBlock(nil);
|
||||
}];
|
||||
|
||||
|
||||
/*!
|
||||
}
|
||||
|
||||
/*!
|
||||
* Get user by user name
|
||||
*
|
||||
* \param username The name that needs to be fetched. Use user1 for testing.
|
||||
* \returns SWGUser*
|
||||
*/
|
||||
-(NSNumber*) getUserByNameWithCompletionBlock: (NSString*) username
|
||||
-(NSNumber*) getUserByNameWithCompletionBlock: (NSString*) username
|
||||
|
||||
completionHandler: (void (^)(SWGUser* output, NSError* error))completionBlock
|
||||
{
|
||||
@ -657,6 +653,7 @@ completionBlock(nil);
|
||||
|
||||
|
||||
// complex response
|
||||
|
||||
// comples response type
|
||||
return [self.apiClient dictionary: requestUrl
|
||||
method: @"GET"
|
||||
@ -683,17 +680,17 @@ completionBlock(nil);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*!
|
||||
/*!
|
||||
* Updated user
|
||||
* This can only be done by the logged in user.
|
||||
* \param username name that need to be deleted
|
||||
* \param body Updated user object
|
||||
* \returns void
|
||||
*/
|
||||
-(NSNumber*) updateUserWithCompletionBlock: (NSString*) username
|
||||
-(NSNumber*) updateUserWithCompletionBlock: (NSString*) username
|
||||
body: (SWGUser*) body
|
||||
|
||||
|
||||
@ -781,32 +778,31 @@ completionBlock(nil);
|
||||
|
||||
// it's void
|
||||
return [self.apiClient stringWithCompletionBlock: requestUrl
|
||||
method: @"PUT"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
requestContentType: requestContentType
|
||||
responseContentType: responseContentType
|
||||
completionBlock: ^(NSString *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(error);
|
||||
return;
|
||||
}
|
||||
completionBlock(nil);
|
||||
}];
|
||||
|
||||
|
||||
method: @"PUT"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
requestContentType: requestContentType
|
||||
responseContentType: responseContentType
|
||||
completionBlock: ^(NSString *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(error);
|
||||
return;
|
||||
}
|
||||
completionBlock(nil);
|
||||
}];
|
||||
|
||||
|
||||
/*!
|
||||
}
|
||||
|
||||
/*!
|
||||
* Delete user
|
||||
* This can only be done by the logged in user.
|
||||
* \param username The name that needs to be deleted
|
||||
* \returns void
|
||||
*/
|
||||
-(NSNumber*) deleteUserWithCompletionBlock: (NSString*) username
|
||||
-(NSNumber*) deleteUserWithCompletionBlock: (NSString*) username
|
||||
|
||||
|
||||
completionHandler: (void (^)(NSError* error))completionBlock {
|
||||
@ -870,25 +866,24 @@ completionBlock(nil);
|
||||
|
||||
// it's void
|
||||
return [self.apiClient stringWithCompletionBlock: requestUrl
|
||||
method: @"DELETE"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
requestContentType: requestContentType
|
||||
responseContentType: responseContentType
|
||||
completionBlock: ^(NSString *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(error);
|
||||
return;
|
||||
}
|
||||
completionBlock(nil);
|
||||
}];
|
||||
|
||||
|
||||
method: @"DELETE"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
requestContentType: requestContentType
|
||||
responseContentType: responseContentType
|
||||
completionBlock: ^(NSString *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(error);
|
||||
return;
|
||||
}
|
||||
completionBlock(nil);
|
||||
}];
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@end
|
||||
|
@ -317,7 +317,7 @@ sub new {
|
||||
|
||||
|
||||
# authentication setting, if any
|
||||
my $auth_settings = ['api_key', 'petstore_auth'];
|
||||
my $auth_settings = ['petstore_auth', 'api_key'];
|
||||
|
||||
# make the API Call
|
||||
my $response = $self->{api_client}->call_api($_resource_path, $_method,
|
||||
|
@ -327,7 +327,7 @@ class PetApi {
|
||||
}
|
||||
|
||||
// authentication setting, if any
|
||||
$authSettings = array('api_key', 'petstore_auth');
|
||||
$authSettings = array('petstore_auth', 'api_key');
|
||||
|
||||
// make the API Call
|
||||
$response = $this->apiClient->callAPI($resourcePath, $method,
|
||||
|
@ -9,8 +9,8 @@ from .models.order import Order
|
||||
|
||||
# import apis into sdk package
|
||||
from .apis.user_api import UserApi
|
||||
from .apis.pet_api import PetApi
|
||||
from .apis.store_api import StoreApi
|
||||
from .apis.pet_api import PetApi
|
||||
|
||||
# import ApiClient
|
||||
from .api_client import ApiClient
|
||||
|
@ -2,6 +2,6 @@ from __future__ import absolute_import
|
||||
|
||||
# import apis into api package
|
||||
from .user_api import UserApi
|
||||
from .pet_api import PetApi
|
||||
from .store_api import StoreApi
|
||||
from .pet_api import PetApi
|
||||
|
||||
|
@ -298,7 +298,7 @@ class PetApi(object):
|
||||
header_params['Content-Type'] = self.api_client.select_header_content_type([])
|
||||
|
||||
# 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,
|
||||
body=body_params, post_params=form_params, files=files,
|
||||
|
@ -1,77 +1,73 @@
|
||||
|
||||
#include "SWGCategory.h"
|
||||
#include "SWGCategory.h"
|
||||
|
||||
#include "SWGHelpers.h"
|
||||
#include "SWGHelpers.h"
|
||||
|
||||
#include
|
||||
<QJsonDocument>
|
||||
#include
|
||||
<QJsonArray>
|
||||
#include
|
||||
<QObject>
|
||||
#include
|
||||
<QDebug>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonArray>
|
||||
#include <QObject>
|
||||
#include <QDebug>
|
||||
|
||||
namespace Swagger {
|
||||
namespace Swagger {
|
||||
|
||||
|
||||
SWGCategory::SWGCategory(QString* json) {
|
||||
SWGCategory::SWGCategory(QString* json) {
|
||||
init();
|
||||
this->fromJson(*json);
|
||||
}
|
||||
}
|
||||
|
||||
SWGCategory::SWGCategory() {
|
||||
SWGCategory::SWGCategory() {
|
||||
init();
|
||||
}
|
||||
}
|
||||
|
||||
SWGCategory::~SWGCategory() {
|
||||
SWGCategory::~SWGCategory() {
|
||||
this->cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SWGCategory::init() {
|
||||
void
|
||||
SWGCategory::init() {
|
||||
id = 0L;
|
||||
name = new QString("");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SWGCategory::cleanup() {
|
||||
void
|
||||
SWGCategory::cleanup() {
|
||||
|
||||
if(name != NULL) {
|
||||
delete name;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
SWGCategory*
|
||||
SWGCategory::fromJson(QString &json) {
|
||||
SWGCategory*
|
||||
SWGCategory::fromJson(QString &json) {
|
||||
QByteArray array (json.toStdString().c_str());
|
||||
QJsonDocument doc = QJsonDocument::fromJson(array);
|
||||
QJsonObject jsonObject = doc.object();
|
||||
this->fromJsonObject(jsonObject);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SWGCategory::fromJsonObject(QJsonObject &pJson) {
|
||||
void
|
||||
SWGCategory::fromJsonObject(QJsonObject &pJson) {
|
||||
setValue(&id, pJson["id"], "qint64", "");
|
||||
setValue(&name, pJson["name"], "QString", "QString");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
QString
|
||||
SWGCategory::asJson ()
|
||||
{
|
||||
QString
|
||||
SWGCategory::asJson ()
|
||||
{
|
||||
QJsonObject* obj = this->asJsonObject();
|
||||
|
||||
QJsonDocument doc(*obj);
|
||||
QByteArray bytes = doc.toJson();
|
||||
return QString(bytes);
|
||||
}
|
||||
}
|
||||
|
||||
QJsonObject*
|
||||
SWGCategory::asJsonObject() {
|
||||
QJsonObject*
|
||||
SWGCategory::asJsonObject() {
|
||||
QJsonObject* obj = new QJsonObject();
|
||||
obj->insert("id", QJsonValue(id));
|
||||
|
||||
@ -83,30 +79,27 @@
|
||||
|
||||
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
qint64
|
||||
SWGCategory::getId() {
|
||||
qint64
|
||||
SWGCategory::getId() {
|
||||
return id;
|
||||
}
|
||||
void
|
||||
SWGCategory::setId(qint64 id) {
|
||||
}
|
||||
void
|
||||
SWGCategory::setId(qint64 id) {
|
||||
this->id = id;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QString*
|
||||
SWGCategory::getName() {
|
||||
QString*
|
||||
SWGCategory::getName() {
|
||||
return name;
|
||||
}
|
||||
void
|
||||
SWGCategory::setName(QString* name) {
|
||||
}
|
||||
void
|
||||
SWGCategory::setName(QString* name) {
|
||||
this->name = name;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} /* namespace Swagger */
|
||||
} /* namespace Swagger */
|
||||
|
||||
|
@ -1,25 +1,24 @@
|
||||
/*
|
||||
* SWGCategory.h
|
||||
*
|
||||
*
|
||||
*/
|
||||
* SWGCategory.h
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SWGCategory_H_
|
||||
#define SWGCategory_H_
|
||||
|
||||
#include
|
||||
<QJsonObject>
|
||||
#include <QJsonObject>
|
||||
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "SWGObject.h"
|
||||
#include "SWGObject.h"
|
||||
|
||||
|
||||
namespace Swagger {
|
||||
namespace Swagger {
|
||||
|
||||
class SWGCategory: public SWGObject {
|
||||
public:
|
||||
class SWGCategory: public SWGObject {
|
||||
public:
|
||||
SWGCategory();
|
||||
SWGCategory(QString* json);
|
||||
virtual ~SWGCategory();
|
||||
@ -37,12 +36,12 @@
|
||||
void setName(QString* name);
|
||||
|
||||
|
||||
private:
|
||||
private:
|
||||
qint64 id;
|
||||
QString* name;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
} /* namespace Swagger */
|
||||
} /* namespace Swagger */
|
||||
|
||||
#endif /* SWGCategory_H_ */
|
||||
#endif /* SWGCategory_H_ */
|
||||
|
@ -1,43 +1,32 @@
|
||||
#include "SWGHelpers.h"
|
||||
#include "SWGModelFactory.h"
|
||||
#include "SWGObject.h"
|
||||
#import
|
||||
<QDebug>
|
||||
#import
|
||||
<QJsonArray>
|
||||
#import
|
||||
<QJsonValue>
|
||||
#import <QDebug>
|
||||
#import <QJsonArray>
|
||||
#import <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) {
|
||||
if(value == NULL) {
|
||||
// can't set value with a null pointer
|
||||
return;
|
||||
}
|
||||
if(QStringLiteral("bool").compare(type) == 0) {
|
||||
bool * val = static_cast
|
||||
<bool
|
||||
*>(value);
|
||||
bool * val = static_cast<bool*>(value);
|
||||
*val = obj.toBool();
|
||||
}
|
||||
else if(QStringLiteral("qint32").compare(type) == 0) {
|
||||
qint32 *val = static_cast
|
||||
<qint32
|
||||
*>(value);
|
||||
qint32 *val = static_cast<qint32*>(value);
|
||||
*val = obj.toInt();
|
||||
}
|
||||
else if(QStringLiteral("qint64").compare(type) == 0) {
|
||||
qint64 *val = static_cast
|
||||
<qint64
|
||||
*>(value);
|
||||
qint64 *val = static_cast<qint64*>(value);
|
||||
*val = obj.toVariant().toLongLong();
|
||||
}
|
||||
else if (QStringLiteral("QString").compare(type) == 0) {
|
||||
QString **val = static_cast
|
||||
<QString
|
||||
**>(value);
|
||||
QString **val = static_cast<QString**>(value);
|
||||
|
||||
if(val != NULL) {
|
||||
if(!obj.isNull()) {
|
||||
@ -62,20 +51,14 @@
|
||||
SWGObject * so = (SWGObject*)Swagger::create(type);
|
||||
if(so != NULL) {
|
||||
so->fromJsonObject(jsonObj);
|
||||
SWGObject **val = static_cast
|
||||
<SWGObject
|
||||
**>(value);
|
||||
SWGObject **val = static_cast<SWGObject**>(value);
|
||||
delete *val;
|
||||
*val = so;
|
||||
}
|
||||
}
|
||||
else if(type.startsWith("QList") && QString("").compare(complexType) != 0 && obj.isArray()) {
|
||||
// list of values
|
||||
QList
|
||||
<void
|
||||
*>* output = new QList
|
||||
<void
|
||||
*>();
|
||||
QList<void*>* output = new QList<void*>();
|
||||
QJsonArray arr = obj.toArray();
|
||||
foreach (const QJsonValue & jval, arr) {
|
||||
if(complexType.startsWith("SWG")) {
|
||||
@ -105,25 +88,19 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
QList
|
||||
<void
|
||||
*> **val = static_cast
|
||||
<QList
|
||||
<void
|
||||
*>**>(value);
|
||||
QList<void*> **val = static_cast<QList<void*>**>(value);
|
||||
delete *val;
|
||||
*val = output;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
toJsonValue(QString name, void* value, QJsonObject* output, QString type) {
|
||||
void
|
||||
toJsonValue(QString name, void* value, QJsonObject* output, QString type) {
|
||||
if(value == NULL) {
|
||||
return;
|
||||
}
|
||||
if(type.startsWith("SWG")) {
|
||||
SWGObject *swgObject = reinterpret_cast
|
||||
<SWGObject *>(value);
|
||||
SWGObject *swgObject = reinterpret_cast<SWGObject *>(value);
|
||||
if(swgObject != NULL) {
|
||||
QJsonObject* o = (*swgObject).asJsonObject();
|
||||
if(name != NULL) {
|
||||
@ -139,63 +116,51 @@
|
||||
}
|
||||
}
|
||||
else if(QStringLiteral("QString").compare(type) == 0) {
|
||||
QString* str = static_cast
|
||||
<QString
|
||||
*>(value);
|
||||
QString* str = static_cast<QString*>(value);
|
||||
output->insert(name, QJsonValue(*str));
|
||||
}
|
||||
else if(QStringLiteral("qint32").compare(type) == 0) {
|
||||
qint32* str = static_cast
|
||||
<qint32
|
||||
*>(value);
|
||||
qint32* str = static_cast<qint32*>(value);
|
||||
output->insert(name, QJsonValue(*str));
|
||||
}
|
||||
else if(QStringLiteral("qint64").compare(type) == 0) {
|
||||
qint64* str = static_cast
|
||||
<qint64
|
||||
*>(value);
|
||||
qint64* str = static_cast<qint64*>(value);
|
||||
output->insert(name, QJsonValue(*str));
|
||||
}
|
||||
else if(QStringLiteral("bool").compare(type) == 0) {
|
||||
bool* str = static_cast
|
||||
<bool
|
||||
*>(value);
|
||||
bool* str = static_cast<bool*>(value);
|
||||
output->insert(name, QJsonValue(*str));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
toJsonArray(QList
|
||||
<void
|
||||
*>* value, QJsonArray* output, QString innerName, QString innerType) {
|
||||
void
|
||||
toJsonArray(QList<void*>* value, QJsonArray* output, QString innerName, QString innerType) {
|
||||
foreach(void* obj, *value) {
|
||||
QJsonObject element;
|
||||
|
||||
toJsonValue(NULL, obj, &element, innerType);
|
||||
output->append(element);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QString
|
||||
stringValue(QString* value) {
|
||||
QString* str = static_cast
|
||||
<QString
|
||||
*>(value);
|
||||
QString
|
||||
stringValue(QString* value) {
|
||||
QString* str = static_cast<QString*>(value);
|
||||
return QString(*str);
|
||||
}
|
||||
}
|
||||
|
||||
QString
|
||||
stringValue(qint32 value) {
|
||||
QString
|
||||
stringValue(qint32 value) {
|
||||
return QString::number(value);
|
||||
}
|
||||
}
|
||||
|
||||
QString
|
||||
stringValue(qint64 value) {
|
||||
QString
|
||||
stringValue(qint64 value) {
|
||||
return QString::number(value);
|
||||
}
|
||||
}
|
||||
|
||||
QString
|
||||
stringValue(bool value) {
|
||||
QString
|
||||
stringValue(bool value) {
|
||||
return QString(value ? "true" : "false");
|
||||
}
|
||||
} /* namespace Swagger */
|
||||
}
|
||||
} /* namespace Swagger */
|
||||
|
@ -1,20 +1,17 @@
|
||||
#ifndef SWGHELPERS_H
|
||||
#define SWGHELPERS_H
|
||||
|
||||
#include
|
||||
<QJsonValue>
|
||||
#include <QJsonValue>
|
||||
|
||||
namespace Swagger {
|
||||
namespace Swagger {
|
||||
void setValue(void* value, QJsonValue obj, QString type, QString complexType);
|
||||
void toJsonArray(QList
|
||||
<void
|
||||
*>* value, QJsonArray* output, QString innerName, QString innerType);
|
||||
void toJsonArray(QList<void*>* value, QJsonArray* output, QString innerName, QString innerType);
|
||||
void toJsonValue(QString name, void* value, QJsonObject* output, QString type);
|
||||
bool isCompatibleJsonValue(QString type);
|
||||
QString stringValue(QString* value);
|
||||
QString stringValue(qint32 value);
|
||||
QString stringValue(qint64 value);
|
||||
QString stringValue(bool value);
|
||||
}
|
||||
}
|
||||
|
||||
#endif // SWGHELPERS_H
|
||||
#endif // SWGHELPERS_H
|
||||
|
@ -2,45 +2,44 @@
|
||||
#define ModelFactory_H_
|
||||
|
||||
|
||||
#include "SWGUser.h"
|
||||
#include "SWGCategory.h"
|
||||
#include "SWGPet.h"
|
||||
#include "SWGTag.h"
|
||||
#include "SWGOrder.h"
|
||||
#include "SWGUser.h"
|
||||
#include "SWGCategory.h"
|
||||
#include "SWGPet.h"
|
||||
#include "SWGTag.h"
|
||||
#include "SWGOrder.h"
|
||||
|
||||
namespace Swagger {
|
||||
inline void* create(QString type) {
|
||||
if(QString("SWGUser").compare(type) == 0) {
|
||||
return new SWGUser();
|
||||
}
|
||||
if(QString("SWGCategory").compare(type) == 0) {
|
||||
return new SWGCategory();
|
||||
}
|
||||
if(QString("SWGPet").compare(type) == 0) {
|
||||
return new SWGPet();
|
||||
}
|
||||
if(QString("SWGTag").compare(type) == 0) {
|
||||
return new SWGTag();
|
||||
}
|
||||
if(QString("SWGOrder").compare(type) == 0) {
|
||||
return new SWGOrder();
|
||||
}
|
||||
inline void* create(QString type) {
|
||||
if(QString("SWGUser").compare(type) == 0) {
|
||||
return new SWGUser();
|
||||
}
|
||||
if(QString("SWGCategory").compare(type) == 0) {
|
||||
return new SWGCategory();
|
||||
}
|
||||
if(QString("SWGPet").compare(type) == 0) {
|
||||
return new SWGPet();
|
||||
}
|
||||
if(QString("SWGTag").compare(type) == 0) {
|
||||
return new SWGTag();
|
||||
}
|
||||
if(QString("SWGOrder").compare(type) == 0) {
|
||||
return new SWGOrder();
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
inline void* create(QString json, QString type) {
|
||||
void* val = create(type);
|
||||
if(val != NULL) {
|
||||
SWGObject* obj = static_cast
|
||||
<SWGObject*>(val);
|
||||
return obj->fromJson(json);
|
||||
}
|
||||
if(type.startsWith("QString")) {
|
||||
return new QString();
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
inline void* create(QString json, QString type) {
|
||||
void* val = create(type);
|
||||
if(val != NULL) {
|
||||
SWGObject* obj = static_cast<SWGObject*>(val);
|
||||
return obj->fromJson(json);
|
||||
}
|
||||
if(type.startsWith("QString")) {
|
||||
return new QString();
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
} /* namespace Swagger */
|
||||
|
||||
#endif /* ModelFactory_H_ */
|
||||
|
@ -1,10 +1,9 @@
|
||||
#ifndef _SWG_OBJECT_H_
|
||||
#define _SWG_OBJECT_H_
|
||||
|
||||
#include
|
||||
<QJsonValue>
|
||||
#include <QJsonValue>
|
||||
|
||||
class SWGObject {
|
||||
class SWGObject {
|
||||
public:
|
||||
virtual QJsonObject* asJsonObject() {
|
||||
return NULL;
|
||||
@ -20,6 +19,6 @@
|
||||
virtual QString asJson() {
|
||||
return QString("");
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
#endif /* _SWG_OBJECT_H_ */
|
||||
#endif /* _SWG_OBJECT_H_ */
|
||||
|
@ -1,35 +1,31 @@
|
||||
|
||||
#include "SWGOrder.h"
|
||||
#include "SWGOrder.h"
|
||||
|
||||
#include "SWGHelpers.h"
|
||||
#include "SWGHelpers.h"
|
||||
|
||||
#include
|
||||
<QJsonDocument>
|
||||
#include
|
||||
<QJsonArray>
|
||||
#include
|
||||
<QObject>
|
||||
#include
|
||||
<QDebug>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonArray>
|
||||
#include <QObject>
|
||||
#include <QDebug>
|
||||
|
||||
namespace Swagger {
|
||||
namespace Swagger {
|
||||
|
||||
|
||||
SWGOrder::SWGOrder(QString* json) {
|
||||
SWGOrder::SWGOrder(QString* json) {
|
||||
init();
|
||||
this->fromJson(*json);
|
||||
}
|
||||
}
|
||||
|
||||
SWGOrder::SWGOrder() {
|
||||
SWGOrder::SWGOrder() {
|
||||
init();
|
||||
}
|
||||
}
|
||||
|
||||
SWGOrder::~SWGOrder() {
|
||||
SWGOrder::~SWGOrder() {
|
||||
this->cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SWGOrder::init() {
|
||||
void
|
||||
SWGOrder::init() {
|
||||
id = 0L;
|
||||
petId = 0L;
|
||||
quantity = 0;
|
||||
@ -37,10 +33,10 @@
|
||||
status = new QString("");
|
||||
complete = false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SWGOrder::cleanup() {
|
||||
void
|
||||
SWGOrder::cleanup() {
|
||||
|
||||
|
||||
|
||||
@ -52,19 +48,19 @@
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
SWGOrder*
|
||||
SWGOrder::fromJson(QString &json) {
|
||||
SWGOrder*
|
||||
SWGOrder::fromJson(QString &json) {
|
||||
QByteArray array (json.toStdString().c_str());
|
||||
QJsonDocument doc = QJsonDocument::fromJson(array);
|
||||
QJsonObject jsonObject = doc.object();
|
||||
this->fromJsonObject(jsonObject);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SWGOrder::fromJsonObject(QJsonObject &pJson) {
|
||||
void
|
||||
SWGOrder::fromJsonObject(QJsonObject &pJson) {
|
||||
setValue(&id, pJson["id"], "qint64", "");
|
||||
setValue(&petId, pJson["petId"], "qint64", "");
|
||||
setValue(&quantity, pJson["quantity"], "qint32", "");
|
||||
@ -72,20 +68,20 @@
|
||||
setValue(&status, pJson["status"], "QString", "QString");
|
||||
setValue(&complete, pJson["complete"], "bool", "");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
QString
|
||||
SWGOrder::asJson ()
|
||||
{
|
||||
QString
|
||||
SWGOrder::asJson ()
|
||||
{
|
||||
QJsonObject* obj = this->asJsonObject();
|
||||
|
||||
QJsonDocument doc(*obj);
|
||||
QByteArray bytes = doc.toJson();
|
||||
return QString(bytes);
|
||||
}
|
||||
}
|
||||
|
||||
QJsonObject*
|
||||
SWGOrder::asJsonObject() {
|
||||
QJsonObject*
|
||||
SWGOrder::asJsonObject() {
|
||||
QJsonObject* obj = new QJsonObject();
|
||||
obj->insert("id", QJsonValue(id));
|
||||
obj->insert("petId", QJsonValue(petId));
|
||||
@ -106,70 +102,63 @@
|
||||
|
||||
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
qint64
|
||||
SWGOrder::getId() {
|
||||
qint64
|
||||
SWGOrder::getId() {
|
||||
return id;
|
||||
}
|
||||
void
|
||||
SWGOrder::setId(qint64 id) {
|
||||
}
|
||||
void
|
||||
SWGOrder::setId(qint64 id) {
|
||||
this->id = id;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
qint64
|
||||
SWGOrder::getPetId() {
|
||||
qint64
|
||||
SWGOrder::getPetId() {
|
||||
return petId;
|
||||
}
|
||||
void
|
||||
SWGOrder::setPetId(qint64 petId) {
|
||||
}
|
||||
void
|
||||
SWGOrder::setPetId(qint64 petId) {
|
||||
this->petId = petId;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
qint32
|
||||
SWGOrder::getQuantity() {
|
||||
qint32
|
||||
SWGOrder::getQuantity() {
|
||||
return quantity;
|
||||
}
|
||||
void
|
||||
SWGOrder::setQuantity(qint32 quantity) {
|
||||
}
|
||||
void
|
||||
SWGOrder::setQuantity(qint32 quantity) {
|
||||
this->quantity = quantity;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QDateTime*
|
||||
SWGOrder::getShipDate() {
|
||||
QDateTime*
|
||||
SWGOrder::getShipDate() {
|
||||
return shipDate;
|
||||
}
|
||||
void
|
||||
SWGOrder::setShipDate(QDateTime* shipDate) {
|
||||
}
|
||||
void
|
||||
SWGOrder::setShipDate(QDateTime* shipDate) {
|
||||
this->shipDate = shipDate;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QString*
|
||||
SWGOrder::getStatus() {
|
||||
QString*
|
||||
SWGOrder::getStatus() {
|
||||
return status;
|
||||
}
|
||||
void
|
||||
SWGOrder::setStatus(QString* status) {
|
||||
}
|
||||
void
|
||||
SWGOrder::setStatus(QString* status) {
|
||||
this->status = status;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
SWGOrder::getComplete() {
|
||||
bool
|
||||
SWGOrder::getComplete() {
|
||||
return complete;
|
||||
}
|
||||
void
|
||||
SWGOrder::setComplete(bool complete) {
|
||||
}
|
||||
void
|
||||
SWGOrder::setComplete(bool complete) {
|
||||
this->complete = complete;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} /* namespace Swagger */
|
||||
} /* namespace Swagger */
|
||||
|
||||
|
@ -1,26 +1,25 @@
|
||||
/*
|
||||
* SWGOrder.h
|
||||
*
|
||||
*
|
||||
*/
|
||||
* SWGOrder.h
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SWGOrder_H_
|
||||
#define SWGOrder_H_
|
||||
|
||||
#include
|
||||
<QJsonObject>
|
||||
#include <QJsonObject>
|
||||
|
||||
|
||||
#include "QDateTime.h"
|
||||
#include <QString>
|
||||
|
||||
#include "SWGObject.h"
|
||||
#include "SWGObject.h"
|
||||
|
||||
|
||||
namespace Swagger {
|
||||
namespace Swagger {
|
||||
|
||||
class SWGOrder: public SWGObject {
|
||||
public:
|
||||
class SWGOrder: public SWGObject {
|
||||
public:
|
||||
SWGOrder();
|
||||
SWGOrder(QString* json);
|
||||
virtual ~SWGOrder();
|
||||
@ -46,7 +45,7 @@
|
||||
void setComplete(bool complete);
|
||||
|
||||
|
||||
private:
|
||||
private:
|
||||
qint64 id;
|
||||
qint64 petId;
|
||||
qint32 quantity;
|
||||
@ -54,8 +53,8 @@
|
||||
QString* status;
|
||||
bool complete;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
} /* namespace Swagger */
|
||||
} /* namespace Swagger */
|
||||
|
||||
#endif /* SWGOrder_H_ */
|
||||
#endif /* SWGOrder_H_ */
|
||||
|
@ -1,35 +1,31 @@
|
||||
|
||||
#include "SWGPet.h"
|
||||
#include "SWGPet.h"
|
||||
|
||||
#include "SWGHelpers.h"
|
||||
#include "SWGHelpers.h"
|
||||
|
||||
#include
|
||||
<QJsonDocument>
|
||||
#include
|
||||
<QJsonArray>
|
||||
#include
|
||||
<QObject>
|
||||
#include
|
||||
<QDebug>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonArray>
|
||||
#include <QObject>
|
||||
#include <QDebug>
|
||||
|
||||
namespace Swagger {
|
||||
namespace Swagger {
|
||||
|
||||
|
||||
SWGPet::SWGPet(QString* json) {
|
||||
SWGPet::SWGPet(QString* json) {
|
||||
init();
|
||||
this->fromJson(*json);
|
||||
}
|
||||
}
|
||||
|
||||
SWGPet::SWGPet() {
|
||||
SWGPet::SWGPet() {
|
||||
init();
|
||||
}
|
||||
}
|
||||
|
||||
SWGPet::~SWGPet() {
|
||||
SWGPet::~SWGPet() {
|
||||
this->cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SWGPet::init() {
|
||||
void
|
||||
SWGPet::init() {
|
||||
id = 0L;
|
||||
category = new SWGCategory();
|
||||
name = new QString("");
|
||||
@ -37,10 +33,10 @@
|
||||
tags = new QList<SWGTag*>();
|
||||
status = new QString("");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SWGPet::cleanup() {
|
||||
void
|
||||
SWGPet::cleanup() {
|
||||
|
||||
if(category != NULL) {
|
||||
delete category;
|
||||
@ -66,19 +62,19 @@
|
||||
delete status;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
SWGPet*
|
||||
SWGPet::fromJson(QString &json) {
|
||||
SWGPet*
|
||||
SWGPet::fromJson(QString &json) {
|
||||
QByteArray array (json.toStdString().c_str());
|
||||
QJsonDocument doc = QJsonDocument::fromJson(array);
|
||||
QJsonObject jsonObject = doc.object();
|
||||
this->fromJsonObject(jsonObject);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SWGPet::fromJsonObject(QJsonObject &pJson) {
|
||||
void
|
||||
SWGPet::fromJsonObject(QJsonObject &pJson) {
|
||||
setValue(&id, pJson["id"], "qint64", "");
|
||||
setValue(&category, pJson["category"], "SWGCategory", "SWGCategory");
|
||||
setValue(&name, pJson["name"], "QString", "QString");
|
||||
@ -86,20 +82,20 @@
|
||||
setValue(&tags, pJson["tags"], "QList", "SWGTag");
|
||||
setValue(&status, pJson["status"], "QString", "QString");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
QString
|
||||
SWGPet::asJson ()
|
||||
{
|
||||
QString
|
||||
SWGPet::asJson ()
|
||||
{
|
||||
QJsonObject* obj = this->asJsonObject();
|
||||
|
||||
QJsonDocument doc(*obj);
|
||||
QByteArray bytes = doc.toJson();
|
||||
return QString(bytes);
|
||||
}
|
||||
}
|
||||
|
||||
QJsonObject*
|
||||
SWGPet::asJsonObject() {
|
||||
QJsonObject*
|
||||
SWGPet::asJsonObject() {
|
||||
QJsonObject* obj = new QJsonObject();
|
||||
obj->insert("id", QJsonValue(id));
|
||||
|
||||
@ -118,8 +114,7 @@
|
||||
|
||||
QList<QString*>* photoUrlsList = photoUrls;
|
||||
QJsonArray photoUrlsJsonArray;
|
||||
toJsonArray((QList
|
||||
<void*>*)photoUrls, &photoUrlsJsonArray, "photoUrls", "QString");
|
||||
toJsonArray((QList<void*>*)photoUrls, &photoUrlsJsonArray, "photoUrls", "QString");
|
||||
|
||||
obj->insert("photoUrls", photoUrlsJsonArray);
|
||||
|
||||
@ -128,8 +123,7 @@
|
||||
|
||||
QList<SWGTag*>* tagsList = tags;
|
||||
QJsonArray tagsJsonArray;
|
||||
toJsonArray((QList
|
||||
<void*>*)tags, &tagsJsonArray, "tags", "SWGTag");
|
||||
toJsonArray((QList<void*>*)tags, &tagsJsonArray, "tags", "SWGTag");
|
||||
|
||||
obj->insert("tags", tagsJsonArray);
|
||||
|
||||
@ -143,70 +137,63 @@
|
||||
|
||||
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
qint64
|
||||
SWGPet::getId() {
|
||||
qint64
|
||||
SWGPet::getId() {
|
||||
return id;
|
||||
}
|
||||
void
|
||||
SWGPet::setId(qint64 id) {
|
||||
}
|
||||
void
|
||||
SWGPet::setId(qint64 id) {
|
||||
this->id = id;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SWGCategory*
|
||||
SWGPet::getCategory() {
|
||||
SWGCategory*
|
||||
SWGPet::getCategory() {
|
||||
return category;
|
||||
}
|
||||
void
|
||||
SWGPet::setCategory(SWGCategory* category) {
|
||||
}
|
||||
void
|
||||
SWGPet::setCategory(SWGCategory* category) {
|
||||
this->category = category;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QString*
|
||||
SWGPet::getName() {
|
||||
QString*
|
||||
SWGPet::getName() {
|
||||
return name;
|
||||
}
|
||||
void
|
||||
SWGPet::setName(QString* name) {
|
||||
}
|
||||
void
|
||||
SWGPet::setName(QString* name) {
|
||||
this->name = name;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QList<QString*>*
|
||||
SWGPet::getPhotoUrls() {
|
||||
QList<QString*>*
|
||||
SWGPet::getPhotoUrls() {
|
||||
return photoUrls;
|
||||
}
|
||||
void
|
||||
SWGPet::setPhotoUrls(QList<QString*>* photoUrls) {
|
||||
}
|
||||
void
|
||||
SWGPet::setPhotoUrls(QList<QString*>* photoUrls) {
|
||||
this->photoUrls = photoUrls;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QList<SWGTag*>*
|
||||
SWGPet::getTags() {
|
||||
QList<SWGTag*>*
|
||||
SWGPet::getTags() {
|
||||
return tags;
|
||||
}
|
||||
void
|
||||
SWGPet::setTags(QList<SWGTag*>* tags) {
|
||||
}
|
||||
void
|
||||
SWGPet::setTags(QList<SWGTag*>* tags) {
|
||||
this->tags = tags;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QString*
|
||||
SWGPet::getStatus() {
|
||||
QString*
|
||||
SWGPet::getStatus() {
|
||||
return status;
|
||||
}
|
||||
void
|
||||
SWGPet::setStatus(QString* status) {
|
||||
}
|
||||
void
|
||||
SWGPet::setStatus(QString* status) {
|
||||
this->status = status;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} /* namespace Swagger */
|
||||
} /* namespace Swagger */
|
||||
|
||||
|
@ -1,28 +1,27 @@
|
||||
/*
|
||||
* SWGPet.h
|
||||
*
|
||||
*
|
||||
*/
|
||||
* SWGPet.h
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SWGPet_H_
|
||||
#define SWGPet_H_
|
||||
|
||||
#include
|
||||
<QJsonObject>
|
||||
#include <QJsonObject>
|
||||
|
||||
|
||||
#include "SWGTag.h"
|
||||
#include <QList>
|
||||
#include "SWGCategory.h"
|
||||
#include <QString>
|
||||
#include "SWGCategory.h"
|
||||
#include <QList>
|
||||
#include "SWGTag.h"
|
||||
|
||||
#include "SWGObject.h"
|
||||
#include "SWGObject.h"
|
||||
|
||||
|
||||
namespace Swagger {
|
||||
namespace Swagger {
|
||||
|
||||
class SWGPet: public SWGObject {
|
||||
public:
|
||||
class SWGPet: public SWGObject {
|
||||
public:
|
||||
SWGPet();
|
||||
SWGPet(QString* json);
|
||||
virtual ~SWGPet();
|
||||
@ -48,7 +47,7 @@
|
||||
void setStatus(QString* status);
|
||||
|
||||
|
||||
private:
|
||||
private:
|
||||
qint64 id;
|
||||
SWGCategory* category;
|
||||
QString* name;
|
||||
@ -56,8 +55,8 @@
|
||||
QList<SWGTag*>* tags;
|
||||
QString* status;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
} /* namespace Swagger */
|
||||
} /* namespace Swagger */
|
||||
|
||||
#endif /* SWGPet_H_ */
|
||||
#endif /* SWGPet_H_ */
|
||||
|
@ -2,25 +2,21 @@
|
||||
#include "SWGHelpers.h"
|
||||
#include "SWGModelFactory.h"
|
||||
|
||||
#include
|
||||
<QJsonArray>
|
||||
#include
|
||||
<QJsonDocument>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
|
||||
namespace Swagger {
|
||||
SWGPetApi::SWGPetApi() {}
|
||||
namespace Swagger {
|
||||
SWGPetApi::SWGPetApi() {}
|
||||
|
||||
SWGPetApi::~SWGPetApi() {}
|
||||
SWGPetApi::~SWGPetApi() {}
|
||||
|
||||
SWGPetApi::SWGPetApi(QString host, QString basePath) {
|
||||
SWGPetApi::SWGPetApi(QString host, QString basePath) {
|
||||
this->host = host;
|
||||
this->basePath = basePath;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
SWGPetApi::updatePet(SWGPet body) {
|
||||
void
|
||||
SWGPetApi::updatePet(SWGPet body) {
|
||||
QString fullPath;
|
||||
fullPath.append(this->host).append(this->basePath).append("/pet");
|
||||
|
||||
@ -48,10 +44,10 @@
|
||||
&SWGPetApi::updatePetCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SWGPetApi::updatePetCallback(HttpRequestWorker * worker) {
|
||||
void
|
||||
SWGPetApi::updatePetCallback(HttpRequestWorker * worker) {
|
||||
QString msg;
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
@ -66,10 +62,9 @@
|
||||
|
||||
|
||||
emit updatePetSignal();
|
||||
}
|
||||
|
||||
void
|
||||
SWGPetApi::addPet(SWGPet body) {
|
||||
}
|
||||
void
|
||||
SWGPetApi::addPet(SWGPet body) {
|
||||
QString fullPath;
|
||||
fullPath.append(this->host).append(this->basePath).append("/pet");
|
||||
|
||||
@ -97,10 +92,10 @@
|
||||
&SWGPetApi::addPetCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SWGPetApi::addPetCallback(HttpRequestWorker * worker) {
|
||||
void
|
||||
SWGPetApi::addPetCallback(HttpRequestWorker * worker) {
|
||||
QString msg;
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
@ -115,10 +110,9 @@
|
||||
|
||||
|
||||
emit addPetSignal();
|
||||
}
|
||||
|
||||
void
|
||||
SWGPetApi::findPetsByStatus(QList<QString*>* status) {
|
||||
}
|
||||
void
|
||||
SWGPetApi::findPetsByStatus(QList<QString*>* status) {
|
||||
QString fullPath;
|
||||
fullPath.append(this->host).append(this->basePath).append("/pet/findByStatus");
|
||||
|
||||
@ -187,10 +181,10 @@
|
||||
&SWGPetApi::findPetsByStatusCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SWGPetApi::findPetsByStatusCallback(HttpRequestWorker * worker) {
|
||||
void
|
||||
SWGPetApi::findPetsByStatusCallback(HttpRequestWorker * worker) {
|
||||
QString msg;
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
@ -221,10 +215,9 @@
|
||||
|
||||
emit findPetsByStatusSignal(output);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
SWGPetApi::findPetsByTags(QList<QString*>* tags) {
|
||||
}
|
||||
void
|
||||
SWGPetApi::findPetsByTags(QList<QString*>* tags) {
|
||||
QString fullPath;
|
||||
fullPath.append(this->host).append(this->basePath).append("/pet/findByTags");
|
||||
|
||||
@ -293,10 +286,10 @@
|
||||
&SWGPetApi::findPetsByTagsCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SWGPetApi::findPetsByTagsCallback(HttpRequestWorker * worker) {
|
||||
void
|
||||
SWGPetApi::findPetsByTagsCallback(HttpRequestWorker * worker) {
|
||||
QString msg;
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
@ -327,10 +320,9 @@
|
||||
|
||||
emit findPetsByTagsSignal(output);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
SWGPetApi::getPetById(qint64 petId) {
|
||||
}
|
||||
void
|
||||
SWGPetApi::getPetById(qint64 petId) {
|
||||
QString fullPath;
|
||||
fullPath.append(this->host).append(this->basePath).append("/pet/{petId}");
|
||||
|
||||
@ -356,10 +348,10 @@
|
||||
&SWGPetApi::getPetByIdCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SWGPetApi::getPetByIdCallback(HttpRequestWorker * worker) {
|
||||
void
|
||||
SWGPetApi::getPetByIdCallback(HttpRequestWorker * worker) {
|
||||
QString msg;
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
@ -374,8 +366,7 @@
|
||||
|
||||
|
||||
QString json(worker->response);
|
||||
SWGPet* output = static_cast<SWGPet*>(create(json,
|
||||
QString("SWGPet")));
|
||||
SWGPet* output = static_cast<SWGPet*>(create(json, QString("SWGPet")));
|
||||
|
||||
|
||||
|
||||
@ -384,12 +375,9 @@
|
||||
|
||||
emit getPetByIdSignal(output);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
SWGPetApi::updatePetWithForm(QString* petId
|
||||
, QString* name
|
||||
, QString* status) {
|
||||
}
|
||||
void
|
||||
SWGPetApi::updatePetWithForm(QString* petId, QString* name, QString* status) {
|
||||
QString fullPath;
|
||||
fullPath.append(this->host).append(this->basePath).append("/pet/{petId}");
|
||||
|
||||
@ -423,10 +411,10 @@
|
||||
&SWGPetApi::updatePetWithFormCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SWGPetApi::updatePetWithFormCallback(HttpRequestWorker * worker) {
|
||||
void
|
||||
SWGPetApi::updatePetWithFormCallback(HttpRequestWorker * worker) {
|
||||
QString msg;
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
@ -441,11 +429,9 @@
|
||||
|
||||
|
||||
emit updatePetWithFormSignal();
|
||||
}
|
||||
|
||||
void
|
||||
SWGPetApi::deletePet(QString* apiKey
|
||||
, qint64 petId) {
|
||||
}
|
||||
void
|
||||
SWGPetApi::deletePet(QString* apiKey, qint64 petId) {
|
||||
QString fullPath;
|
||||
fullPath.append(this->host).append(this->basePath).append("/pet/{petId}");
|
||||
|
||||
@ -473,10 +459,10 @@
|
||||
&SWGPetApi::deletePetCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SWGPetApi::deletePetCallback(HttpRequestWorker * worker) {
|
||||
void
|
||||
SWGPetApi::deletePetCallback(HttpRequestWorker * worker) {
|
||||
QString msg;
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
@ -491,12 +477,9 @@
|
||||
|
||||
|
||||
emit deletePetSignal();
|
||||
}
|
||||
|
||||
void
|
||||
SWGPetApi::uploadFile(qint64 petId
|
||||
, QString* additionalMetadata
|
||||
, SWGHttpRequestInputFileElement* file) {
|
||||
}
|
||||
void
|
||||
SWGPetApi::uploadFile(qint64 petId, QString* additionalMetadata, SWGHttpRequestInputFileElement* file) {
|
||||
QString fullPath;
|
||||
fullPath.append(this->host).append(this->basePath).append("/pet/{petId}/uploadImage");
|
||||
|
||||
@ -526,10 +509,10 @@
|
||||
&SWGPetApi::uploadFileCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SWGPetApi::uploadFileCallback(HttpRequestWorker * worker) {
|
||||
void
|
||||
SWGPetApi::uploadFileCallback(HttpRequestWorker * worker) {
|
||||
QString msg;
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
@ -544,7 +527,5 @@
|
||||
|
||||
|
||||
emit uploadFileSignal();
|
||||
}
|
||||
|
||||
|
||||
} /* namespace Swagger */
|
||||
}
|
||||
} /* namespace Swagger */
|
||||
|
@ -7,15 +7,14 @@
|
||||
#include <QString>
|
||||
#include "SWGHttpRequest.h"
|
||||
|
||||
#include
|
||||
<QObject>
|
||||
#include <QObject>
|
||||
|
||||
namespace Swagger {
|
||||
namespace Swagger {
|
||||
|
||||
class SWGPetApi: public QObject {
|
||||
class SWGPetApi: public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
public:
|
||||
SWGPetApi();
|
||||
SWGPetApi(QString host, QString basePath);
|
||||
~SWGPetApi();
|
||||
@ -28,16 +27,11 @@
|
||||
void findPetsByStatus(QList<QString*>* status);
|
||||
void findPetsByTags(QList<QString*>* tags);
|
||||
void getPetById(qint64 petId);
|
||||
void updatePetWithForm(QString* petId
|
||||
, QString* name
|
||||
, QString* status);
|
||||
void deletePet(QString* apiKey
|
||||
, qint64 petId);
|
||||
void uploadFile(qint64 petId
|
||||
, QString* additionalMetadata
|
||||
, SWGHttpRequestInputFileElement* file);
|
||||
void updatePetWithForm(QString* petId, QString* name, QString* status);
|
||||
void deletePet(QString* apiKey, qint64 petId);
|
||||
void uploadFile(qint64 petId, QString* additionalMetadata, SWGHttpRequestInputFileElement* file);
|
||||
|
||||
private:
|
||||
private:
|
||||
void updatePetCallback (HttpRequestWorker * worker);
|
||||
void addPetCallback (HttpRequestWorker * worker);
|
||||
void findPetsByStatusCallback (HttpRequestWorker * worker);
|
||||
@ -47,7 +41,7 @@
|
||||
void deletePetCallback (HttpRequestWorker * worker);
|
||||
void uploadFileCallback (HttpRequestWorker * worker);
|
||||
|
||||
signals:
|
||||
signals:
|
||||
void updatePetSignal();
|
||||
void addPetSignal();
|
||||
void findPetsByStatusSignal(QList<SWGPet*>* summary);
|
||||
@ -57,6 +51,6 @@
|
||||
void deletePetSignal();
|
||||
void uploadFileSignal();
|
||||
|
||||
};
|
||||
}
|
||||
#endif
|
||||
};
|
||||
}
|
||||
#endif
|
@ -2,25 +2,21 @@
|
||||
#include "SWGHelpers.h"
|
||||
#include "SWGModelFactory.h"
|
||||
|
||||
#include
|
||||
<QJsonArray>
|
||||
#include
|
||||
<QJsonDocument>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
|
||||
namespace Swagger {
|
||||
SWGStoreApi::SWGStoreApi() {}
|
||||
namespace Swagger {
|
||||
SWGStoreApi::SWGStoreApi() {}
|
||||
|
||||
SWGStoreApi::~SWGStoreApi() {}
|
||||
SWGStoreApi::~SWGStoreApi() {}
|
||||
|
||||
SWGStoreApi::SWGStoreApi(QString host, QString basePath) {
|
||||
SWGStoreApi::SWGStoreApi(QString host, QString basePath) {
|
||||
this->host = host;
|
||||
this->basePath = basePath;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
SWGStoreApi::getInventory() {
|
||||
void
|
||||
SWGStoreApi::getInventory() {
|
||||
QString fullPath;
|
||||
fullPath.append(this->host).append(this->basePath).append("/store/inventory");
|
||||
|
||||
@ -43,10 +39,10 @@
|
||||
&SWGStoreApi::getInventoryCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SWGStoreApi::getInventoryCallback(HttpRequestWorker * worker) {
|
||||
void
|
||||
SWGStoreApi::getInventoryCallback(HttpRequestWorker * worker) {
|
||||
QString msg;
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
@ -81,10 +77,9 @@
|
||||
|
||||
emit getInventorySignal(output);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
SWGStoreApi::placeOrder(SWGOrder body) {
|
||||
}
|
||||
void
|
||||
SWGStoreApi::placeOrder(SWGOrder body) {
|
||||
QString fullPath;
|
||||
fullPath.append(this->host).append(this->basePath).append("/store/order");
|
||||
|
||||
@ -112,10 +107,10 @@
|
||||
&SWGStoreApi::placeOrderCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SWGStoreApi::placeOrderCallback(HttpRequestWorker * worker) {
|
||||
void
|
||||
SWGStoreApi::placeOrderCallback(HttpRequestWorker * worker) {
|
||||
QString msg;
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
@ -130,8 +125,7 @@
|
||||
|
||||
|
||||
QString json(worker->response);
|
||||
SWGOrder* output = static_cast<SWGOrder*>(create(json,
|
||||
QString("SWGOrder")));
|
||||
SWGOrder* output = static_cast<SWGOrder*>(create(json, QString("SWGOrder")));
|
||||
|
||||
|
||||
|
||||
@ -140,10 +134,9 @@
|
||||
|
||||
emit placeOrderSignal(output);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
SWGStoreApi::getOrderById(QString* orderId) {
|
||||
}
|
||||
void
|
||||
SWGStoreApi::getOrderById(QString* orderId) {
|
||||
QString fullPath;
|
||||
fullPath.append(this->host).append(this->basePath).append("/store/order/{orderId}");
|
||||
|
||||
@ -169,10 +162,10 @@
|
||||
&SWGStoreApi::getOrderByIdCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SWGStoreApi::getOrderByIdCallback(HttpRequestWorker * worker) {
|
||||
void
|
||||
SWGStoreApi::getOrderByIdCallback(HttpRequestWorker * worker) {
|
||||
QString msg;
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
@ -187,8 +180,7 @@
|
||||
|
||||
|
||||
QString json(worker->response);
|
||||
SWGOrder* output = static_cast<SWGOrder*>(create(json,
|
||||
QString("SWGOrder")));
|
||||
SWGOrder* output = static_cast<SWGOrder*>(create(json, QString("SWGOrder")));
|
||||
|
||||
|
||||
|
||||
@ -197,10 +189,9 @@
|
||||
|
||||
emit getOrderByIdSignal(output);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
SWGStoreApi::deleteOrder(QString* orderId) {
|
||||
}
|
||||
void
|
||||
SWGStoreApi::deleteOrder(QString* orderId) {
|
||||
QString fullPath;
|
||||
fullPath.append(this->host).append(this->basePath).append("/store/order/{orderId}");
|
||||
|
||||
@ -226,10 +217,10 @@
|
||||
&SWGStoreApi::deleteOrderCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SWGStoreApi::deleteOrderCallback(HttpRequestWorker * worker) {
|
||||
void
|
||||
SWGStoreApi::deleteOrderCallback(HttpRequestWorker * worker) {
|
||||
QString msg;
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
@ -244,7 +235,5 @@
|
||||
|
||||
|
||||
emit deleteOrderSignal();
|
||||
}
|
||||
|
||||
|
||||
} /* namespace Swagger */
|
||||
}
|
||||
} /* namespace Swagger */
|
||||
|
@ -7,15 +7,14 @@
|
||||
#include "SWGOrder.h"
|
||||
#include <QString>
|
||||
|
||||
#include
|
||||
<QObject>
|
||||
#include <QObject>
|
||||
|
||||
namespace Swagger {
|
||||
namespace Swagger {
|
||||
|
||||
class SWGStoreApi: public QObject {
|
||||
class SWGStoreApi: public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
public:
|
||||
SWGStoreApi();
|
||||
SWGStoreApi(QString host, QString basePath);
|
||||
~SWGStoreApi();
|
||||
@ -28,18 +27,18 @@
|
||||
void getOrderById(QString* orderId);
|
||||
void deleteOrder(QString* orderId);
|
||||
|
||||
private:
|
||||
private:
|
||||
void getInventoryCallback (HttpRequestWorker * worker);
|
||||
void placeOrderCallback (HttpRequestWorker * worker);
|
||||
void getOrderByIdCallback (HttpRequestWorker * worker);
|
||||
void deleteOrderCallback (HttpRequestWorker * worker);
|
||||
|
||||
signals:
|
||||
signals:
|
||||
void getInventorySignal(QMap<QString, qint32>* summary);
|
||||
void placeOrderSignal(SWGOrder* summary);
|
||||
void getOrderByIdSignal(SWGOrder* summary);
|
||||
void deleteOrderSignal();
|
||||
|
||||
};
|
||||
}
|
||||
#endif
|
||||
};
|
||||
}
|
||||
#endif
|
@ -1,77 +1,73 @@
|
||||
|
||||
#include "SWGTag.h"
|
||||
#include "SWGTag.h"
|
||||
|
||||
#include "SWGHelpers.h"
|
||||
#include "SWGHelpers.h"
|
||||
|
||||
#include
|
||||
<QJsonDocument>
|
||||
#include
|
||||
<QJsonArray>
|
||||
#include
|
||||
<QObject>
|
||||
#include
|
||||
<QDebug>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonArray>
|
||||
#include <QObject>
|
||||
#include <QDebug>
|
||||
|
||||
namespace Swagger {
|
||||
namespace Swagger {
|
||||
|
||||
|
||||
SWGTag::SWGTag(QString* json) {
|
||||
SWGTag::SWGTag(QString* json) {
|
||||
init();
|
||||
this->fromJson(*json);
|
||||
}
|
||||
}
|
||||
|
||||
SWGTag::SWGTag() {
|
||||
SWGTag::SWGTag() {
|
||||
init();
|
||||
}
|
||||
}
|
||||
|
||||
SWGTag::~SWGTag() {
|
||||
SWGTag::~SWGTag() {
|
||||
this->cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SWGTag::init() {
|
||||
void
|
||||
SWGTag::init() {
|
||||
id = 0L;
|
||||
name = new QString("");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SWGTag::cleanup() {
|
||||
void
|
||||
SWGTag::cleanup() {
|
||||
|
||||
if(name != NULL) {
|
||||
delete name;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
SWGTag*
|
||||
SWGTag::fromJson(QString &json) {
|
||||
SWGTag*
|
||||
SWGTag::fromJson(QString &json) {
|
||||
QByteArray array (json.toStdString().c_str());
|
||||
QJsonDocument doc = QJsonDocument::fromJson(array);
|
||||
QJsonObject jsonObject = doc.object();
|
||||
this->fromJsonObject(jsonObject);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SWGTag::fromJsonObject(QJsonObject &pJson) {
|
||||
void
|
||||
SWGTag::fromJsonObject(QJsonObject &pJson) {
|
||||
setValue(&id, pJson["id"], "qint64", "");
|
||||
setValue(&name, pJson["name"], "QString", "QString");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
QString
|
||||
SWGTag::asJson ()
|
||||
{
|
||||
QString
|
||||
SWGTag::asJson ()
|
||||
{
|
||||
QJsonObject* obj = this->asJsonObject();
|
||||
|
||||
QJsonDocument doc(*obj);
|
||||
QByteArray bytes = doc.toJson();
|
||||
return QString(bytes);
|
||||
}
|
||||
}
|
||||
|
||||
QJsonObject*
|
||||
SWGTag::asJsonObject() {
|
||||
QJsonObject*
|
||||
SWGTag::asJsonObject() {
|
||||
QJsonObject* obj = new QJsonObject();
|
||||
obj->insert("id", QJsonValue(id));
|
||||
|
||||
@ -83,30 +79,27 @@
|
||||
|
||||
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
qint64
|
||||
SWGTag::getId() {
|
||||
qint64
|
||||
SWGTag::getId() {
|
||||
return id;
|
||||
}
|
||||
void
|
||||
SWGTag::setId(qint64 id) {
|
||||
}
|
||||
void
|
||||
SWGTag::setId(qint64 id) {
|
||||
this->id = id;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QString*
|
||||
SWGTag::getName() {
|
||||
QString*
|
||||
SWGTag::getName() {
|
||||
return name;
|
||||
}
|
||||
void
|
||||
SWGTag::setName(QString* name) {
|
||||
}
|
||||
void
|
||||
SWGTag::setName(QString* name) {
|
||||
this->name = name;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} /* namespace Swagger */
|
||||
} /* namespace Swagger */
|
||||
|
||||
|
@ -1,25 +1,24 @@
|
||||
/*
|
||||
* SWGTag.h
|
||||
*
|
||||
*
|
||||
*/
|
||||
* SWGTag.h
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SWGTag_H_
|
||||
#define SWGTag_H_
|
||||
|
||||
#include
|
||||
<QJsonObject>
|
||||
#include <QJsonObject>
|
||||
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "SWGObject.h"
|
||||
#include "SWGObject.h"
|
||||
|
||||
|
||||
namespace Swagger {
|
||||
namespace Swagger {
|
||||
|
||||
class SWGTag: public SWGObject {
|
||||
public:
|
||||
class SWGTag: public SWGObject {
|
||||
public:
|
||||
SWGTag();
|
||||
SWGTag(QString* json);
|
||||
virtual ~SWGTag();
|
||||
@ -37,12 +36,12 @@
|
||||
void setName(QString* name);
|
||||
|
||||
|
||||
private:
|
||||
private:
|
||||
qint64 id;
|
||||
QString* name;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
} /* namespace Swagger */
|
||||
} /* namespace Swagger */
|
||||
|
||||
#endif /* SWGTag_H_ */
|
||||
#endif /* SWGTag_H_ */
|
||||
|
@ -1,35 +1,31 @@
|
||||
|
||||
#include "SWGUser.h"
|
||||
#include "SWGUser.h"
|
||||
|
||||
#include "SWGHelpers.h"
|
||||
#include "SWGHelpers.h"
|
||||
|
||||
#include
|
||||
<QJsonDocument>
|
||||
#include
|
||||
<QJsonArray>
|
||||
#include
|
||||
<QObject>
|
||||
#include
|
||||
<QDebug>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonArray>
|
||||
#include <QObject>
|
||||
#include <QDebug>
|
||||
|
||||
namespace Swagger {
|
||||
namespace Swagger {
|
||||
|
||||
|
||||
SWGUser::SWGUser(QString* json) {
|
||||
SWGUser::SWGUser(QString* json) {
|
||||
init();
|
||||
this->fromJson(*json);
|
||||
}
|
||||
}
|
||||
|
||||
SWGUser::SWGUser() {
|
||||
SWGUser::SWGUser() {
|
||||
init();
|
||||
}
|
||||
}
|
||||
|
||||
SWGUser::~SWGUser() {
|
||||
SWGUser::~SWGUser() {
|
||||
this->cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SWGUser::init() {
|
||||
void
|
||||
SWGUser::init() {
|
||||
id = 0L;
|
||||
username = new QString("");
|
||||
firstName = new QString("");
|
||||
@ -39,10 +35,10 @@
|
||||
phone = new QString("");
|
||||
userStatus = 0;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SWGUser::cleanup() {
|
||||
void
|
||||
SWGUser::cleanup() {
|
||||
|
||||
if(username != NULL) {
|
||||
delete username;
|
||||
@ -64,19 +60,19 @@
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
SWGUser*
|
||||
SWGUser::fromJson(QString &json) {
|
||||
SWGUser*
|
||||
SWGUser::fromJson(QString &json) {
|
||||
QByteArray array (json.toStdString().c_str());
|
||||
QJsonDocument doc = QJsonDocument::fromJson(array);
|
||||
QJsonObject jsonObject = doc.object();
|
||||
this->fromJsonObject(jsonObject);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SWGUser::fromJsonObject(QJsonObject &pJson) {
|
||||
void
|
||||
SWGUser::fromJsonObject(QJsonObject &pJson) {
|
||||
setValue(&id, pJson["id"], "qint64", "");
|
||||
setValue(&username, pJson["username"], "QString", "QString");
|
||||
setValue(&firstName, pJson["firstName"], "QString", "QString");
|
||||
@ -86,20 +82,20 @@
|
||||
setValue(&phone, pJson["phone"], "QString", "QString");
|
||||
setValue(&userStatus, pJson["userStatus"], "qint32", "");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
QString
|
||||
SWGUser::asJson ()
|
||||
{
|
||||
QString
|
||||
SWGUser::asJson ()
|
||||
{
|
||||
QJsonObject* obj = this->asJsonObject();
|
||||
|
||||
QJsonDocument doc(*obj);
|
||||
QByteArray bytes = doc.toJson();
|
||||
return QString(bytes);
|
||||
}
|
||||
}
|
||||
|
||||
QJsonObject*
|
||||
SWGUser::asJsonObject() {
|
||||
QJsonObject*
|
||||
SWGUser::asJsonObject() {
|
||||
QJsonObject* obj = new QJsonObject();
|
||||
obj->insert("id", QJsonValue(id));
|
||||
|
||||
@ -142,90 +138,81 @@
|
||||
|
||||
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
qint64
|
||||
SWGUser::getId() {
|
||||
qint64
|
||||
SWGUser::getId() {
|
||||
return id;
|
||||
}
|
||||
void
|
||||
SWGUser::setId(qint64 id) {
|
||||
}
|
||||
void
|
||||
SWGUser::setId(qint64 id) {
|
||||
this->id = id;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QString*
|
||||
SWGUser::getUsername() {
|
||||
QString*
|
||||
SWGUser::getUsername() {
|
||||
return username;
|
||||
}
|
||||
void
|
||||
SWGUser::setUsername(QString* username) {
|
||||
}
|
||||
void
|
||||
SWGUser::setUsername(QString* username) {
|
||||
this->username = username;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QString*
|
||||
SWGUser::getFirstName() {
|
||||
QString*
|
||||
SWGUser::getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
void
|
||||
SWGUser::setFirstName(QString* firstName) {
|
||||
}
|
||||
void
|
||||
SWGUser::setFirstName(QString* firstName) {
|
||||
this->firstName = firstName;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QString*
|
||||
SWGUser::getLastName() {
|
||||
QString*
|
||||
SWGUser::getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
void
|
||||
SWGUser::setLastName(QString* lastName) {
|
||||
}
|
||||
void
|
||||
SWGUser::setLastName(QString* lastName) {
|
||||
this->lastName = lastName;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QString*
|
||||
SWGUser::getEmail() {
|
||||
QString*
|
||||
SWGUser::getEmail() {
|
||||
return email;
|
||||
}
|
||||
void
|
||||
SWGUser::setEmail(QString* email) {
|
||||
}
|
||||
void
|
||||
SWGUser::setEmail(QString* email) {
|
||||
this->email = email;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QString*
|
||||
SWGUser::getPassword() {
|
||||
QString*
|
||||
SWGUser::getPassword() {
|
||||
return password;
|
||||
}
|
||||
void
|
||||
SWGUser::setPassword(QString* password) {
|
||||
}
|
||||
void
|
||||
SWGUser::setPassword(QString* password) {
|
||||
this->password = password;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QString*
|
||||
SWGUser::getPhone() {
|
||||
QString*
|
||||
SWGUser::getPhone() {
|
||||
return phone;
|
||||
}
|
||||
void
|
||||
SWGUser::setPhone(QString* phone) {
|
||||
}
|
||||
void
|
||||
SWGUser::setPhone(QString* phone) {
|
||||
this->phone = phone;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
qint32
|
||||
SWGUser::getUserStatus() {
|
||||
qint32
|
||||
SWGUser::getUserStatus() {
|
||||
return userStatus;
|
||||
}
|
||||
void
|
||||
SWGUser::setUserStatus(qint32 userStatus) {
|
||||
}
|
||||
void
|
||||
SWGUser::setUserStatus(qint32 userStatus) {
|
||||
this->userStatus = userStatus;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} /* namespace Swagger */
|
||||
} /* namespace Swagger */
|
||||
|
||||
|
@ -1,25 +1,24 @@
|
||||
/*
|
||||
* SWGUser.h
|
||||
*
|
||||
*
|
||||
*/
|
||||
* SWGUser.h
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SWGUser_H_
|
||||
#define SWGUser_H_
|
||||
|
||||
#include
|
||||
<QJsonObject>
|
||||
#include <QJsonObject>
|
||||
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "SWGObject.h"
|
||||
#include "SWGObject.h"
|
||||
|
||||
|
||||
namespace Swagger {
|
||||
namespace Swagger {
|
||||
|
||||
class SWGUser: public SWGObject {
|
||||
public:
|
||||
class SWGUser: public SWGObject {
|
||||
public:
|
||||
SWGUser();
|
||||
SWGUser(QString* json);
|
||||
virtual ~SWGUser();
|
||||
@ -49,7 +48,7 @@
|
||||
void setUserStatus(qint32 userStatus);
|
||||
|
||||
|
||||
private:
|
||||
private:
|
||||
qint64 id;
|
||||
QString* username;
|
||||
QString* firstName;
|
||||
@ -59,8 +58,8 @@
|
||||
QString* phone;
|
||||
qint32 userStatus;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
} /* namespace Swagger */
|
||||
} /* namespace Swagger */
|
||||
|
||||
#endif /* SWGUser_H_ */
|
||||
#endif /* SWGUser_H_ */
|
||||
|
@ -2,25 +2,21 @@
|
||||
#include "SWGHelpers.h"
|
||||
#include "SWGModelFactory.h"
|
||||
|
||||
#include
|
||||
<QJsonArray>
|
||||
#include
|
||||
<QJsonDocument>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
|
||||
namespace Swagger {
|
||||
SWGUserApi::SWGUserApi() {}
|
||||
namespace Swagger {
|
||||
SWGUserApi::SWGUserApi() {}
|
||||
|
||||
SWGUserApi::~SWGUserApi() {}
|
||||
SWGUserApi::~SWGUserApi() {}
|
||||
|
||||
SWGUserApi::SWGUserApi(QString host, QString basePath) {
|
||||
SWGUserApi::SWGUserApi(QString host, QString basePath) {
|
||||
this->host = host;
|
||||
this->basePath = basePath;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
SWGUserApi::createUser(SWGUser body) {
|
||||
void
|
||||
SWGUserApi::createUser(SWGUser body) {
|
||||
QString fullPath;
|
||||
fullPath.append(this->host).append(this->basePath).append("/user");
|
||||
|
||||
@ -48,10 +44,10 @@
|
||||
&SWGUserApi::createUserCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SWGUserApi::createUserCallback(HttpRequestWorker * worker) {
|
||||
void
|
||||
SWGUserApi::createUserCallback(HttpRequestWorker * worker) {
|
||||
QString msg;
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
@ -66,10 +62,9 @@
|
||||
|
||||
|
||||
emit createUserSignal();
|
||||
}
|
||||
|
||||
void
|
||||
SWGUserApi::createUsersWithArrayInput(QList<SWGUser*>* body) {
|
||||
}
|
||||
void
|
||||
SWGUserApi::createUsersWithArrayInput(QList<SWGUser*>* body) {
|
||||
QString fullPath;
|
||||
fullPath.append(this->host).append(this->basePath).append("/user/createWithArray");
|
||||
|
||||
@ -85,9 +80,7 @@
|
||||
|
||||
|
||||
QJsonArray* bodyArray = new QJsonArray();
|
||||
toJsonArray((QList
|
||||
<void
|
||||
*>*)body, bodyArray, QString("body"), QString("SWGUser*"));
|
||||
toJsonArray((QList<void*>*)body, bodyArray, QString("body"), QString("SWGUser*"));
|
||||
|
||||
QJsonDocument doc(*bodyArray);
|
||||
QByteArray bytes = doc.toJson();
|
||||
@ -104,10 +97,10 @@
|
||||
&SWGUserApi::createUsersWithArrayInputCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SWGUserApi::createUsersWithArrayInputCallback(HttpRequestWorker * worker) {
|
||||
void
|
||||
SWGUserApi::createUsersWithArrayInputCallback(HttpRequestWorker * worker) {
|
||||
QString msg;
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
@ -122,10 +115,9 @@
|
||||
|
||||
|
||||
emit createUsersWithArrayInputSignal();
|
||||
}
|
||||
|
||||
void
|
||||
SWGUserApi::createUsersWithListInput(QList<SWGUser*>* body) {
|
||||
}
|
||||
void
|
||||
SWGUserApi::createUsersWithListInput(QList<SWGUser*>* body) {
|
||||
QString fullPath;
|
||||
fullPath.append(this->host).append(this->basePath).append("/user/createWithList");
|
||||
|
||||
@ -141,9 +133,7 @@
|
||||
|
||||
|
||||
QJsonArray* bodyArray = new QJsonArray();
|
||||
toJsonArray((QList
|
||||
<void
|
||||
*>*)body, bodyArray, QString("body"), QString("SWGUser*"));
|
||||
toJsonArray((QList<void*>*)body, bodyArray, QString("body"), QString("SWGUser*"));
|
||||
|
||||
QJsonDocument doc(*bodyArray);
|
||||
QByteArray bytes = doc.toJson();
|
||||
@ -160,10 +150,10 @@
|
||||
&SWGUserApi::createUsersWithListInputCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SWGUserApi::createUsersWithListInputCallback(HttpRequestWorker * worker) {
|
||||
void
|
||||
SWGUserApi::createUsersWithListInputCallback(HttpRequestWorker * worker) {
|
||||
QString msg;
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
@ -178,11 +168,9 @@
|
||||
|
||||
|
||||
emit createUsersWithListInputSignal();
|
||||
}
|
||||
|
||||
void
|
||||
SWGUserApi::loginUser(QString* username
|
||||
, QString* password) {
|
||||
}
|
||||
void
|
||||
SWGUserApi::loginUser(QString* username, QString* password) {
|
||||
QString fullPath;
|
||||
fullPath.append(this->host).append(this->basePath).append("/user/login");
|
||||
|
||||
@ -229,10 +217,10 @@
|
||||
&SWGUserApi::loginUserCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SWGUserApi::loginUserCallback(HttpRequestWorker * worker) {
|
||||
void
|
||||
SWGUserApi::loginUserCallback(HttpRequestWorker * worker) {
|
||||
QString msg;
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
@ -247,8 +235,7 @@
|
||||
|
||||
|
||||
QString json(worker->response);
|
||||
QString* output = static_cast<QString*>(create(json,
|
||||
QString("QString")));
|
||||
QString* output = static_cast<QString*>(create(json, QString("QString")));
|
||||
|
||||
|
||||
|
||||
@ -257,10 +244,9 @@
|
||||
|
||||
emit loginUserSignal(output);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
SWGUserApi::logoutUser() {
|
||||
}
|
||||
void
|
||||
SWGUserApi::logoutUser() {
|
||||
QString fullPath;
|
||||
fullPath.append(this->host).append(this->basePath).append("/user/logout");
|
||||
|
||||
@ -283,10 +269,10 @@
|
||||
&SWGUserApi::logoutUserCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SWGUserApi::logoutUserCallback(HttpRequestWorker * worker) {
|
||||
void
|
||||
SWGUserApi::logoutUserCallback(HttpRequestWorker * worker) {
|
||||
QString msg;
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
@ -301,10 +287,9 @@
|
||||
|
||||
|
||||
emit logoutUserSignal();
|
||||
}
|
||||
|
||||
void
|
||||
SWGUserApi::getUserByName(QString* username) {
|
||||
}
|
||||
void
|
||||
SWGUserApi::getUserByName(QString* username) {
|
||||
QString fullPath;
|
||||
fullPath.append(this->host).append(this->basePath).append("/user/{username}");
|
||||
|
||||
@ -330,10 +315,10 @@
|
||||
&SWGUserApi::getUserByNameCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SWGUserApi::getUserByNameCallback(HttpRequestWorker * worker) {
|
||||
void
|
||||
SWGUserApi::getUserByNameCallback(HttpRequestWorker * worker) {
|
||||
QString msg;
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
@ -348,8 +333,7 @@
|
||||
|
||||
|
||||
QString json(worker->response);
|
||||
SWGUser* output = static_cast<SWGUser*>(create(json,
|
||||
QString("SWGUser")));
|
||||
SWGUser* output = static_cast<SWGUser*>(create(json, QString("SWGUser")));
|
||||
|
||||
|
||||
|
||||
@ -358,11 +342,9 @@
|
||||
|
||||
emit getUserByNameSignal(output);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
SWGUserApi::updateUser(QString* username
|
||||
, SWGUser body) {
|
||||
}
|
||||
void
|
||||
SWGUserApi::updateUser(QString* username, SWGUser body) {
|
||||
QString fullPath;
|
||||
fullPath.append(this->host).append(this->basePath).append("/user/{username}");
|
||||
|
||||
@ -393,10 +375,10 @@
|
||||
&SWGUserApi::updateUserCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SWGUserApi::updateUserCallback(HttpRequestWorker * worker) {
|
||||
void
|
||||
SWGUserApi::updateUserCallback(HttpRequestWorker * worker) {
|
||||
QString msg;
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
@ -411,10 +393,9 @@
|
||||
|
||||
|
||||
emit updateUserSignal();
|
||||
}
|
||||
|
||||
void
|
||||
SWGUserApi::deleteUser(QString* username) {
|
||||
}
|
||||
void
|
||||
SWGUserApi::deleteUser(QString* username) {
|
||||
QString fullPath;
|
||||
fullPath.append(this->host).append(this->basePath).append("/user/{username}");
|
||||
|
||||
@ -440,10 +421,10 @@
|
||||
&SWGUserApi::deleteUserCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SWGUserApi::deleteUserCallback(HttpRequestWorker * worker) {
|
||||
void
|
||||
SWGUserApi::deleteUserCallback(HttpRequestWorker * worker) {
|
||||
QString msg;
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
@ -458,7 +439,5 @@
|
||||
|
||||
|
||||
emit deleteUserSignal();
|
||||
}
|
||||
|
||||
|
||||
} /* namespace Swagger */
|
||||
}
|
||||
} /* namespace Swagger */
|
||||
|
@ -7,15 +7,14 @@
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
|
||||
#include
|
||||
<QObject>
|
||||
#include <QObject>
|
||||
|
||||
namespace Swagger {
|
||||
namespace Swagger {
|
||||
|
||||
class SWGUserApi: public QObject {
|
||||
class SWGUserApi: public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
public:
|
||||
SWGUserApi();
|
||||
SWGUserApi(QString host, QString basePath);
|
||||
~SWGUserApi();
|
||||
@ -26,15 +25,13 @@
|
||||
void createUser(SWGUser body);
|
||||
void createUsersWithArrayInput(QList<SWGUser*>* body);
|
||||
void createUsersWithListInput(QList<SWGUser*>* body);
|
||||
void loginUser(QString* username
|
||||
, QString* password);
|
||||
void loginUser(QString* username, QString* password);
|
||||
void logoutUser();
|
||||
void getUserByName(QString* username);
|
||||
void updateUser(QString* username
|
||||
, SWGUser body);
|
||||
void updateUser(QString* username, SWGUser body);
|
||||
void deleteUser(QString* username);
|
||||
|
||||
private:
|
||||
private:
|
||||
void createUserCallback (HttpRequestWorker * worker);
|
||||
void createUsersWithArrayInputCallback (HttpRequestWorker * worker);
|
||||
void createUsersWithListInputCallback (HttpRequestWorker * worker);
|
||||
@ -44,7 +41,7 @@
|
||||
void updateUserCallback (HttpRequestWorker * worker);
|
||||
void deleteUserCallback (HttpRequestWorker * worker);
|
||||
|
||||
signals:
|
||||
signals:
|
||||
void createUserSignal();
|
||||
void createUsersWithArrayInputSignal();
|
||||
void createUsersWithListInputSignal();
|
||||
@ -54,6 +51,6 @@
|
||||
void updateUserSignal();
|
||||
void deleteUserSignal();
|
||||
|
||||
};
|
||||
}
|
||||
#endif
|
||||
};
|
||||
}
|
||||
#endif
|
@ -77,8 +77,7 @@
|
||||
</goals>
|
||||
<configuration>
|
||||
<sources>
|
||||
<source>
|
||||
src/main/java</source>
|
||||
<source>src/main/java</source>
|
||||
</sources>
|
||||
</configuration>
|
||||
</execution>
|
||||
@ -90,8 +89,7 @@
|
||||
</goals>
|
||||
<configuration>
|
||||
<sources>
|
||||
<source>
|
||||
src/test/java</source>
|
||||
<source>src/test/java</source>
|
||||
</sources>
|
||||
</configuration>
|
||||
</execution>
|
||||
@ -102,8 +100,7 @@
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>2.3.2</version>
|
||||
<configuration>
|
||||
<source>
|
||||
1.6</source>
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
@ -6,10 +6,10 @@ import retrofit.RestAdapter;
|
||||
import retrofit.converter.GsonConverter;
|
||||
|
||||
public class ServiceGenerator {
|
||||
// No need to instantiate this class.
|
||||
private ServiceGenerator() { }
|
||||
// No need to instantiate this class.
|
||||
private ServiceGenerator() { }
|
||||
|
||||
public static <S> S createService(Class<S> serviceClass) {
|
||||
public static <S> S createService(Class<S> serviceClass) {
|
||||
Gson gson = new GsonBuilder()
|
||||
.setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ")
|
||||
.create();
|
||||
@ -20,4 +20,4 @@ public static <S> S createService(Class<S> serviceClass) {
|
||||
|
||||
return adapter.create(serviceClass);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ import java.util.*;
|
||||
import io.swagger.client.model.Pet;
|
||||
import java.io.File;
|
||||
|
||||
public interface PetApi {
|
||||
public interface PetApi {
|
||||
|
||||
/**
|
||||
* Update an existing pet
|
||||
@ -114,4 +114,4 @@ import java.io.File;
|
||||
@Path("petId") Long petId,@Part("additionalMetadata") String additionalMetadata,@Part("file") TypedFile file
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ import java.util.*;
|
||||
import java.util.Map;
|
||||
import io.swagger.client.model.Order;
|
||||
|
||||
public interface StoreApi {
|
||||
public interface StoreApi {
|
||||
|
||||
/**
|
||||
* Returns pet inventories by status
|
||||
@ -57,4 +57,4 @@ import io.swagger.client.model.Order;
|
||||
@Path("orderId") String orderId
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ import java.util.*;
|
||||
import io.swagger.client.model.User;
|
||||
import java.util.*;
|
||||
|
||||
public interface UserApi {
|
||||
public interface UserApi {
|
||||
|
||||
/**
|
||||
* Create user
|
||||
@ -107,4 +107,4 @@ import java.util.*;
|
||||
@Path("username") String username
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -5,8 +5,8 @@ import io.swagger.annotations.*;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
|
||||
@ApiModel(description = "")
|
||||
public class Category {
|
||||
@ApiModel(description = "")
|
||||
public class Category {
|
||||
|
||||
|
||||
/**
|
||||
@ -46,5 +46,4 @@ import com.google.gson.annotations.SerializedName;
|
||||
sb.append("}\n");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,8 +6,8 @@ import io.swagger.annotations.*;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
|
||||
@ApiModel(description = "")
|
||||
public class Order {
|
||||
@ApiModel(description = "")
|
||||
public class Order {
|
||||
|
||||
|
||||
/**
|
||||
@ -107,5 +107,4 @@ import com.google.gson.annotations.SerializedName;
|
||||
sb.append("}\n");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,15 +1,15 @@
|
||||
package io.swagger.client.model;
|
||||
|
||||
import io.swagger.client.model.Category;
|
||||
import io.swagger.client.model.Tag;
|
||||
import java.util.*;
|
||||
import io.swagger.client.model.Tag;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
|
||||
@ApiModel(description = "")
|
||||
public class Pet {
|
||||
@ApiModel(description = "")
|
||||
public class Pet {
|
||||
|
||||
|
||||
/**
|
||||
@ -109,5 +109,4 @@ import com.google.gson.annotations.SerializedName;
|
||||
sb.append("}\n");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,8 +5,8 @@ import io.swagger.annotations.*;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
|
||||
@ApiModel(description = "")
|
||||
public class Tag {
|
||||
@ApiModel(description = "")
|
||||
public class Tag {
|
||||
|
||||
|
||||
/**
|
||||
@ -46,5 +46,4 @@ import com.google.gson.annotations.SerializedName;
|
||||
sb.append("}\n");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,8 +5,8 @@ import io.swagger.annotations.*;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
|
||||
@ApiModel(description = "")
|
||||
public class User {
|
||||
@ApiModel(description = "")
|
||||
public class User {
|
||||
|
||||
|
||||
/**
|
||||
@ -131,5 +131,4 @@ import com.google.gson.annotations.SerializedName;
|
||||
sb.append("}\n");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -16,8 +16,8 @@ require 'swagger_client/models/order'
|
||||
|
||||
# APIs
|
||||
require 'swagger_client/api/user_api'
|
||||
require 'swagger_client/api/pet_api'
|
||||
require 'swagger_client/api/store_api'
|
||||
require 'swagger_client/api/pet_api'
|
||||
|
||||
module SwaggerClient
|
||||
# Initialize the default configuration
|
||||
|
@ -190,7 +190,7 @@ module SwaggerClient
|
||||
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
|
||||
obj = Pet.new() and obj.build_from_hash(response)
|
||||
end
|
||||
|
@ -81,8 +81,7 @@
|
||||
</goals>
|
||||
<configuration>
|
||||
<sources>
|
||||
<source>
|
||||
src/main/java</source>
|
||||
<source>src/main/java</source>
|
||||
</sources>
|
||||
</configuration>
|
||||
</execution>
|
||||
@ -94,8 +93,7 @@
|
||||
</goals>
|
||||
<configuration>
|
||||
<sources>
|
||||
<source>
|
||||
src/test/java</source>
|
||||
<source>src/test/java</source>
|
||||
</sources>
|
||||
</configuration>
|
||||
</execution>
|
||||
@ -106,8 +104,7 @@
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>2.3.2</version>
|
||||
<configuration>
|
||||
<source>
|
||||
1.6</source>
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
@ -25,179 +25,179 @@ import com.fasterxml.jackson.annotation._
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize
|
||||
|
||||
object ScalaJsonUtil {
|
||||
def getJsonMapper = {
|
||||
val mapper = new ObjectMapper()
|
||||
mapper.registerModule(new DefaultScalaModule())
|
||||
mapper.registerModule(new JodaModule());
|
||||
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
mapper.setSerializationInclusion(JsonInclude.Include.NON_DEFAULT)
|
||||
mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false)
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
|
||||
mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY)
|
||||
mapper
|
||||
}
|
||||
def getJsonMapper = {
|
||||
val mapper = new ObjectMapper()
|
||||
mapper.registerModule(new DefaultScalaModule())
|
||||
mapper.registerModule(new JodaModule());
|
||||
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
mapper.setSerializationInclusion(JsonInclude.Include.NON_DEFAULT)
|
||||
mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false)
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
|
||||
mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY)
|
||||
mapper
|
||||
}
|
||||
}
|
||||
|
||||
class ApiInvoker(val mapper: ObjectMapper = ScalaJsonUtil.getJsonMapper,
|
||||
httpHeaders: HashMap[String, String] = HashMap(),
|
||||
hostMap: HashMap[String, Client] = HashMap(),
|
||||
asyncHttpClient: Boolean = false,
|
||||
authScheme: String = "",
|
||||
authPreemptive: Boolean = false) {
|
||||
httpHeaders: HashMap[String, String] = HashMap(),
|
||||
hostMap: HashMap[String, Client] = HashMap(),
|
||||
asyncHttpClient: Boolean = false,
|
||||
authScheme: String = "",
|
||||
authPreemptive: Boolean = false) {
|
||||
|
||||
var defaultHeaders: HashMap[String, String] = httpHeaders
|
||||
var defaultHeaders: HashMap[String, String] = httpHeaders
|
||||
|
||||
def escape(value: String): String = {
|
||||
URLEncoder.encode(value, "utf-8").replaceAll("\\+", "%20")
|
||||
}
|
||||
def escape(value: String): String = {
|
||||
URLEncoder.encode(value, "utf-8").replaceAll("\\+", "%20")
|
||||
}
|
||||
|
||||
def escape(value: Long): String = value.toString
|
||||
def escape(value: Double): String = value.toString
|
||||
def escape(value: Float): String = value.toString
|
||||
def escape(value: Long): String = value.toString
|
||||
def escape(value: Double): String = value.toString
|
||||
def escape(value: Float): String = value.toString
|
||||
|
||||
def deserialize(json: String, containerType: String, cls: Class[_]) = {
|
||||
if (cls == classOf[String]) {
|
||||
json match {
|
||||
case s: String => {
|
||||
if (s.startsWith("\"") && s.endsWith("\"") && s.length > 1) s.substring(1, s.length - 2)
|
||||
else s
|
||||
}
|
||||
case _ => null
|
||||
}
|
||||
} else {
|
||||
containerType.toLowerCase match {
|
||||
case "array" => {
|
||||
val typeInfo = mapper.getTypeFactory().constructCollectionType(classOf[java.util.List[_]], cls)
|
||||
val response = mapper.readValue(json, typeInfo).asInstanceOf[java.util.List[_]]
|
||||
response.asScala.toList
|
||||
}
|
||||
case "list" => {
|
||||
val typeInfo = mapper.getTypeFactory().constructCollectionType(classOf[java.util.List[_]], cls)
|
||||
val response = mapper.readValue(json, typeInfo).asInstanceOf[java.util.List[_]]
|
||||
response.asScala.toList
|
||||
}
|
||||
case _ => {
|
||||
json match {
|
||||
case e: String if ("\"\"" == e) => null
|
||||
case _ => mapper.readValue(json, cls)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
def deserialize(json: String, containerType: String, cls: Class[_]) = {
|
||||
if (cls == classOf[String]) {
|
||||
json match {
|
||||
case s: String => {
|
||||
if (s.startsWith("\"") && s.endsWith("\"") && s.length > 1) s.substring(1, s.length - 2)
|
||||
else s
|
||||
}
|
||||
case _ => null
|
||||
}
|
||||
} else {
|
||||
containerType.toLowerCase match {
|
||||
case "array" => {
|
||||
val typeInfo = mapper.getTypeFactory().constructCollectionType(classOf[java.util.List[_]], cls)
|
||||
val response = mapper.readValue(json, typeInfo).asInstanceOf[java.util.List[_]]
|
||||
response.asScala.toList
|
||||
}
|
||||
case "list" => {
|
||||
val typeInfo = mapper.getTypeFactory().constructCollectionType(classOf[java.util.List[_]], cls)
|
||||
val response = mapper.readValue(json, typeInfo).asInstanceOf[java.util.List[_]]
|
||||
response.asScala.toList
|
||||
}
|
||||
case _ => {
|
||||
json match {
|
||||
case e: String if ("\"\"" == e) => null
|
||||
case _ => mapper.readValue(json, cls)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def serialize(obj: AnyRef): String = {
|
||||
if (obj != null) {
|
||||
obj match {
|
||||
case e: List[_] => mapper.writeValueAsString(obj.asInstanceOf[List[_]].asJava)
|
||||
case _ => mapper.writeValueAsString(obj)
|
||||
}
|
||||
} else null
|
||||
}
|
||||
def serialize(obj: AnyRef): String = {
|
||||
if (obj != null) {
|
||||
obj match {
|
||||
case e: List[_] => mapper.writeValueAsString(obj.asInstanceOf[List[_]].asJava)
|
||||
case _ => mapper.writeValueAsString(obj)
|
||||
}
|
||||
} 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 = {
|
||||
val client = getClient(host)
|
||||
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 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)
|
||||
headerParams.map(p => builder.header(p._1, p._2))
|
||||
defaultHeaders.map(p => {
|
||||
headerParams.contains(p._1) match {
|
||||
case true => // override default with supplied header
|
||||
case false => if (p._2 != null) builder.header(p._1, p._2)
|
||||
}
|
||||
})
|
||||
var formData: MultivaluedMapImpl = null
|
||||
if(contentType == "application/x-www-form-urlencoded") {
|
||||
formData = new MultivaluedMapImpl()
|
||||
formParams.map(p => formData.add(p._1, p._2))
|
||||
}
|
||||
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)
|
||||
headerParams.map(p => builder.header(p._1, p._2))
|
||||
defaultHeaders.map(p => {
|
||||
headerParams.contains(p._1) match {
|
||||
case true => // override default with supplied header
|
||||
case false => if (p._2 != null) builder.header(p._1, p._2)
|
||||
}
|
||||
})
|
||||
var formData: MultivaluedMapImpl = null
|
||||
if(contentType == "application/x-www-form-urlencoded") {
|
||||
formData = new MultivaluedMapImpl()
|
||||
formParams.map(p => formData.add(p._1, p._2))
|
||||
}
|
||||
|
||||
val response: ClientResponse = method match {
|
||||
case "GET" => {
|
||||
builder.get(classOf[ClientResponse]).asInstanceOf[ClientResponse]
|
||||
}
|
||||
case "POST" => {
|
||||
if(formData != null) builder.post(classOf[ClientResponse], formData)
|
||||
else if(body != null && body.isInstanceOf[File]) {
|
||||
val file = body.asInstanceOf[File]
|
||||
val form = new FormDataMultiPart()
|
||||
form.field("filename", file.getName())
|
||||
form.bodyPart(new FileDataBodyPart("file", file, MediaType.MULTIPART_FORM_DATA_TYPE))
|
||||
builder.post(classOf[ClientResponse], form)
|
||||
}
|
||||
else {
|
||||
if(body == null) builder.post(classOf[ClientResponse], serialize(body))
|
||||
else builder.`type`(contentType).post(classOf[ClientResponse], serialize(body))
|
||||
}
|
||||
}
|
||||
case "PUT" => {
|
||||
if(formData != null) builder.post(classOf[ClientResponse], formData)
|
||||
else if(body == null) builder.put(classOf[ClientResponse], null)
|
||||
else builder.`type`(contentType).put(classOf[ClientResponse], serialize(body))
|
||||
}
|
||||
case "DELETE" => {
|
||||
builder.delete(classOf[ClientResponse])
|
||||
}
|
||||
case _ => null
|
||||
}
|
||||
response.getClientResponseStatus().getStatusCode() match {
|
||||
case 204 => ""
|
||||
case code: Int if (Range(200, 299).contains(code)) => {
|
||||
response.hasEntity() match {
|
||||
case true => response.getEntity(classOf[String])
|
||||
case false => ""
|
||||
}
|
||||
}
|
||||
case _ => {
|
||||
val entity = response.hasEntity() match {
|
||||
case true => response.getEntity(classOf[String])
|
||||
case false => "no data"
|
||||
}
|
||||
throw new ApiException(
|
||||
response.getClientResponseStatus().getStatusCode(),
|
||||
entity)
|
||||
}
|
||||
}
|
||||
}
|
||||
val response: ClientResponse = method match {
|
||||
case "GET" => {
|
||||
builder.get(classOf[ClientResponse]).asInstanceOf[ClientResponse]
|
||||
}
|
||||
case "POST" => {
|
||||
if(formData != null) builder.post(classOf[ClientResponse], formData)
|
||||
else if(body != null && body.isInstanceOf[File]) {
|
||||
val file = body.asInstanceOf[File]
|
||||
val form = new FormDataMultiPart()
|
||||
form.field("filename", file.getName())
|
||||
form.bodyPart(new FileDataBodyPart("file", file, MediaType.MULTIPART_FORM_DATA_TYPE))
|
||||
builder.post(classOf[ClientResponse], form)
|
||||
}
|
||||
else {
|
||||
if(body == null) builder.post(classOf[ClientResponse], serialize(body))
|
||||
else builder.`type`(contentType).post(classOf[ClientResponse], serialize(body))
|
||||
}
|
||||
}
|
||||
case "PUT" => {
|
||||
if(formData != null) builder.post(classOf[ClientResponse], formData)
|
||||
else if(body == null) builder.put(classOf[ClientResponse], null)
|
||||
else builder.`type`(contentType).put(classOf[ClientResponse], serialize(body))
|
||||
}
|
||||
case "DELETE" => {
|
||||
builder.delete(classOf[ClientResponse])
|
||||
}
|
||||
case _ => null
|
||||
}
|
||||
response.getClientResponseStatus().getStatusCode() match {
|
||||
case 204 => ""
|
||||
case code: Int if (Range(200, 299).contains(code)) => {
|
||||
response.hasEntity() match {
|
||||
case true => response.getEntity(classOf[String])
|
||||
case false => ""
|
||||
}
|
||||
}
|
||||
case _ => {
|
||||
val entity = response.hasEntity() match {
|
||||
case true => response.getEntity(classOf[String])
|
||||
case false => "no data"
|
||||
}
|
||||
throw new ApiException(
|
||||
response.getClientResponseStatus().getStatusCode(),
|
||||
entity)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def getClient(host: String): Client = {
|
||||
hostMap.contains(host) match {
|
||||
case true => hostMap(host)
|
||||
case false => {
|
||||
val client = newClient(host)
|
||||
// client.addFilter(new LoggingFilter())
|
||||
hostMap += host -> client
|
||||
client
|
||||
}
|
||||
}
|
||||
}
|
||||
def getClient(host: String): Client = {
|
||||
hostMap.contains(host) match {
|
||||
case true => hostMap(host)
|
||||
case false => {
|
||||
val client = newClient(host)
|
||||
// client.addFilter(new LoggingFilter())
|
||||
hostMap += host -> client
|
||||
client
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def newClient(host: String): Client = asyncHttpClient match {
|
||||
case true => {
|
||||
import org.sonatype.spice.jersey.client.ahc.config.DefaultAhcConfig
|
||||
import org.sonatype.spice.jersey.client.ahc.AhcHttpClient
|
||||
import com.ning.http.client.Realm
|
||||
def newClient(host: String): Client = asyncHttpClient match {
|
||||
case true => {
|
||||
import org.sonatype.spice.jersey.client.ahc.config.DefaultAhcConfig
|
||||
import org.sonatype.spice.jersey.client.ahc.AhcHttpClient
|
||||
import com.ning.http.client.Realm
|
||||
|
||||
val config: DefaultAhcConfig = new DefaultAhcConfig()
|
||||
if (!authScheme.isEmpty) {
|
||||
val authSchemeEnum = Realm.AuthScheme.valueOf(authScheme)
|
||||
config.getAsyncHttpClientConfigBuilder
|
||||
.setRealm(new Realm.RealmBuilder().setScheme(authSchemeEnum)
|
||||
.setUsePreemptiveAuth(authPreemptive).build)
|
||||
}
|
||||
AhcHttpClient.create(config)
|
||||
}
|
||||
case _ => Client.create()
|
||||
}
|
||||
val config: DefaultAhcConfig = new DefaultAhcConfig()
|
||||
if (!authScheme.isEmpty) {
|
||||
val authSchemeEnum = Realm.AuthScheme.valueOf(authScheme)
|
||||
config.getAsyncHttpClientConfigBuilder
|
||||
.setRealm(new Realm.RealmBuilder().setScheme(authSchemeEnum)
|
||||
.setUsePreemptiveAuth(authPreemptive).build)
|
||||
}
|
||||
AhcHttpClient.create(config)
|
||||
}
|
||||
case _ => Client.create()
|
||||
}
|
||||
}
|
||||
|
||||
object ApiInvoker extends ApiInvoker(mapper = ScalaJsonUtil.getJsonMapper,
|
||||
httpHeaders = HashMap(),
|
||||
hostMap = HashMap(),
|
||||
asyncHttpClient = false,
|
||||
authScheme = "",
|
||||
authPreemptive = false)
|
||||
httpHeaders = HashMap(),
|
||||
hostMap = HashMap(),
|
||||
asyncHttpClient = false,
|
||||
authScheme = "",
|
||||
authPreemptive = false)
|
||||
|
||||
class ApiException(val code: Int, msg: String) extends RuntimeException(msg)
|
||||
|
||||
|
@ -15,7 +15,7 @@ import java.util.Date
|
||||
|
||||
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) {
|
||||
var basePath = defBasePath
|
||||
var apiInvoker = defApiInvoker
|
||||
@ -431,4 +431,4 @@ import scala.collection.mutable.HashMap
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ import java.util.Date
|
||||
|
||||
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) {
|
||||
var basePath = defBasePath
|
||||
var apiInvoker = defApiInvoker
|
||||
@ -216,4 +216,4 @@ import scala.collection.mutable.HashMap
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ import java.util.Date
|
||||
|
||||
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) {
|
||||
var basePath = defBasePath
|
||||
var apiInvoker = defApiInvoker
|
||||
@ -409,4 +409,4 @@ import scala.collection.mutable.HashMap
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -3,9 +3,7 @@ package io.swagger.client.model
|
||||
|
||||
|
||||
|
||||
|
||||
case class Category (
|
||||
case class Category (
|
||||
id: Long,
|
||||
name: String)
|
||||
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user