Skip to content

Commit 74c83af

Browse files
Refactor validation response structures (#845)
1 parent 3c75bef commit 74c83af

File tree

3 files changed

+14
-20
lines changed

3 files changed

+14
-20
lines changed

src/services/psc-extensions-link/types.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,11 @@ export interface ExtensionDetails {
149149
}
150150

151151
export interface ValidationStatusError {
152-
error: string;
153-
location: string;
154-
type?: string;
155-
locationType: string;
152+
field: string;
153+
message: string;
156154
}
157155
export interface ValidationStatusResponse {
158-
errors: ValidationStatusError[];
156+
validationStatusError: ValidationStatusError[];
159157
valid: boolean;
160158
}
161159
export interface ValidationStatusErrorResource {

test/services/psc-extensions-link/service.mock.ts

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,34 +48,30 @@ export const PSC_EXTENSION: PscExtension = {
4848

4949
const VALIDATION_STATUS_RESPONSE_RESOURCE = {
5050
valid: true,
51-
errors: []
51+
validation_status_error: []
5252
};
5353

5454
export const VALIDATION_STATUS_RESPONSE: ValidationStatusResponse = {
5555
valid: true,
56-
errors: []
56+
validationStatusError: []
5757
};
5858

5959
const VALIDATION_STATUS_RESPONSE_INVALID_RESOURCE = {
6060
valid: false,
61-
errors: [
61+
validation_status_error: [
6262
{
63-
error: "PSC has exceeded maximum number of extension requests",
64-
location: "$.",
65-
location_type: "json-path",
66-
type: "ch:validation"
63+
message: "PSC has exceeded maximum number of extension requests",
64+
field: "$."
6765
}
6866
]
6967
};
7068

7169
export const VALIDATION_STATUS_RESPONSE_INVALID: ValidationStatusResponse = {
7270
valid: false,
73-
errors: [
71+
validationStatusError: [
7472
{
75-
error: "PSC has exceeded maximum number of extension requests",
76-
location: "$.",
77-
locationType: "json-path",
78-
type: "ch:validation"
73+
message: "PSC has exceeded maximum number of extension requests",
74+
field: "$."
7975
}
8076
]
8177
};

test/services/psc-extensions-link/service.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ describe("PSC Extensions Service", () => {
156156

157157
expect(response.httpStatusCode).to.equal(StatusCodes.OK);
158158
expect(response.resource!.valid).to.be.true;
159-
expect(response.resource!.errors).to.be.empty;
159+
expect(response.resource!.validationStatusError).to.be.empty;
160160
});
161161

162162
it("should return status 200 OK and validation response when extension is invalid", async () => {
@@ -167,8 +167,8 @@ describe("PSC Extensions Service", () => {
167167

168168
expect(response.httpStatusCode).to.equal(StatusCodes.OK);
169169
expect(response.resource!.valid).to.be.false;
170-
expect(response.resource!.errors).to.have.length(1);
171-
expect(response.resource!.errors[0].error).to.equal("PSC has exceeded maximum number of extension requests");
170+
expect(response.resource!.validationStatusError).to.have.length(1);
171+
expect(response.resource!.validationStatusError[0].message).to.equal("PSC has exceeded maximum number of extension requests");
172172
});
173173

174174
it("should return status 400 Bad Request when parameters are invalid", async () => {

0 commit comments

Comments
 (0)