Skip to content

Commit

Permalink
feat: add option to skipValidation when using `/digital-planning-appl…
Browse files Browse the repository at this point in the history
…ication` admin endpoint (#3021)
  • Loading branch information
jessicamcinchak authored Apr 16, 2024
1 parent 4b7d32f commit 8ce4397
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 21 deletions.
11 changes: 11 additions & 0 deletions api.planx.uk/modules/admin/session/digitalPlanningData.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,15 @@ describe("Digital Planning Application payload admin endpoint", () => {
expect(res.body).toEqual(expectedPlanningPermissionPayload),
);
});

it("returns an invalid JSON payload if the skipValidation query param is set", async () => {
await supertest(app)
.get(endpoint`123`.concat("?skipValidation=true"))
.set(authHeader({ role: "platformAdmin" }))
.expect(200)
.expect("content-type", "application/json; charset=utf-8")
.then((res) =>
expect(res.body).toEqual(expectedPlanningPermissionPayload),
);
});
});
13 changes: 13 additions & 0 deletions api.planx.uk/modules/admin/session/digitalPlanningData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ import { $api } from "../../../client";
* - admin
* parameters:
* - $ref: '#/components/parameters/sessionId'
* - in: query
* name: skipValidation
* type: boolean
* required: false
* description: If invalid JSON data should still be returned, instead of logging validation errors
* security:
* - bearerAuth: []
*/
Expand All @@ -20,9 +25,17 @@ export const getDigitalPlanningApplicationPayload = async (
next: NextFunction,
) => {
try {
let skipValidation = false;
if (req.query?.skipValidation) {
skipValidation =
(req.query.skipValidation as string).toLowerCase() === "true";
}

const data = await $api.export.digitalPlanningDataPayload(
req.params.sessionId,
skipValidation,
);

res.set("content-type", "application/json");
return res.send(data);
} catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion api.planx.uk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"dependencies": {
"@airbrake/node": "^2.1.8",
"@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#7ff62e4",
"@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#15bde6b",
"@types/isomorphic-fetch": "^0.0.36",
"adm-zip": "^0.5.10",
"aws-sdk": "^2.1467.0",
Expand Down
8 changes: 4 additions & 4 deletions api.planx.uk/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion e2e/tests/api-driven/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
},
"dependencies": {
"@cucumber/cucumber": "^9.3.0",
"@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#7ff62e4",
"@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#15bde6b",
"axios": "^1.6.8",
"dotenv": "^16.3.1",
"dotenv-expand": "^10.0.0",
Expand Down
8 changes: 4 additions & 4 deletions e2e/tests/api-driven/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion e2e/tests/ui-driven/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"postinstall": "./install-dependencies.sh"
},
"dependencies": {
"@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#7ff62e4",
"@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#15bde6b",
"axios": "^1.6.8",
"dotenv": "^16.3.1",
"eslint": "^8.56.0",
Expand Down
8 changes: 4 additions & 4 deletions e2e/tests/ui-driven/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion editor.planx.uk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"@mui/material": "^5.15.2",
"@mui/utils": "^5.15.2",
"@opensystemslab/map": "^0.8.1",
"@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#7ff62e4",
"@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#15bde6b",
"@tiptap/core": "^2.0.3",
"@tiptap/extension-bold": "^2.0.3",
"@tiptap/extension-bubble-menu": "^2.1.13",
Expand Down
10 changes: 5 additions & 5 deletions editor.planx.uk/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8ce4397

Please sign in to comment.