diff --git a/modules/swagger-codegen/src/main/resources/csharp/api.mustache b/modules/swagger-codegen/src/main/resources/csharp/api.mustache
index 493a5a4de7c..c524d7ed329 100644
--- a/modules/swagger-codegen/src/main/resources/csharp/api.mustache
+++ b/modules/swagger-codegen/src/main/resources/csharp/api.mustache
@@ -41,15 +41,16 @@ namespace {{package}} {
/// {{summary}} {{notes}}
///
{{#allParams}} /// {{description}}
-{{/allParams}} /// {{#returnType}}{{{returnType}}}{{/returnType}}
+{{/allParams}}
+ /// {{#returnType}}{{{returnType}}}{{/returnType}}
public {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} {{nickname}} ({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) {
var _request = new RestRequest("{{path}}", Method.{{httpMethod}});
- {{#requiredParams}}
- // verify required param {{paramName}} is set
- if ({{paramName}} == null) throw new ApiException(400, "missing required params {{paramName}}");
- {{/requiredParams}}
+ {{#allParams}}{{#required}}
+ // verify the required parameter '{{paramName}}' is set
+ if ({{paramName}} == null) throw new ApiException(400, "Missing required parameter '{{paramName}}' when calling {{nickname}}");
+ {{/required}}{{/allParams}}
_request.AddUrlSegment("format", "json"); // set format to json by default
{{#pathParams}}_request.AddUrlSegment("{{baseName}}", ApiInvoker.ParameterToString({{{paramName}}})); // path (url segment) parameter
@@ -58,17 +59,15 @@ namespace {{package}} {
{{/queryParams}}
{{#headerParams}} if ({{paramName}} != null) _request.AddHeader("{{baseName}}", ApiInvoker.ParameterToString({{paramName}})); // header parameter
{{/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}}
- {{#bodyParam}}
- _request.AddParameter("application/json", ApiInvoker.Serialize({{paramName}}), ParameterType.RequestBody); // HTTP request body (model)
+ {{#bodyParam}}_request.AddParameter("application/json", ApiInvoker.Serialize({{paramName}}), ParameterType.RequestBody); // http body (model) parameter
{{/bodyParam}}
try {
+ // make the HTTP request
{{#returnType}}IRestResponse response = restClient.Execute(_request);
- return ({{{returnType}}}) ApiInvoker.Deserialize(response.Content, typeof({{{returnType}}}));
- //return ((object)response) as {{{returnType}}};{{/returnType}}
- {{^returnType}}restClient.Execute(_request);
+ return ({{{returnType}}}) ApiInvoker.Deserialize(response.Content, typeof({{{returnType}}}));{{/returnType}}{{^returnType}}restClient.Execute(_request);
return;{{/returnType}}
} catch (Exception ex) {
if(ex != null) {
diff --git a/samples/client/petstore/csharp/src/main/csharp/io/swagger/Api/PetApi.cs b/samples/client/petstore/csharp/src/main/csharp/io/swagger/Api/PetApi.cs
index 52f67631966..850d9fc5c54 100644
--- a/samples/client/petstore/csharp/src/main/csharp/io/swagger/Api/PetApi.cs
+++ b/samples/client/petstore/csharp/src/main/csharp/io/swagger/Api/PetApi.cs
@@ -40,9 +40,7 @@ namespace io.swagger.Api {
///
/// Pet object that needs to be added to the store
///
- public void UpdatePet (Pet Body) {
- // create path and map variables
- var path = "/pet".Replace("{format}","json");
+ public void UpdatePet (Pet Body) {
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 request body (model)
+ _request.AddParameter("application/json", ApiInvoker.Serialize(Body), ParameterType.RequestBody); // http body (model) parameter
try {
-
+ // make the HTTP request
restClient.Execute(_request);
return;
} catch (Exception ex) {
@@ -77,9 +74,7 @@ namespace io.swagger.Api {
///
/// Pet object that needs to be added to the store
///
- public void AddPet (Pet Body) {
- // create path and map variables
- var path = "/pet".Replace("{format}","json");
+ public void AddPet (Pet Body) {
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 request body (model)
+ _request.AddParameter("application/json", ApiInvoker.Serialize(Body), ParameterType.RequestBody); // http body (model) parameter
try {
-
+ // make the HTTP request
restClient.Execute(_request);
return;
} 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
///
/// Status values that need to be considered for filter
- ///
- public List FindPetsByStatus (List Status) {
- // create path and map variables
- var path = "/pet/findByStatus".Replace("{format}","json");
+ /// List
+ public List FindPetsByStatus (List Status) {
var _request = new RestRequest("/pet/findByStatus", Method.GET);
@@ -131,10 +123,9 @@ namespace io.swagger.Api {
try {
+ // make the HTTP request
IRestResponse response = restClient.Execute(_request);
return (List) ApiInvoker.Deserialize(response.Content, typeof(List));
- //return ((object)response) as List;
-
} catch (Exception ex) {
if(ex != 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.
///
/// Tags to filter by
- ///
- public List FindPetsByTags (List Tags) {
- // create path and map variables
- var path = "/pet/findByTags".Replace("{format}","json");
+ /// List
+ public List FindPetsByTags (List Tags) {
var _request = new RestRequest("/pet/findByTags", Method.GET);
@@ -168,10 +157,9 @@ namespace io.swagger.Api {
try {
+ // make the HTTP request
IRestResponse response = restClient.Execute(_request);
return (List) ApiInvoker.Deserialize(response.Content, typeof(List));
- //return ((object)response) as List;
-
} catch (Exception ex) {
if(ex != null) {
return null;
@@ -187,14 +175,15 @@ namespace io.swagger.Api {
/// Find pet by ID Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
///
/// ID of pet that needs to be fetched
- ///
- public Pet GetPetById (long? PetId) {
- // create path and map variables
- var path = "/pet/{petId}".Replace("{format}","json").Replace("{" + "petId" + "}", apiInvoker.ParameterToString(PetId));
+ /// Pet
+ public Pet GetPetById (long? PetId) {
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("petId", ApiInvoker.ParameterToString(PetId)); // path (url segment) parameter
@@ -205,10 +194,9 @@ namespace io.swagger.Api {
try {
+ // make the HTTP request
IRestResponse response = restClient.Execute(_request);
return (Pet) ApiInvoker.Deserialize(response.Content, typeof(Pet));
- //return ((object)response) as Pet;
-
} catch (Exception ex) {
if(ex != null) {
return null;
@@ -227,13 +215,14 @@ namespace io.swagger.Api {
/// Updated name of the pet
/// Updated status of the pet
///
- 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));
+ public void UpdatePetWithForm (string PetId, string Name, string Status) {
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("petId", ApiInvoker.ParameterToString(PetId)); // path (url segment) parameter
@@ -246,7 +235,7 @@ namespace io.swagger.Api {
try {
-
+ // make the HTTP request
restClient.Execute(_request);
return;
} catch (Exception ex) {
@@ -266,13 +255,14 @@ namespace io.swagger.Api {
///
/// Pet id to delete
///
- public void DeletePet (string ApiKey, long? PetId) {
- // create path and map variables
- var path = "/pet/{petId}".Replace("{format}","json").Replace("{" + "petId" + "}", apiInvoker.ParameterToString(PetId));
+ public void DeletePet (string ApiKey, long? PetId) {
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("petId", ApiInvoker.ParameterToString(PetId)); // path (url segment) parameter
@@ -284,7 +274,7 @@ namespace io.swagger.Api {
try {
-
+ // make the HTTP request
restClient.Execute(_request);
return;
} catch (Exception ex) {
@@ -305,13 +295,14 @@ namespace io.swagger.Api {
/// Additional data to pass to server
/// file to upload
///
- public void UploadFile (long? PetId, string AdditionalMetadata, byte[] File) {
- // create path and map variables
- var path = "/pet/{petId}/uploadImage".Replace("{format}","json").Replace("{" + "petId" + "}", apiInvoker.ParameterToString(PetId));
+ public void UploadFile (long? PetId, string AdditionalMetadata, string File) {
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("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 (File != null) _request.AddFile("file", File); // form parameter
+ if (File != null) _request.AddFile("file", File);
try {
-
+ // make the HTTP request
restClient.Execute(_request);
return;
} catch (Exception ex) {
diff --git a/samples/client/petstore/csharp/src/main/csharp/io/swagger/Api/StoreApi.cs b/samples/client/petstore/csharp/src/main/csharp/io/swagger/Api/StoreApi.cs
index 4aadd02e9cc..98b1b5f6526 100644
--- a/samples/client/petstore/csharp/src/main/csharp/io/swagger/Api/StoreApi.cs
+++ b/samples/client/petstore/csharp/src/main/csharp/io/swagger/Api/StoreApi.cs
@@ -38,10 +38,8 @@ namespace io.swagger.Api {
///
/// Returns pet inventories by status Returns a map of status codes to quantities
///
- ///
- public Dictionary GetInventory () {
- // create path and map variables
- var path = "/store/inventory".Replace("{format}","json");
+ /// Dictionary
+ public Dictionary GetInventory () {
var _request = new RestRequest("/store/inventory", Method.GET);
@@ -55,10 +53,9 @@ namespace io.swagger.Api {
try {
+ // make the HTTP request
IRestResponse response = restClient.Execute(_request);
return (Dictionary) ApiInvoker.Deserialize(response.Content, typeof(Dictionary));
- //return ((object)response) as Dictionary;
-
} catch (Exception ex) {
if(ex != null) {
return null;
@@ -74,10 +71,8 @@ namespace io.swagger.Api {
/// Place an order for a pet
///
/// order placed for purchasing the pet
- ///
- public Order PlaceOrder (Order Body) {
- // create path and map variables
- var path = "/store/order".Replace("{format}","json");
+ /// Order
+ public Order PlaceOrder (Order Body) {
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 request body (model)
+ _request.AddParameter("application/json", ApiInvoker.Serialize(Body), ParameterType.RequestBody); // http body (model) parameter
try {
+ // make the HTTP request
IRestResponse response = restClient.Execute(_request);
return (Order) ApiInvoker.Deserialize(response.Content, typeof(Order));
- //return ((object)response) as Order;
-
} catch (Exception ex) {
if(ex != null) {
return null;
@@ -112,14 +105,15 @@ namespace io.swagger.Api {
/// Find purchase order by ID For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
///
/// 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.ParameterToString(OrderId));
+ /// Order
+ public Order GetOrderById (string OrderId) {
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("orderId", ApiInvoker.ParameterToString(OrderId)); // path (url segment) parameter
@@ -130,10 +124,9 @@ namespace io.swagger.Api {
try {
+ // make the HTTP request
IRestResponse response = restClient.Execute(_request);
return (Order) ApiInvoker.Deserialize(response.Content, typeof(Order));
- //return ((object)response) as Order;
-
} catch (Exception ex) {
if(ex != null) {
return null;
@@ -150,13 +143,14 @@ namespace io.swagger.Api {
///
/// ID of the order that needs to be deleted
///
- public void DeleteOrder (string OrderId) {
- // create path and map variables
- var path = "/store/order/{orderId}".Replace("{format}","json").Replace("{" + "orderId" + "}", apiInvoker.ParameterToString(OrderId));
+ public void DeleteOrder (string OrderId) {
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("orderId", ApiInvoker.ParameterToString(OrderId)); // path (url segment) parameter
@@ -167,7 +161,7 @@ namespace io.swagger.Api {
try {
-
+ // make the HTTP request
restClient.Execute(_request);
return;
} catch (Exception ex) {
diff --git a/samples/client/petstore/csharp/src/main/csharp/io/swagger/Api/UserApi.cs b/samples/client/petstore/csharp/src/main/csharp/io/swagger/Api/UserApi.cs
index 154dd099ba9..d7ccf0e9429 100644
--- a/samples/client/petstore/csharp/src/main/csharp/io/swagger/Api/UserApi.cs
+++ b/samples/client/petstore/csharp/src/main/csharp/io/swagger/Api/UserApi.cs
@@ -40,9 +40,7 @@ namespace io.swagger.Api {
///
/// Created user object
///
- public void CreateUser (User Body) {
- // create path and map variables
- var path = "/user".Replace("{format}","json");
+ public void CreateUser (User Body) {
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 request body (model)
+ _request.AddParameter("application/json", ApiInvoker.Serialize(Body), ParameterType.RequestBody); // http body (model) parameter
try {
-
+ // make the HTTP request
restClient.Execute(_request);
return;
} catch (Exception ex) {
@@ -77,9 +74,7 @@ namespace io.swagger.Api {
///
/// List of user object
///
- public void CreateUsersWithArrayInput (List Body) {
- // create path and map variables
- var path = "/user/createWithArray".Replace("{format}","json");
+ public void CreateUsersWithArrayInput (List Body) {
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 request body (model)
+ _request.AddParameter("application/json", ApiInvoker.Serialize(Body), ParameterType.RequestBody); // http body (model) parameter
try {
-
+ // make the HTTP request
restClient.Execute(_request);
return;
} catch (Exception ex) {
@@ -114,9 +108,7 @@ namespace io.swagger.Api {
///
/// List of user object
///
- public void CreateUsersWithListInput (List Body) {
- // create path and map variables
- var path = "/user/createWithList".Replace("{format}","json");
+ public void CreateUsersWithListInput (List Body) {
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 request body (model)
+ _request.AddParameter("application/json", ApiInvoker.Serialize(Body), ParameterType.RequestBody); // http body (model) parameter
try {
-
+ // make the HTTP request
restClient.Execute(_request);
return;
} catch (Exception ex) {
@@ -151,11 +142,8 @@ namespace io.swagger.Api {
///
/// 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");
+ /// string
+ public string LoginUser (string Username, string Password) {
var _request = new RestRequest("/user/login", Method.GET);
@@ -171,10 +159,9 @@ namespace io.swagger.Api {
try {
+ // make the HTTP request
IRestResponse response = restClient.Execute(_request);
return (string) ApiInvoker.Deserialize(response.Content, typeof(string));
- //return ((object)response) as string;
-
} catch (Exception ex) {
if(ex != null) {
return null;
@@ -190,9 +177,7 @@ namespace io.swagger.Api {
/// Logs out current logged in user session
///
///
- public void LogoutUser () {
- // create path and map variables
- var path = "/user/logout".Replace("{format}","json");
+ public void LogoutUser () {
var _request = new RestRequest("/user/logout", Method.GET);
@@ -206,7 +191,7 @@ namespace io.swagger.Api {
try {
-
+ // make the HTTP request
restClient.Execute(_request);
return;
} catch (Exception ex) {
@@ -224,13 +209,15 @@ namespace io.swagger.Api {
/// 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.ParameterToString(Username));
+ /// User
+ public User GetUserByName (string Username) {
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("username", ApiInvoker.ParameterToString(Username)); // path (url segment) parameter
@@ -241,10 +228,9 @@ namespace io.swagger.Api {
try {
+ // make the HTTP request
IRestResponse response = restClient.Execute(_request);
return (User) ApiInvoker.Deserialize(response.Content, typeof(User));
- //return ((object)response) as User;
-
} catch (Exception ex) {
if(ex != null) {
return null;
@@ -262,13 +248,14 @@ namespace io.swagger.Api {
/// 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.ParameterToString(Username));
+ public void UpdateUser (string Username, User Body) {
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("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 request body (model)
+ _request.AddParameter("application/json", ApiInvoker.Serialize(Body), ParameterType.RequestBody); // http body (model) parameter
try {
-
+ // make the HTTP request
restClient.Execute(_request);
return;
} catch (Exception ex) {
@@ -300,13 +286,14 @@ namespace io.swagger.Api {
///
/// 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.ParameterToString(Username));
+ public void DeleteUser (string Username) {
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("username", ApiInvoker.ParameterToString(Username)); // path (url segment) parameter
@@ -317,7 +304,7 @@ namespace io.swagger.Api {
try {
-
+ // make the HTTP request
restClient.Execute(_request);
return;
} catch (Exception ex) {