Skip to content

Commit

Permalink
#723 | Handle null or invalid entityType value for "/api/approvalStat…
Browse files Browse the repository at this point in the history
…uses"
  • Loading branch information
himeshr committed May 3, 2024
1 parent 72ca050 commit e61088d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ public EntityApprovalStatusApiController(EntityApprovalStatusRepository entityAp
@PreAuthorize(value = "hasAnyAuthority('user')")
public ResponsePage getEntityApprovalStatuses(@RequestParam(value = "lastModifiedDateTime", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) DateTime lastModifiedDateTime,
@RequestParam(value = "now", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) DateTime now,
@RequestParam(value = "entityType", required = false) String entityType,
@RequestParam(value = "entityType", required = false) EntityApprovalStatus.EntityType entityType,
@RequestParam(value = "entityTypeId", required = false) String entityTypeUuid,
Pageable pageable) {

Page<EntityApprovalStatus> entityApprovalStatuses = entityApprovalStatusRepository.findEntityApprovalStatuses(new EntityApprovalStatusSearchParams(lastModifiedDateTime, now, EntityApprovalStatus.EntityType.valueOf(entityType), entityTypeUuid), pageable);
Page<EntityApprovalStatus> entityApprovalStatuses = entityApprovalStatusRepository.findEntityApprovalStatuses(new EntityApprovalStatusSearchParams(lastModifiedDateTime, now, entityType, entityTypeUuid), pageable);
accessControlService.checkApprovePrivilegeOnEntityApprovalStatuses(entityApprovalStatuses.getContent());
ArrayList<EntityApprovalStatusResponse> entityApprovalStatusResponse = new ArrayList<>();
entityApprovalStatuses.forEach(entityApprovalStatus -> entityApprovalStatusResponse.add(EntityApprovalStatusResponse.fromEntityApprovalStatus(entityApprovalStatus, entityApprovalStatusService.getEntityUuid(entityApprovalStatus))));
Expand Down
6 changes: 4 additions & 2 deletions avni-server-api/src/main/resources/api/external-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1253,7 +1253,7 @@ paths:
responses:
"200":
description: successful
/api/entityApprovalStatuses:
/api/approvalStatuses:
get:
tags:
- Entity Approval Status
Expand Down Expand Up @@ -1286,6 +1286,8 @@ paths:
explode: true
schema:
type: string
nullable: true
enum: [Subject,ProgramEnrolment,ProgramEncounter,Encounter,ChecklistItem]
- name: entityTypeId
in: query
description: "Allows filtering results by entity type id"
Expand All @@ -1294,7 +1296,7 @@ paths:
explode: true
schema:
type: string
example: "{\"Diagnosis\": \"Diabetes\", \"Blood Group\": \"B+\"}"
example: 1e9afb68-7e64-4295-8865-dbe7c433823e
- name: auth-token
in: header
required: false
Expand Down

0 comments on commit e61088d

Please sign in to comment.