From 4a449918401bba7919ac128824ba4269329b938a Mon Sep 17 00:00:00 2001 From: Felix Blanke <info@fblanke.de> Date: Tue, 4 Mar 2025 01:41:23 +0100 Subject: [PATCH] Reuse common subschema --- static_common/common/schemas/ak.schema.json | 29 +++++++------------ .../schemas/common/constraints.schema.json | 7 +++++ .../common/schemas/common/id.schema.json | 6 ++++ .../schemas/common/id_array.schema.json | 7 +++++ .../common/schemas/participant.schema.json | 22 +++++--------- static_common/common/schemas/room.schema.json | 22 +++++--------- .../common/schemas/timeslot.schema.json | 11 +++---- 7 files changed, 49 insertions(+), 55 deletions(-) create mode 100644 static_common/common/schemas/common/constraints.schema.json create mode 100644 static_common/common/schemas/common/id.schema.json create mode 100644 static_common/common/schemas/common/id_array.schema.json diff --git a/static_common/common/schemas/ak.schema.json b/static_common/common/schemas/ak.schema.json index c2356010..f8b6711c 100644 --- a/static_common/common/schemas/ak.schema.json +++ b/static_common/common/schemas/ak.schema.json @@ -5,9 +5,8 @@ "type": "object", "properties": { "id": { - "description": "The unique identifier of a room", - "type": "integer", - "minimum": 0 + "$ref": "/schema/common/id.schema.json", + "description": "The unique identifier of an AK" }, "duration": { "description": "The number of consecutive slot units", @@ -15,31 +14,23 @@ "exclusiveMinimum": 0 }, "room_constraints": { - "description": "Room constraints required by this AK", - "type": "array", - "items": {"type": "string"}, - "uniqueItems": true + "$ref": "/schema/common/constraints.schema.json", + "description": "Room constraints required by this AK" }, "time_constraints": { - "description": "Time constraints required by this AK", - "type": "array", - "items": {"type": "string"}, - "uniqueItems": true + "$ref": "/schema/common/constraints.schema.json", + "description": "Time constraints required by this AK" }, "properties": { "type": "object", "properties": { "conflicts": { - "description": "IDs of all AKs that are in conflict with this AK", - "type": "array", - "items": {"type": "integer"}, - "uniqueItems": true + "$ref": "/schema/common/id_array.schema.json", + "description": "IDs of all AKs that are in conflict with this AK" }, "dependencies": { - "description": "IDs of all AKs that should be scheduled before this AK", - "type": "array", - "items": {"type": "integer"}, - "uniqueItems": true + "$ref": "/schema/common/id_array.schema.json", + "description": "IDs of all AKs that should be scheduled before this AK" } }, "required": ["conflicts", "dependencies"] diff --git a/static_common/common/schemas/common/constraints.schema.json b/static_common/common/schemas/common/constraints.schema.json new file mode 100644 index 00000000..7d3fce56 --- /dev/null +++ b/static_common/common/schemas/common/constraints.schema.json @@ -0,0 +1,7 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "/schema/common/constraints.schema.json", + "type": "array", + "items": {"type": "string"}, + "uniqueItems": true +} \ No newline at end of file diff --git a/static_common/common/schemas/common/id.schema.json b/static_common/common/schemas/common/id.schema.json new file mode 100644 index 00000000..4dd06e34 --- /dev/null +++ b/static_common/common/schemas/common/id.schema.json @@ -0,0 +1,6 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "/schema/common/id.schema.json", + "type": "integer", + "minimum": 0 +} \ No newline at end of file diff --git a/static_common/common/schemas/common/id_array.schema.json b/static_common/common/schemas/common/id_array.schema.json new file mode 100644 index 00000000..622e692a --- /dev/null +++ b/static_common/common/schemas/common/id_array.schema.json @@ -0,0 +1,7 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "/schema/common/id_array.schema.json", + "type": "array", + "items": {"type": "integer"}, + "uniqueItems": true +} \ No newline at end of file diff --git a/static_common/common/schemas/participant.schema.json b/static_common/common/schemas/participant.schema.json index 09775329..1a7d6656 100644 --- a/static_common/common/schemas/participant.schema.json +++ b/static_common/common/schemas/participant.schema.json @@ -5,9 +5,8 @@ "type": "object", "properties": { "id": { - "description": "The unique identifier of a participant", - "type": "integer", - "minimum": 0 + "$ref": "/schema/common/id.schema.json", + "description": "The unique identifier of a participant" }, "preferences": { "description": "AK preferences of the participant", @@ -16,9 +15,8 @@ "type": "object", "properties": { "ak_id": { - "type": "integer", - "description": "The unique identifier of the AK", - "minimum": 0 + "$ref": "/schema/common/id.schema.json", + "description": "The unique identifier of the AK" }, "required": { "type": "boolean", @@ -40,16 +38,12 @@ "uniqueItems": true }, "room_constraints": { - "description": "Room constraints required by this participant", - "type": "array", - "items": {"type": "string"}, - "uniqueItems": true + "$ref": "/schema/common/constraints.schema.json", + "description": "Room constraints required by this participant" }, "time_constraints": { - "description": "Time constraints required by this participant", - "type": "array", - "items": {"type": "string"}, - "uniqueItems": true + "$ref": "/schema/common/constraints.schema.json", + "description": "Time constraints required by this participant" }, "info": { "type": "object", diff --git a/static_common/common/schemas/room.schema.json b/static_common/common/schemas/room.schema.json index da192a0e..80b149e0 100644 --- a/static_common/common/schemas/room.schema.json +++ b/static_common/common/schemas/room.schema.json @@ -5,9 +5,8 @@ "type": "object", "properties": { "id": { - "description": "The unique identifier of a room", - "type": "integer", - "minimum": 0 + "$ref": "/schema/common/id.schema.json", + "description": "The unique identifier of a room" }, "capacity": { "description": "The maximum number of total participants. Unbounded capacity is represented by -1", @@ -15,24 +14,17 @@ "minimum": -1 }, "fulfilled_room_constraints": { - "description": "Constraints fulfilled by this room", - "type": "array", - "items": {"type": "string"}, - "uniqueItems": true + "$ref": "/schema/common/constraints.schema.json", + "description": "Constraints fulfilled by this room" }, "time_constraints": { - "description": "Time constraints required by this room", - "type": "array", - "items": {"type": "string"}, - "uniqueItems": true + "$ref": "/schema/common/constraints.schema.json", + "description": "Time constraints required by this room" }, "info": { "type": "object", "properties": { - "name": { - "description": "Name of the room", - "type": "string" - } + "name": {"description": "Name of the room", "type": "string"} }, "required": ["name"] } diff --git a/static_common/common/schemas/timeslot.schema.json b/static_common/common/schemas/timeslot.schema.json index 6f8333e9..a77d8d08 100644 --- a/static_common/common/schemas/timeslot.schema.json +++ b/static_common/common/schemas/timeslot.schema.json @@ -32,9 +32,8 @@ "description": "A single timeslot", "properties": { "id": { - "description": "The unique identifier of the single timeslot. Accross all blocks, the ids must be sorted chronologically.", - "type": "integer", - "minimum": 0 + "$ref": "/schema/common/id.schema.json", + "description": "The unique identifier of the single timeslot. Accross all blocks, the ids must be sorted chronologically." }, "info": { "type": "object", @@ -45,10 +44,8 @@ "required": ["start", "end"] }, "fulfilled_time_constraints": { - "description": "Time constraints fulfilled by this timeslot", - "type": "array", - "items": {"type": "string"}, - "uniqueItems": true + "$ref": "/schema/common/constraints.schema.json", + "description": "Time constraints fulfilled by this timeslot" } }, "required": ["id", "info", "fulfilled_time_constraints"] -- GitLab