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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"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",
"generate-sandbox": "openapi-generator-cli generate -g nodejs-express-server -i build/notify-supplier.json -o sandbox-staging",
"generate:cs": "./sdk/generate-cs.sh $npm_config_buildver",
"generate:cs-server": "./server/generate-cs-server.sh $npm_config_buildver",
"generate:html": "docker run --rm --user $(id -u) -v ${PWD}:/local openapitools/openapi-generator-cli generate -i /local/build/notify-supplier.yml -g html -o /local/sdk/html --skip-validate-spec",
Expand Down
209 changes: 141 additions & 68 deletions sandbox/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,25 @@ paths:
schema:
$ref: "#/components/schemas/listLetters_200_response"
description: List of letters to process
headers:
X-Request-ID:
description: |
Unique request identifier, in the format of a GUID
explode: false
required: false
schema:
example: dcb9c8dc-c2f4-4d5f-8674-a2e913e040b2
type: string
style: simple
X-Correlation-ID:
description: |
An optional ID which you can use to track transactions across multiple systems. It can take any value, but we recommend avoiding . characters. If not provided in the request, NHS Notify will default to a system generated ID in its place. The ID will be returned in a response header.
explode: false
required: false
schema:
example: 11C46F5F-CDEF-4865-94B2-0EE0EDCC26DA
type: string
style: simple
"400":
content:
application/vnd.api+json:
Expand All @@ -213,7 +232,7 @@ paths:
value:
errors:
- code: NOTIFY_INVALID_REQUEST
detail: "Only 'limit' query parameter is supported"
detail: 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 All @@ -223,8 +242,8 @@ paths:
value:
errors:
- code: NOTIFY_INVALID_REQUEST
detail: "The limit parameter must be a positive\
\ number not greater than 2500"
detail: The 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 Expand Up @@ -368,66 +387,28 @@ paths:
type: Letter
schema:
$ref: "#/components/schemas/postLetters_request"
required: true
responses:
"200":
content:
application/vnd.api+json:
examples:
post-letters-responses:
value:
data:
- attributes:
status: PENDING
id: 2WL5eYSWGzCHlGmzNxuqVusPxDg
type: Letter
- attributes:
status: ACCEPTED
id: 2WL5eYSWGzCHlGmzNxuqVusPxDg
type: Letter
- attributes:
status: PRINTED
id: 2WL5eYSWGzCHlGmzNxuqVusPxDg
type: Letter
- attributes:
status: ENCLOSED
id: 2WL5eYSWGzCHlGmzNxuqVusPxDg
type: Letter
- attributes:
status: DISPATCHED
id: 2WL5eYSWGzCHlGmzNxuqVusPxDg
type: Letter
- attributes:
status: DELIVERED
id: 2WL5eYSWGzCHlGmzNxuqVusPxDg
type: Letter
- attributes:
reasonCode: 100
reasonText: failed validation
status: RETURNED
id: 2WL5eYSWGzCHlGmzNxuqVusPxDg
type: Letter
- attributes:
reasonCode: 100
reasonText: failed validation
status: CANCELLED
id: 2WL5eYSWGzCHlGmzNxuqVusPxDg
type: Letter
- attributes:
reasonCode: 100
reasonText: failed validation
status: FAILED
id: 2WL5eYSWGzCHlGmzNxuqVusPxDg
type: Letter
- attributes:
reasonCode: 100
reasonText: failed validation
status: RETURNED
id: 2WL5eYSWGzCHlGmzNxuqVusPxDg
type: Letter
"202":
description: 202 (Accepted) Acknowledges that status updates have been posted
headers:
X-Request-ID:
description: |
Unique request identifier, in the format of a GUID
explode: false
required: false
schema:
$ref: "#/components/schemas/listLetters_200_response"
description: Letter Resources Updated successfully
example: dcb9c8dc-c2f4-4d5f-8674-a2e913e040b2
type: string
style: simple
X-Correlation-ID:
description: |
An optional ID which you can use to track transactions across multiple systems. It can take any value, but we recommend avoiding . characters. If not provided in the request, NHS Notify will default to a system generated ID in its place. The ID will be returned in a response header.
explode: false
required: false
schema:
example: 11C46F5F-CDEF-4865-94B2-0EE0EDCC26DA
type: string
style: simple
"404":
content:
application/vnd.api+json:
Expand Down Expand Up @@ -551,6 +532,25 @@ paths:
schema:
$ref: "#/components/schemas/getLetterStatus_200_response"
description: Letter status
headers:
X-Request-ID:
description: |
Unique request identifier, in the format of a GUID
explode: false
required: false
schema:
example: dcb9c8dc-c2f4-4d5f-8674-a2e913e040b2
type: string
style: simple
X-Correlation-ID:
description: |
An optional ID which you can use to track transactions across multiple systems. It can take any value, but we recommend avoiding . characters. If not provided in the request, NHS Notify will default to a system generated ID in its place. The ID will be returned in a response header.
explode: false
required: false
schema:
example: 11C46F5F-CDEF-4865-94B2-0EE0EDCC26DA
type: string
style: simple
"404":
content:
application/vnd.api+json:
Expand Down Expand Up @@ -756,7 +756,6 @@ paths:
type: Letter
schema:
$ref: "#/components/schemas/patchLetter_request"
required: true
responses:
"200":
content:
Expand All @@ -773,6 +772,25 @@ paths:
schema:
$ref: "#/components/schemas/getLetterStatus_200_response"
description: Letter resource updated successfully
headers:
X-Request-ID:
description: |
Unique request identifier, in the format of a GUID
explode: false
required: false
schema:
example: dcb9c8dc-c2f4-4d5f-8674-a2e913e040b2
type: string
style: simple
X-Correlation-ID:
description: |
An optional ID which you can use to track transactions across multiple systems. It can take any value, but we recommend avoiding . characters. If not provided in the request, NHS Notify will default to a system generated ID in its place. The ID will be returned in a response header.
explode: false
required: false
schema:
example: 11C46F5F-CDEF-4865-94B2-0EE0EDCC26DA
type: string
style: simple
"400":
content:
application/vnd.api+json:
Expand Down Expand Up @@ -889,6 +907,24 @@ paths:
schema:
type: string
style: simple
X-Request-ID:
description: |
Unique request identifier, in the format of a GUID
explode: false
required: false
schema:
example: dcb9c8dc-c2f4-4d5f-8674-a2e913e040b2
type: string
style: simple
X-Correlation-ID:
description: |
An optional ID which you can use to track transactions across multiple systems. It can take any value, but we recommend avoiding . characters. If not provided in the request, NHS Notify will default to a system generated ID in its place. The ID will be returned in a response header.
explode: false
required: false
schema:
example: 11C46F5F-CDEF-4865-94B2-0EE0EDCC26DA
type: string
style: simple
"404":
content:
application/vnd.api+json:
Expand Down Expand Up @@ -1049,7 +1085,6 @@ paths:
type: ManagementInformation
schema:
$ref: "#/components/schemas/createMI_request"
required: true
responses:
"201":
content:
Expand All @@ -1070,6 +1105,25 @@ paths:
schema:
$ref: "#/components/schemas/createMI_201_response"
description: Management Information created successfully
headers:
X-Request-ID:
description: |
Unique request identifier, in the format of a GUID
explode: false
required: false
schema:
example: dcb9c8dc-c2f4-4d5f-8674-a2e913e040b2
type: string
style: simple
X-Correlation-ID:
description: |
An optional ID which you can use to track transactions across multiple systems. It can take any value, but we recommend avoiding . characters. If not provided in the request, NHS Notify will default to a system generated ID in its place. The ID will be returned in a response header.
explode: false
required: false
schema:
example: 11C46F5F-CDEF-4865-94B2-0EE0EDCC26DA
type: string
style: simple
"404":
content:
application/vnd.api+json:
Expand Down Expand Up @@ -1144,6 +1198,9 @@ components:
type: string
attributes:
$ref: "#/components/schemas/createMI_request_data_attributes"
required:
- attributes
- type
type: object
listLetters_200_response_data_inner_attributes:
properties:
Expand Down Expand Up @@ -1183,11 +1240,6 @@ components:
- specificationId
- status
type: object
patchLetter_request:
properties:
data:
$ref: "#/components/schemas/postLetters_request_data_inner"
type: object
listLetters_400_response:
properties:
errors:
Expand Down Expand Up @@ -1232,10 +1284,19 @@ components:
$ref: "#/components/schemas/listLetters_200_response_data_inner"
type: array
type: object
patchLetter_request:
properties:
data:
$ref: "#/components/schemas/postLetters_request_data_inner"
required:
- data
type: object
getLetterStatus_200_response:
properties:
data:
$ref: "#/components/schemas/listLetters_200_response_data_inner"
required:
- data
type: object
postLetters_request_data_inner_attributes:
properties:
Expand Down Expand Up @@ -1265,6 +1326,8 @@ components:
description: Reason text for the given status
example: failed validation
type: string
required:
- status
type: object
listLetters_200_response_data_inner:
properties:
Expand All @@ -1289,13 +1352,19 @@ components:
type: string
attributes:
$ref: "#/components/schemas/postLetters_request_data_inner_attributes"
required:
- attributes
- id
- type
type: object
postLetters_request:
properties:
data:
items:
$ref: "#/components/schemas/postLetters_request_data_inner"
type: array
required:
- data
type: object
createMI_request:
properties:
Expand Down Expand Up @@ -1390,3 +1459,7 @@ x-nhsd-apim:
- name: NHSD-Supplier-ID
header: NHSD-Supplier-ID
required: false
ratelimiting:
app-default:
limit: 300
timeunit: second
11 changes: 7 additions & 4 deletions sandbox/controllers/Controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@ class Controller {
*/
Object.entries(payload.headers).forEach(([name, value]) => response.setHeader(name, String(value)));
response.status(payload.code || 200);
const responsePayload = payload.body !== undefined ? payload.body : payload;
if (responsePayload instanceof Object) {
response.json(responsePayload);
if (payload.body) {
if (payload.body instanceof Object) {
response.json(payload.body);
} else {
response.end(payload.body);
}
} else {
response.end(responsePayload);
response.end();
}
}

Expand Down
Loading
Loading