From 2f16ee3b295c1e6ddab1e6f3a231f140f7cbea38 Mon Sep 17 00:00:00 2001 From: Tony Tam Date: Thu, 5 Feb 2015 11:34:23 -0800 Subject: [PATCH] renamed package --- .../java/com/wordnik/client/api/PetApi.java | 38 ++ .../petstore/java/JavaPetstoreCodegen.scala | 49 -- .../java/com/wordnik/client/ApiException.java | 29 -- .../java/com/wordnik/client/ApiInvoker.java | 187 ------- .../java/com/wordnik/client/JsonUtil.java | 23 - .../java/com/wordnik/client/api/PetApi.java | 409 ---------------- .../java/com/wordnik/client/api/StoreApi.java | 195 -------- .../java/com/wordnik/client/api/UserApi.java | 461 ------------------ .../com/wordnik/client/model/Category.java | 49 -- .../java/com/wordnik/client/model/Order.java | 109 ----- .../java/com/wordnik/client/model/Pet.java | 105 ---- .../java/com/wordnik/client/model/Tag.java | 49 -- .../java/com/wordnik/client/model/User.java | 131 ----- .../petstore/tizen/client/SamiStoreApi.cpp | 62 +++ .../petstore/tizen/client/SamiStoreApi.h | 4 + 15 files changed, 104 insertions(+), 1796 deletions(-) delete mode 100644 samples/client/petstore/java/JavaPetstoreCodegen.scala delete mode 100644 samples/client/petstore/java/src/main/java/com/wordnik/client/ApiException.java delete mode 100644 samples/client/petstore/java/src/main/java/com/wordnik/client/ApiInvoker.java delete mode 100644 samples/client/petstore/java/src/main/java/com/wordnik/client/JsonUtil.java delete mode 100644 samples/client/petstore/java/src/main/java/com/wordnik/client/api/PetApi.java delete mode 100644 samples/client/petstore/java/src/main/java/com/wordnik/client/api/StoreApi.java delete mode 100644 samples/client/petstore/java/src/main/java/com/wordnik/client/api/UserApi.java delete mode 100644 samples/client/petstore/java/src/main/java/com/wordnik/client/model/Category.java delete mode 100644 samples/client/petstore/java/src/main/java/com/wordnik/client/model/Order.java delete mode 100644 samples/client/petstore/java/src/main/java/com/wordnik/client/model/Pet.java delete mode 100644 samples/client/petstore/java/src/main/java/com/wordnik/client/model/Tag.java delete mode 100644 samples/client/petstore/java/src/main/java/com/wordnik/client/model/User.java diff --git a/samples/client/petstore/android-java/src/main/java/com/wordnik/client/api/PetApi.java b/samples/client/petstore/android-java/src/main/java/com/wordnik/client/api/PetApi.java index 5aa488c7577..c665531ff47 100644 --- a/samples/client/petstore/android-java/src/main/java/com/wordnik/client/api/PetApi.java +++ b/samples/client/petstore/android-java/src/main/java/com/wordnik/client/api/PetApi.java @@ -8,6 +8,7 @@ import com.wordnik.client.model.*; import java.util.*; import com.wordnik.client.model.Pet; +import java.io.File; import java.util.Map; import java.util.HashMap; @@ -298,4 +299,41 @@ public class PetApi { } } + + public void uploadImage (File petImage) throws ApiException { + Object postBody = null; + + + + // create path and map variables + String path = "/pet/{petId}/upload".replaceAll("\\{format\\}","json"); + + // query params + Map queryParams = new HashMap(); + Map headerParams = new HashMap(); + + + + + + String contentType = "application/json"; + + try { + String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, postBody, headerParams, contentType); + if(response != null){ + return ; + } + else { + return ; + } + } catch (ApiException ex) { + if(ex.getCode() == 404) { + return ; + } + else { + throw ex; + } + } + } + } diff --git a/samples/client/petstore/java/JavaPetstoreCodegen.scala b/samples/client/petstore/java/JavaPetstoreCodegen.scala deleted file mode 100644 index 1e23a176813..00000000000 --- a/samples/client/petstore/java/JavaPetstoreCodegen.scala +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Copyright 2014 Wordnik, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import com.wordnik.swagger.codegen.BasicJavaGenerator - -object JavaPetstoreCodegen extends BasicJavaGenerator { - def main(args: Array[String]) = generateClient(args) - - // location of templates - override def templateDir = "src/main/resources/Java" - - // where to write generated code - override def destinationDir = "samples/client/petstore/java/src/main/java" - - // package for api invoker, error files - override def invokerPackage = Some("com.wordnik.client") - - // package for models - override def modelPackage = Some("com.wordnik.petstore.model") - - // package for api classes - override def apiPackage = Some("com.wordnik.petstore.api") - - additionalParams ++= Map( - "artifactId" -> "swagger-petstore", - "artifactVersion" -> "1.0.0", - "groupId" -> "com.wordnik") - - // supporting classes - override def supportingFiles = - List( - ("apiInvoker.mustache", destinationDir + java.io.File.separator + invokerPackage.get.replace(".", java.io.File.separator) + java.io.File.separator, "ApiInvoker.java"), - ("JsonUtil.mustache", destinationDir + java.io.File.separator + invokerPackage.get.replace(".", java.io.File.separator) + java.io.File.separator, "JsonUtil.java"), - ("apiException.mustache", destinationDir + java.io.File.separator + invokerPackage.get.replace(".", java.io.File.separator) + java.io.File.separator, "ApiException.java"), - ("pom.mustache", "samples/client/petstore/java", "pom.xml")) -} diff --git a/samples/client/petstore/java/src/main/java/com/wordnik/client/ApiException.java b/samples/client/petstore/java/src/main/java/com/wordnik/client/ApiException.java deleted file mode 100644 index 9a1f62b3061..00000000000 --- a/samples/client/petstore/java/src/main/java/com/wordnik/client/ApiException.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.wordnik.client; - -public class ApiException extends Exception { - int code = 0; - String message = null; - - public ApiException() {} - - public ApiException(int code, String message) { - this.code = code; - this.message = message; - } - - public int getCode() { - return code; - } - - public void setCode(int code) { - this.code = code; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } -} \ No newline at end of file diff --git a/samples/client/petstore/java/src/main/java/com/wordnik/client/ApiInvoker.java b/samples/client/petstore/java/src/main/java/com/wordnik/client/ApiInvoker.java deleted file mode 100644 index cd6a73937ba..00000000000 --- a/samples/client/petstore/java/src/main/java/com/wordnik/client/ApiInvoker.java +++ /dev/null @@ -1,187 +0,0 @@ -package com.wordnik.client; - -import com.fasterxml.jackson.core.JsonGenerator.Feature; -import com.fasterxml.jackson.databind.*; -import com.fasterxml.jackson.annotation.*; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; - -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.ClientResponse; -import com.sun.jersey.api.client.config.ClientConfig; -import com.sun.jersey.api.client.config.DefaultClientConfig; -import com.sun.jersey.api.client.filter.LoggingFilter; -import com.sun.jersey.api.client.WebResource.Builder; -import com.sun.jersey.multipart.FormDataMultiPart; - -import javax.ws.rs.core.Response.Status.Family; -import javax.ws.rs.core.MediaType; - -import java.util.Map; -import java.util.HashMap; -import java.util.List; -import java.io.IOException; -import java.net.URLEncoder; -import java.io.UnsupportedEncodingException; - -public class ApiInvoker { - private static ApiInvoker INSTANCE = new ApiInvoker(); - private Map hostMap = new HashMap(); - private Map defaultHeaderMap = new HashMap(); - private boolean isDebug = false; - - public void enableDebug() { - isDebug = true; - } - - public static ApiInvoker getInstance() { - return INSTANCE; - } - - public void addDefaultHeader(String key, String value) { - defaultHeaderMap.put(key, value); - } - - public String escapeString(String str) { - try{ - return URLEncoder.encode(str, "utf8").replaceAll("\\+", "%20"); - } - catch(UnsupportedEncodingException e) { - return str; - } - } - - public static Object deserialize(String json, String containerType, Class cls) throws ApiException { - try{ - if("List".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()); - } - } - - public static String serialize(Object obj) throws ApiException { - try { - if (obj != null) - return JsonUtil.getJsonMapper().writeValueAsString(obj); - else - return null; - } - catch (Exception e) { - throw new ApiException(500, e.getMessage()); - } - } - - public String invokeAPI(String host, String path, String method, Map queryParams, Object body, Map headerParams, Map formParams, String contentType) throws ApiException { - Client 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 querystring = b.toString(); - - Builder builder = client.resource(host + path + querystring).accept("application/json"); - for(String key : headerParams.keySet()) { - builder.header(key, headerParams.get(key)); - } - - for(String key : defaultHeaderMap.keySet()) { - if(!headerParams.containsKey(key)) { - builder.header(key, defaultHeaderMap.get(key)); - } - } - ClientResponse response = null; - - if("GET".equals(method)) { - response = (ClientResponse) builder.get(ClientResponse.class); - } - else if ("POST".equals(method)) { - 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(body == null) - response = builder.put(ClientResponse.class, serialize(body)); - else { - 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 - } - } - } - response = builder.type(contentType).put(ClientResponse.class, formParamBuilder.toString()); - } - else - response = builder.type(contentType).put(ClientResponse.class, serialize(body)); - } - } - else if ("DELETE".equals(method)) { - if(body == null) - response = builder.delete(ClientResponse.class, serialize(body)); - 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) { - return (String) response.getEntity(String.class); - } - else { - throw new ApiException( - response.getClientResponseStatus().getStatusCode(), - response.getEntity(String.class)); - } - } - - private Client getClient(String host) { - if(!hostMap.containsKey(host)) { - Client client = Client.create(); - if(isDebug) - client.addFilter(new LoggingFilter()); - hostMap.put(host, client); - } - return hostMap.get(host); - } -} diff --git a/samples/client/petstore/java/src/main/java/com/wordnik/client/JsonUtil.java b/samples/client/petstore/java/src/main/java/com/wordnik/client/JsonUtil.java deleted file mode 100644 index a650c968f4c..00000000000 --- a/samples/client/petstore/java/src/main/java/com/wordnik/client/JsonUtil.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.wordnik.client; - -import com.fasterxml.jackson.annotation.*; -import com.fasterxml.jackson.databind.*; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import com.fasterxml.jackson.core.JsonGenerator.Feature; - -import com.fasterxml.jackson.datatype.joda.*; - -public class JsonUtil { - public static ObjectMapper mapper; - - static { - mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); - mapper.registerModule(new JodaModule()); - } - - public static ObjectMapper getJsonMapper() { - return mapper; - } -} diff --git a/samples/client/petstore/java/src/main/java/com/wordnik/client/api/PetApi.java b/samples/client/petstore/java/src/main/java/com/wordnik/client/api/PetApi.java deleted file mode 100644 index f89c0939dc4..00000000000 --- a/samples/client/petstore/java/src/main/java/com/wordnik/client/api/PetApi.java +++ /dev/null @@ -1,409 +0,0 @@ -package com.wordnik.client.api; - -import com.wordnik.client.ApiException; -import com.wordnik.client.ApiInvoker; - -import com.wordnik.client.model.*; - -import java.util.*; - -import com.wordnik.client.model.Pet; - -import com.sun.jersey.multipart.FormDataMultiPart; - -import javax.ws.rs.core.MediaType; - -import java.io.File; -import java.util.Map; -import java.util.HashMap; - -public class PetApi { - String basePath = "http://petstore.swagger.wordnik.com/v2"; - ApiInvoker apiInvoker = ApiInvoker.getInstance(); - - public ApiInvoker getInvoker() { - return apiInvoker; - } - - public void setBasePath(String basePath) { - this.basePath = basePath; - } - - public String getBasePath() { - return basePath; - } - - - - public void updatePet (Pet body) throws ApiException { - Object postBody = body; - - - // create path and map variables - String path = "/pet".replaceAll("\\{format\\}","json"); - - // query params - Map queryParams = new HashMap(); - Map headerParams = new HashMap(); - Map formParams = new HashMap(); - - - - - - String[] contentTypes = { - "application/json","application/xml" - }; - - String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - - if(contentType.startsWith("multipart/form-data")) { - boolean hasFields = false; - FormDataMultiPart mp = new FormDataMultiPart(); - - if(hasFields) - postBody = mp; - } - else { - - } - - try { - String response = apiInvoker.invokeAPI(basePath, path, "PUT", queryParams, postBody, headerParams, formParams, contentType); - if(response != null){ - return ; - } - else { - return ; - } - } catch (ApiException ex) { - if(ex.getCode() == 404) { - return ; - } - else { - throw ex; - } - } - } - - - public void addPet (Pet body) throws ApiException { - Object postBody = body; - - - // create path and map variables - String path = "/pet".replaceAll("\\{format\\}","json"); - - // query params - Map queryParams = new HashMap(); - Map headerParams = new HashMap(); - Map formParams = new HashMap(); - - - - - - String[] contentTypes = { - "application/json","application/xml" - }; - - String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - - if(contentType.startsWith("multipart/form-data")) { - boolean hasFields = false; - FormDataMultiPart mp = new FormDataMultiPart(); - - if(hasFields) - postBody = mp; - } - else { - - } - - 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; - } - } - } - - - public List findPetsByStatus (List status) throws ApiException { - Object postBody = null; - - - // create path and map variables - String path = "/pet/findByStatus".replaceAll("\\{format\\}","json"); - - // query params - Map queryParams = new HashMap(); - Map headerParams = new HashMap(); - Map formParams = new HashMap(); - - if(!"null".equals(String.valueOf(status))) - queryParams.put("status", String.valueOf(status)); - - - - - String[] contentTypes = { - - }; - - String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - - if(contentType.startsWith("multipart/form-data")) { - boolean hasFields = false; - FormDataMultiPart mp = new FormDataMultiPart(); - - if(hasFields) - postBody = mp; - } - else { - - } - - try { - String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType); - if(response != null){ - return (List) ApiInvoker.deserialize(response, "Pet", Pet.class); - } - else { - return null; - } - } catch (ApiException ex) { - if(ex.getCode() == 404) { - return null; - } - else { - throw ex; - } - } - } - - - public List findPetsByTags (List tags) throws ApiException { - Object postBody = null; - - - // create path and map variables - String path = "/pet/findByTags".replaceAll("\\{format\\}","json"); - - // query params - Map queryParams = new HashMap(); - Map headerParams = new HashMap(); - Map formParams = new HashMap(); - - if(!"null".equals(String.valueOf(tags))) - queryParams.put("tags", String.valueOf(tags)); - - - - - String[] contentTypes = { - - }; - - String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - - if(contentType.startsWith("multipart/form-data")) { - boolean hasFields = false; - FormDataMultiPart mp = new FormDataMultiPart(); - - if(hasFields) - postBody = mp; - } - else { - - } - - try { - String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType); - if(response != null){ - return (List) ApiInvoker.deserialize(response, "Pet", Pet.class); - } - else { - return null; - } - } catch (ApiException ex) { - if(ex.getCode() == 404) { - return null; - } - else { - throw ex; - } - } - } - - - public Pet getPetById (Long petId) throws ApiException { - Object postBody = null; - - - // create path and map variables - String path = "/pet/{petId}".replaceAll("\\{format\\}","json") - .replaceAll("\\{" + "petId" + "\\}", apiInvoker.escapeString(petId.toString())); - - // query params - Map queryParams = new HashMap(); - Map headerParams = new HashMap(); - Map formParams = new HashMap(); - - - - - - String[] contentTypes = { - - }; - - String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - - if(contentType.startsWith("multipart/form-data")) { - boolean hasFields = false; - FormDataMultiPart mp = new FormDataMultiPart(); - - if(hasFields) - postBody = mp; - } - else { - - } - - try { - String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType); - if(response != null){ - return (Pet) ApiInvoker.deserialize(response, "", Pet.class); - } - else { - return null; - } - } catch (ApiException ex) { - if(ex.getCode() == 404) { - return null; - } - else { - throw ex; - } - } - } - - - public void updatePetWithForm (String petId, String name, String status) throws ApiException { - Object postBody = null; - - - // create path and map variables - String path = "/pet/{petId}".replaceAll("\\{format\\}","json") - .replaceAll("\\{" + "petId" + "\\}", apiInvoker.escapeString(petId.toString())); - - // query params - Map queryParams = new HashMap(); - Map headerParams = new HashMap(); - Map formParams = new HashMap(); - - - - - - String[] contentTypes = { - "application/x-www-form-urlencoded" - }; - - String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - - if(contentType.startsWith("multipart/form-data")) { - boolean hasFields = false; - FormDataMultiPart mp = new FormDataMultiPart(); - - if(hasFields) - postBody = mp; - } - else { - - } - - 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; - } - } - } - - - public void deletePet (String api_key, Long petId) throws ApiException { - Object postBody = null; - - - // create path and map variables - String path = "/pet/{petId}".replaceAll("\\{format\\}","json") - .replaceAll("\\{" + "petId" + "\\}", apiInvoker.escapeString(petId.toString())); - - // query params - Map queryParams = new HashMap(); - Map headerParams = new HashMap(); - Map formParams = new HashMap(); - - - - headerParams.put("api_key", api_key); - - - String[] contentTypes = { - - }; - - String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - - if(contentType.startsWith("multipart/form-data")) { - boolean hasFields = false; - FormDataMultiPart mp = new FormDataMultiPart(); - - if(hasFields) - postBody = mp; - } - else { - - } - - try { - String response = apiInvoker.invokeAPI(basePath, path, "DELETE", queryParams, postBody, headerParams, formParams, contentType); - if(response != null){ - return ; - } - else { - return ; - } - } catch (ApiException ex) { - if(ex.getCode() == 404) { - return ; - } - else { - throw ex; - } - } - } - -} diff --git a/samples/client/petstore/java/src/main/java/com/wordnik/client/api/StoreApi.java b/samples/client/petstore/java/src/main/java/com/wordnik/client/api/StoreApi.java deleted file mode 100644 index 968d5840a78..00000000000 --- a/samples/client/petstore/java/src/main/java/com/wordnik/client/api/StoreApi.java +++ /dev/null @@ -1,195 +0,0 @@ -package com.wordnik.client.api; - -import com.wordnik.client.ApiException; -import com.wordnik.client.ApiInvoker; - -import com.wordnik.client.model.*; - -import java.util.*; - -import com.wordnik.client.model.Order; - -import com.sun.jersey.multipart.FormDataMultiPart; - -import javax.ws.rs.core.MediaType; - -import java.io.File; -import java.util.Map; -import java.util.HashMap; - -public class StoreApi { - String basePath = "http://petstore.swagger.wordnik.com/v2"; - ApiInvoker apiInvoker = ApiInvoker.getInstance(); - - public ApiInvoker getInvoker() { - return apiInvoker; - } - - public void setBasePath(String basePath) { - this.basePath = basePath; - } - - public String getBasePath() { - return basePath; - } - - - - public Order placeOrder (Order body) throws ApiException { - Object postBody = body; - - - // create path and map variables - String path = "/store/order".replaceAll("\\{format\\}","json"); - - // query params - Map queryParams = new HashMap(); - Map headerParams = new HashMap(); - Map formParams = new HashMap(); - - - - - - String[] contentTypes = { - - }; - - String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - - if(contentType.startsWith("multipart/form-data")) { - boolean hasFields = false; - FormDataMultiPart mp = new FormDataMultiPart(); - - if(hasFields) - postBody = mp; - } - else { - - } - - try { - String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, postBody, headerParams, formParams, contentType); - if(response != null){ - return (Order) ApiInvoker.deserialize(response, "", Order.class); - } - else { - return null; - } - } catch (ApiException ex) { - if(ex.getCode() == 404) { - return null; - } - else { - throw ex; - } - } - } - - - public Order getOrderById (String orderId) throws ApiException { - Object postBody = null; - - - // create path and map variables - String path = "/store/order/{orderId}".replaceAll("\\{format\\}","json") - .replaceAll("\\{" + "orderId" + "\\}", apiInvoker.escapeString(orderId.toString())); - - // query params - Map queryParams = new HashMap(); - Map headerParams = new HashMap(); - Map formParams = new HashMap(); - - - - - - String[] contentTypes = { - - }; - - String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - - if(contentType.startsWith("multipart/form-data")) { - boolean hasFields = false; - FormDataMultiPart mp = new FormDataMultiPart(); - - if(hasFields) - postBody = mp; - } - else { - - } - - try { - String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType); - if(response != null){ - return (Order) ApiInvoker.deserialize(response, "", Order.class); - } - else { - return null; - } - } catch (ApiException ex) { - if(ex.getCode() == 404) { - return null; - } - else { - throw ex; - } - } - } - - - public void deleteOrder (String orderId) throws ApiException { - Object postBody = null; - - - // create path and map variables - String path = "/store/order/{orderId}".replaceAll("\\{format\\}","json") - .replaceAll("\\{" + "orderId" + "\\}", apiInvoker.escapeString(orderId.toString())); - - // query params - Map queryParams = new HashMap(); - Map headerParams = new HashMap(); - Map formParams = new HashMap(); - - - - - - String[] contentTypes = { - - }; - - String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - - if(contentType.startsWith("multipart/form-data")) { - boolean hasFields = false; - FormDataMultiPart mp = new FormDataMultiPart(); - - if(hasFields) - postBody = mp; - } - else { - - } - - try { - String response = apiInvoker.invokeAPI(basePath, path, "DELETE", queryParams, postBody, headerParams, formParams, contentType); - if(response != null){ - return ; - } - else { - return ; - } - } catch (ApiException ex) { - if(ex.getCode() == 404) { - return ; - } - else { - throw ex; - } - } - } - -} diff --git a/samples/client/petstore/java/src/main/java/com/wordnik/client/api/UserApi.java b/samples/client/petstore/java/src/main/java/com/wordnik/client/api/UserApi.java deleted file mode 100644 index 73b764f1a3d..00000000000 --- a/samples/client/petstore/java/src/main/java/com/wordnik/client/api/UserApi.java +++ /dev/null @@ -1,461 +0,0 @@ -package com.wordnik.client.api; - -import com.wordnik.client.ApiException; -import com.wordnik.client.ApiInvoker; - -import com.wordnik.client.model.*; - -import java.util.*; - -import com.wordnik.client.model.User; -import java.util.*; - -import com.sun.jersey.multipart.FormDataMultiPart; - -import javax.ws.rs.core.MediaType; - -import java.io.File; -import java.util.Map; -import java.util.HashMap; - -public class UserApi { - String basePath = "http://petstore.swagger.wordnik.com/v2"; - ApiInvoker apiInvoker = ApiInvoker.getInstance(); - - public ApiInvoker getInvoker() { - return apiInvoker; - } - - public void setBasePath(String basePath) { - this.basePath = basePath; - } - - public String getBasePath() { - return basePath; - } - - - - public void createUser (User body) throws ApiException { - Object postBody = body; - - - // create path and map variables - String path = "/user".replaceAll("\\{format\\}","json"); - - // query params - Map queryParams = new HashMap(); - Map headerParams = new HashMap(); - Map formParams = new HashMap(); - - - - - - String[] contentTypes = { - - }; - - String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - - if(contentType.startsWith("multipart/form-data")) { - boolean hasFields = false; - FormDataMultiPart mp = new FormDataMultiPart(); - - if(hasFields) - postBody = mp; - } - else { - - } - - 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; - } - } - } - - - public void createUsersWithArrayInput (List body) throws ApiException { - Object postBody = body; - - - // create path and map variables - String path = "/user/createWithArray".replaceAll("\\{format\\}","json"); - - // query params - Map queryParams = new HashMap(); - Map headerParams = new HashMap(); - Map formParams = new HashMap(); - - - - - - String[] contentTypes = { - - }; - - String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - - if(contentType.startsWith("multipart/form-data")) { - boolean hasFields = false; - FormDataMultiPart mp = new FormDataMultiPart(); - - if(hasFields) - postBody = mp; - } - else { - - } - - 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; - } - } - } - - - public void createUsersWithListInput (List body) throws ApiException { - Object postBody = body; - - - // create path and map variables - String path = "/user/createWithList".replaceAll("\\{format\\}","json"); - - // query params - Map queryParams = new HashMap(); - Map headerParams = new HashMap(); - Map formParams = new HashMap(); - - - - - - String[] contentTypes = { - - }; - - String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - - if(contentType.startsWith("multipart/form-data")) { - boolean hasFields = false; - FormDataMultiPart mp = new FormDataMultiPart(); - - if(hasFields) - postBody = mp; - } - else { - - } - - 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; - } - } - } - - - public String loginUser (String username, String password) throws ApiException { - Object postBody = null; - - - // create path and map variables - String path = "/user/login".replaceAll("\\{format\\}","json"); - - // query params - Map queryParams = new HashMap(); - Map headerParams = new HashMap(); - Map formParams = new HashMap(); - - if(!"null".equals(String.valueOf(username))) - queryParams.put("username", String.valueOf(username)); - if(!"null".equals(String.valueOf(password))) - queryParams.put("password", String.valueOf(password)); - - - - - String[] contentTypes = { - - }; - - String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - - if(contentType.startsWith("multipart/form-data")) { - boolean hasFields = false; - FormDataMultiPart mp = new FormDataMultiPart(); - - if(hasFields) - postBody = mp; - } - else { - - } - - try { - String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType); - if(response != null){ - return (String) ApiInvoker.deserialize(response, "", String.class); - } - else { - return null; - } - } catch (ApiException ex) { - if(ex.getCode() == 404) { - return null; - } - else { - throw ex; - } - } - } - - - public void logoutUser () throws ApiException { - Object postBody = null; - - - // create path and map variables - String path = "/user/logout".replaceAll("\\{format\\}","json"); - - // query params - Map queryParams = new HashMap(); - Map headerParams = new HashMap(); - Map formParams = new HashMap(); - - - - - - String[] contentTypes = { - - }; - - String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - - if(contentType.startsWith("multipart/form-data")) { - boolean hasFields = false; - FormDataMultiPart mp = new FormDataMultiPart(); - - if(hasFields) - postBody = mp; - } - else { - - } - - try { - String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType); - if(response != null){ - return ; - } - else { - return ; - } - } catch (ApiException ex) { - if(ex.getCode() == 404) { - return ; - } - else { - throw ex; - } - } - } - - - public User getUserByName (String username) throws ApiException { - Object postBody = null; - - - // create path and map variables - String path = "/user/{username}".replaceAll("\\{format\\}","json") - .replaceAll("\\{" + "username" + "\\}", apiInvoker.escapeString(username.toString())); - - // query params - Map queryParams = new HashMap(); - Map headerParams = new HashMap(); - Map formParams = new HashMap(); - - - - - - String[] contentTypes = { - - }; - - String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - - if(contentType.startsWith("multipart/form-data")) { - boolean hasFields = false; - FormDataMultiPart mp = new FormDataMultiPart(); - - if(hasFields) - postBody = mp; - } - else { - - } - - try { - String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType); - if(response != null){ - return (User) ApiInvoker.deserialize(response, "", User.class); - } - else { - return null; - } - } catch (ApiException ex) { - if(ex.getCode() == 404) { - return null; - } - else { - throw ex; - } - } - } - - - public void updateUser (String username, User body) throws ApiException { - Object postBody = body; - - - // create path and map variables - String path = "/user/{username}".replaceAll("\\{format\\}","json") - .replaceAll("\\{" + "username" + "\\}", apiInvoker.escapeString(username.toString())); - - // query params - Map queryParams = new HashMap(); - Map headerParams = new HashMap(); - Map formParams = new HashMap(); - - - - - - String[] contentTypes = { - - }; - - String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - - if(contentType.startsWith("multipart/form-data")) { - boolean hasFields = false; - FormDataMultiPart mp = new FormDataMultiPart(); - - if(hasFields) - postBody = mp; - } - else { - - } - - try { - String response = apiInvoker.invokeAPI(basePath, path, "PUT", queryParams, postBody, headerParams, formParams, contentType); - if(response != null){ - return ; - } - else { - return ; - } - } catch (ApiException ex) { - if(ex.getCode() == 404) { - return ; - } - else { - throw ex; - } - } - } - - - public void deleteUser (String username) throws ApiException { - Object postBody = null; - - - // create path and map variables - String path = "/user/{username}".replaceAll("\\{format\\}","json") - .replaceAll("\\{" + "username" + "\\}", apiInvoker.escapeString(username.toString())); - - // query params - Map queryParams = new HashMap(); - Map headerParams = new HashMap(); - Map formParams = new HashMap(); - - - - - - String[] contentTypes = { - - }; - - String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - - if(contentType.startsWith("multipart/form-data")) { - boolean hasFields = false; - FormDataMultiPart mp = new FormDataMultiPart(); - - if(hasFields) - postBody = mp; - } - else { - - } - - try { - String response = apiInvoker.invokeAPI(basePath, path, "DELETE", queryParams, postBody, headerParams, formParams, contentType); - if(response != null){ - return ; - } - else { - return ; - } - } catch (ApiException ex) { - if(ex.getCode() == 404) { - return ; - } - else { - throw ex; - } - } - } - -} diff --git a/samples/client/petstore/java/src/main/java/com/wordnik/client/model/Category.java b/samples/client/petstore/java/src/main/java/com/wordnik/client/model/Category.java deleted file mode 100644 index 5a0a18d40a5..00000000000 --- a/samples/client/petstore/java/src/main/java/com/wordnik/client/model/Category.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.wordnik.client.model; - - -import com.wordnik.swagger.annotations.*; - - -@ApiModel(description = "") -public class Category { - private Long id = null; - - //public enum idEnum { }; - - private String name = null; - - - /** - **/ - @ApiModelProperty(required = false, value = "") - public Long getId() { - return id; - } - public void setId(Long id) { - this.id = id; - } - - - /** - **/ - @ApiModelProperty(required = false, value = "") - public String getName() { - return name; - } - public void setName(String name) { - this.name = name; - } - - - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Category {\n"); - - sb.append(" id: ").append(id).append("\n"); - sb.append(" name: ").append(name).append("\n"); - sb.append("}\n"); - return sb.toString(); - } -} diff --git a/samples/client/petstore/java/src/main/java/com/wordnik/client/model/Order.java b/samples/client/petstore/java/src/main/java/com/wordnik/client/model/Order.java deleted file mode 100644 index 65af51c2f6d..00000000000 --- a/samples/client/petstore/java/src/main/java/com/wordnik/client/model/Order.java +++ /dev/null @@ -1,109 +0,0 @@ -package com.wordnik.client.model; - -import java.util.Date; - -import com.wordnik.swagger.annotations.*; - - -@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; - private Boolean complete = null; - - - /** - **/ - @ApiModelProperty(required = false, value = "") - public Long getId() { - return id; - } - public void setId(Long id) { - this.id = id; - } - - - /** - **/ - @ApiModelProperty(required = false, value = "") - public Long getPetId() { - return petId; - } - public void setPetId(Long petId) { - this.petId = petId; - } - - - /** - **/ - @ApiModelProperty(required = false, value = "") - public Integer getQuantity() { - return quantity; - } - public void setQuantity(Integer quantity) { - this.quantity = quantity; - } - - - /** - **/ - @ApiModelProperty(required = false, value = "") - public Date getShipDate() { - return shipDate; - } - public void setShipDate(Date shipDate) { - this.shipDate = shipDate; - } - - - /** - * Order Status - **/ - @ApiModelProperty(required = false, value = "Order Status") - public String getStatus() { - return status; - } - public void setStatus(String status) { - this.status = status; - } - - - /** - **/ - @ApiModelProperty(required = false, value = "") - public Boolean getComplete() { - return complete; - } - public void setComplete(Boolean complete) { - this.complete = complete; - } - - - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Order {\n"); - - sb.append(" id: ").append(id).append("\n"); - sb.append(" petId: ").append(petId).append("\n"); - sb.append(" quantity: ").append(quantity).append("\n"); - sb.append(" shipDate: ").append(shipDate).append("\n"); - sb.append(" status: ").append(status).append("\n"); - sb.append(" complete: ").append(complete).append("\n"); - sb.append("}\n"); - return sb.toString(); - } -} diff --git a/samples/client/petstore/java/src/main/java/com/wordnik/client/model/Pet.java b/samples/client/petstore/java/src/main/java/com/wordnik/client/model/Pet.java deleted file mode 100644 index f84c1d0d925..00000000000 --- a/samples/client/petstore/java/src/main/java/com/wordnik/client/model/Pet.java +++ /dev/null @@ -1,105 +0,0 @@ -package com.wordnik.client.model; - -import com.wordnik.client.model.Category; -import com.wordnik.client.model.Tag; -import java.util.*; - -import com.wordnik.swagger.annotations.*; - - -@ApiModel(description = "") -public class Pet { - private Long id = null; - - //public enum idEnum { }; - - private Category category = null; - private String name = null; - private List photoUrls = new ArrayList() ; - private List tags = new ArrayList() ; - private String status = null; - - - /** - **/ - @ApiModelProperty(required = false, value = "") - public Long getId() { - return id; - } - public void setId(Long id) { - this.id = id; - } - - - /** - **/ - @ApiModelProperty(required = false, value = "") - public Category getCategory() { - return category; - } - public void setCategory(Category category) { - this.category = category; - } - - - /** - **/ - @ApiModelProperty(required = true, value = "") - public String getName() { - return name; - } - public void setName(String name) { - this.name = name; - } - - - /** - **/ - @ApiModelProperty(required = true, value = "") - public List getPhotoUrls() { - return photoUrls; - } - public void setPhotoUrls(List photoUrls) { - this.photoUrls = photoUrls; - } - - - /** - **/ - @ApiModelProperty(required = false, value = "") - public List getTags() { - return tags; - } - public void setTags(List tags) { - this.tags = tags; - } - - - /** - * pet status in the store - **/ - @ApiModelProperty(required = false, value = "pet status in the store") - public String getStatus() { - return status; - } - public void setStatus(String status) { - this.status = status; - } - - - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Pet {\n"); - - sb.append(" id: ").append(id).append("\n"); - sb.append(" category: ").append(category).append("\n"); - sb.append(" name: ").append(name).append("\n"); - sb.append(" photoUrls: ").append(photoUrls).append("\n"); - sb.append(" tags: ").append(tags).append("\n"); - sb.append(" status: ").append(status).append("\n"); - sb.append("}\n"); - return sb.toString(); - } -} diff --git a/samples/client/petstore/java/src/main/java/com/wordnik/client/model/Tag.java b/samples/client/petstore/java/src/main/java/com/wordnik/client/model/Tag.java deleted file mode 100644 index 6fdc13bb049..00000000000 --- a/samples/client/petstore/java/src/main/java/com/wordnik/client/model/Tag.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.wordnik.client.model; - - -import com.wordnik.swagger.annotations.*; - - -@ApiModel(description = "") -public class Tag { - private Long id = null; - - //public enum idEnum { }; - - private String name = null; - - - /** - **/ - @ApiModelProperty(required = false, value = "") - public Long getId() { - return id; - } - public void setId(Long id) { - this.id = id; - } - - - /** - **/ - @ApiModelProperty(required = false, value = "") - public String getName() { - return name; - } - public void setName(String name) { - this.name = name; - } - - - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Tag {\n"); - - sb.append(" id: ").append(id).append("\n"); - sb.append(" name: ").append(name).append("\n"); - sb.append("}\n"); - return sb.toString(); - } -} diff --git a/samples/client/petstore/java/src/main/java/com/wordnik/client/model/User.java b/samples/client/petstore/java/src/main/java/com/wordnik/client/model/User.java deleted file mode 100644 index 3e1d8d032e6..00000000000 --- a/samples/client/petstore/java/src/main/java/com/wordnik/client/model/User.java +++ /dev/null @@ -1,131 +0,0 @@ -package com.wordnik.client.model; - - -import com.wordnik.swagger.annotations.*; - - -@ApiModel(description = "") -public class User { - private Long id = null; - - //public enum idEnum { }; - - private String username = null; - private String firstName = null; - private String lastName = null; - private String email = null; - private String password = null; - private String phone = null; - private Integer userStatus = null; - - //public enum userStatusEnum { }; - - - - /** - **/ - @ApiModelProperty(required = false, value = "") - public Long getId() { - return id; - } - public void setId(Long id) { - this.id = id; - } - - - /** - **/ - @ApiModelProperty(required = false, value = "") - public String getUsername() { - return username; - } - public void setUsername(String username) { - this.username = username; - } - - - /** - **/ - @ApiModelProperty(required = false, value = "") - public String getFirstName() { - return firstName; - } - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - - /** - **/ - @ApiModelProperty(required = false, value = "") - public String getLastName() { - return lastName; - } - public void setLastName(String lastName) { - this.lastName = lastName; - } - - - /** - **/ - @ApiModelProperty(required = false, value = "") - public String getEmail() { - return email; - } - public void setEmail(String email) { - this.email = email; - } - - - /** - **/ - @ApiModelProperty(required = false, value = "") - public String getPassword() { - return password; - } - public void setPassword(String password) { - this.password = password; - } - - - /** - **/ - @ApiModelProperty(required = false, value = "") - public String getPhone() { - return phone; - } - public void setPhone(String phone) { - this.phone = phone; - } - - - /** - * User Status - **/ - @ApiModelProperty(required = false, value = "User Status") - public Integer getUserStatus() { - return userStatus; - } - public void setUserStatus(Integer userStatus) { - this.userStatus = userStatus; - } - - - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class User {\n"); - - sb.append(" id: ").append(id).append("\n"); - sb.append(" username: ").append(username).append("\n"); - sb.append(" firstName: ").append(firstName).append("\n"); - sb.append(" lastName: ").append(lastName).append("\n"); - sb.append(" email: ").append(email).append("\n"); - sb.append(" password: ").append(password).append("\n"); - sb.append(" phone: ").append(phone).append("\n"); - sb.append(" userStatus: ").append(userStatus).append("\n"); - sb.append("}\n"); - return sb.toString(); - } -} diff --git a/samples/client/petstore/tizen/client/SamiStoreApi.cpp b/samples/client/petstore/tizen/client/SamiStoreApi.cpp index 0c0833ecfbd..c567896c48d 100644 --- a/samples/client/petstore/tizen/client/SamiStoreApi.cpp +++ b/samples/client/petstore/tizen/client/SamiStoreApi.cpp @@ -16,6 +16,68 @@ SamiStoreApi::~SamiStoreApi() { } +void +getInventoryProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { + int code = pHttpResponse->GetHttpStatusCode(); + + if(code >= 200 && code < 300) { + ByteBuffer* pBuffer = pHttpResponse->ReadBodyN(); + IJsonValue* pJson = JsonParser::ParseN(*pBuffer); + + HashMap* out = new HashMap(); + jsonToValue(out, pJson, L"HashMap*", L"Integer"); + + if (pJson) { + if (pJson->GetType() == JSON_TYPE_OBJECT) { + JsonObject* pObject = static_cast< JsonObject* >(pJson); + pObject->RemoveAll(true); + } + else if (pJson->GetType() == JSON_TYPE_ARRAY) { + JsonArray* pArray = static_cast< JsonArray* >(pJson); + pArray->RemoveAll(true); + } + handler(out, null); + } + else { + SamiError* error = new SamiError(0, new String(L"No parsable response received")); + handler(null, error); + } + + } + else { + SamiError* error = new SamiError(code, new String(pHttpResponse->GetStatusText())); + handler(null, error); + + } +} + +HashMap* +SamiStoreApi::getInventoryWithCompletion( void (* success)(HashMap*, SamiError*)) { + client = new SamiApiClient(); + + client->success(&getInventoryProcessor, (void(*)(void*, SamiError*))success); + HashMap* headerParams = new HashMap(SingleObjectDeleter); + headerParams->Construct(); + + + + HashMap* queryParams = new HashMap(SingleObjectDeleter); + queryParams->Construct(); + + + + String* mBody = null; + + + + String url(L"/store/inventory"); + + + + client->execute(SamiStoreApi::getBasePath(), url, "GET", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); + return null; +} + void placeOrderProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { int code = pHttpResponse->GetHttpStatusCode(); diff --git a/samples/client/petstore/tizen/client/SamiStoreApi.h b/samples/client/petstore/tizen/client/SamiStoreApi.h index ad835cd42a9..510e74e9a53 100644 --- a/samples/client/petstore/tizen/client/SamiStoreApi.h +++ b/samples/client/petstore/tizen/client/SamiStoreApi.h @@ -7,6 +7,7 @@ #include "SamiOrder.h" using Tizen::Base::String; +using Tizen::Base::Integer; using namespace Tizen::Net::Http; @@ -18,6 +19,9 @@ public: virtual ~SamiStoreApi(); + HashMap* + getInventoryWithCompletion( void (* handler)(HashMap*, SamiError*)); + SamiOrder* placeOrderWithCompletion(SamiOrder* body, void (* handler)(SamiOrder*, SamiError*));