Skip to content

Commit e61088d

Browse files
committed
#723 | Handle null or invalid entityType value for "/api/approvalStatuses"
1 parent 72ca050 commit e61088d

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

avni-server-api/src/main/java/org/avni/server/web/api/EntityApprovalStatusApiController.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ public EntityApprovalStatusApiController(EntityApprovalStatusRepository entityAp
3838
@PreAuthorize(value = "hasAnyAuthority('user')")
3939
public ResponsePage getEntityApprovalStatuses(@RequestParam(value = "lastModifiedDateTime", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) DateTime lastModifiedDateTime,
4040
@RequestParam(value = "now", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) DateTime now,
41-
@RequestParam(value = "entityType", required = false) String entityType,
41+
@RequestParam(value = "entityType", required = false) EntityApprovalStatus.EntityType entityType,
4242
@RequestParam(value = "entityTypeId", required = false) String entityTypeUuid,
4343
Pageable pageable) {
4444

45-
Page<EntityApprovalStatus> entityApprovalStatuses = entityApprovalStatusRepository.findEntityApprovalStatuses(new EntityApprovalStatusSearchParams(lastModifiedDateTime, now, EntityApprovalStatus.EntityType.valueOf(entityType), entityTypeUuid), pageable);
45+
Page<EntityApprovalStatus> entityApprovalStatuses = entityApprovalStatusRepository.findEntityApprovalStatuses(new EntityApprovalStatusSearchParams(lastModifiedDateTime, now, entityType, entityTypeUuid), pageable);
4646
accessControlService.checkApprovePrivilegeOnEntityApprovalStatuses(entityApprovalStatuses.getContent());
4747
ArrayList<EntityApprovalStatusResponse> entityApprovalStatusResponse = new ArrayList<>();
4848
entityApprovalStatuses.forEach(entityApprovalStatus -> entityApprovalStatusResponse.add(EntityApprovalStatusResponse.fromEntityApprovalStatus(entityApprovalStatus, entityApprovalStatusService.getEntityUuid(entityApprovalStatus))));

avni-server-api/src/main/resources/api/external-api.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,7 +1253,7 @@ paths:
12531253
responses:
12541254
"200":
12551255
description: successful
1256-
/api/entityApprovalStatuses:
1256+
/api/approvalStatuses:
12571257
get:
12581258
tags:
12591259
- Entity Approval Status
@@ -1286,6 +1286,8 @@ paths:
12861286
explode: true
12871287
schema:
12881288
type: string
1289+
nullable: true
1290+
enum: [Subject,ProgramEnrolment,ProgramEncounter,Encounter,ChecklistItem]
12891291
- name: entityTypeId
12901292
in: query
12911293
description: "Allows filtering results by entity type id"
@@ -1294,7 +1296,7 @@ paths:
12941296
explode: true
12951297
schema:
12961298
type: string
1297-
example: "{\"Diagnosis\": \"Diabetes\", \"Blood Group\": \"B+\"}"
1299+
example: 1e9afb68-7e64-4295-8865-dbe7c433823e
12981300
- name: auth-token
12991301
in: header
13001302
required: false

0 commit comments

Comments
 (0)