better comment on csharp api, add ParameterToString to handle date

This commit is contained in:
wing328 2015-04-29 16:27:08 +08:00
parent 96d837274e
commit e7b170bf3c
4 changed files with 93 additions and 122 deletions

View File

@ -41,15 +41,16 @@ namespace {{package}} {
/// {{summary}} {{notes}} /// {{summary}} {{notes}}
/// </summary> /// </summary>
{{#allParams}} /// <param name="{{paramName}}">{{description}}</param> {{#allParams}} /// <param name="{{paramName}}">{{description}}</param>
{{/allParams}} /// <returns>{{#returnType}}{{{returnType}}}{{/returnType}}</returns> {{/allParams}}
/// <returns>{{#returnType}}{{{returnType}}}{{/returnType}}</returns>
public {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} {{nickname}} ({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) { public {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} {{nickname}} ({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) {
var _request = new RestRequest("{{path}}", Method.{{httpMethod}}); var _request = new RestRequest("{{path}}", Method.{{httpMethod}});
{{#requiredParams}} {{#allParams}}{{#required}}
// verify required param {{paramName}} is set // verify the required parameter '{{paramName}}' is set
if ({{paramName}} == null) throw new ApiException(400, "missing required params {{paramName}}"); if ({{paramName}} == null) throw new ApiException(400, "Missing required parameter '{{paramName}}' when calling {{nickname}}");
{{/requiredParams}} {{/required}}{{/allParams}}
_request.AddUrlSegment("format", "json"); // set format to json by default _request.AddUrlSegment("format", "json"); // set format to json by default
{{#pathParams}}_request.AddUrlSegment("{{baseName}}", ApiInvoker.ParameterToString({{{paramName}}})); // path (url segment) parameter {{#pathParams}}_request.AddUrlSegment("{{baseName}}", ApiInvoker.ParameterToString({{{paramName}}})); // path (url segment) parameter
@ -58,17 +59,15 @@ namespace {{package}} {
{{/queryParams}} {{/queryParams}}
{{#headerParams}} if ({{paramName}} != null) _request.AddHeader("{{baseName}}", ApiInvoker.ParameterToString({{paramName}})); // header parameter {{#headerParams}} if ({{paramName}} != null) _request.AddHeader("{{baseName}}", ApiInvoker.ParameterToString({{paramName}})); // header parameter
{{/headerParams}} {{/headerParams}}
{{#formParams}}if ({{paramName}} != null) {{#isFile}}_request.AddFile("{{baseName}}", {{paramName}});{{/isFile}}{{^isFile}}_request.AddParameter("{{baseName}}", ApiInvoker.ParameterToString({{paramName}}));{{/isFile}} // form parameter {{#formParams}}if ({{paramName}} != null) {{#isFile}}_request.AddFile("{{baseName}}", {{paramName}});{{/isFile}}{{^isFile}}_request.AddParameter("{{baseName}}", ApiInvoker.ParameterToString({{paramName}})); // form parameter{{/isFile}}
{{/formParams}} {{/formParams}}
{{#bodyParam}} {{#bodyParam}}_request.AddParameter("application/json", ApiInvoker.Serialize({{paramName}}), ParameterType.RequestBody); // http body (model) parameter
_request.AddParameter("application/json", ApiInvoker.Serialize({{paramName}}), ParameterType.RequestBody); // HTTP request body (model)
{{/bodyParam}} {{/bodyParam}}
try { try {
// make the HTTP request
{{#returnType}}IRestResponse response = restClient.Execute(_request); {{#returnType}}IRestResponse response = restClient.Execute(_request);
return ({{{returnType}}}) ApiInvoker.Deserialize(response.Content, typeof({{{returnType}}})); return ({{{returnType}}}) ApiInvoker.Deserialize(response.Content, typeof({{{returnType}}}));{{/returnType}}{{^returnType}}restClient.Execute(_request);
//return ((object)response) as {{{returnType}}};{{/returnType}}
{{^returnType}}restClient.Execute(_request);
return;{{/returnType}} return;{{/returnType}}
} catch (Exception ex) { } catch (Exception ex) {
if(ex != null) { if(ex != null) {

View File

@ -40,9 +40,7 @@ namespace io.swagger.Api {
/// </summary> /// </summary>
/// <param name="Body">Pet object that needs to be added to the store</param> /// <param name="Body">Pet object that needs to be added to the store</param>
/// <returns></returns> /// <returns></returns>
public void UpdatePet (Pet Body) { public void UpdatePet (Pet Body) {
// create path and map variables
var path = "/pet".Replace("{format}","json");
var _request = new RestRequest("/pet", Method.PUT); var _request = new RestRequest("/pet", Method.PUT);
@ -53,12 +51,11 @@ namespace io.swagger.Api {
_request.AddParameter("application/json", ApiInvoker.Serialize(Body), ParameterType.RequestBody); // http body (model) parameter
_request.AddParameter("application/json", ApiInvoker.Serialize(Body), ParameterType.RequestBody); // HTTP request body (model)
try { try {
// make the HTTP request
restClient.Execute(_request); restClient.Execute(_request);
return; return;
} catch (Exception ex) { } catch (Exception ex) {
@ -77,9 +74,7 @@ namespace io.swagger.Api {
/// </summary> /// </summary>
/// <param name="Body">Pet object that needs to be added to the store</param> /// <param name="Body">Pet object that needs to be added to the store</param>
/// <returns></returns> /// <returns></returns>
public void AddPet (Pet Body) { public void AddPet (Pet Body) {
// create path and map variables
var path = "/pet".Replace("{format}","json");
var _request = new RestRequest("/pet", Method.POST); var _request = new RestRequest("/pet", Method.POST);
@ -90,12 +85,11 @@ namespace io.swagger.Api {
_request.AddParameter("application/json", ApiInvoker.Serialize(Body), ParameterType.RequestBody); // http body (model) parameter
_request.AddParameter("application/json", ApiInvoker.Serialize(Body), ParameterType.RequestBody); // HTTP request body (model)
try { try {
// make the HTTP request
restClient.Execute(_request); restClient.Execute(_request);
return; return;
} catch (Exception ex) { } catch (Exception ex) {
@ -113,10 +107,8 @@ namespace io.swagger.Api {
/// Finds Pets by status Multiple status values can be provided with comma seperated strings /// Finds Pets by status Multiple status values can be provided with comma seperated strings
/// </summary> /// </summary>
/// <param name="Status">Status values that need to be considered for filter</param> /// <param name="Status">Status values that need to be considered for filter</param>
/// <returns></returns> /// <returns>List<Pet></returns>
public List<Pet> FindPetsByStatus (List<string> Status) { public List<Pet> FindPetsByStatus (List<string> Status) {
// create path and map variables
var path = "/pet/findByStatus".Replace("{format}","json");
var _request = new RestRequest("/pet/findByStatus", Method.GET); var _request = new RestRequest("/pet/findByStatus", Method.GET);
@ -131,10 +123,9 @@ namespace io.swagger.Api {
try { try {
// make the HTTP request
IRestResponse response = restClient.Execute(_request); IRestResponse response = restClient.Execute(_request);
return (List<Pet>) ApiInvoker.Deserialize(response.Content, typeof(List<Pet>)); return (List<Pet>) ApiInvoker.Deserialize(response.Content, typeof(List<Pet>));
//return ((object)response) as List<Pet>;
} catch (Exception ex) { } catch (Exception ex) {
if(ex != null) { if(ex != null) {
return null; return null;
@ -150,10 +141,8 @@ namespace io.swagger.Api {
/// Finds Pets by tags Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. /// Finds Pets by tags Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.
/// </summary> /// </summary>
/// <param name="Tags">Tags to filter by</param> /// <param name="Tags">Tags to filter by</param>
/// <returns></returns> /// <returns>List<Pet></returns>
public List<Pet> FindPetsByTags (List<string> Tags) { public List<Pet> FindPetsByTags (List<string> Tags) {
// create path and map variables
var path = "/pet/findByTags".Replace("{format}","json");
var _request = new RestRequest("/pet/findByTags", Method.GET); var _request = new RestRequest("/pet/findByTags", Method.GET);
@ -168,10 +157,9 @@ namespace io.swagger.Api {
try { try {
// make the HTTP request
IRestResponse response = restClient.Execute(_request); IRestResponse response = restClient.Execute(_request);
return (List<Pet>) ApiInvoker.Deserialize(response.Content, typeof(List<Pet>)); return (List<Pet>) ApiInvoker.Deserialize(response.Content, typeof(List<Pet>));
//return ((object)response) as List<Pet>;
} catch (Exception ex) { } catch (Exception ex) {
if(ex != null) { if(ex != null) {
return null; return null;
@ -187,14 +175,15 @@ namespace io.swagger.Api {
/// Find pet by ID Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions /// Find pet by ID Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions
/// </summary> /// </summary>
/// <param name="PetId">ID of pet that needs to be fetched</param> /// <param name="PetId">ID of pet that needs to be fetched</param>
/// <returns></returns> /// <returns>Pet</returns>
public Pet GetPetById (long? PetId) { public Pet GetPetById (long? PetId) {
// create path and map variables
var path = "/pet/{petId}".Replace("{format}","json").Replace("{" + "petId" + "}", apiInvoker.ParameterToString(PetId));
var _request = new RestRequest("/pet/{petId}", Method.GET); var _request = new RestRequest("/pet/{petId}", Method.GET);
// verify the required parameter 'PetId' is set
if (PetId == null) throw new ApiException(400, "Missing required parameter 'PetId' when calling GetPetById");
_request.AddUrlSegment("format", "json"); // set format to json by default _request.AddUrlSegment("format", "json"); // set format to json by default
_request.AddUrlSegment("petId", ApiInvoker.ParameterToString(PetId)); // path (url segment) parameter _request.AddUrlSegment("petId", ApiInvoker.ParameterToString(PetId)); // path (url segment) parameter
@ -205,10 +194,9 @@ namespace io.swagger.Api {
try { try {
// make the HTTP request
IRestResponse response = restClient.Execute(_request); IRestResponse response = restClient.Execute(_request);
return (Pet) ApiInvoker.Deserialize(response.Content, typeof(Pet)); return (Pet) ApiInvoker.Deserialize(response.Content, typeof(Pet));
//return ((object)response) as Pet;
} catch (Exception ex) { } catch (Exception ex) {
if(ex != null) { if(ex != null) {
return null; return null;
@ -227,13 +215,14 @@ namespace io.swagger.Api {
/// <param name="Name">Updated name of the pet</param> /// <param name="Name">Updated name of the pet</param>
/// <param name="Status">Updated status of the pet</param> /// <param name="Status">Updated status of the pet</param>
/// <returns></returns> /// <returns></returns>
public void UpdatePetWithForm (string PetId, string Name, string Status) { public void UpdatePetWithForm (string PetId, string Name, string Status) {
// create path and map variables
var path = "/pet/{petId}".Replace("{format}","json").Replace("{" + "petId" + "}", apiInvoker.ParameterToString(PetId));
var _request = new RestRequest("/pet/{petId}", Method.POST); var _request = new RestRequest("/pet/{petId}", Method.POST);
// verify the required parameter 'PetId' is set
if (PetId == null) throw new ApiException(400, "Missing required parameter 'PetId' when calling UpdatePetWithForm");
_request.AddUrlSegment("format", "json"); // set format to json by default _request.AddUrlSegment("format", "json"); // set format to json by default
_request.AddUrlSegment("petId", ApiInvoker.ParameterToString(PetId)); // path (url segment) parameter _request.AddUrlSegment("petId", ApiInvoker.ParameterToString(PetId)); // path (url segment) parameter
@ -246,7 +235,7 @@ namespace io.swagger.Api {
try { try {
// make the HTTP request
restClient.Execute(_request); restClient.Execute(_request);
return; return;
} catch (Exception ex) { } catch (Exception ex) {
@ -266,13 +255,14 @@ namespace io.swagger.Api {
/// <param name="ApiKey"></param> /// <param name="ApiKey"></param>
/// <param name="PetId">Pet id to delete</param> /// <param name="PetId">Pet id to delete</param>
/// <returns></returns> /// <returns></returns>
public void DeletePet (string ApiKey, long? PetId) { public void DeletePet (string ApiKey, long? PetId) {
// create path and map variables
var path = "/pet/{petId}".Replace("{format}","json").Replace("{" + "petId" + "}", apiInvoker.ParameterToString(PetId));
var _request = new RestRequest("/pet/{petId}", Method.DELETE); var _request = new RestRequest("/pet/{petId}", Method.DELETE);
// verify the required parameter 'PetId' is set
if (PetId == null) throw new ApiException(400, "Missing required parameter 'PetId' when calling DeletePet");
_request.AddUrlSegment("format", "json"); // set format to json by default _request.AddUrlSegment("format", "json"); // set format to json by default
_request.AddUrlSegment("petId", ApiInvoker.ParameterToString(PetId)); // path (url segment) parameter _request.AddUrlSegment("petId", ApiInvoker.ParameterToString(PetId)); // path (url segment) parameter
@ -284,7 +274,7 @@ namespace io.swagger.Api {
try { try {
// make the HTTP request
restClient.Execute(_request); restClient.Execute(_request);
return; return;
} catch (Exception ex) { } catch (Exception ex) {
@ -305,13 +295,14 @@ namespace io.swagger.Api {
/// <param name="AdditionalMetadata">Additional data to pass to server</param> /// <param name="AdditionalMetadata">Additional data to pass to server</param>
/// <param name="File">file to upload</param> /// <param name="File">file to upload</param>
/// <returns></returns> /// <returns></returns>
public void UploadFile (long? PetId, string AdditionalMetadata, byte[] File) { public void UploadFile (long? PetId, string AdditionalMetadata, string File) {
// create path and map variables
var path = "/pet/{petId}/uploadImage".Replace("{format}","json").Replace("{" + "petId" + "}", apiInvoker.ParameterToString(PetId));
var _request = new RestRequest("/pet/{petId}/uploadImage", Method.POST); var _request = new RestRequest("/pet/{petId}/uploadImage", Method.POST);
// verify the required parameter 'PetId' is set
if (PetId == null) throw new ApiException(400, "Missing required parameter 'PetId' when calling UploadFile");
_request.AddUrlSegment("format", "json"); // set format to json by default _request.AddUrlSegment("format", "json"); // set format to json by default
_request.AddUrlSegment("petId", ApiInvoker.ParameterToString(PetId)); // path (url segment) parameter _request.AddUrlSegment("petId", ApiInvoker.ParameterToString(PetId)); // path (url segment) parameter
@ -319,12 +310,12 @@ namespace io.swagger.Api {
if (AdditionalMetadata != null) _request.AddParameter("additionalMetadata", ApiInvoker.ParameterToString(AdditionalMetadata)); // form parameter if (AdditionalMetadata != null) _request.AddParameter("additionalMetadata", ApiInvoker.ParameterToString(AdditionalMetadata)); // form parameter
if (File != null) _request.AddFile("file", File); // form parameter if (File != null) _request.AddFile("file", File);
try { try {
// make the HTTP request
restClient.Execute(_request); restClient.Execute(_request);
return; return;
} catch (Exception ex) { } catch (Exception ex) {

View File

@ -38,10 +38,8 @@ namespace io.swagger.Api {
/// <summary> /// <summary>
/// Returns pet inventories by status Returns a map of status codes to quantities /// Returns pet inventories by status Returns a map of status codes to quantities
/// </summary> /// </summary>
/// <returns></returns> /// <returns>Dictionary<String, int?></returns>
public Dictionary<String, int?> GetInventory () { public Dictionary<String, int?> GetInventory () {
// create path and map variables
var path = "/store/inventory".Replace("{format}","json");
var _request = new RestRequest("/store/inventory", Method.GET); var _request = new RestRequest("/store/inventory", Method.GET);
@ -55,10 +53,9 @@ namespace io.swagger.Api {
try { try {
// make the HTTP request
IRestResponse response = restClient.Execute(_request); IRestResponse response = restClient.Execute(_request);
return (Dictionary<String, int?>) ApiInvoker.Deserialize(response.Content, typeof(Dictionary<String, int?>)); return (Dictionary<String, int?>) ApiInvoker.Deserialize(response.Content, typeof(Dictionary<String, int?>));
//return ((object)response) as Dictionary<String, int?>;
} catch (Exception ex) { } catch (Exception ex) {
if(ex != null) { if(ex != null) {
return null; return null;
@ -74,10 +71,8 @@ namespace io.swagger.Api {
/// Place an order for a pet /// Place an order for a pet
/// </summary> /// </summary>
/// <param name="Body">order placed for purchasing the pet</param> /// <param name="Body">order placed for purchasing the pet</param>
/// <returns></returns> /// <returns>Order</returns>
public Order PlaceOrder (Order Body) { public Order PlaceOrder (Order Body) {
// create path and map variables
var path = "/store/order".Replace("{format}","json");
var _request = new RestRequest("/store/order", Method.POST); var _request = new RestRequest("/store/order", Method.POST);
@ -88,15 +83,13 @@ namespace io.swagger.Api {
_request.AddParameter("application/json", ApiInvoker.Serialize(Body), ParameterType.RequestBody); // http body (model) parameter
_request.AddParameter("application/json", ApiInvoker.Serialize(Body), ParameterType.RequestBody); // HTTP request body (model)
try { try {
// make the HTTP request
IRestResponse response = restClient.Execute(_request); IRestResponse response = restClient.Execute(_request);
return (Order) ApiInvoker.Deserialize(response.Content, typeof(Order)); return (Order) ApiInvoker.Deserialize(response.Content, typeof(Order));
//return ((object)response) as Order;
} catch (Exception ex) { } catch (Exception ex) {
if(ex != null) { if(ex != null) {
return null; return null;
@ -112,14 +105,15 @@ namespace io.swagger.Api {
/// Find purchase order by ID For valid response try integer IDs with value &lt;= 5 or &gt; 10. Other values will generated exceptions /// Find purchase order by ID For valid response try integer IDs with value &lt;= 5 or &gt; 10. Other values will generated exceptions
/// </summary> /// </summary>
/// <param name="OrderId">ID of pet that needs to be fetched</param> /// <param name="OrderId">ID of pet that needs to be fetched</param>
/// <returns></returns> /// <returns>Order</returns>
public Order GetOrderById (string OrderId) { public Order GetOrderById (string OrderId) {
// create path and map variables
var path = "/store/order/{orderId}".Replace("{format}","json").Replace("{" + "orderId" + "}", apiInvoker.ParameterToString(OrderId));
var _request = new RestRequest("/store/order/{orderId}", Method.GET); var _request = new RestRequest("/store/order/{orderId}", Method.GET);
// verify the required parameter 'OrderId' is set
if (OrderId == null) throw new ApiException(400, "Missing required parameter 'OrderId' when calling GetOrderById");
_request.AddUrlSegment("format", "json"); // set format to json by default _request.AddUrlSegment("format", "json"); // set format to json by default
_request.AddUrlSegment("orderId", ApiInvoker.ParameterToString(OrderId)); // path (url segment) parameter _request.AddUrlSegment("orderId", ApiInvoker.ParameterToString(OrderId)); // path (url segment) parameter
@ -130,10 +124,9 @@ namespace io.swagger.Api {
try { try {
// make the HTTP request
IRestResponse response = restClient.Execute(_request); IRestResponse response = restClient.Execute(_request);
return (Order) ApiInvoker.Deserialize(response.Content, typeof(Order)); return (Order) ApiInvoker.Deserialize(response.Content, typeof(Order));
//return ((object)response) as Order;
} catch (Exception ex) { } catch (Exception ex) {
if(ex != null) { if(ex != null) {
return null; return null;
@ -150,13 +143,14 @@ namespace io.swagger.Api {
/// </summary> /// </summary>
/// <param name="OrderId">ID of the order that needs to be deleted</param> /// <param name="OrderId">ID of the order that needs to be deleted</param>
/// <returns></returns> /// <returns></returns>
public void DeleteOrder (string OrderId) { public void DeleteOrder (string OrderId) {
// create path and map variables
var path = "/store/order/{orderId}".Replace("{format}","json").Replace("{" + "orderId" + "}", apiInvoker.ParameterToString(OrderId));
var _request = new RestRequest("/store/order/{orderId}", Method.DELETE); var _request = new RestRequest("/store/order/{orderId}", Method.DELETE);
// verify the required parameter 'OrderId' is set
if (OrderId == null) throw new ApiException(400, "Missing required parameter 'OrderId' when calling DeleteOrder");
_request.AddUrlSegment("format", "json"); // set format to json by default _request.AddUrlSegment("format", "json"); // set format to json by default
_request.AddUrlSegment("orderId", ApiInvoker.ParameterToString(OrderId)); // path (url segment) parameter _request.AddUrlSegment("orderId", ApiInvoker.ParameterToString(OrderId)); // path (url segment) parameter
@ -167,7 +161,7 @@ namespace io.swagger.Api {
try { try {
// make the HTTP request
restClient.Execute(_request); restClient.Execute(_request);
return; return;
} catch (Exception ex) { } catch (Exception ex) {

View File

@ -40,9 +40,7 @@ namespace io.swagger.Api {
/// </summary> /// </summary>
/// <param name="Body">Created user object</param> /// <param name="Body">Created user object</param>
/// <returns></returns> /// <returns></returns>
public void CreateUser (User Body) { public void CreateUser (User Body) {
// create path and map variables
var path = "/user".Replace("{format}","json");
var _request = new RestRequest("/user", Method.POST); var _request = new RestRequest("/user", Method.POST);
@ -53,12 +51,11 @@ namespace io.swagger.Api {
_request.AddParameter("application/json", ApiInvoker.Serialize(Body), ParameterType.RequestBody); // http body (model) parameter
_request.AddParameter("application/json", ApiInvoker.Serialize(Body), ParameterType.RequestBody); // HTTP request body (model)
try { try {
// make the HTTP request
restClient.Execute(_request); restClient.Execute(_request);
return; return;
} catch (Exception ex) { } catch (Exception ex) {
@ -77,9 +74,7 @@ namespace io.swagger.Api {
/// </summary> /// </summary>
/// <param name="Body">List of user object</param> /// <param name="Body">List of user object</param>
/// <returns></returns> /// <returns></returns>
public void CreateUsersWithArrayInput (List<User> Body) { public void CreateUsersWithArrayInput (List<User> Body) {
// create path and map variables
var path = "/user/createWithArray".Replace("{format}","json");
var _request = new RestRequest("/user/createWithArray", Method.POST); var _request = new RestRequest("/user/createWithArray", Method.POST);
@ -90,12 +85,11 @@ namespace io.swagger.Api {
_request.AddParameter("application/json", ApiInvoker.Serialize(Body), ParameterType.RequestBody); // http body (model) parameter
_request.AddParameter("application/json", ApiInvoker.Serialize(Body), ParameterType.RequestBody); // HTTP request body (model)
try { try {
// make the HTTP request
restClient.Execute(_request); restClient.Execute(_request);
return; return;
} catch (Exception ex) { } catch (Exception ex) {
@ -114,9 +108,7 @@ namespace io.swagger.Api {
/// </summary> /// </summary>
/// <param name="Body">List of user object</param> /// <param name="Body">List of user object</param>
/// <returns></returns> /// <returns></returns>
public void CreateUsersWithListInput (List<User> Body) { public void CreateUsersWithListInput (List<User> Body) {
// create path and map variables
var path = "/user/createWithList".Replace("{format}","json");
var _request = new RestRequest("/user/createWithList", Method.POST); var _request = new RestRequest("/user/createWithList", Method.POST);
@ -127,12 +119,11 @@ namespace io.swagger.Api {
_request.AddParameter("application/json", ApiInvoker.Serialize(Body), ParameterType.RequestBody); // http body (model) parameter
_request.AddParameter("application/json", ApiInvoker.Serialize(Body), ParameterType.RequestBody); // HTTP request body (model)
try { try {
// make the HTTP request
restClient.Execute(_request); restClient.Execute(_request);
return; return;
} catch (Exception ex) { } catch (Exception ex) {
@ -151,11 +142,8 @@ namespace io.swagger.Api {
/// </summary> /// </summary>
/// <param name="Username">The user name for login</param> /// <param name="Username">The user name for login</param>
/// <param name="Password">The password for login in clear text</param> /// <param name="Password">The password for login in clear text</param>
/// <returns>string</returns>
/// <returns></returns> public string LoginUser (string Username, string Password) {
public string LoginUser (string Username, string Password) {
// create path and map variables
var path = "/user/login".Replace("{format}","json");
var _request = new RestRequest("/user/login", Method.GET); var _request = new RestRequest("/user/login", Method.GET);
@ -171,10 +159,9 @@ namespace io.swagger.Api {
try { try {
// make the HTTP request
IRestResponse response = restClient.Execute(_request); IRestResponse response = restClient.Execute(_request);
return (string) ApiInvoker.Deserialize(response.Content, typeof(string)); return (string) ApiInvoker.Deserialize(response.Content, typeof(string));
//return ((object)response) as string;
} catch (Exception ex) { } catch (Exception ex) {
if(ex != null) { if(ex != null) {
return null; return null;
@ -190,9 +177,7 @@ namespace io.swagger.Api {
/// Logs out current logged in user session /// Logs out current logged in user session
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public void LogoutUser () { public void LogoutUser () {
// create path and map variables
var path = "/user/logout".Replace("{format}","json");
var _request = new RestRequest("/user/logout", Method.GET); var _request = new RestRequest("/user/logout", Method.GET);
@ -206,7 +191,7 @@ namespace io.swagger.Api {
try { try {
// make the HTTP request
restClient.Execute(_request); restClient.Execute(_request);
return; return;
} catch (Exception ex) { } catch (Exception ex) {
@ -224,13 +209,15 @@ namespace io.swagger.Api {
/// Get user by user name /// Get user by user name
/// </summary> /// </summary>
/// <param name="Username">The name that needs to be fetched. Use user1 for testing. </param> /// <param name="Username">The name that needs to be fetched. Use user1 for testing. </param>
public User GetUserByName (string Username) { /// <returns>User</returns>
// create path and map variables public User GetUserByName (string Username) {
var path = "/user/{username}".Replace("{format}","json").Replace("{" + "username" + "}", apiInvoker.ParameterToString(Username));
var _request = new RestRequest("/user/{username}", Method.GET); var _request = new RestRequest("/user/{username}", Method.GET);
// verify the required parameter 'Username' is set
if (Username == null) throw new ApiException(400, "Missing required parameter 'Username' when calling GetUserByName");
_request.AddUrlSegment("format", "json"); // set format to json by default _request.AddUrlSegment("format", "json"); // set format to json by default
_request.AddUrlSegment("username", ApiInvoker.ParameterToString(Username)); // path (url segment) parameter _request.AddUrlSegment("username", ApiInvoker.ParameterToString(Username)); // path (url segment) parameter
@ -241,10 +228,9 @@ namespace io.swagger.Api {
try { try {
// make the HTTP request
IRestResponse response = restClient.Execute(_request); IRestResponse response = restClient.Execute(_request);
return (User) ApiInvoker.Deserialize(response.Content, typeof(User)); return (User) ApiInvoker.Deserialize(response.Content, typeof(User));
//return ((object)response) as User;
} catch (Exception ex) { } catch (Exception ex) {
if(ex != null) { if(ex != null) {
return null; return null;
@ -262,13 +248,14 @@ namespace io.swagger.Api {
/// <param name="Username">name that need to be deleted</param> /// <param name="Username">name that need to be deleted</param>
/// <param name="Body">Updated user object</param> /// <param name="Body">Updated user object</param>
/// <returns></returns> /// <returns></returns>
public void UpdateUser (string Username, User Body) { public void UpdateUser (string Username, User Body) {
// create path and map variables
var path = "/user/{username}".Replace("{format}","json").Replace("{" + "username" + "}", apiInvoker.ParameterToString(Username));
var _request = new RestRequest("/user/{username}", Method.PUT); var _request = new RestRequest("/user/{username}", Method.PUT);
// verify the required parameter 'Username' is set
if (Username == null) throw new ApiException(400, "Missing required parameter 'Username' when calling UpdateUser");
_request.AddUrlSegment("format", "json"); // set format to json by default _request.AddUrlSegment("format", "json"); // set format to json by default
_request.AddUrlSegment("username", ApiInvoker.ParameterToString(Username)); // path (url segment) parameter _request.AddUrlSegment("username", ApiInvoker.ParameterToString(Username)); // path (url segment) parameter
@ -276,12 +263,11 @@ namespace io.swagger.Api {
_request.AddParameter("application/json", ApiInvoker.Serialize(Body), ParameterType.RequestBody); // http body (model) parameter
_request.AddParameter("application/json", ApiInvoker.Serialize(Body), ParameterType.RequestBody); // HTTP request body (model)
try { try {
// make the HTTP request
restClient.Execute(_request); restClient.Execute(_request);
return; return;
} catch (Exception ex) { } catch (Exception ex) {
@ -300,13 +286,14 @@ namespace io.swagger.Api {
/// </summary> /// </summary>
/// <param name="Username">The name that needs to be deleted</param> /// <param name="Username">The name that needs to be deleted</param>
/// <returns></returns> /// <returns></returns>
public void DeleteUser (string Username) { public void DeleteUser (string Username) {
// create path and map variables
var path = "/user/{username}".Replace("{format}","json").Replace("{" + "username" + "}", apiInvoker.ParameterToString(Username));
var _request = new RestRequest("/user/{username}", Method.DELETE); var _request = new RestRequest("/user/{username}", Method.DELETE);
// verify the required parameter 'Username' is set
if (Username == null) throw new ApiException(400, "Missing required parameter 'Username' when calling DeleteUser");
_request.AddUrlSegment("format", "json"); // set format to json by default _request.AddUrlSegment("format", "json"); // set format to json by default
_request.AddUrlSegment("username", ApiInvoker.ParameterToString(Username)); // path (url segment) parameter _request.AddUrlSegment("username", ApiInvoker.ParameterToString(Username)); // path (url segment) parameter
@ -317,7 +304,7 @@ namespace io.swagger.Api {
try { try {
// make the HTTP request
restClient.Execute(_request); restClient.Execute(_request);
return; return;
} catch (Exception ex) { } catch (Exception ex) {