updated client

This commit is contained in:
Tony Tam 2015-02-12 21:54:34 -08:00
parent 2bc5e71f91
commit 20deb15c8c
26 changed files with 146 additions and 999 deletions

View File

@ -1,7 +1,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.wordnik</groupId>
<groupId>io.swagger</groupId>
<artifactId>swagger-client</artifactId>
<packaging>jar</packaging>
<name>swagger-client</name>

View File

@ -1,164 +0,0 @@
package io.swagger.client
import com.sun.jersey.api.client.Client
import com.sun.jersey.api.client.ClientResponse
import com.sun.jersey.api.client.config.ClientConfig
import com.sun.jersey.api.client.config.DefaultClientConfig
import com.sun.jersey.api.client.filter.LoggingFilter
import com.sun.jersey.multipart.FormDataMultiPart
import com.sun.jersey.multipart.file.FileDataBodyPart
import java.io.File
import java.net.URLEncoder
import javax.ws.rs.core.MediaType
import scala.collection.JavaConverters._
import scala.collection.mutable.HashMap
import com.fasterxml.jackson.module.scala.DefaultScalaModule
import com.fasterxml.jackson.core.JsonGenerator.Feature
import com.fasterxml.jackson.databind._
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.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
}
}
object ApiInvoker {
val mapper = ScalaJsonUtil.getJsonMapper
val defaultHeaders: HashMap[String, String] = HashMap()
val hostMap: HashMap[String, Client] = HashMap()
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 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 invokeApi(host: String, path: String, method: String, queryParams: 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)
}
})
val response: ClientResponse = method match {
case "GET" => {
builder.get(classOf[ClientResponse]).asInstanceOf[ClientResponse]
}
case "POST" => {
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(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 = Client.create()
// client.addFilter(new LoggingFilter())
hostMap += host -> client
client
}
}
}
}
class ApiException(val code: Int, msg: String) extends RuntimeException(msg)

View File

