Skip to content

Commit 580c6fc

Browse files
authored
CCM-12357: Add environment-specific selection of security schemes (#232)
1 parent ec75f5e commit 580c6fc

12 files changed

+44
-15
lines changed

Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ clean:: # Clean-up project resources (main) @Operations
3030
# (cd src/server && make clean)
3131

3232
guard-%:
33-
@ if [ "${${*}}" = "" ]; then \
33+
@if [ -z "$${$*}" ]; then \
3434
echo "Variable $* not set"; \
35-
echo "Usage: make <target> APIM_ENV=<env>"
35+
echo "Usage: make <target> $*=<env>"; \
3636
exit 1; \
3737
fi
3838
serve:
@@ -59,6 +59,9 @@ set-security: guard-APIM_ENV
5959
@ SECURITY=security-$$APIM_ENV.yml \
6060
envsubst '$${SECURITY}' \
6161
< specification/api/components/security/security-template.yml > specification/api/components/security/security.yml
62+
@ SECURITY_SCHEMES=security-schemes-$$APIM_ENV.yml \
63+
envsubst '$${SECURITY_SCHEMES}' \
64+
< specification/api/components/security-schemes/security-schemes-template.yml > specification/api/components/security-schemes/security-schemes.yml
6265

6366
construct-spec: guard-APIM_ENV
6467
$(MAKE) set-target APIM_ENV=$$APIM_ENV
Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,39 @@
1-
import {LetterSchema, MISchema, SupplierSchema} from '../types';
2-
import { generateMermaidDiagram } from 'zod-mermaid';
3-
import * as fs from 'node:fs';
1+
import { generateMermaidDiagram } from "zod-mermaid";
2+
import * as fs from "node:fs";
3+
import {
4+
LetterSchema,
5+
MISchema,
6+
SupplierSchema,
7+
} from "internal/datastore/src/types";
48

5-
const out = fs.openSync('src/types.md', 'w');
9+
const out = fs.openSync("src/types.md", "w");
610

7-
fs.writeSync(out, `# Data Store Schemas
11+
fs.writeSync(
12+
out,
13+
`# Data Store Schemas
814
915
This document contains the mermaid diagrams for the data store schemas used in the application.
1016
1117
The schemas are generated from Zod definitions and provide a visual representation of the data structure.
12-
`);
18+
`,
19+
);
1320

14-
for (const [name, schema] of Object.entries({ Letter: [LetterSchema], MI: [MISchema], Supplier: [SupplierSchema] })) {
21+
for (const [name, schema] of Object.entries({
22+
Letter: [LetterSchema],
23+
MI: [MISchema],
24+
Supplier: [SupplierSchema],
25+
})) {
1526
const mermaid = generateMermaidDiagram(schema);
16-
fs.writeSync(out, `
27+
fs.writeSync(
28+
out,
29+
`
1730
## ${name} schema
1831
1932
\`\`\`mermaid
2033
${mermaid}
2134
\`\`\`
22-
`);
35+
`,
36+
);
2337
}
2438

2539
fs.closeSync(out);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
$ref: './security-schemes-ptl.yml'
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
$ref: './security-schemes-ptl.yml'
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
$ref: './security-schemes-ptl.yml'
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
app-level3:
2+
$ref: https://proxygen.prod.api.platform.nhs.uk/components/securitySchemes/app-level3
3+
app-level0:
4+
$ref: https://proxygen.prod.api.platform.nhs.uk/components/securitySchemes/app-level0
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
app-level3:
2+
$ref: https://proxygen.ptl.api.platform.nhs.uk/components/securitySchemes/app-level3
3+
app-level0:
4+
$ref: https://proxygen.ptl.api.platform.nhs.uk/components/securitySchemes/app-level0
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
$ref: './security-schemes-ptl.yml'
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
$ref: './security-schemes-ptl.yml'
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
$ref: $SECURITY_SCHEMES

0 commit comments

Comments
 (0)