From bb3bd0d357cb235fa7dd30c50525513d3b6fff16 Mon Sep 17 00:00:00 2001 From: Tony Tam Date: Mon, 27 Jan 2014 07:49:58 -0800 Subject: [PATCH] regenerated clients --- .../src/Com/Wordnik/Petstore/Api/PetApi.cs | 76 ++-- .../src/Com/Wordnik/Petstore/Api/StoreApi.cs | 70 ++-- .../src/Com/Wordnik/Petstore/Api/UserApi.cs | 360 +++++++++--------- .../Com/Wordnik/Petstore/Model/Category.cs | 2 - .../src/Com/Wordnik/Petstore/Model/Order.cs | 6 +- .../src/Com/Wordnik/Petstore/Model/Pet.cs | 6 +- .../src/Com/Wordnik/Petstore/Model/Tag.cs | 2 - .../src/Com/Wordnik/Petstore/Model/User.cs | 13 +- samples/client/petstore/java/pom.xml | 6 +- .../java/com/wordnik/client/ApiInvoker.java | 1 + .../java/com/wordnik/petstore/api/PetApi.java | 54 +-- .../com/wordnik/petstore/api/StoreApi.java | 62 +-- .../com/wordnik/petstore/api/UserApi.java | 310 +++++++-------- .../com/wordnik/petstore/model/Category.java | 2 - .../com/wordnik/petstore/model/Order.java | 6 +- .../java/com/wordnik/petstore/model/Pet.java | 6 +- .../java/com/wordnik/petstore/model/Tag.java | 2 - .../java/com/wordnik/petstore/model/User.java | 25 +- .../scala/com/wordnik/client/ApiInvoker.scala | 2 + 19 files changed, 488 insertions(+), 523 deletions(-) diff --git a/samples/client/petstore/csharp/src/Com/Wordnik/Petstore/Api/PetApi.cs b/samples/client/petstore/csharp/src/Com/Wordnik/Petstore/Api/PetApi.cs index 733e22f12db1..f56b2b020706 100644 --- a/samples/client/petstore/csharp/src/Com/Wordnik/Petstore/Api/PetApi.cs +++ b/samples/client/petstore/csharp/src/Com/Wordnik/Petstore/Api/PetApi.cs @@ -21,6 +21,38 @@ return basePath; } + /// + /// uploads an image + /// + /// Additional data to pass to server + /// file to upload + /// + public void uploadFile (string additionalMetadata, File body) { + // create path and map variables + var path = "/pet/uploadImage".Replace("{format}","json"); + + // query params + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + + string paramStr = null; + try { + var response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, body, headerParams); + if(response != null){ + return ; + } + else { + return ; + } + } catch (ApiException ex) { + if(ex.ErrorCode == 404) { + return ; + } + else { + throw ex; + } + } + } /// /// Find pet by ID Returns a pet based on ID /// @@ -97,7 +129,7 @@ /// ID of pet that needs to be fetched /// Pet object that needs to be added to the store /// - public Array partialUpdate (string petId, Pet body) { + public List partialUpdate (string petId, Pet body) { // create path and map variables var path = "/pet/{petId}".Replace("{format}","json").Replace("{" + "petId" + "}", apiInvoker.escapeString(petId.ToString())); @@ -113,7 +145,7 @@ try { var response = apiInvoker.invokeAPI(basePath, path, "PATCH", queryParams, body, headerParams); if(response != null){ - return (Array) ApiInvoker.deserialize(response, typeof(Array)); + return (List) ApiInvoker.deserialize(response, typeof(List)); } else { return null; @@ -165,38 +197,6 @@ } } /// - /// uploads an image - /// - /// Additional data to pass to server - /// file to upload - /// - public void uploadFile (string additionalMetadata, File body) { - // create path and map variables - var path = "/pet/uploadImage".Replace("{format}","json"); - - // query params - var queryParams = new Dictionary(); - var headerParams = new Dictionary(); - - string paramStr = null; - try { - var response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, body, headerParams); - if(response != null){ - return ; - } - else { - return ; - } - } catch (ApiException ex) { - if(ex.ErrorCode == 404) { - return ; - } - else { - throw ex; - } - } - } - /// /// Add a new pet to the store /// /// Pet object that needs to be added to the store @@ -271,7 +271,7 @@ /// /// Status values that need to be considered for filter /// - public Array findPetsByStatus (string status) { + public List findPetsByStatus (string status) { // create path and map variables var path = "/pet/findByStatus".Replace("{format}","json"); @@ -291,7 +291,7 @@ try { var response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams); if(response != null){ - return (Array) ApiInvoker.deserialize(response, typeof(Array)); + return (List) ApiInvoker.deserialize(response, typeof(List)); } else { return null; @@ -310,7 +310,7 @@ /// /// Tags to filter by /// - public Array findPetsByTags (string tags) { + public List findPetsByTags (string tags) { // create path and map variables var path = "/pet/findByTags".Replace("{format}","json"); @@ -330,7 +330,7 @@ try { var response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams); if(response != null){ - return (Array) ApiInvoker.deserialize(response, typeof(Array)); + return (List) ApiInvoker.deserialize(response, typeof(List)); } else { return null; diff --git a/samples/client/petstore/csharp/src/Com/Wordnik/Petstore/Api/StoreApi.cs b/samples/client/petstore/csharp/src/Com/Wordnik/Petstore/Api/StoreApi.cs index 22c36a411caf..c085d9c07ac9 100644 --- a/samples/client/petstore/csharp/src/Com/Wordnik/Petstore/Api/StoreApi.cs +++ b/samples/client/petstore/csharp/src/Com/Wordnik/Petstore/Api/StoreApi.cs @@ -21,41 +21,6 @@ return basePath; } - /// - /// Find purchase order by ID For valid response try integer IDs with value <= 5. Anything above 5 or nonintegers will generate API errors - /// - /// ID of pet that needs to be fetched - /// - public Order getOrderById (string orderId) { - // create path and map variables - var path = "/store/order/{orderId}".Replace("{format}","json").Replace("{" + "orderId" + "}", apiInvoker.escapeString(orderId.ToString())); - - // query params - var queryParams = new Dictionary(); - var headerParams = new Dictionary(); - - // verify required params are set - if (orderId == null ) { - throw new ApiException(400, "missing required params"); - } - string paramStr = null; - try { - var response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams); - if(response != null){ - return (Order) ApiInvoker.deserialize(response, typeof(Order)); - } - else { - return null; - } - } catch (ApiException ex) { - if(ex.ErrorCode == 404) { - return null; - } - else { - throw ex; - } - } - } /// /// Delete purchase order by ID For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors /// @@ -92,6 +57,41 @@ } } /// + /// Find purchase order by ID For valid response try integer IDs with value <= 5. Anything above 5 or nonintegers will generate API errors + /// + /// ID of pet that needs to be fetched + /// + public Order getOrderById (string orderId) { + // create path and map variables + var path = "/store/order/{orderId}".Replace("{format}","json").Replace("{" + "orderId" + "}", apiInvoker.escapeString(orderId.ToString())); + + // query params + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + + // verify required params are set + if (orderId == null ) { + throw new ApiException(400, "missing required params"); + } + string paramStr = null; + try { + var response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams); + if(response != null){ + return (Order) ApiInvoker.deserialize(response, typeof(Order)); + } + else { + return null; + } + } catch (ApiException ex) { + if(ex.ErrorCode == 404) { + return null; + } + else { + throw ex; + } + } + } + /// /// Place an order for a pet /// /// order placed for purchasing the pet diff --git a/samples/client/petstore/csharp/src/Com/Wordnik/Petstore/Api/UserApi.cs b/samples/client/petstore/csharp/src/Com/Wordnik/Petstore/Api/UserApi.cs index bde3ed4af4b5..a9c941951516 100644 --- a/samples/client/petstore/csharp/src/Com/Wordnik/Petstore/Api/UserApi.cs +++ b/samples/client/petstore/csharp/src/Com/Wordnik/Petstore/Api/UserApi.cs @@ -21,6 +21,186 @@ return basePath; } + /// + /// Delete user This can only be done by the logged in user. + /// + /// The name that needs to be deleted + /// + public void deleteUser (string username) { + // create path and map variables + var path = "/user/{username}".Replace("{format}","json").Replace("{" + "username" + "}", apiInvoker.escapeString(username.ToString())); + + // query params + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + + // verify required params are set + if (username == null ) { + throw new ApiException(400, "missing required params"); + } + string paramStr = null; + try { + var response = apiInvoker.invokeAPI(basePath, path, "DELETE", queryParams, null, headerParams); + if(response != null){ + return ; + } + else { + return ; + } + } catch (ApiException ex) { + if(ex.ErrorCode == 404) { + return ; + } + else { + throw ex; + } + } + } + /// + /// Get user by user name + /// + /// The name that needs to be fetched. Use user1 for testing. + /// + public User getUserByName (string username) { + // create path and map variables + var path = "/user/{username}".Replace("{format}","json").Replace("{" + "username" + "}", apiInvoker.escapeString(username.ToString())); + + // query params + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + + // verify required params are set + if (username == null ) { + throw new ApiException(400, "missing required params"); + } + string paramStr = null; + try { + var response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams); + if(response != null){ + return (User) ApiInvoker.deserialize(response, typeof(User)); + } + else { + return null; + } + } catch (ApiException ex) { + if(ex.ErrorCode == 404) { + return null; + } + else { + throw ex; + } + } + } + /// + /// Updated user This can only be done by the logged in user. + /// + /// name that need to be deleted + /// Updated user object + /// + public void updateUser (string username, User body) { + // create path and map variables + var path = "/user/{username}".Replace("{format}","json").Replace("{" + "username" + "}", apiInvoker.escapeString(username.ToString())); + + // query params + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + + // verify required params are set + if (username == null || body == null ) { + throw new ApiException(400, "missing required params"); + } + string paramStr = null; + try { + var response = apiInvoker.invokeAPI(basePath, path, "PUT", queryParams, body, headerParams); + if(response != null){ + return ; + } + else { + return ; + } + } catch (ApiException ex) { + if(ex.ErrorCode == 404) { + return ; + } + else { + throw ex; + } + } + } + /// + /// Logs user into the system + /// + /// The user name for login + /// The password for login in clear text + /// + public string loginUser (string username, string password) { + // create path and map variables + var path = "/user/login".Replace("{format}","json"); + + // query params + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + + // verify required params are set + if (username == null || password == null ) { + throw new ApiException(400, "missing required params"); + } + string paramStr = null; + if (username != null){ + paramStr = (username != null && username is DateTime) ? ((DateTime)(object)username).ToString("u") : Convert.ToString(username); + queryParams.Add("username", paramStr); + } + if (password != null){ + paramStr = (password != null && password is DateTime) ? ((DateTime)(object)password).ToString("u") : Convert.ToString(password); + queryParams.Add("password", paramStr); + } + try { + var response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams); + if(response != null){ + return (string) ApiInvoker.deserialize(response, typeof(string)); + } + else { + return null; + } + } catch (ApiException ex) { + if(ex.ErrorCode == 404) { + return null; + } + else { + throw ex; + } + } + } + /// + /// Logs out current logged in user session + /// + /// + public void logoutUser () { + // create path and map variables + var path = "/user/logout".Replace("{format}","json"); + + // query params + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + + string paramStr = null; + try { + var response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams); + if(response != null){ + return ; + } + else { + return ; + } + } catch (ApiException ex) { + if(ex.ErrorCode == 404) { + return ; + } + else { + throw ex; + } + } + } /// /// Create user This can only be done by the logged in user. /// @@ -126,185 +306,5 @@ } } } - /// - /// Updated user This can only be done by the logged in user. - /// - /// name that need to be deleted - /// Updated user object - /// - public void updateUser (string username, User body) { - // create path and map variables - var path = "/user/{username}".Replace("{format}","json").Replace("{" + "username" + "}", apiInvoker.escapeString(username.ToString())); - - // query params - var queryParams = new Dictionary(); - var headerParams = new Dictionary(); - - // verify required params are set - if (username == null || body == null ) { - throw new ApiException(400, "missing required params"); - } - string paramStr = null; - try { - var response = apiInvoker.invokeAPI(basePath, path, "PUT", queryParams, body, headerParams); - if(response != null){ - return ; - } - else { - return ; - } - } catch (ApiException ex) { - if(ex.ErrorCode == 404) { - return ; - } - else { - throw ex; - } - } - } - /// - /// Delete user This can only be done by the logged in user. - /// - /// The name that needs to be deleted - /// - public void deleteUser (string username) { - // create path and map variables - var path = "/user/{username}".Replace("{format}","json").Replace("{" + "username" + "}", apiInvoker.escapeString(username.ToString())); - - // query params - var queryParams = new Dictionary(); - var headerParams = new Dictionary(); - - // verify required params are set - if (username == null ) { - throw new ApiException(400, "missing required params"); - } - string paramStr = null; - try { - var response = apiInvoker.invokeAPI(basePath, path, "DELETE", queryParams, null, headerParams); - if(response != null){ - return ; - } - else { - return ; - } - } catch (ApiException ex) { - if(ex.ErrorCode == 404) { - return ; - } - else { - throw ex; - } - } - } - /// - /// Get user by user name - /// - /// The name that needs to be fetched. Use user1 for testing. - /// - public User getUserByName (string username) { - // create path and map variables - var path = "/user/{username}".Replace("{format}","json").Replace("{" + "username" + "}", apiInvoker.escapeString(username.ToString())); - - // query params - var queryParams = new Dictionary(); - var headerParams = new Dictionary(); - - // verify required params are set - if (username == null ) { - throw new ApiException(400, "missing required params"); - } - string paramStr = null; - try { - var response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams); - if(response != null){ - return (User) ApiInvoker.deserialize(response, typeof(User)); - } - else { - return null; - } - } catch (ApiException ex) { - if(ex.ErrorCode == 404) { - return null; - } - else { - throw ex; - } - } - } - /// - /// Logs user into the system - /// - /// The user name for login - /// The password for login in clear text - /// - public string loginUser (string username, string password) { - // create path and map variables - var path = "/user/login".Replace("{format}","json"); - - // query params - var queryParams = new Dictionary(); - var headerParams = new Dictionary(); - - // verify required params are set - if (username == null || password == null ) { - throw new ApiException(400, "missing required params"); - } - string paramStr = null; - if (username != null){ - paramStr = (username != null && username is DateTime) ? ((DateTime)(object)username).ToString("u") : Convert.ToString(username); - queryParams.Add("username", paramStr); - } - if (password != null){ - paramStr = (password != null && password is DateTime) ? ((DateTime)(object)password).ToString("u") : Convert.ToString(password); - queryParams.Add("password", paramStr); - } - try { - var response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams); - if(response != null){ - return (string) ApiInvoker.deserialize(response, typeof(string)); - } - else { - return null; - } - } catch (ApiException ex) { - if(ex.ErrorCode == 404) { - return null; - } - else { - throw ex; - } - } - } - /// - /// Logs out current logged in user session - /// - /// - public void logoutUser () { - // create path and map variables - var path = "/user/logout".Replace("{format}","json"); - - // query params - var queryParams = new Dictionary(); - var headerParams = new Dictionary(); - - string paramStr = null; - try { - var response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams); - if(response != null){ - return ; - } - else { - return ; - } - } catch (ApiException ex) { - if(ex.ErrorCode == 404) { - return ; - } - else { - throw ex; - } - } - } } } diff --git a/samples/client/petstore/csharp/src/Com/Wordnik/Petstore/Model/Category.cs b/samples/client/petstore/csharp/src/Com/Wordnik/Petstore/Model/Category.cs index e5aa324be6c7..dfad92a046fa 100644 --- a/samples/client/petstore/csharp/src/Com/Wordnik/Petstore/Model/Category.cs +++ b/samples/client/petstore/csharp/src/Com/Wordnik/Petstore/Model/Category.cs @@ -5,10 +5,8 @@ using System.Collections.Generic; namespace Com.Wordnik.Petstore.Model { public class Category { - /* Category unique identifier */ public long id { get; set; } - /* Name of the category */ public string name { get; set; } public override string ToString() { diff --git a/samples/client/petstore/csharp/src/Com/Wordnik/Petstore/Model/Order.cs b/samples/client/petstore/csharp/src/Com/Wordnik/Petstore/Model/Order.cs index d4d5a0d77a1d..ae5012193e77 100644 --- a/samples/client/petstore/csharp/src/Com/Wordnik/Petstore/Model/Order.cs +++ b/samples/client/petstore/csharp/src/Com/Wordnik/Petstore/Model/Order.cs @@ -5,19 +5,15 @@ using System.Collections.Generic; namespace Com.Wordnik.Petstore.Model { public class Order { - /* Unique identifier for the order */ public long id { get; set; } - /* ID of pet being ordered */ public long petId { get; set; } - /* Number of pets ordered */ public int quantity { get; set; } - /* Status of the order */ + /* Order Status */ public string status { get; set; } - /* Date shipped, only if it has been */ public DateTime shipDate { get; set; } public override string ToString() { diff --git a/samples/client/petstore/csharp/src/Com/Wordnik/Petstore/Model/Pet.cs b/samples/client/petstore/csharp/src/Com/Wordnik/Petstore/Model/Pet.cs index 87bca18a1f4a..8bd8f2606012 100644 --- a/samples/client/petstore/csharp/src/Com/Wordnik/Petstore/Model/Pet.cs +++ b/samples/client/petstore/csharp/src/Com/Wordnik/Petstore/Model/Pet.cs @@ -5,19 +5,15 @@ using System.Collections.Generic; namespace Com.Wordnik.Petstore.Model { public class Pet { - /* Unique identifier for the Pet */ + /* unique identifier for the pet */ public long id { get; set; } - /* Category the pet is in */ public Category category { get; set; } - /* Friendly name of the pet */ public string name { get; set; } - /* Image URLs */ public List photoUrls { get; set; } - /* Tags assigned to this pet */ public List tags { get; set; } /* pet status in the store */ diff --git a/samples/client/petstore/csharp/src/Com/Wordnik/Petstore/Model/Tag.cs b/samples/client/petstore/csharp/src/Com/Wordnik/Petstore/Model/Tag.cs index 8a4b38b656b5..61187fbd7724 100644 --- a/samples/client/petstore/csharp/src/Com/Wordnik/Petstore/Model/Tag.cs +++ b/samples/client/petstore/csharp/src/Com/Wordnik/Petstore/Model/Tag.cs @@ -5,10 +5,8 @@ using System.Collections.Generic; namespace Com.Wordnik.Petstore.Model { public class Tag { - /* Unique identifier for the tag */ public long id { get; set; } - /* Friendly name for the tag */ public string name { get; set; } public override string ToString() { diff --git a/samples/client/petstore/csharp/src/Com/Wordnik/Petstore/Model/User.cs b/samples/client/petstore/csharp/src/Com/Wordnik/Petstore/Model/User.cs index adce974f71fd..bbbd6eaccc36 100644 --- a/samples/client/petstore/csharp/src/Com/Wordnik/Petstore/Model/User.cs +++ b/samples/client/petstore/csharp/src/Com/Wordnik/Petstore/Model/User.cs @@ -5,25 +5,18 @@ using System.Collections.Generic; namespace Com.Wordnik.Petstore.Model { public class User { - /* Unique identifier for the user */ public long id { get; set; } - /* Unique username */ - public string username { get; set; } - - /* First name of the user */ public string firstName { get; set; } - /* Last name of the user */ + public string username { get; set; } + public string lastName { get; set; } - /* Email address of the user */ public string email { get; set; } - /* Password name of the user */ public string password { get; set; } - /* Phone number of the user */ public string phone { get; set; } /* User Status */ @@ -33,8 +26,8 @@ namespace Com.Wordnik.Petstore.Model { var 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(" username: ").Append(username).Append("\n"); sb.Append(" lastName: ").Append(lastName).Append("\n"); sb.Append(" email: ").Append(email).Append("\n"); sb.Append(" password: ").Append(password).Append("\n"); diff --git a/samples/client/petstore/java/pom.xml b/samples/client/petstore/java/pom.xml index 63bfe1612b53..76835a980233 100644 --- a/samples/client/petstore/java/pom.xml +++ b/samples/client/petstore/java/pom.xml @@ -1,10 +1,10 @@ 4.0.0 - com.wordnik - swagger-petstore + com.wordnik.client + api-client jar - swagger-petstore + api-client 1.0.0 scm:git:git@github.com:wordnik/swagger-mustache.git 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 index 8f2269c144cc..de64ba9f1e78 100644 --- 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 @@ -146,3 +146,4 @@ public class ApiInvoker { return hostMap.get(host); } } + diff --git a/samples/client/petstore/java/src/main/java/com/wordnik/petstore/api/PetApi.java b/samples/client/petstore/java/src/main/java/com/wordnik/petstore/api/PetApi.java index 4abd43de856b..9dfa392ded96 100644 --- a/samples/client/petstore/java/src/main/java/com/wordnik/petstore/api/PetApi.java +++ b/samples/client/petstore/java/src/main/java/com/wordnik/petstore/api/PetApi.java @@ -22,6 +22,33 @@ public class PetApi { return basePath; } + public void uploadFile (String additionalMetadata, File body) throws ApiException { + // create path and map variables + String path = "/pet/uploadImage".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, body, headerParams, contentType); + if(response != null){ + return ; + } + else { + return ; + } + } catch (ApiException ex) { + if(ex.getCode() == 404) { + return ; + } + else { + throw ex; + } + } + } public Pet getPetById (Long petId) throws ApiException { // verify required params are set if(petId == null ) { @@ -146,33 +173,6 @@ public class PetApi { } } } - public void uploadFile (String additionalMetadata, File body) throws ApiException { - // create path and map variables - String path = "/pet/uploadImage".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, body, headerParams, 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 { // verify required params are set if(body == null ) { diff --git a/samples/client/petstore/java/src/main/java/com/wordnik/petstore/api/StoreApi.java b/samples/client/petstore/java/src/main/java/com/wordnik/petstore/api/StoreApi.java index 9be137cd79f0..3d60b1a7c078 100644 --- a/samples/client/petstore/java/src/main/java/com/wordnik/petstore/api/StoreApi.java +++ b/samples/client/petstore/java/src/main/java/com/wordnik/petstore/api/StoreApi.java @@ -21,37 +21,6 @@ public class StoreApi { return basePath; } - public Order getOrderById (String orderId) throws ApiException { - // verify required params are set - if(orderId == null ) { - throw new ApiException(400, "missing required params"); - } - // 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(); - - String contentType = "application/json"; - - try { - String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, 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 { // verify required params are set if(orderId == null ) { @@ -83,6 +52,37 @@ public class StoreApi { } } } + public Order getOrderById (String orderId) throws ApiException { + // verify required params are set + if(orderId == null ) { + throw new ApiException(400, "missing required params"); + } + // 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(); + + String contentType = "application/json"; + + try { + String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, 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 placeOrder (Order body) throws ApiException { // verify required params are set if(body == null ) { diff --git a/samples/client/petstore/java/src/main/java/com/wordnik/petstore/api/UserApi.java b/samples/client/petstore/java/src/main/java/com/wordnik/petstore/api/UserApi.java index 0527a5a49ca7..7d788f393220 100644 --- a/samples/client/petstore/java/src/main/java/com/wordnik/petstore/api/UserApi.java +++ b/samples/client/petstore/java/src/main/java/com/wordnik/petstore/api/UserApi.java @@ -21,6 +21,161 @@ public class UserApi { return basePath; } + public void deleteUser (String username) throws ApiException { + // verify required params are set + if(username == null ) { + throw new ApiException(400, "missing required params"); + } + // 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(); + + String contentType = "application/json"; + + try { + String response = apiInvoker.invokeAPI(basePath, path, "DELETE", queryParams, null, headerParams, 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 { + // verify required params are set + if(username == null ) { + throw new ApiException(400, "missing required params"); + } + // 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(); + + String contentType = "application/json"; + + try { + String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, 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 { + // verify required params are set + if(username == null || body == null ) { + throw new ApiException(400, "missing required params"); + } + // 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(); + + String contentType = "application/json"; + + try { + String response = apiInvoker.invokeAPI(basePath, path, "PUT", queryParams, body, headerParams, 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 { + // verify required params are set + if(username == null || password == null ) { + throw new ApiException(400, "missing required params"); + } + // create path and map variables + String path = "/user/login".replaceAll("\\{format\\}","json"); + + // query params + Map queryParams = new HashMap(); + Map headerParams = 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 contentType = "application/json"; + + try { + String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, 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 { + // create path and map variables + String path = "/user/logout".replaceAll("\\{format\\}","json"); + + // query params + Map queryParams = new HashMap(); + Map headerParams = new HashMap(); + + String contentType = "application/json"; + + try { + String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, contentType); + if(response != null){ + return ; + } + else { + return ; + } + } catch (ApiException ex) { + if(ex.getCode() == 404) { + return ; + } + else { + throw ex; + } + } + } public void createUser (User body) throws ApiException { // verify required params are set if(body == null ) { @@ -114,160 +269,5 @@ public class UserApi { } } } - public void updateUser (String username, User body) throws ApiException { - // verify required params are set - if(username == null || body == null ) { - throw new ApiException(400, "missing required params"); - } - // 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(); - - String contentType = "application/json"; - - try { - String response = apiInvoker.invokeAPI(basePath, path, "PUT", queryParams, body, headerParams, 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 { - // verify required params are set - if(username == null ) { - throw new ApiException(400, "missing required params"); - } - // 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(); - - String contentType = "application/json"; - - try { - String response = apiInvoker.invokeAPI(basePath, path, "DELETE", queryParams, null, headerParams, 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 { - // verify required params are set - if(username == null ) { - throw new ApiException(400, "missing required params"); - } - // 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(); - - String contentType = "application/json"; - - try { - String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, 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 String loginUser (String username, String password) throws ApiException { - // verify required params are set - if(username == null || password == null ) { - throw new ApiException(400, "missing required params"); - } - // create path and map variables - String path = "/user/login".replaceAll("\\{format\\}","json"); - - // query params - Map queryParams = new HashMap(); - Map headerParams = 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 contentType = "application/json"; - - try { - String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, 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 { - // create path and map variables - String path = "/user/logout".replaceAll("\\{format\\}","json"); - - // query params - Map queryParams = new HashMap(); - Map headerParams = new HashMap(); - - String contentType = "application/json"; - - try { - String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, 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/src/main/java/com/wordnik/petstore/model/Category.java b/samples/client/petstore/java/src/main/java/com/wordnik/petstore/model/Category.java index 080008e4864a..aa9303084bbd 100644 --- a/samples/client/petstore/java/src/main/java/com/wordnik/petstore/model/Category.java +++ b/samples/client/petstore/java/src/main/java/com/wordnik/petstore/model/Category.java @@ -1,9 +1,7 @@ package com.wordnik.petstore.model; public class Category { - /* Category unique identifier */ private Long id = null; - /* Name of the category */ private String name = null; public Long getId() { return id; diff --git a/samples/client/petstore/java/src/main/java/com/wordnik/petstore/model/Order.java b/samples/client/petstore/java/src/main/java/com/wordnik/petstore/model/Order.java index cc462a953ae2..c44ea0f38cc1 100644 --- a/samples/client/petstore/java/src/main/java/com/wordnik/petstore/model/Order.java +++ b/samples/client/petstore/java/src/main/java/com/wordnik/petstore/model/Order.java @@ -2,16 +2,12 @@ package com.wordnik.petstore.model; import java.util.Date; public class Order { - /* Unique identifier for the order */ private Long id = null; - /* ID of pet being ordered */ private Long petId = null; - /* Number of pets ordered */ private Integer quantity = null; - /* Status of the order */ + /* Order Status */ private String status = null; //public enum statusEnum { placed, approved, delivered, }; - /* Date shipped, only if it has been */ private Date shipDate = null; public Long getId() { return id; diff --git a/samples/client/petstore/java/src/main/java/com/wordnik/petstore/model/Pet.java b/samples/client/petstore/java/src/main/java/com/wordnik/petstore/model/Pet.java index 99f0c088fb40..b5a577d1a863 100644 --- a/samples/client/petstore/java/src/main/java/com/wordnik/petstore/model/Pet.java +++ b/samples/client/petstore/java/src/main/java/com/wordnik/petstore/model/Pet.java @@ -4,15 +4,11 @@ import java.util.*; import com.wordnik.petstore.model.Category; import com.wordnik.petstore.model.Tag; public class Pet { - /* Unique identifier for the Pet */ + /* unique identifier for the pet */ private Long id = null; - /* Category the pet is in */ private Category category = null; - /* Friendly name of the pet */ private String name = null; - /* Image URLs */ private List photoUrls = new ArrayList(); - /* Tags assigned to this pet */ private List tags = new ArrayList(); /* pet status in the store */ private String status = null; diff --git a/samples/client/petstore/java/src/main/java/com/wordnik/petstore/model/Tag.java b/samples/client/petstore/java/src/main/java/com/wordnik/petstore/model/Tag.java index 4ce4a0eb5e2b..886a5a6513be 100644 --- a/samples/client/petstore/java/src/main/java/com/wordnik/petstore/model/Tag.java +++ b/samples/client/petstore/java/src/main/java/com/wordnik/petstore/model/Tag.java @@ -1,9 +1,7 @@ package com.wordnik.petstore.model; public class Tag { - /* Unique identifier for the tag */ private Long id = null; - /* Friendly name for the tag */ private String name = null; public Long getId() { return id; diff --git a/samples/client/petstore/java/src/main/java/com/wordnik/petstore/model/User.java b/samples/client/petstore/java/src/main/java/com/wordnik/petstore/model/User.java index 23535b05cd3c..4b28758addea 100644 --- a/samples/client/petstore/java/src/main/java/com/wordnik/petstore/model/User.java +++ b/samples/client/petstore/java/src/main/java/com/wordnik/petstore/model/User.java @@ -1,19 +1,12 @@ package com.wordnik.petstore.model; public class User { - /* Unique identifier for the user */ private Long id = null; - /* Unique username */ - private String username = null; - /* First name of the user */ private String firstName = null; - /* Last name of the user */ + private String username = null; private String lastName = null; - /* Email address of the user */ private String email = null; - /* Password name of the user */ private String password = null; - /* Phone number of the user */ private String phone = null; /* User Status */ private Integer userStatus = null; @@ -25,13 +18,6 @@ public class User { this.id = id; } - public String getUsername() { - return username; - } - public void setUsername(String username) { - this.username = username; - } - public String getFirstName() { return firstName; } @@ -39,6 +25,13 @@ public class User { this.firstName = firstName; } + public String getUsername() { + return username; + } + public void setUsername(String username) { + this.username = username; + } + public String getLastName() { return lastName; } @@ -79,8 +72,8 @@ public class User { 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(" username: ").append(username).append("\n"); sb.append(" lastName: ").append(lastName).append("\n"); sb.append(" email: ").append(email).append("\n"); sb.append(" password: ").append(password).append("\n"); diff --git a/samples/client/petstore/scala/src/main/scala/com/wordnik/client/ApiInvoker.scala b/samples/client/petstore/scala/src/main/scala/com/wordnik/client/ApiInvoker.scala index b9252e8d0f0f..7056e3bee8b5 100644 --- a/samples/client/petstore/scala/src/main/scala/com/wordnik/client/ApiInvoker.scala +++ b/samples/client/petstore/scala/src/main/scala/com/wordnik/client/ApiInvoker.scala @@ -44,6 +44,8 @@ object ApiInvoker { URLEncoder.encode(value, "utf-8").replaceAll("\\+", "%20") } + def addHeader(key: String, value: String) = defaultHeaders += key -> value + def escape(value: Long): String = value.toString def escape(value: Double): String = value.toString def escape(value: Float): String = value.toString