Reputation: 485
I'm having some issues using Swashbuckle to generate Swagger documentation for an API that returns a custom type containing a property which is a Dictionary whose value is IEnumerable.
public class MyReturnModel
{
public IDictionary<int, IEnumerable<MyModel>> Data { get; set;}
public MyReturnModel()
{
Data = new Dictionary<int, IEnumerable<MyModel>>();
}
}
public class MyModel
{
public int Value { get; set; }
}
If I have an API endpoint like so:
[ProducesResponseType(typeof(MyReturnModel), (int)HttpStatusCode.OK)]
[HttpGet]
public async Task<IActionResult> GetAsync()
{
var myReturn = await MyReturnModelRepository.GetAsync();
return Ok(myReturn);
}
The Swagger UI I can see shows the response type like so:
MyReturnModel {
data (inline_model, optional)
}
inline_model {}
How can I get the Swagger gen to generate documentation for the collection and the inner model?
Upvotes: 1
Views: 1595
Reputation: 485
The answer was that I was on version 1.2.0 of Swashbuckle. Updating to version 2.0.0 fixed the issue.
Upvotes: 1