Aller au contenu

Action naming (ARCH802)

Ce contenu n’est pas encore disponible dans votre langue.

Key dotnet.api.action-naming · Severity info · Category api

API action names should represent the resource rather than repeat the HTTP verb. Consistent RESTful naming makes the API predictable.

[HttpGet]
public IActionResult GetAllUsersList() => Ok(_service.All());
[HttpPost]
public IActionResult DoCreateUser(CreateUserRequest request) => Ok();
[HttpGet]
public IActionResult List() => Ok(_service.All());
[HttpPost]
public IActionResult Create(CreateUserRequest request) => Ok();

Rename actions to be resource-focused and consistent, without repeating the action already implied by the HTTP verb.