diff --git a/schemas/app.json b/schemas/app.json index e436a7ef..adbb73cd 100644 --- a/schemas/app.json +++ b/schemas/app.json @@ -26,96 +26,6 @@ ], "type": "object" }, - "BaseWTT": { - "additionalProperties": false, - "properties": { - "applicationType": { - "const": "wtt", - "type": "string" - }, - "data": { - "additionalProperties": false, - "properties": { - "application": { - "$ref": "#/definitions/WTTApplicationData" - }, - "user": { - "$ref": "#/definitions/WTTUser" - } - }, - "required": [ - "user", - "application" - ], - "type": "object" - } - }, - "required": [ - "applicationType", - "data" - ], - "type": "object" - }, - "ConsentWTT": { - "additionalProperties": false, - "properties": { - "applicationType": { - "const": "wtt.consent", - "type": "string" - }, - "data": { - "additionalProperties": false, - "properties": { - "application": { - "$ref": "#/definitions/WTTApplicationData" - }, - "user": { - "$ref": "#/definitions/WTTUser" - } - }, - "required": [ - "user", - "application" - ], - "type": "object" - } - }, - "required": [ - "applicationType", - "data" - ], - "type": "object" - }, - "NoticeWTT": { - "additionalProperties": false, - "properties": { - "applicationType": { - "const": "wtt.notice", - "type": "string" - }, - "data": { - "additionalProperties": false, - "properties": { - "application": { - "$ref": "#/definitions/WTTApplicationData" - }, - "user": { - "$ref": "#/definitions/WTTUser" - } - }, - "required": [ - "user", - "application" - ], - "type": "object" - } - }, - "required": [ - "applicationType", - "data" - ], - "type": "object" - }, "PPApplicationData": { "additionalProperties": false, "description": "Specific ApplicationData required for \"Planning Permission\" applications", @@ -270,17 +180,38 @@ "type": "object" }, "WorksToTreesApplications": { - "anyOf": [ - { - "$ref": "#/definitions/BaseWTT" - }, - { - "$ref": "#/definitions/ConsentWTT" + "additionalProperties": false, + "properties": { + "applicationType": { + "enum": [ + "wtt", + "wtt.consent", + "wtt.notice" + ], + "type": "string" }, - { - "$ref": "#/definitions/NoticeWTT" + "data": { + "additionalProperties": false, + "properties": { + "application": { + "$ref": "#/definitions/WTTApplicationData" + }, + "user": { + "$ref": "#/definitions/WTTUser" + } + }, + "required": [ + "user", + "application" + ], + "type": "object" } - ] + }, + "required": [ + "applicationType", + "data" + ], + "type": "object" } }, "description": "(Temporary name to not clash with the existing `Application` type)\nThe root specification for a planning application in England generated by a digital planning service", diff --git a/types/schemas/app/index.ts b/types/schemas/app/index.ts index 8cd96be2..e520863a 100644 --- a/types/schemas/app/index.ts +++ b/types/schemas/app/index.ts @@ -31,10 +31,10 @@ export type PlanningPermissionApplication = ApplicationSpecification< export type PriorApprovalApplication = ApplicationSpecification<'pa', 'pa'>; // TODO: All granular types -export type WorksToTreesApplications = BaseWTT | ConsentWTT | NoticeWTT; -export type BaseWTT = ApplicationSpecification<'wtt', 'wtt'>; -export type ConsentWTT = ApplicationSpecification<'wtt', 'wtt.consent'>; -export type NoticeWTT = ApplicationSpecification<'wtt', 'wtt.notice'>; +export type WorksToTreesApplications = ApplicationSpecification< + 'wtt', + Extract +>; /** * @title App