Swashbuckle.AspNetCore: Doesn't generate summary doc when the controller class has overload methods.
Swashbuckle.AspNetCore 6.5.0 .net 7.0
Project.csproj
<GenerateDocumentationFile>true</GenerateDocumentationFile>
Controller class:
[ApiController]
[Route("api/[controller]")]
public class MyController : MyBaseController<MyModel>
{
public MyController(MyBuzService service):base(service){}
/// <summary>
/// Find by single id
/// </summary>
/// <param name="id">ID</param>
/// <returns></returns>
[HttpGet]
[Route("Find/{id}")]
public async Task<IActionResult> Find([FromRoute] string id) => await Find(new[] { id });
/// <summary>
/// Find by multi id
/// </summary>
/// <param name="id">ID</param>
/// <returns></returns>
[HttpPost]
[Route("Find")]
public async Task<IActionResult> Find([FromQuery] [FromBody] string[] id)
{
return Ok(await Service.GetModelAsync(id));
}
}
public abstract class MyBaseController<TModel>
{
private MyBuzService Service;
public MyController(MyBuzService service)
{
Service = service;
}
/// <summary>
/// Add some models
/// </summary>
/// <param name="models">Models to add</param>
/// <returns></returns>
[HttpPost]
[Route("AddRange")]
public async Task<IActionResult> AddRange([FromBody] TModel[] models)
{
return Ok(await Service.AddRange(models));
}
}
I’ve checked the generated XML documentation file, it’s generated correctly.
But summary document are missing in the swagger.json.
I’ve created a class that implements IOperationFilter interface, when I’m debugging, I found OpenApiOperation.Summary property with value null.
update issue:
The method public async Task<IActionResult> AddRange([FromBody] TModel[] models) takes one parameter of TModel[] type which is array type doesn’t generate summary doc too!.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 15 (4 by maintainers)
Thank you, this worked!
You can test it now with 6.7.1 package
It should be fixed on MyGet latest version @codelovercc could you test it and if it’s working close the issue? Thanks
I am reviewing this issue 😃
Thanks, I will check
@Havunen Thank you for your work. There still is a problem with overloaded method in this case:
XML documents file generated will. Method
Listwith full documented in swagger, but methodDelete([Required, FromRoute] TKey id, CancellationToken cancellationToken)andDelete([Required, FromBody] TKey[] ids, CancellationToken cancellationToken)lost all of xml comment docs in swagger.FYI. This is supported in DotSwashbuckle