@ -8,6 +8,7 @@ import io.swagger.client.model.*;
import java.util.*;
import io.swagger.client.model.Pet;
import java.io.File;
import com.sun.jersey.multipart.FormDataMultiPart;
@ -18,7 +19,7 @@ import java.util.Map;
import java.util.HashMap;
public class PetApi {
String basePath = "http://petstore.swagger.wordnik.com/v2";
String basePath = "http://petstore.swagger.io/v2";
ApiInvoker apiInvoker = ApiInvoker.getInstance();
public ApiInvoker getInvoker() {
@ -171,7 +172,7 @@ public class PetApi {
try {
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType);
if(response != null){
return (List<Pet>) ApiInvoker.deserialize(response, "Pet", Pet.class);
return (List<Pet>) ApiInvoker.deserialize(response, "array", Pet.class);
}
else {
return null;
@ -223,7 +224,7 @@ public class PetApi {
try {
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType);
if(response != null){
return (List<Pet>) ApiInvoker.deserialize(response, "Pet", Pet.class);
return (List<Pet>) ApiInvoker.deserialize(response, "array", Pet.class);
}
else {
return null;
@ -400,4 +401,62 @@ public class PetApi {
}
}
public void uploadFile (String additionalMetadata, File file) throws ApiException {
Object postBody = null;
// create path and map variables
String path = "/pet/{petId}/uploadImage".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>();
String[] contentTypes = {
"multipart/form-data"
};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
FormDataMultiPart mp = new FormDataMultiPart();
hasFields = true;
mp.field("additionalMetadata", additionalMetadata, MediaType.MULTIPART_FORM_DATA_TYPE);
hasFields = true;
mp.field("file", file, MediaType.MULTIPART_FORM_DATA_TYPE);
if(hasFields)
postBody = mp;
}
else {
formParams.put("additionalMetadata", additionalMetadata);
}
try {
String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, postBody, headerParams, formParams, contentType);
if(response != null){
return ;
}
else {
return ;
}
} catch (ApiException ex) {
if(ex.getCode() == 404) {
return ;
}
else {
throw ex;
}
}
}
}

View File

@ -1,261 +0,0 @@
package io.swagger.client.api
import io.swagger.client.model.Pet
import io.swagger.client.ApiInvoker
import io.swagger.client.ApiException
import java.io.File
import java.util.Date
import scala.collection.mutable.HashMap
class PetApi {
var basePath: String = "http://petstore.swagger.wordnik.com/v2"
var apiInvoker = ApiInvoker
def addHeader(key: String, value: String) = apiInvoker.defaultHeaders += key -> value
def updatePet (body: Pet) = {
// create path and map variables
val path = "/pet".replaceAll("\\{format\\}","json")
val contentType = {
if(body != null && body.isInstanceOf[File] )
"multipart/form-data"
else "application/json"
}
// query params
val queryParams = new HashMap[String, String]
val headerParams = new HashMap[String, String]
try {
apiInvoker.invokeApi(basePath, path, "PUT", queryParams.toMap, body, headerParams.toMap, contentType) match {
case s: String =>
case _ => None
}
} catch {
case ex: ApiException if ex.code == 404 => None
case ex: ApiException => throw ex
}
}
def addPet (body: Pet) = {
// create path and map variables
val path = "/pet".replaceAll("\\{format\\}","json")
val contentType = {
if(body != null && body.isInstanceOf[File] )
"multipart/form-data"
else "application/json"
}
// query params
val queryParams = new HashMap[String, String]
val headerParams = new HashMap[String, String]
try {
apiInvoker.invokeApi(basePath, path, "POST", queryParams.toMap, body, headerParams.toMap, contentType) match {
case s: String =>
case _ => None
}
} catch {
case ex: ApiException if ex.code == 404 => None
case ex: ApiException => throw ex
}
}
def findPetsByStatus (status: List[String]) : Option[List[Pet]] = {
// create path and map variables
val path = "/pet/findByStatus".replaceAll("\\{format\\}","json")
val contentType = {
"application/json"
}
// query params
val queryParams = new HashMap[String, String]
val headerParams = new HashMap[String, String]
if(String.valueOf(status) != "null") queryParams += "status" -> status.toString
try {
apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap, contentType) match {
case s: String =>
Some(ApiInvoker.deserialize(s, "Pet", classOf[Pet]).asInstanceOf[List[Pet]])
case _ => None
}
} catch {
case ex: ApiException if ex.code == 404 => None
case ex: ApiException => throw ex
}
}
def findPetsByTags (tags: List[String]) : Option[List[Pet]] = {
// create path and map variables
val path = "/pet/findByTags".replaceAll("\\{format\\}","json")
val contentType = {
"application/json"
}
// query params
val queryParams = new HashMap[String, String]
val headerParams = new HashMap[String, String]
if(String.valueOf(tags) != "null") queryParams += "tags" -> tags.toString
try {
apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap, contentType) match {
case s: String =>
Some(ApiInvoker.deserialize(s, "Pet", classOf[Pet]).asInstanceOf[List[Pet]])
case _ => None
}
} catch {
case ex: ApiException if ex.code == 404 => None
case ex: ApiException => throw ex
}
}
def getPetById (petId: Long) : Option[Pet] = {
// create path and map variables
val path = "/pet/{petId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}",apiInvoker.escape(petId))
val contentType = {
"application/json"
}
// query params
val queryParams = new HashMap[String, String]
val headerParams = new HashMap[String, String]
try {
apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap, contentType) match {
case s: String =>
Some(ApiInvoker.deserialize(s, "", classOf[Pet]).asInstanceOf[Pet])
case _ => None
}
} catch {
case ex: ApiException if ex.code == 404 => None
case ex: ApiException => throw ex
}
}
def updatePetWithForm (petId: String, name: String, status: String) = {
// create path and map variables
val path = "/pet/{petId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}",apiInvoker.escape(petId))
val contentType = {
"application/json"
}
// query params
val queryParams = new HashMap[String, String]
val headerParams = new HashMap[String, String]
try {
apiInvoker.invokeApi(basePath, path, "POST", queryParams.toMap, None, headerParams.toMap, contentType) match {
case s: String =>
case _ => None
}
} catch {
case ex: ApiException if ex.code == 404 => None
case ex: ApiException => throw ex
}
}
def deletePet (api_key: String, petId: Long) = {
// create path and map variables
val path = "/pet/{petId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}",apiInvoker.escape(petId))
val contentType = {
"application/json"
}
// query params
val queryParams = new HashMap[String, String]
val headerParams = new HashMap[String, String]
headerParams += "api_key" -> api_key
try {
apiInvoker.invokeApi(basePath, path, "DELETE", queryParams.toMap, None, headerParams.toMap, contentType) match {
case s: String =>
case _ => None
}
} catch {
case ex: ApiException if ex.code == 404 => None
case ex: ApiException => throw ex
}
}
}

