ArdaSDK fails with invalid response HTTP 201 Create
Closed this issue · 1 comments
fcatae commented
The problem happens in the integration test for AddItem method.
public void WorkspaceFolders_AddItems()
{
// Add Test with different properties
_client.WorkspaceFoldersService.AddItem(_user, new AddItemInput() { Title = "Test 1" });
_client.WorkspaceFoldersService.AddItem(_user, new AddItemInput() { Title = "Test 2", Description = "123" });
_client.WorkspaceFoldersService.AddItem(_user, new AddItemInput() { Title = "Test 3", ItemState = 2 });
}
fcatae commented
The problem happens in the AddItem method.
public IActionResult AddItem(string folderId, [FromBody,Required] AddItemInput workloadInput)
{
if (folderId == null || folderId == "")
return BadRequest("folderId is empty");
...
...
...
return CreatedAtRoute("GetItem", new { itemId = workload.Id }, workload);
}
Solution:
Add the attribute ProducesResponseType
to the method in order to indicate the return type:
[HttpPost("{folderId}/add")]
[ProducesResponseType(typeof(WorkspaceItem), 201)]
[ProducesResponseType(typeof(string), 400)]
public IActionResult AddItem(string folderId, [FromBody,Required] AddItemInput workloadInput)
{
...
...
The swagger.json will reflect the code, and AutoRest will produce the correct code. ArdaSDK client will work correctly.