Skip to content

Commit cb47bec

Browse files
committed
Issue #3138
Continuation from original PR to update the pet store server auto gen sample code based on previous commit.
1 parent 0980261 commit cb47bec

File tree

4 files changed

+28
-42
lines changed

4 files changed

+28
-42
lines changed

samples/server/petstore/aspnet5/src/IO.Swagger/Controllers/PetApi.cs

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class PetApiController : Controller
2828
[HttpPost]
2929
[Route("/pet")]
3030
[SwaggerOperation("AddPet")]
31-
public void AddPet([FromBody]Pet body)
31+
public virtual void AddPet([FromBody]Pet body)
3232
{
3333
throw new NotImplementedException();
3434
}
@@ -44,7 +44,7 @@ public void AddPet([FromBody]Pet body)
4444
[HttpDelete]
4545
[Route("/pet/{petId}")]
4646
[SwaggerOperation("DeletePet")]
47-
public void DeletePet([FromRoute]long? petId, [FromHeader]string apiKey)
47+
public virtual void DeletePet([FromRoute]long? petId, [FromHeader]string apiKey)
4848
{
4949
throw new NotImplementedException();
5050
}
@@ -53,15 +53,15 @@ public void DeletePet([FromRoute]long? petId, [FromHeader]string apiKey)
5353
/// <summary>
5454
/// Finds Pets by status
5555
/// </summary>
56-
/// <remarks>Multiple status values can be provided with comma separated strings</remarks>
56+
/// <remarks>Multiple status values can be provided with comma seperated strings</remarks>
5757
/// <param name="status">Status values that need to be considered for filter</param>
5858
/// <response code="200">successful operation</response>
5959
/// <response code="400">Invalid status value</response>
6060
[HttpGet]
6161
[Route("/pet/findByStatus")]
6262
[SwaggerOperation("FindPetsByStatus")]
6363
[SwaggerResponse(200, type: typeof(List<Pet>))]
64-
public IActionResult FindPetsByStatus([FromQuery]List<string> status)
64+
public virtual IActionResult FindPetsByStatus([FromQuery]List<string> status)
6565
{
6666
string exampleJson = null;
6767

@@ -75,15 +75,15 @@ public IActionResult FindPetsByStatus([FromQuery]List<string> status)
7575
/// <summary>
7676
/// Finds Pets by tags
7777
/// </summary>
78-
/// <remarks>Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.</remarks>
78+
/// <remarks>Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.</remarks>
7979
/// <param name="tags">Tags to filter by</param>
8080
/// <response code="200">successful operation</response>
8181
/// <response code="400">Invalid tag value</response>
8282
[HttpGet]
8383
[Route("/pet/findByTags")]
8484
[SwaggerOperation("FindPetsByTags")]
8585
[SwaggerResponse(200, type: typeof(List<Pet>))]
86-
public IActionResult FindPetsByTags([FromQuery]List<string> tags)
86+
public virtual IActionResult FindPetsByTags([FromQuery]List<string> tags)
8787
{
8888
string exampleJson = null;
8989

@@ -97,16 +97,16 @@ public IActionResult FindPetsByTags([FromQuery]List<string> tags)
9797
/// <summary>
9898
/// Find pet by ID
9999
/// </summary>
100-
/// <remarks>Returns a single pet</remarks>
101-
/// <param name="petId">ID of pet to return</param>
100+
/// <remarks>Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions</remarks>
101+
/// <param name="petId">ID of pet that needs to be fetched</param>
102102
/// <response code="200">successful operation</response>
103103
/// <response code="400">Invalid ID supplied</response>
104104
/// <response code="404">Pet not found</response>
105105
[HttpGet]
106106
[Route("/pet/{petId}")]
107107
[SwaggerOperation("GetPetById")]
108108
[SwaggerResponse(200, type: typeof(Pet))]
109-
public IActionResult GetPetById([FromRoute]long? petId)
109+
public virtual IActionResult GetPetById([FromRoute]long? petId)
110110
{
111111
string exampleJson = null;
112112

@@ -128,7 +128,7 @@ public IActionResult GetPetById([FromRoute]long? petId)
128128
[HttpPut]
129129
[Route("/pet")]
130130
[SwaggerOperation("UpdatePet")]
131-
public void UpdatePet([FromBody]Pet body)
131+
public virtual void UpdatePet([FromBody]Pet body)
132132
{
133133
throw new NotImplementedException();
134134
}
@@ -145,7 +145,7 @@ public void UpdatePet([FromBody]Pet body)
145145
[HttpPost]
146146
[Route("/pet/{petId}")]
147147
[SwaggerOperation("UpdatePetWithForm")]
148-
public void UpdatePetWithForm([FromRoute]long? petId, [FromForm]string name, [FromForm]string status)
148+
public virtual void UpdatePetWithForm([FromRoute]string petId, [FromForm]string name, [FromForm]string status)
149149
{
150150
throw new NotImplementedException();
151151
}
@@ -158,19 +158,13 @@ public void UpdatePetWithForm([FromRoute]long? petId, [FromForm]string name, [Fr
158158
/// <param name="petId">ID of pet to update</param>
159159
/// <param name="additionalMetadata">Additional data to pass to server</param>
160160
/// <param name="file">file to upload</param>
161-
/// <response code="200">successful operation</response>
161+
/// <response code="0">successful operation</response>
162162
[HttpPost]
163163
[Route("/pet/{petId}/uploadImage")]
164164
[SwaggerOperation("UploadFile")]
165-
[SwaggerResponse(200, type: typeof(ApiResponse))]
166-
public IActionResult UploadFile([FromRoute]long? petId, [FromForm]string additionalMetadata, [FromForm]System.IO.Stream file)
165+
public virtual void UploadFile([FromRoute]long? petId, [FromForm]string additionalMetadata, [FromForm]System.IO.Stream file)
167166
{
168-
string exampleJson = null;
169-
170-
var example = exampleJson != null
171-
? JsonConvert.DeserializeObject<ApiResponse>(exampleJson)
172-
: default(ApiResponse);
173-
return new ObjectResult(example);
167+
throw new NotImplementedException();
174168
}
175169
}
176170
}

samples/server/petstore/aspnet5/src/IO.Swagger/Controllers/StoreApi.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class StoreApiController : Controller
2929
[HttpDelete]
3030
[Route("/store/order/{orderId}")]
3131
[SwaggerOperation("DeleteOrder")]
32-
public void DeleteOrder([FromRoute]string orderId)
32+
public virtual void DeleteOrder([FromRoute]string orderId)
3333
{
3434
throw new NotImplementedException();
3535
}
@@ -44,7 +44,7 @@ public void DeleteOrder([FromRoute]string orderId)
4444
[Route("/store/inventory")]
4545
[SwaggerOperation("GetInventory")]
4646
[SwaggerResponse(200, type: typeof(Dictionary<string, int?>))]
47-
public IActionResult GetInventory()
47+
public virtual IActionResult GetInventory()
4848
{
4949
string exampleJson = null;
5050

@@ -67,7 +67,7 @@ public IActionResult GetInventory()
6767
[Route("/store/order/{orderId}")]
6868
[SwaggerOperation("GetOrderById")]
6969
[SwaggerResponse(200, type: typeof(Order))]
70-
public IActionResult GetOrderById([FromRoute]long? orderId)
70+
public virtual IActionResult GetOrderById([FromRoute]string orderId)
7171
{
7272
string exampleJson = null;
7373

@@ -89,7 +89,7 @@ public IActionResult GetOrderById([FromRoute]long? orderId)
8989
[Route("/store/order")]
9090
[SwaggerOperation("PlaceOrder")]
9191
[SwaggerResponse(200, type: typeof(Order))]
92-
public IActionResult PlaceOrder([FromBody]Order body)
92+
public virtual IActionResult PlaceOrder([FromBody]Order body)
9393
{
9494
string exampleJson = null;
9595

samples/server/petstore/aspnet5/src/IO.Swagger/Controllers/UserApi.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class UserApiController : Controller
2828
[HttpPost]
2929
[Route("/user")]
3030
[SwaggerOperation("CreateUser")]
31-
public void CreateUser([FromBody]User body)
31+
public virtual void CreateUser([FromBody]User body)
3232
{
3333
throw new NotImplementedException();
3434
}
@@ -43,7 +43,7 @@ public void CreateUser([FromBody]User body)
4343
[HttpPost]
4444
[Route("/user/createWithArray")]
4545
[SwaggerOperation("CreateUsersWithArrayInput")]
46-
public void CreateUsersWithArrayInput([FromBody]List<User> body)
46+
public virtual void CreateUsersWithArrayInput([FromBody]List<User> body)
4747
{
4848
throw new NotImplementedException();
4949
}
@@ -58,7 +58,7 @@ public void CreateUsersWithArrayInput([FromBody]List<User> body)
5858
[HttpPost]
5959
[Route("/user/createWithList")]
6060
[SwaggerOperation("CreateUsersWithListInput")]
61-
public void CreateUsersWithListInput([FromBody]List<User> body)
61+
public virtual void CreateUsersWithListInput([FromBody]List<User> body)
6262
{
6363
throw new NotImplementedException();
6464
}
@@ -74,7 +74,7 @@ public void CreateUsersWithListInput([FromBody]List<User> body)
7474
[HttpDelete]
7575
[Route("/user/{username}")]
7676
[SwaggerOperation("DeleteUser")]
77-
public void DeleteUser([FromRoute]string username)
77+
public virtual void DeleteUser([FromRoute]string username)
7878
{
7979
throw new NotImplementedException();
8080
}
@@ -92,7 +92,7 @@ public void DeleteUser([FromRoute]string username)
9292
[Route("/user/{username}")]
9393
[SwaggerOperation("GetUserByName")]
9494
[SwaggerResponse(200, type: typeof(User))]
95-
public IActionResult GetUserByName([FromRoute]string username)
95+
public virtual IActionResult GetUserByName([FromRoute]string username)
9696
{
9797
string exampleJson = null;
9898

@@ -115,7 +115,7 @@ public IActionResult GetUserByName([FromRoute]string username)
115115
[Route("/user/login")]
116116
[SwaggerOperation("LoginUser")]
117117
[SwaggerResponse(200, type: typeof(string))]
118-
public IActionResult LoginUser([FromQuery]string username, [FromQuery]string password)
118+
public virtual IActionResult LoginUser([FromQuery]string username, [FromQuery]string password)
119119
{
120120
string exampleJson = null;
121121

@@ -134,7 +134,7 @@ public IActionResult LoginUser([FromQuery]string username, [FromQuery]string pas
134134
[HttpGet]
135135
[Route("/user/logout")]
136136
[SwaggerOperation("LogoutUser")]
137-
public void LogoutUser()
137+
public virtual void LogoutUser()
138138
{
139139
throw new NotImplementedException();
140140
}
@@ -151,7 +151,7 @@ public void LogoutUser()
151151
[HttpPut]
152152
[Route("/user/{username}")]
153153
[SwaggerOperation("UpdateUser")]
154-
public void UpdateUser([FromRoute]string username, [FromBody]User body)
154+
public virtual void UpdateUser([FromRoute]string username, [FromBody]User body)
155155
{
156156
throw new NotImplementedException();
157157
}

samples/server/petstore/aspnet5/src/IO.Swagger/Models/Order.cs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,15 @@ public partial class Order : IEquatable<Order>
2323
/// <param name="Quantity">Quantity.</param>
2424
/// <param name="ShipDate">ShipDate.</param>
2525
/// <param name="Status">Order Status.</param>
26-
/// <param name="Complete">Complete (default to false).</param>
26+
/// <param name="Complete">Complete.</param>
2727
public Order(long? Id = null, long? PetId = null, int? Quantity = null, DateTime? ShipDate = null, string Status = null, bool? Complete = null)
2828
{
2929
this.Id = Id;
3030
this.PetId = PetId;
3131
this.Quantity = Quantity;
3232
this.ShipDate = ShipDate;
3333
this.Status = Status;
34-
// use default value if no "Complete" provided
35-
if (Complete == null)
36-
{
37-
this.Complete = false;
38-
}
39-
else
40-
{
41-
this.Complete = Complete;
42-
}
34+
this.Complete = Complete;
4335

4436
}
4537

0 commit comments

Comments
 (0)