View File

@ -19,7 +19,7 @@ import java.util.Map;
import java.util.HashMap;
public class StoreApi {
String basePath = "http://petstore.swagger.wordnik.com/v2";
String basePath = "http://petstore.swagger.io/v2";
ApiInvoker apiInvoker = ApiInvoker.getInstance();
public ApiInvoker getInvoker() {
@ -70,7 +70,7 @@ public class StoreApi {
try {
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType);
if(response != null){
return (Map<String, Integer>) ApiInvoker.deserialize(response, "", Map.class);
return (Map<String, Integer>) ApiInvoker.deserialize(response, "map", Map.class);
}
else {
return null;

View File

@ -1,157 +0,0 @@
package io.swagger.client.api
import io.swagger.client.model.Order
import io.swagger.client.ApiInvoker
import io.swagger.client.ApiException
import java.io.File
import java.util.Date
import scala.collection.mutable.HashMap
class StoreApi {
var basePath: String = "http://petstore.swagger.wordnik.com/v2"
var apiInvoker = ApiInvoker
def addHeader(key: String, value: String) = apiInvoker.defaultHeaders += key -> value
def getInventory () : Option[Map[String, Integer]] = {
// create path and map variables
val path = "/store/inventory".replaceAll("\\{format\\}","json")
val contentType = {
"application/json"
}
// query params
val queryParams = new HashMap[String, String]
val headerParams = new HashMap[String, String]
try {
apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap, contentType) match {
case s: String =>
Some(ApiInvoker.deserialize(s, "Integer", classOf[Integer]).asInstanceOf[Map[String, Integer]])
case _ => None
}
} catch {
case ex: ApiException if ex.code == 404 => None
case ex: ApiException => throw ex
}
}
def placeOrder (body: Order) : Option[Order] = {
// create path and map variables
val path = "/store/order".replaceAll("\\{format\\}","json")
val contentType = {
if(body != null && body.isInstanceOf[File] )
"multipart/form-data"
else "application/json"
}
// query params
val queryParams = new HashMap[String, String]
val headerParams = new HashMap[String, String]
try {
apiInvoker.invokeApi(basePath, path, "POST", queryParams.toMap, body, headerParams.toMap, contentType) match {
case s: String =>
Some(ApiInvoker.deserialize(s, "", classOf[Order]).asInstanceOf[Order])
case _ => None
}
} catch {
case ex: ApiException if ex.code == 404 => None
case ex: ApiException => throw ex
}
}
def getOrderById (orderId: String) : Option[Order] = {
// create path and map variables
val path = "/store/order/{orderId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "orderId" + "\\}",apiInvoker.escape(orderId))
val contentType = {
"application/json"
}
// query params
val queryParams = new HashMap[String, String]
val headerParams = new HashMap[String, String]
try {
apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap, contentType) match {
case s: String =>
Some(ApiInvoker.deserialize(s, "", classOf[Order]).asInstanceOf[Order])
case _ => None
}
} catch {
case ex: ApiException if ex.code == 404 => None
case ex: ApiException => throw ex
}
}
def deleteOrder (orderId: String) = {
// create path and map variables
val path = "/store/order/{orderId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "orderId" + "\\}",apiInvoker.escape(orderId))
val contentType = {
"application/json"
}
// query params
val queryParams = new HashMap[String, String]
val headerParams = new HashMap[String, String]
try {
apiInvoker.invokeApi(basePath, path, "DELETE", queryParams.toMap, None, headerParams.toMap, contentType) match {
case s: String =>
case _ => None
}
} catch {
case ex: ApiException if ex.code == 404 => None
case ex: ApiException => throw ex
}
}
}

View File

