Problem:
- The
Get All (Accounts) endpoint's Gateway does not make use of provided Account Type parameter when filtering entities (see bellow), ...
|
public async Task<List<Account>> GetAllAsync(Guid targetId, AccountType accountType) |
|
{ |
|
if (targetId == null) |
|
throw new ArgumentException("Invalid targetId"); |
|
|
|
IQueryable<AccountDbEntity> data = _accountDbContext |
|
.AccountEntities |
|
.Where(p => p.TargetId == targetId); |
|
return await data.Select(p => p.ToDomain()) |
|
.ToListAsync() |
|
.ConfigureAwait(false); |
|
} |
... while it is specified as available, active parameter on the endpoint controller's xml comment documentation (see Line 82):
|
/// <summary> |
|
/// Get a list of Account models |
|
/// </summary> |
|
/// <param name="targetId">The target id by which we are looking for account</param> |
|
/// <param name="accountType">The account type by which we are looking for accounts</param> |
|
/// <response code="200">Success. Account models was received successfully</response> |
|
/// <response code="400">Bad Request</response> |
|
/// <response code="404">Accounts with provided id cannot be found</response> |
|
/// <response code="500">Internal Server Error</response> |
|
[ProducesResponseType(typeof(AccountResponses), StatusCodes.Status200OK)] |
|
[ProducesResponseType(typeof(BaseErrorResponse), StatusCodes.Status404NotFound)] |
|
[ProducesResponseType(typeof(BaseErrorResponse), StatusCodes.Status400BadRequest)] |
|
[ProducesResponseType(typeof(BaseErrorResponse), StatusCodes.Status500InternalServerError)] |
|
[HttpGet] |
|
public async Task<IActionResult> GetAllAsync([FromQuery] Guid targetId, [FromQuery] AccountType accountType) |
Potential Solution:
- If missing account type filter is an oversight, then when assuming it is optional it could be fixed by adding a conditional addon onto the already existing queryable object (see bellow comment):
public async Task<List<Account>> GetAllAsync(Guid targetId, AccountType accountType)
{
if (targetId == null)
throw new ArgumentException("Invalid targetId");
var data = _accountDbContext
.AccountEntities
.Where(p => p.TargetId == targetId);
// something like:
if (accountType != null)
data = data.Where(a => a.AccountType == accountType);
return await data.Select(p => p.ToDomain())
.ToListAsync()
.ConfigureAwait(false);
}
- However, if the "Account Type" search parameter is not needed, then it needs to be removed from the Gateway signature, Use Case signature & their interfaces, as well as from Controller parameters and its XML documentation. Depending on how well this API is tested, the tests might need to change as well.
Problem:
Get All (Accounts)endpoint's Gateway does not make use of providedAccount Typeparameter when filtering entities (see bellow), ...account-api/AccountsApi/V1/Gateways/AccountApiGateway.cs
Lines 38 to 49 in 069bfa1
... while it is specified as available, active parameter on the endpoint controller's xml comment documentation (see Line 82):
account-api/AccountsApi/V1/Controllers/AccountApiController.cs
Lines 78 to 92 in 069bfa1
Potential Solution: