Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ dist
.reports
/sandbox/*.log
/sandbox-staging
/specification/api/components/examples
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ lint-oas:
npm run lint-oas

publish-oas:
$(MAKE) copy-examples
npm run publish-oas

set-target: guard-APIM_ENV
Expand Down Expand Up @@ -74,9 +75,11 @@ build-yml-oas-spec: guard-APIM_ENV
$(MAKE) bundle-oas

serve-oas:
$(MAKE) copy-examples
npm run serve-oas

bundle-oas:
$(MAKE) copy-examples
npm run bundle-oas

generate-sandbox:
Expand All @@ -88,6 +91,9 @@ generate-sandbox:
serve-swagger:
npm run serve-swagger-docs

copy-examples:
cp -r ./sandbox/data/examples/. ./specification/api/components/examples

config:: _install-dependencies version # Configure development environment (main) @Configuration
npm install
(cd docs && make install && cd ..)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
},
"scripts": {
"build": "npm run bundle-oas && npm run generate --buildver=$npm_config_buildver",
"bundle-oas": "mkdir -p build && redocly bundle specification/api/notify-supplier-phase1.yml --dereferenced -k --remove-unused-components --ext yml > build/notify-supplier.yml",
"bundle-oas": "cp -r sandbox/data/examples/. specification/api/components/examples && mkdir -p build && redocly bundle specification/api/notify-supplier-phase1.yml --dereferenced -k --remove-unused-components --ext yml > build/notify-supplier.yml",
"generate": "npm run generate:cs --buildver=$npm_config_buildver && npm run generate:html && npm run generate:ts --buildver=$npm_config_buildver && npm run generate:python",
"generate-dependencies": "npm run generate-dependencies --workspaces --if-present",
"generate-sandbox": "openapi-generator-cli generate -g nodejs-express-server -i build/notify-supplier.json --skip-validate-spec -o sandbox-staging",
Expand Down
586 changes: 475 additions & 111 deletions sandbox/api/openapi.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion sandbox/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const path = require('path');

const config = {
ROOT_DIR: __dirname,
URL_PORT: 3000,
URL_PORT: 9000,
URL_PATH: 'http://127.0.0.1',
BASE_VERSION: '',
CONTROLLER_DIRECTORY: path.join(__dirname, 'controllers'),
Expand Down
9 changes: 6 additions & 3 deletions sandbox/controllers/Controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ class Controller {
* payload will be an object consisting of a code and a payload. If not customized
* send 200 and the payload as received in this method.
*/
Object.entries(payload.headers).forEach(([name, value]) => response.setHeader(name, String(value)));
response.status(payload.code || 200);
const responsePayload = payload.payload !== undefined ? payload.payload : payload;
const responsePayload = payload.body !== undefined ? payload.body : payload;
if (responsePayload instanceof Object) {
response.json(responsePayload);
} else {
Expand Down Expand Up @@ -91,12 +92,13 @@ class Controller {

if (request.openapi.schema.parameters !== undefined) {
request.openapi.schema.parameters.forEach((param) => {

if (param.in === 'path') {
requestParams[param.name] = request.openapi.pathParams[param.name];
} else if (param.in === 'query') {
requestParams[param.name] = request.query[param.name];
} else if (param.in === 'header') {
requestParams[param.name] = request.headers[param.name];
requestParams[camelCase(param.name)] = request.headers[param.name.toLowerCase()];
}
});
}
Expand All @@ -105,7 +107,8 @@ class Controller {

static async handleRequest(request, response, serviceOperation) {
try {
const serviceResponse = await serviceOperation(this.collectRequestParams(request));
const requestParams = this.collectRequestParams(request);
const serviceResponse = await serviceOperation(requestParams);
Controller.sendResponse(response, serviceResponse);
} catch (error) {
Controller.sendError(response, error);
Expand Down
13 changes: 13 additions & 0 deletions sandbox/data/examples/createMI/requests/createMI_INVALID.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"data": {
"attributes": {
"groupId": "abc123",
"lineItem": "envelope-business-standard",
"quantity": 22,
"specificationId": "2WL5eYSWGzCHlGmzNxuqVusPxDg",
"stockRemaining": 2000,
"timestamp": "yesterday"
},
"type": "ManagementInformation"
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
{
"data": {
"attributes": {
"cost": 10.25,
"groupId": "abc123",
"lineItem": "Letter",
"lineItem": "envelope-business-standard",
"quantity": 22,
"specificationId": "da0b1495-c7cb-468c-9d81-07dee089d728",
"specificationId": "123456",
"stockRemaining": 2000,
"timestamp": "2023-11-17T14:27:51.413Z"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"data": {
"attributes": {
"cost": 10.25,
"lineItem": "Letter",
"groupId": "abc123",
"lineItem": "envelope-business-standard",
"quantity": 22,
"specificationId": "da0b1495-c7cb-468c-9d81-07dee089d728",
"specificationId": "2WL5eYSWGzCHlGmzNxuqVusPxDg",
"stockRemaining": 2000,
"timestamp": "2023-11-17T14:27:51.413Z"
},
Expand Down
14 changes: 0 additions & 14 deletions sandbox/data/examples/createMI/responses/createMI.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
{
"data": {
"attributes": {
"cost": 10.25,
"groupId": "abc123",
"lineItem": "Letter",
"lineItem": "envelope-business-standard",
"quantity": 22,
"specificationId": "da0b1495-c7cb-468c-9d81-07dee089d728",
"specificationId": "2WL5eYSWGzCHlGmzNxuqVusPxDg",
"stockRemaining": 2000,
"timestamp": "2023-11-17T14:27:51.413Z"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"errors": [
{
"code": "NOTIFY_INVALID_REQUEST",
"detail": "The limit parameter must be a positive number not greater than 2500",
"detail": "Invalid Request: limit parameter must be a positive number not greater than 2500",
"id": "rrt-1931948104716186917-c-geu2-10664-3111479-3.0",
"links": {
"about": "https://digital.nhs.uk/developer/api-catalogue/nhs-notify-supplier"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"errors": [
{
"code": "NOTIFY_INVALID_REQUEST",
"detail": "Only 'limit' query parameter is supported",
"detail": "Invalid Request: Only 'limit' query parameter is supported",
"id": "rrt-1931948104716186917-c-geu2-10664-3111479-3.0",
"links": {
"about": "https://digital.nhs.uk/developer/api-catalogue/nhs-notify-supplier"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"data": {
"attributes": {
"reasonCode": 100,
"reasonText": "failed validation",
"groupId": "c5d93f917f5546d08beccf770a915d96",
"specificationId": "2WL5eYSWGzCHlGmzNxuqVusPxDg",
"status": "PENDING"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"data": {
"attributes": {
"groupId": "c5d93f917f5546d08beccf770a915d96",
"specificationId": "2WL5eYSWGzCHlGmzNxuqVusPxDg",
"status": "ACCEPTED"
},
"id": "2AL5eYSWGzCHlGmzNxuqVusPxDg",
"type": "Letter"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"data": {
"attributes": {
"groupId": "c5d93f917f5546d08beccf770a915d96",
"specificationId": "2WL5eYSWGzCHlGmzNxuqVusPxDg",
"status": "PRINTED"
},
"id": "2BL5eYSWGzCHlGmzNxuqVusPxDg",
"type": "Letter"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"data": {
"attributes": {
"groupId": "c5d93f917f5546d08beccf770a915d96",
"specificationId": "2WL5eYSWGzCHlGmzNxuqVusPxDg",
"status": "ENCLOSED"
},
"id": "2CL5eYSWGzCHlGmzNxuqVusPxDg",
"type": "Letter"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"data": {
"attributes": {
"groupId": "c5d93f917f5546d08beccf770a915d96",
"specificationId": "2WL5eYSWGzCHlGmzNxuqVusPxDg",
"status": "DISPATCHED"
},
"id": "2DL5eYSWGzCHlGmzNxuqVusPxDg",
"type": "Letter"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"data": {
"attributes": {
"groupId": "c5d93f917f5546d08beccf770a915d96",
"specificationId": "2WL5eYSWGzCHlGmzNxuqVusPxDg",
"status": "DELIVERED"
},
"id": "2EL5eYSWGzCHlGmzNxuqVusPxDg",
"type": "Letter"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"data": {
"attributes": {
"groupId": "c5d93f917f5546d08beccf770a915d96",
"reasonCode": 100,
"reasonText": "failed validation",
"specificationId": "2WL5eYSWGzCHlGmzNxuqVusPxDg",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"data": {
"attributes": {
"groupId": "c5d93f917f5546d08beccf770a915d96",
"reasonCode": 100,
"specificationId": "2WL5eYSWGzCHlGmzNxuqVusPxDg",
"status": "CANCELLED"
},
"id": "2XL5eYSWGzCHlGmzNxuqVusPxDg",
"type": "Letter"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"data": {
"attributes": {
"groupId": "c5d93f917f5546d08beccf770a915d96",
"reasonCode": 100,
"reasonText": "failed validation",
"specificationId": "2WL5eYSWGzCHlGmzNxuqVusPxDg",
"status": "FAILED"
},
"id": "2YL5eYSWGzCHlGmzNxuqVusPxDg",
"type": "Letter"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"data": {
"attributes": {
"groupId": "c5d93f917f5546d08beccf770a915d96",
"reasonCode": 100,
"reasonText": "failed validation",
"specificationId": "2WL5eYSWGzCHlGmzNxuqVusPxDg",
"status": "RETURNED"
},
"id": "2ZL5eYSWGzCHlGmzNxuqVusPxDg",
"type": "Letter"
}
}
Loading
Loading