@ -19,7 +19,7 @@ import java.util.Map;
import java.util.HashMap;
public class UserApi {
String basePath = "http://petstore.swagger.wordnik.com/v2";
String basePath = "http://petstore.swagger.io/v2";
ApiInvoker apiInvoker = ApiInvoker.getInstance();
public ApiInvoker getInvoker() {

View File

@ -1,297 +0,0 @@
package io.swagger.client.api
import io.swagger.client.model.User
import io.swagger.client.ApiInvoker
import io.swagger.client.ApiException
import java.io.File
import java.util.Date
import scala.collection.mutable.HashMap
class UserApi {
var basePath: String = "http://petstore.swagger.wordnik.com/v2"
var apiInvoker = ApiInvoker
def addHeader(key: String, value: String) = apiInvoker.defaultHeaders += key -> value
def createUser (body: User) = {
// create path and map variables
val path = "/user".replaceAll("\\{format\\}","json")
val contentType = {
if(body != null && body.isInstanceOf[File] )
"multipart/form-data"
else "application/json"
}
// query params
val queryParams = new HashMap[String, String]
val headerParams = new HashMap[String, String]
try {
apiInvoker.invokeApi(basePath, path, "POST", queryParams.toMap, body, headerParams.toMap, contentType) match {
case s: String =>
case _ => None
}
} catch {
case ex: ApiException if ex.code == 404 => None
case ex: ApiException => throw ex
}
}
def createUsersWithArrayInput (body: List[User]) = {
// create path and map variables
val path = "/user/createWithArray".replaceAll("\\{format\\}","json")
val contentType = {
if(body != null && body.isInstanceOf[File] )
"multipart/form-data"
else "application/json"
}
// query params
val queryParams = new HashMap[String, String]
val headerParams = new HashMap[String, String]
try {
apiInvoker.invokeApi(basePath, path, "POST", queryParams.toMap, body, headerParams.toMap, contentType) match {
case s: String =>
case _ => None
}
} catch {
case ex: ApiException if ex.code == 404 => None
case ex: ApiException => throw ex
}
}
def createUsersWithListInput (body: List[User]) = {
// create path and map variables
val path = "/user/createWithList".replaceAll("\\{format\\}","json")
val contentType = {
if(body != null && body.isInstanceOf[File] )
"multipart/form-data"
else "application/json"
}
// query params
val queryParams = new HashMap[String, String]
val headerParams = new HashMap[String, String]
try {
apiInvoker.invokeApi(basePath, path, "POST", queryParams.toMap, body, headerParams.toMap, contentType) match {
case s: String =>
case _ => None
}
} catch {
case ex: ApiException if ex.code == 404 => None
case ex: ApiException => throw ex
}
}
def loginUser (username: String, password: String) : Option[String] = {
// create path and map variables
val path = "/user/login".replaceAll("\\{format\\}","json")
val contentType = {
"application/json"
}
// query params
val queryParams = new HashMap[String, String]
val headerParams = new HashMap[String, String]
if(String.valueOf(username) != "null") queryParams += "username" -> username.toString
if(String.valueOf(password) != "null") queryParams += "password" -> password.toString
try {
apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap, contentType) match {
case s: String =>
Some(ApiInvoker.deserialize(s, "", classOf[String]).asInstanceOf[String])
case _ => None
}
} catch {
case ex: ApiException if ex.code == 404 => None
case ex: ApiException => throw ex
}
}
def logoutUser () = {
// create path and map variables
val path = "/user/logout".replaceAll("\\{format\\}","json")
val contentType = {
"application/json"
}
// query params
val queryParams = new HashMap[String, String]
val headerParams = new HashMap[String, String]
try {
apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap, contentType) match {
case s: String =>
case _ => None
}
} catch {
case ex: ApiException if ex.code == 404 => None
case ex: ApiException => throw ex
}
}
def getUserByName (username: String) : Option[User] = {
// create path and map variables
val path = "/user/{username}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "username" + "\\}",apiInvoker.escape(username))
val contentType = {
"application/json"
}
// query params
val queryParams = new HashMap[String, String]
val headerParams = new HashMap[String, String]
try {
apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap, contentType) match {
case s: String =>
Some(ApiInvoker.deserialize(s, "", classOf[User]).asInstanceOf[User])
case _ => None
}
} catch {
case ex: ApiException if ex.code == 404 => None
case ex: ApiException => throw ex
}
}
def updateUser (username: String, body: User) = {
// create path and map variables
val path = "/user/{username}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "username" + "\\}",apiInvoker.escape(username))
val contentType = {
if(body != null && body.isInstanceOf[File] )
"multipart/form-data"
else "application/json"
}
// query params
val queryParams = new HashMap[String, String]
val headerParams = new HashMap[String, String]
try {
apiInvoker.invokeApi(basePath, path, "PUT", queryParams.toMap, body, headerParams.toMap, contentType) match {
case s: String =>
case _ => None
}
} catch {
case ex: ApiException if ex.code == 404 => None
case ex: ApiException => throw ex
}
}
def deleteUser (username: String) = {
// create path and map variables
val path = "/user/{username}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "username" + "\\}",apiInvoker.escape(username))
val contentType = {
"application/json"
}
// query params
val queryParams = new HashMap[String, String]
val headerParams = new HashMap[String, String]
try {
apiInvoker.invokeApi(basePath, path, "DELETE", queryParams.toMap, None, headerParams.toMap, contentType) match {
case s: String =>
case _ => None
}
} catch {
case ex: ApiException if ex.code == 404 => None
case ex: ApiException => throw ex
}
}
}

