I'm trying to get Swagger to recognize the type returned by my 
Action/Method in my C# Web Api. I've coded my method like this:

    [HttpGet]
    [Route("api/categories/top")]
    [ResponseType("200", typeof(List<MyCustomType>)), ResponseType("500", 
typeof(Exception))]
    public async Task<IHttpActionResult> GetMyCustomsAsync()
    {
        var myList = Mapper.Map<List<MyCustomType>>(await _myService.
GetCustomAsync());
        foreach (var thisItem in myList)
        {
            thisItem.Children = Mapper.Map<IList<CustomChildType>>(await 
_myService.GetChildremForCustomAsync(thisItem.MyTypeId));
        }

        return Ok(myList);
    }


Swagger returns this:

Response Class (Status 200)
Model
Inline Model [
 Inline Model 1
]Inline Model 1 {
 children (Array[CustomChildType], optional)
}CustomChildType {
 childId (integer),
 name (string, optional)
}

I've tried IList instead of List, but receive the same result.

Am I defining the list incorrectly? How can I get it to report the correct 
values?

-- 
You received this message because you are subscribed to the Google Groups 
"Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to swagger-swaggersocket+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to