I'm developing one web service with WebAPI 2 and OWIN. My goal is add some documentation with Swashbuckle.
Following my method:
/// <summary>
/// La mia descrizione...
/// </summary>
/// <param name="id">Identificativo</param>
/// <param name="list">Una lista</param>
[HttpPut]
[Route("~/api/v1/documents/{id}/attribute")]
public IHttpActionResult Put(int id, List<AttributeDto> list)
{
_myService.Create(list, id);
return Ok();
}
Below my AttributeDto class code:
using Newtonsoft.Json;
namespace WebApi.Dtos
{
public class AttributeDto
{
[JsonIgnore]
public int Id { get; set; }
[JsonIgnore]
public int OtherId { get; set; }
public string Label { get; set; }
public string Value { get; set; }
}
}
If I open Swagger UI I can view one example section with autogenerated data:
How can I customize autogenerated data so that JSON in picture becomes like below:
[
{
"label": "Etichetta di esempio",
"value": "Valore di esempio"
}
]