View File

@ -7,10 +7,8 @@ import com.fasterxml.jackson.annotation.JsonProperty;
@ApiModel(description = "")
public class Category {
private Long id = null;
//public enum idEnum { };
private String name = null;

View File

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

View File

@ -8,20 +8,15 @@ import com.fasterxml.jackson.annotation.JsonProperty;
@ApiModel(description = "")
public class Order {
private Long id = null;
//public enum idEnum { };
private Long petId = null;
//public enum petIdEnum { };
private Integer quantity = null;
//public enum quantityEnum { };
private Date shipDate = null;
private String status = null;
public enum StatusEnum {
placed, approved, delivered,
};
private StatusEnum status = null;
private Boolean complete = null;
@ -78,10 +73,10 @@ public class Order {
**/
@ApiModelProperty(required = false, value = "Order Status")
@JsonProperty("status")
public String getStatus() {
public StatusEnum getStatus() {
return status;
}
public void setStatus(String status) {
public void setStatus(StatusEnum status) {
this.status = status;
}

View File

@ -1,15 +0,0 @@
package io.swagger.client.model
import org.joda.time.DateTime
case class Order (
id: Long,
petId: Long,
quantity: Integer,
shipDate: DateTime,
/* Order Status */
status: String,
complete: Boolean)

View File

@ -10,15 +10,16 @@ import com.fasterxml.jackson.annotation.JsonProperty;
@ApiModel(description = "")
public class Pet {
private Long id = null;
//public enum idEnum { };
private Category category = null;
private String name = null;
private List<String> photoUrls = new ArrayList<String>() ;
private List<Tag> tags = new ArrayList<Tag>() ;
private String status = null;
public enum StatusEnum {
available, pending, sold,
};
private StatusEnum status = null;
/**
@ -86,10 +87,10 @@ public class Pet {
**/
@ApiModelProperty(required = false, value = "pet status in the store")
@JsonProperty("status")
public String getStatus() {
public StatusEnum getStatus() {
return status;
}
public void setStatus(String status) {
public void setStatus(StatusEnum status) {
this.status = status;
}

View File

@ -1,16 +0,0 @@
package io.swagger.client.model
import io.swagger.client.model.Category
import io.swagger.client.model.Tag
case class Pet (
id: Long,
category: Category,
name: String,
photoUrls: List[String],
tags: List[Tag],
/* pet status in the store */
status: String)

View File

@ -7,10 +7,8 @@ import com.fasterxml.jackson.annotation.JsonProperty;
@ApiModel(description = "")
public class Tag {
private Long id = null;
//public enum idEnum { };
private String name = null;

View File

@ -1,9 +0,0 @@
package io.swagger.client.model
case class Tag (
id: Long,
name: String)

View File

@ -7,10 +7,8 @@ import com.fasterxml.jackson.annotation.JsonProperty;
@ApiModel(description = "")
public class User {
private Long id = null;
//public enum idEnum { };
private String username = null;
private String firstName = null;
private String lastName = null;
@ -19,9 +17,6 @@ public class User {
private String phone = null;
private Integer userStatus = null;
//public enum userStatusEnum { };
/**
**/

View File

@ -1,16 +0,0 @@
package io.swagger.client.model
case class User (
id: Long,
username: String,
firstName: String,
lastName: String,
email: String,
password: String,
phone: String,
/* User Status */
userStatus: Integer)

View File

@ -270,12 +270,12 @@ SamiOrder::setShipDate(DateTime* pShipDate) {
this->pShipDate = pShipDate;
}
String*
PStatusEnum
SamiOrder::getStatus() {
return pStatus;
}
void
SamiOrder::setStatus(String* pStatus) {
SamiOrder::setStatus(PStatusEnum pStatus) {
this->pStatus = pStatus;
}

View File

@ -57,8 +57,8 @@ public:
DateTime* getShipDate();
void setShipDate(DateTime* pShipDate);
String* getStatus();
void setStatus(String* pStatus);
PStatusEnum getStatus();
void setStatus(PStatusEnum pStatus);
Boolean* getComplete();
void setComplete(Boolean* pComplete);
@ -69,7 +69,7 @@ private:
Long* pPetId;
Integer* pQuantity;
DateTime* pShipDate;
String* pStatus;
PStatusEnum pStatus;
Boolean* pComplete;
};

View File

@ -279,12 +279,12 @@ SamiPet::setTags(IList* pTags) {
this->pTags = pTags;
}
String*
PStatusEnum
SamiPet::getStatus() {
return pStatus;
}
void
SamiPet::setStatus(String* pStatus) {
SamiPet::setStatus(PStatusEnum pStatus) {
this->pStatus = pStatus;
}

View File

@ -60,8 +60,8 @@ public:
IList* getTags();
void setTags(IList* pTags);
String* getStatus();
void setStatus(String* pStatus);
PStatusEnum getStatus();
void setStatus(PStatusEnum pStatus);
private:
@ -70,7 +70,7 @@ private:
String* pName;
IList* pPhotoUrls;
IList* pTags;
String* pStatus;
PStatusEnum pStatus;
};

View File

@ -414,5 +414,46 @@ SamiPetApi::deletePetWithCompletion(String* api_key, Long* petId, void(*success)
}
void
uploadFileProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) {
int code = pHttpResponse->GetHttpStatusCode();
if(code >= 200 && code < 300) {
handler(null, null);
}
else {
SamiError* error = new SamiError(code, new String(pHttpResponse->GetStatusText()));
handler(error, null);
}
}
void
SamiPetApi::uploadFileWithCompletion(String* additionalMetadata, SamiFile* file, void(*success)(SamiError*)) {
client = new SamiApiClient();
client->success(&uploadFileProcessor, (void(*)(void*, SamiError*))success);
HashMap* headerParams = new HashMap(SingleObjectDeleter);
headerParams->Construct();
HashMap* queryParams = new HashMap(SingleObjectDeleter);
queryParams->Construct();
String* mBody = null;
String url(L"/pet/{petId}/uploadImage");
client->execute(SamiPetApi::getBasePath(), url, "POST", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json");
}
} /* namespace Swagger */

View File

@ -6,6 +6,7 @@
#include "SamiError.h"
using Tizen::Base::Long;
#include "SamiFile.h"
using Tizen::Base::String;
#include "SamiPet.h"
@ -40,8 +41,11 @@ public:
void
deletePetWithCompletion(String* api_key, Long* petId, void(* handler)(SamiError*));
void
uploadFileWithCompletion(String* additionalMetadata, SamiFile* file, void(* handler)(SamiError*));
static String getBasePath() {
return L"http://petstore.swagger.wordnik.com/v2";
return L"http://petstore.swagger.io/v2";
}
private:

View File

@ -32,7 +32,7 @@ public:
deleteOrderWithCompletion(String* orderId, void(* handler)(SamiError*));
static String getBasePath() {
return L"http://petstore.swagger.wordnik.com/v2";
return L"http://petstore.swagger.io/v2";
}
private:

View File

@ -44,7 +44,7 @@ public:
deleteUserWithCompletion(String* username, void(* handler)(SamiError*));
static String getBasePath() {
return L"http://petstore.swagger.wordnik.com/v2";
return L"http://petstore.swagger.io/v2";
}
private: