1
0
mirror of https://github.com/bitwarden/server synced 2025-12-20 02:03:46 +00:00

[PM-12777] Fixed Issue #4034, API endpoint now handles optional parameters (#4812)

* resolves issue #4043 default values for itemsPerPage and startIndex

* UsersController#Get now uses a queryParamModel
Co-authored-by: Ahmad Mustafa Jebran <jebran.mustafa@gmail.com>
Co-authored-by: Luris Solis <solisluris@gmail.com>

* Test now passes, default 50 is represented

---------

Co-authored-by: Jared McCannon <jmccannon@bitwarden.com>
This commit is contained in:
Benson Bird
2024-10-17 08:03:26 -06:00
committed by GitHub
parent 7a509d20da
commit da0421890f
6 changed files with 71 additions and 16 deletions

View File

@@ -57,17 +57,15 @@ public class UsersController : Controller
[HttpGet("")]
public async Task<IActionResult> Get(
Guid organizationId,
[FromQuery] string filter,
[FromQuery] int? count,
[FromQuery] int? startIndex)
[FromQuery] GetUsersQueryParamModel model)
{
var usersListQueryResult = await _getUsersListQuery.GetUsersListAsync(organizationId, filter, count, startIndex);
var usersListQueryResult = await _getUsersListQuery.GetUsersListAsync(organizationId, model);
var scimListResponseModel = new ScimListResponseModel<ScimUserResponseModel>
{
Resources = usersListQueryResult.userList.Select(u => new ScimUserResponseModel(u)).ToList(),
ItemsPerPage = count.GetValueOrDefault(usersListQueryResult.userList.Count()),
ItemsPerPage = model.Count,
TotalResults = usersListQueryResult.totalResults,
StartIndex = startIndex.GetValueOrDefault(1),
StartIndex = model.StartIndex,
};
return Ok(scimListResponseModel);
}