40系はデフォだと ProblemDetails Class (Microsoft.AspNetCore.Mvc) | Microsoft Docs になってしまうので、
ProducesErrorResponseTypeAttribute Class (Microsoft.AspNetCore.Mvc) | Microsoft Docs でデフォルトの type を変える。
例:403 は void で 400 は IdentityError[] の時
[Produces("application/json")] [Route("api/[controller]")] [ApiController] public class AccountController : ControllerBase { [HttpPost("register")] [ProducesErrorResponseType(typeof(void))] // これが無いと 403 が ProblemDetails になる [ProducesResponseType(403)] // [ProducesResponseType(typeof(void), 403)] にしても ProducesErrorResponseType が無いと ProblemDetails になる [ProducesResponseType(typeof(IdentityError[]), 400)] [ProducesResponseType(typeof(string), 200)] public async Task<object> Hoge([FromBody] HogeModel model) { // ... }