Swagger使用--在一个Controller中使用相同(类似)参数的方法
解决方法:在Startup.cs
中加入CustomSchemaIds
// Register the Swagger generator, defining 1 or more Swagger documents
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new Info { Title = "CompareAPI", Version = "v1" });
c.CustomSchemaIds((type) => type.FullName);//根据全名来生成
});
控制器代码类似:
[Route("api/[controller]")]
[ApiController]
public class AccountController : ControllerBase
{
[HttpPost]
[Route("Register")]
public async Task<ActionResult<T>> Register(RegisterModel registerModel)
{
}
[HttpPost]
[Route("ResetPassword")]
public async Task<ActionResult<T>> ResetPassword(ResetPasswordModel resetPasswordModel)
{
}
}
https://github.com/domaindrivendev/Swashbuckle.AspNetCore/blob/master/README.md#customize-schema-ids
总有一些人过着你想要的生活