目前我有以下用户模型
public class User {
[Key]
public int Id { get; set; }
[Required]
public string Name { get; set; }
[Required]
public string Email { get; set; }
[Required]
public string Password { get; set; }
}
以及以下接收电子邮件和密码的 Auth Endpoint:
[AllowAnonymous]
[HttpPost("[action]")]
public IActionResult Authenticate([FromBody] User operatorParam) {
var user = _userService.Authenticate(operatorParam.Email, operatorParam.Password);
if (user == null) {
return BadRequest(new {message = "Email or password is incorrect"});
}
return Ok(user);
}
Swagger 自动文档生成以下内容:
有什么方法可以从示例中删除 ID、名称和令牌?因为在此特定端点中只需要电子邮件和密码。
