diff --git a/modules/swagger-codegen/src/main/resources/aspnetcore/controller.mustache b/modules/swagger-codegen/src/main/resources/aspnetcore/controller.mustache
index a6cdff4cdef..e89ca80cc0d 100644
--- a/modules/swagger-codegen/src/main/resources/aspnetcore/controller.mustache
+++ b/modules/swagger-codegen/src/main/resources/aspnetcore/controller.mustache
@@ -33,11 +33,21 @@ namespace {{packageName}}.Controllers
[ValidateModelState]
[SwaggerOperation("{{operationId}}")]{{#responses}}{{#returnType}}
[SwaggerResponse({{code}}, typeof({{&returnType}}), "{{message}}")]{{/returnType}}{{/responses}}
- public virtual {{#returnType}}IActionResult{{/returnType}}{{^returnType}}void{{/returnType}} {{operationId}}({{#allParams}}{{>pathParam}}{{>queryParam}}{{>bodyParam}}{{>formParam}}{{>headerParam}}{{#hasMore}}, {{/hasMore}}{{/allParams}})
- { {{#returnType}}
+ public virtual IActionResult {{operationId}}({{#allParams}}{{>pathParam}}{{>queryParam}}{{>bodyParam}}{{>formParam}}{{>headerParam}}{{#hasMore}}, {{/hasMore}}{{/allParams}})
+ { {{#responses}}
+{{#dataType}}
+ //TODO: Uncomment the next line to return response {{code}} or use other options such as return this.NotFound(), return this.BadRequest(..), ...
+ // return StatusCode({{code}}, default({{&dataType}}));
+{{/dataType}}
+{{^dataType}}
+ //TODO: Uncomment the next line to return response {{code}} or use other options such as return this.NotFound(), return this.BadRequest(..), ...
+ // return StatusCode({{code}});
+{{/dataType}}{{/responses}}
+{{#returnType}}
string exampleJson = null;
{{#isListCollection}}{{>listReturn}}{{/isListCollection}}{{^isListCollection}}{{#isMapContainer}}{{>mapReturn}}{{/isMapContainer}}{{^isMapContainer}}{{>objectReturn}}{{/isMapContainer}}{{/isListCollection}}
{{!TODO: defaultResponse, examples, auth, consumes, produces, nickname, externalDocs, imports, security}}
+ //TODO: Change the data returned
return new ObjectResult(example);{{/returnType}}{{^returnType}}
throw new NotImplementedException();{{/returnType}}
}
diff --git a/samples/server/petstore/aspnetcore/src/IO.Swagger/Controllers/PetApi.cs b/samples/server/petstore/aspnetcore/src/IO.Swagger/Controllers/PetApi.cs
index ad5f2d39cec..60dfd3bbb87 100644
--- a/samples/server/petstore/aspnetcore/src/IO.Swagger/Controllers/PetApi.cs
+++ b/samples/server/petstore/aspnetcore/src/IO.Swagger/Controllers/PetApi.cs
@@ -33,22 +33,26 @@ public class PetApiController : Controller
///
/// Add a new pet to the store
///
- ///
+
/// Pet object that needs to be added to the store
/// Invalid input
[HttpPost]
[Route("/v2/pet")]
[ValidateModelState]
[SwaggerOperation("AddPet")]
- public virtual void AddPet([FromBody]Pet body)
+ public virtual IActionResult AddPet([FromBody]Pet body)
{
+ //TODO: Uncomment the next line to return response 405 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
+ // return StatusCode(405);
+
+
throw new NotImplementedException();
}
///
/// Deletes a pet
///
- ///
+
/// Pet id to delete
///
/// Invalid pet value
@@ -56,8 +60,12 @@ public virtual void AddPet([FromBody]Pet body)
[Route("/v2/pet/{petId}")]
[ValidateModelState]
[SwaggerOperation("DeletePet")]
- public virtual void DeletePet([FromRoute]long? petId, [FromHeader]string apiKey)
+ public virtual IActionResult DeletePet([FromRoute]long? petId, [FromHeader]string apiKey)
{
+ //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
+ // return StatusCode(400);
+
+
throw new NotImplementedException();
}
@@ -76,11 +84,18 @@ public virtual void DeletePet([FromRoute]long? petId, [FromHeader]string apiKey)
[SwaggerResponse(400, typeof(List), "Invalid status value")]
public virtual IActionResult FindPetsByStatus([FromQuery]List status)
{
+ //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
+ // return StatusCode(200, default(List));
+
+ //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
+ // return StatusCode(400);
+
string exampleJson = null;
var example = exampleJson != null
? JsonConvert.DeserializeObject>(exampleJson)
: default(List);
+ //TODO: Change the data returned
return new ObjectResult(example);
}
@@ -99,11 +114,18 @@ public virtual IActionResult FindPetsByStatus([FromQuery]List status)
[SwaggerResponse(400, typeof(List), "Invalid tag value")]
public virtual IActionResult FindPetsByTags([FromQuery]List tags)
{
+ //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
+ // return StatusCode(200, default(List));
+
+ //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
+ // return StatusCode(400);
+
string exampleJson = null;
var example = exampleJson != null
? JsonConvert.DeserializeObject>(exampleJson)
: default(List);
+ //TODO: Change the data returned
return new ObjectResult(example);
}
@@ -124,18 +146,28 @@ public virtual IActionResult FindPetsByTags([FromQuery]List tags)
[SwaggerResponse(404, typeof(Pet), "Pet not found")]
public virtual IActionResult GetPetById([FromRoute]long? petId)
{
+ //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
+ // return StatusCode(200, default(Pet));
+
+ //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
+ // return StatusCode(400);
+
+ //TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
+ // return StatusCode(404);
+
string exampleJson = null;
var example = exampleJson != null
? JsonConvert.DeserializeObject(exampleJson)
: default(Pet);
+ //TODO: Change the data returned
return new ObjectResult(example);
}
///
/// Update an existing pet
///
- ///
+
/// Pet object that needs to be added to the store
/// Invalid ID supplied
/// Pet not found
@@ -144,15 +176,25 @@ public virtual IActionResult GetPetById([FromRoute]long? petId)
[Route("/v2/pet")]
[ValidateModelState]
[SwaggerOperation("UpdatePet")]
- public virtual void UpdatePet([FromBody]Pet body)
+ public virtual IActionResult UpdatePet([FromBody]Pet body)
{
+ //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
+ // return StatusCode(400);
+
+ //TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
+ // return StatusCode(404);
+
+ //TODO: Uncomment the next line to return response 405 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
+ // return StatusCode(405);
+
+
throw new NotImplementedException();
}
///
/// Updates a pet in the store with form data
///
- ///
+
/// ID of pet that needs to be updated
/// Updated name of the pet
/// Updated status of the pet
@@ -161,15 +203,19 @@ public virtual void UpdatePet([FromBody]Pet body)
[Route("/v2/pet/{petId}")]
[ValidateModelState]
[SwaggerOperation("UpdatePetWithForm")]
- public virtual void UpdatePetWithForm([FromRoute]long? petId, [FromForm]string name, [FromForm]string status)
+ public virtual IActionResult UpdatePetWithForm([FromRoute]long? petId, [FromForm]string name, [FromForm]string status)
{
+ //TODO: Uncomment the next line to return response 405 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
+ // return StatusCode(405);
+
+
throw new NotImplementedException();
}
///
/// uploads an image
///
- ///
+
/// ID of pet to update
/// Additional data to pass to server
/// file to upload
@@ -181,11 +227,15 @@ public virtual void UpdatePetWithForm([FromRoute]long? petId, [FromForm]string n
[SwaggerResponse(200, typeof(ApiResponse), "successful operation")]
public virtual IActionResult UploadFile([FromRoute]long? petId, [FromForm]string additionalMetadata, [FromForm]System.IO.Stream file)
{
+ //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
+ // return StatusCode(200, default(ApiResponse));
+
string exampleJson = null;
var example = exampleJson != null
? JsonConvert.DeserializeObject(exampleJson)
: default(ApiResponse);
+ //TODO: Change the data returned
return new ObjectResult(example);
}
}
diff --git a/samples/server/petstore/aspnetcore/src/IO.Swagger/Controllers/StoreApi.cs b/samples/server/petstore/aspnetcore/src/IO.Swagger/Controllers/StoreApi.cs
index 0bfb79eb2d2..edd7cfae6bc 100644
--- a/samples/server/petstore/aspnetcore/src/IO.Swagger/Controllers/StoreApi.cs
+++ b/samples/server/petstore/aspnetcore/src/IO.Swagger/Controllers/StoreApi.cs
@@ -41,8 +41,15 @@ public class StoreApiController : Controller
[Route("/v2/store/order/{orderId}")]
[ValidateModelState]
[SwaggerOperation("DeleteOrder")]
- public virtual void DeleteOrder([FromRoute]string orderId)
+ public virtual IActionResult DeleteOrder([FromRoute]string orderId)
{
+ //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
+ // return StatusCode(400);
+
+ //TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
+ // return StatusCode(404);
+
+
throw new NotImplementedException();
}
@@ -58,11 +65,15 @@ public virtual void DeleteOrder([FromRoute]string orderId)
[SwaggerResponse(200, typeof(Dictionary), "successful operation")]
public virtual IActionResult GetInventory()
{
+ //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
+ // return StatusCode(200, default(Dictionary));
+
string exampleJson = null;
var example = exampleJson != null
? JsonConvert.DeserializeObject>(exampleJson)
: default(Dictionary);
+ //TODO: Change the data returned
return new ObjectResult(example);
}
@@ -83,18 +94,28 @@ public virtual IActionResult GetInventory()
[SwaggerResponse(404, typeof(Order), "Order not found")]
public virtual IActionResult GetOrderById([FromRoute]long? orderId)
{
+ //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
+ // return StatusCode(200, default(Order));
+
+ //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
+ // return StatusCode(400);
+
+ //TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
+ // return StatusCode(404);
+
string exampleJson = null;
var example = exampleJson != null
? JsonConvert.DeserializeObject(exampleJson)
: default(Order);
+ //TODO: Change the data returned
return new ObjectResult(example);
}
///
/// Place an order for a pet
///
- ///
+
/// order placed for purchasing the pet
/// successful operation
/// Invalid Order
@@ -106,11 +127,18 @@ public virtual IActionResult GetOrderById([FromRoute]long? orderId)
[SwaggerResponse(400, typeof(Order), "Invalid Order")]
public virtual IActionResult PlaceOrder([FromBody]Order body)
{
+ //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
+ // return StatusCode(200, default(Order));
+
+ //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
+ // return StatusCode(400);
+
string exampleJson = null;
var example = exampleJson != null
? JsonConvert.DeserializeObject(exampleJson)
: default(Order);
+ //TODO: Change the data returned
return new ObjectResult(example);
}
}
diff --git a/samples/server/petstore/aspnetcore/src/IO.Swagger/Controllers/UserApi.cs b/samples/server/petstore/aspnetcore/src/IO.Swagger/Controllers/UserApi.cs
index aaa5d027c5d..85d4e840cf6 100644
--- a/samples/server/petstore/aspnetcore/src/IO.Swagger/Controllers/UserApi.cs
+++ b/samples/server/petstore/aspnetcore/src/IO.Swagger/Controllers/UserApi.cs
@@ -40,38 +40,50 @@ public class UserApiController : Controller
[Route("/v2/user")]
[ValidateModelState]
[SwaggerOperation("CreateUser")]
- public virtual void CreateUser([FromBody]User body)
+ public virtual IActionResult CreateUser([FromBody]User body)
{
+ //TODO: Uncomment the next line to return response 0 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
+ // return StatusCode(0);
+
+
throw new NotImplementedException();
}
///
/// Creates list of users with given input array
///
- ///
+
/// List of user object
/// successful operation
[HttpPost]
[Route("/v2/user/createWithArray")]
[ValidateModelState]
[SwaggerOperation("CreateUsersWithArrayInput")]
- public virtual void CreateUsersWithArrayInput([FromBody]List body)
+ public virtual IActionResult CreateUsersWithArrayInput([FromBody]List body)
{
+ //TODO: Uncomment the next line to return response 0 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
+ // return StatusCode(0);
+
+
throw new NotImplementedException();
}
///
/// Creates list of users with given input array
///
- ///
+
/// List of user object
/// successful operation
[HttpPost]
[Route("/v2/user/createWithList")]
[ValidateModelState]
[SwaggerOperation("CreateUsersWithListInput")]
- public virtual void CreateUsersWithListInput([FromBody]List body)
+ public virtual IActionResult CreateUsersWithListInput([FromBody]List body)
{
+ //TODO: Uncomment the next line to return response 0 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
+ // return StatusCode(0);
+
+
throw new NotImplementedException();
}
@@ -86,15 +98,22 @@ public virtual void CreateUsersWithListInput([FromBody]List body)
[Route("/v2/user/{username}")]
[ValidateModelState]
[SwaggerOperation("DeleteUser")]
- public virtual void DeleteUser([FromRoute]string username)
+ public virtual IActionResult DeleteUser([FromRoute]string username)
{
+ //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
+ // return StatusCode(400);
+
+ //TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
+ // return StatusCode(404);
+
+
throw new NotImplementedException();
}
///
/// Get user by user name
///
- ///
+
/// The name that needs to be fetched. Use user1 for testing.
/// successful operation
/// Invalid username supplied
@@ -108,18 +127,28 @@ public virtual void DeleteUser([FromRoute]string username)
[SwaggerResponse(404, typeof(User), "User not found")]
public virtual IActionResult GetUserByName([FromRoute]string username)
{
+ //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
+ // return StatusCode(200, default(User));
+
+ //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
+ // return StatusCode(400);
+
+ //TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
+ // return StatusCode(404);
+
string exampleJson = null;
var example = exampleJson != null
? JsonConvert.DeserializeObject(exampleJson)
: default(User);
+ //TODO: Change the data returned
return new ObjectResult(example);
}
///
/// Logs user into the system
///
- ///
+
/// The user name for login
/// The password for login in clear text
/// successful operation
@@ -132,25 +161,36 @@ public virtual IActionResult GetUserByName([FromRoute]string username)
[SwaggerResponse(400, typeof(string), "Invalid username/password supplied")]
public virtual IActionResult LoginUser([FromQuery]string username, [FromQuery]string password)
{
+ //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
+ // return StatusCode(200, default(string));
+
+ //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
+ // return StatusCode(400);
+
string exampleJson = null;
var example = exampleJson != null
? JsonConvert.DeserializeObject(exampleJson)
: default(string);
+ //TODO: Change the data returned
return new ObjectResult(example);
}
///
/// Logs out current logged in user session
///
- ///
+
/// successful operation
[HttpGet]
[Route("/v2/user/logout")]
[ValidateModelState]
[SwaggerOperation("LogoutUser")]
- public virtual void LogoutUser()
+ public virtual IActionResult LogoutUser()
{
+ //TODO: Uncomment the next line to return response 0 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
+ // return StatusCode(0);
+
+
throw new NotImplementedException();
}
@@ -166,8 +206,15 @@ public virtual void LogoutUser()
[Route("/v2/user/{username}")]
[ValidateModelState]
[SwaggerOperation("UpdateUser")]
- public virtual void UpdateUser([FromRoute]string username, [FromBody]User body)
+ public virtual IActionResult UpdateUser([FromRoute]string username, [FromBody]User body)
{
+ //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
+ // return StatusCode(400);
+
+ //TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
+ // return StatusCode(404);
+
+
throw new NotImplementedException();
}
}
diff --git a/samples/server/petstore/aspnetcore/src/IO.Swagger/Models/Order.cs b/samples/server/petstore/aspnetcore/src/IO.Swagger/Models/Order.cs
index d10381c688b..1ce1b448c8c 100644
--- a/samples/server/petstore/aspnetcore/src/IO.Swagger/Models/Order.cs
+++ b/samples/server/petstore/aspnetcore/src/IO.Swagger/Models/Order.cs
@@ -60,19 +60,19 @@ public enum StatusEnum
/// Enum PlacedEnum for "placed"
///
[EnumMember(Value = "placed")]
- PlacedEnum,
+ PlacedEnum = 1,
///
/// Enum ApprovedEnum for "approved"
///
[EnumMember(Value = "approved")]
- ApprovedEnum,
+ ApprovedEnum = 2,
///
/// Enum DeliveredEnum for "delivered"
///
[EnumMember(Value = "delivered")]
- DeliveredEnum
+ DeliveredEnum = 3
}
///
diff --git a/samples/server/petstore/aspnetcore/src/IO.Swagger/Models/Pet.cs b/samples/server/petstore/aspnetcore/src/IO.Swagger/Models/Pet.cs
index 8396dc33f13..329a0986435 100644
--- a/samples/server/petstore/aspnetcore/src/IO.Swagger/Models/Pet.cs
+++ b/samples/server/petstore/aspnetcore/src/IO.Swagger/Models/Pet.cs
@@ -68,19 +68,19 @@ public enum StatusEnum
/// Enum AvailableEnum for "available"
///
[EnumMember(Value = "available")]
- AvailableEnum,
+ AvailableEnum = 1,
///
/// Enum PendingEnum for "pending"
///
[EnumMember(Value = "pending")]
- PendingEnum,
+ PendingEnum = 2,
///
/// Enum SoldEnum for "sold"
///
[EnumMember(Value = "sold")]
- SoldEnum
+ SoldEnum = 3
}
///
diff --git a/samples/server/petstore/aspnetcore/src/IO.Swagger/project.json b/samples/server/petstore/aspnetcore/src/IO.Swagger/project.json
index 3dbfd87246e..1d9b3396da1 100644
--- a/samples/server/petstore/aspnetcore/src/IO.Swagger/project.json
+++ b/samples/server/petstore/aspnetcore/src/IO.Swagger/project.json
@@ -22,7 +22,8 @@
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
"Microsoft.EntityFrameworkCore": "1.0.0",
"Swashbuckle.AspNetCore": "1.0.0-rc3",
- "Newtonsoft.Json": "9.0.1"
+ "Newtonsoft.Json": "10.0.3",
+ "JsonSubTypes": "1.1.3"
},
"tools": {