İçeriğe geç

Missing produces response type (ARCH801)

Anahtar dotnet.api.missing-produces-response-type · Önem info · Kategori api

ProducesResponseType öznitelikleri olmayan aksiyonlar, OpenAPI/Swagger dokümantasyonunda eksik veya yanlış yanıt şemaları üretir. Olası durum kodları açıkça bildirilmelidir.

[HttpGet("{id}")]
public async Task<IActionResult> GetById(int id)
{
var user = await _service.FindAsync(id);
return user is null ? NotFound() : Ok(user);
}
[HttpGet("{id}")]
[ProducesResponseType(typeof(UserResponse), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<IActionResult> GetById(int id)
{
var user = await _service.FindAsync(id);
return user is null ? NotFound() : Ok(user);
}

Her aksiyonun döndürebileceği durum kodları ve gövde tipleri için [ProducesResponseType] öznitelikleri ekleyin.