解决方法:在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> Register(RegisterModel registerModel) { } [HttpPost] [Route("ResetPassword")] public async Task > ResetPassword(ResetPasswordModel resetPasswordModel) { } }