From cb47bec293edff4653d55173007e070da67ddc8f Mon Sep 17 00:00:00 2001 From: stunney Date: Wed, 15 Jun 2016 10:04:28 -0400 Subject: [PATCH] Issue #3138 Continuation from original PR to update the pet store server auto gen sample code based on previous commit. --- .../src/IO.Swagger/Controllers/PetApi.cs | 34 ++++++++----------- .../src/IO.Swagger/Controllers/StoreApi.cs | 8 ++--- .../src/IO.Swagger/Controllers/UserApi.cs | 16 ++++----- .../aspnet5/src/IO.Swagger/Models/Order.cs | 12 ++----- 4 files changed, 28 insertions(+), 42 deletions(-) diff --git a/samples/server/petstore/aspnet5/src/IO.Swagger/Controllers/PetApi.cs b/samples/server/petstore/aspnet5/src/IO.Swagger/Controllers/PetApi.cs index a30ac7a5f1..18fefec1cb 100644 --- a/samples/server/petstore/aspnet5/src/IO.Swagger/Controllers/PetApi.cs +++ b/samples/server/petstore/aspnet5/src/IO.Swagger/Controllers/PetApi.cs @@ -28,7 +28,7 @@ namespace IO.Swagger.Controllers [HttpPost] [Route("/pet")] [SwaggerOperation("AddPet")] - public void AddPet([FromBody]Pet body) + public virtual void AddPet([FromBody]Pet body) { throw new NotImplementedException(); } @@ -44,7 +44,7 @@ namespace IO.Swagger.Controllers [HttpDelete] [Route("/pet/{petId}")] [SwaggerOperation("DeletePet")] - public void DeletePet([FromRoute]long? petId, [FromHeader]string apiKey) + public virtual void DeletePet([FromRoute]long? petId, [FromHeader]string apiKey) { throw new NotImplementedException(); } @@ -53,7 +53,7 @@ namespace IO.Swagger.Controllers /// /// Finds Pets by status /// - /// Multiple status values can be provided with comma separated strings + /// Multiple status values can be provided with comma seperated strings /// Status values that need to be considered for filter /// successful operation /// Invalid status value @@ -61,7 +61,7 @@ namespace IO.Swagger.Controllers [Route("/pet/findByStatus")] [SwaggerOperation("FindPetsByStatus")] [SwaggerResponse(200, type: typeof(List))] - public IActionResult FindPetsByStatus([FromQuery]List status) + public virtual IActionResult FindPetsByStatus([FromQuery]List status) { string exampleJson = null; @@ -75,7 +75,7 @@ namespace IO.Swagger.Controllers /// /// Finds Pets by tags /// - /// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + /// Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. /// Tags to filter by /// successful operation /// Invalid tag value @@ -83,7 +83,7 @@ namespace IO.Swagger.Controllers [Route("/pet/findByTags")] [SwaggerOperation("FindPetsByTags")] [SwaggerResponse(200, type: typeof(List))] - public IActionResult FindPetsByTags([FromQuery]List tags) + public virtual IActionResult FindPetsByTags([FromQuery]List tags) { string exampleJson = null; @@ -97,8 +97,8 @@ namespace IO.Swagger.Controllers /// /// Find pet by ID /// - /// Returns a single pet - /// ID of pet to return + /// Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + /// ID of pet that needs to be fetched /// successful operation /// Invalid ID supplied /// Pet not found @@ -106,7 +106,7 @@ namespace IO.Swagger.Controllers [Route("/pet/{petId}")] [SwaggerOperation("GetPetById")] [SwaggerResponse(200, type: typeof(Pet))] - public IActionResult GetPetById([FromRoute]long? petId) + public virtual IActionResult GetPetById([FromRoute]long? petId) { string exampleJson = null; @@ -128,7 +128,7 @@ namespace IO.Swagger.Controllers [HttpPut] [Route("/pet")] [SwaggerOperation("UpdatePet")] - public void UpdatePet([FromBody]Pet body) + public virtual void UpdatePet([FromBody]Pet body) { throw new NotImplementedException(); } @@ -145,7 +145,7 @@ namespace IO.Swagger.Controllers [HttpPost] [Route("/pet/{petId}")] [SwaggerOperation("UpdatePetWithForm")] - public void UpdatePetWithForm([FromRoute]long? petId, [FromForm]string name, [FromForm]string status) + public virtual void UpdatePetWithForm([FromRoute]string petId, [FromForm]string name, [FromForm]string status) { throw new NotImplementedException(); } @@ -158,19 +158,13 @@ namespace IO.Swagger.Controllers /// ID of pet to update /// Additional data to pass to server /// file to upload - /// successful operation + /// successful operation [HttpPost] [Route("/pet/{petId}/uploadImage")] [SwaggerOperation("UploadFile")] - [SwaggerResponse(200, type: typeof(ApiResponse))] - public IActionResult UploadFile([FromRoute]long? petId, [FromForm]string additionalMetadata, [FromForm]System.IO.Stream file) + public virtual void UploadFile([FromRoute]long? petId, [FromForm]string additionalMetadata, [FromForm]System.IO.Stream file) { - string exampleJson = null; - - var example = exampleJson != null - ? JsonConvert.DeserializeObject(exampleJson) - : default(ApiResponse); - return new ObjectResult(example); + throw new NotImplementedException(); } } } diff --git a/samples/server/petstore/aspnet5/src/IO.Swagger/Controllers/StoreApi.cs b/samples/server/petstore/aspnet5/src/IO.Swagger/Controllers/StoreApi.cs index 0483825388..0ba31771bb 100644 --- a/samples/server/petstore/aspnet5/src/IO.Swagger/Controllers/StoreApi.cs +++ b/samples/server/petstore/aspnet5/src/IO.Swagger/Controllers/StoreApi.cs @@ -29,7 +29,7 @@ namespace IO.Swagger.Controllers [HttpDelete] [Route("/store/order/{orderId}")] [SwaggerOperation("DeleteOrder")] - public void DeleteOrder([FromRoute]string orderId) + public virtual void DeleteOrder([FromRoute]string orderId) { throw new NotImplementedException(); } @@ -44,7 +44,7 @@ namespace IO.Swagger.Controllers [Route("/store/inventory")] [SwaggerOperation("GetInventory")] [SwaggerResponse(200, type: typeof(Dictionary))] - public IActionResult GetInventory() + public virtual IActionResult GetInventory() { string exampleJson = null; @@ -67,7 +67,7 @@ namespace IO.Swagger.Controllers [Route("/store/order/{orderId}")] [SwaggerOperation("GetOrderById")] [SwaggerResponse(200, type: typeof(Order))] - public IActionResult GetOrderById([FromRoute]long? orderId) + public virtual IActionResult GetOrderById([FromRoute]string orderId) { string exampleJson = null; @@ -89,7 +89,7 @@ namespace IO.Swagger.Controllers [Route("/store/order")] [SwaggerOperation("PlaceOrder")] [SwaggerResponse(200, type: typeof(Order))] - public IActionResult PlaceOrder([FromBody]Order body) + public virtual IActionResult PlaceOrder([FromBody]Order body) { string exampleJson = null; diff --git a/samples/server/petstore/aspnet5/src/IO.Swagger/Controllers/UserApi.cs b/samples/server/petstore/aspnet5/src/IO.Swagger/Controllers/UserApi.cs index dd676fac85..b73cdd23c8 100644 --- a/samples/server/petstore/aspnet5/src/IO.Swagger/Controllers/UserApi.cs +++ b/samples/server/petstore/aspnet5/src/IO.Swagger/Controllers/UserApi.cs @@ -28,7 +28,7 @@ namespace IO.Swagger.Controllers [HttpPost] [Route("/user")] [SwaggerOperation("CreateUser")] - public void CreateUser([FromBody]User body) + public virtual void CreateUser([FromBody]User body) { throw new NotImplementedException(); } @@ -43,7 +43,7 @@ namespace IO.Swagger.Controllers [HttpPost] [Route("/user/createWithArray")] [SwaggerOperation("CreateUsersWithArrayInput")] - public void CreateUsersWithArrayInput([FromBody]List body) + public virtual void CreateUsersWithArrayInput([FromBody]List body) { throw new NotImplementedException(); } @@ -58,7 +58,7 @@ namespace IO.Swagger.Controllers [HttpPost] [Route("/user/createWithList")] [SwaggerOperation("CreateUsersWithListInput")] - public void CreateUsersWithListInput([FromBody]List body) + public virtual void CreateUsersWithListInput([FromBody]List body) { throw new NotImplementedException(); } @@ -74,7 +74,7 @@ namespace IO.Swagger.Controllers [HttpDelete] [Route("/user/{username}")] [SwaggerOperation("DeleteUser")] - public void DeleteUser([FromRoute]string username) + public virtual void DeleteUser([FromRoute]string username) { throw new NotImplementedException(); } @@ -92,7 +92,7 @@ namespace IO.Swagger.Controllers [Route("/user/{username}")] [SwaggerOperation("GetUserByName")] [SwaggerResponse(200, type: typeof(User))] - public IActionResult GetUserByName([FromRoute]string username) + public virtual IActionResult GetUserByName([FromRoute]string username) { string exampleJson = null; @@ -115,7 +115,7 @@ namespace IO.Swagger.Controllers [Route("/user/login")] [SwaggerOperation("LoginUser")] [SwaggerResponse(200, type: typeof(string))] - public IActionResult LoginUser([FromQuery]string username, [FromQuery]string password) + public virtual IActionResult LoginUser([FromQuery]string username, [FromQuery]string password) { string exampleJson = null; @@ -134,7 +134,7 @@ namespace IO.Swagger.Controllers [HttpGet] [Route("/user/logout")] [SwaggerOperation("LogoutUser")] - public void LogoutUser() + public virtual void LogoutUser() { throw new NotImplementedException(); } @@ -151,7 +151,7 @@ namespace IO.Swagger.Controllers [HttpPut] [Route("/user/{username}")] [SwaggerOperation("UpdateUser")] - public void UpdateUser([FromRoute]string username, [FromBody]User body) + public virtual void UpdateUser([FromRoute]string username, [FromBody]User body) { throw new NotImplementedException(); } diff --git a/samples/server/petstore/aspnet5/src/IO.Swagger/Models/Order.cs b/samples/server/petstore/aspnet5/src/IO.Swagger/Models/Order.cs index 5b5a9b6d14..80c3bcfb69 100644 --- a/samples/server/petstore/aspnet5/src/IO.Swagger/Models/Order.cs +++ b/samples/server/petstore/aspnet5/src/IO.Swagger/Models/Order.cs @@ -23,7 +23,7 @@ namespace IO.Swagger.Models /// Quantity. /// ShipDate. /// Order Status. - /// Complete (default to false). + /// Complete. public Order(long? Id = null, long? PetId = null, int? Quantity = null, DateTime? ShipDate = null, string Status = null, bool? Complete = null) { this.Id = Id; @@ -31,15 +31,7 @@ namespace IO.Swagger.Models this.Quantity = Quantity; this.ShipDate = ShipDate; this.Status = Status; - // use default value if no "Complete" provided - if (Complete == null) - { - this.Complete = false; - } - else - { - this.Complete = Complete; - } + this.Complete = Complete; }