From 90216286766a0a0dc4974bf72368567228edb211 Mon Sep 17 00:00:00 2001
From: Felix Blanke <info@fblanke.de>
Date: Tue, 4 Mar 2025 17:39:29 +0100
Subject: [PATCH] Split schema into general and export schema

---
 AKModel/tests/test_json_export.py       |  2 +-
 schemas/ak-export.schema.json           |  8 ++++++++
 schemas/ak.schema.json                  |  3 +--
 schemas/participant-export.schema.json  | 20 ++++++++++++++++++++
 schemas/participant.schema.json         |  8 ++------
 schemas/room-export.schema.json         |  8 ++++++++
 schemas/room.schema.json                |  3 +--
 schemas/solver-input-export.schema.json | 12 ++++++++++++
 schemas/solver-input.schema.json        |  3 +--
 schemas/timeslot-export.schema.json     | 15 +++++++++++++++
 schemas/timeslot.schema.json            |  6 ++----
 11 files changed, 71 insertions(+), 17 deletions(-)
 create mode 100644 schemas/ak-export.schema.json
 create mode 100644 schemas/participant-export.schema.json
 create mode 100644 schemas/room-export.schema.json
 create mode 100644 schemas/solver-input-export.schema.json
 create mode 100644 schemas/timeslot-export.schema.json

diff --git a/AKModel/tests/test_json_export.py b/AKModel/tests/test_json_export.py
index 5ec11749..71101302 100644
--- a/AKModel/tests/test_json_export.py
+++ b/AKModel/tests/test_json_export.py
@@ -38,7 +38,7 @@ class JSONExportTest(TestCase):
         )
 
         cls.json_export_validator = construct_schema_validator(
-            "solver-input.schema.json"
+            "solver-input-export.schema.json"
         )
 
     def setUp(self):
diff --git a/schemas/ak-export.schema.json b/schemas/ak-export.schema.json
new file mode 100644
index 00000000..2ab8cf77
--- /dev/null
+++ b/schemas/ak-export.schema.json
@@ -0,0 +1,8 @@
+{
+  "$schema": "https://json-schema.org/draft/2020-12/schema",
+  "$id": "schemas/ak-export.schema.json",
+  "allOf": [{ "$ref": "ak.schema.json" }],
+  "properties": {
+    "info": {"unevaluatedProperties": false}
+  }
+}
diff --git a/schemas/ak.schema.json b/schemas/ak.schema.json
index 24395110..a8578a34 100644
--- a/schemas/ak.schema.json
+++ b/schemas/ak.schema.json
@@ -53,8 +53,7 @@
           "description": "Types of this AK"
         }
       },
-      "required": ["name", "head", "description", "reso", "duration_in_hours", "django_ak_id", "types"],
-      "additionalProperties": false
+      "required": ["name", "head", "description", "reso", "duration_in_hours", "django_ak_id", "types"]
     }
   },
   "required": ["id", "duration", "room_constraints", "time_constraints", "properties", "info"],
diff --git a/schemas/participant-export.schema.json b/schemas/participant-export.schema.json
new file mode 100644
index 00000000..935b2188
--- /dev/null
+++ b/schemas/participant-export.schema.json
@@ -0,0 +1,20 @@
+
+{
+  "$schema": "https://json-schema.org/draft/2020-12/schema",
+  "$id": "schemas/participant-export.schema.json",
+  "allOf": [{ "$ref": "participant.schema.json" }],
+  "properties": {
+    "preferences": {
+        "items": {
+          "properties": {
+            "preference_score": {
+              "anyOf": [
+                {"const": -1}, {"const": 1}, {"const": 2}
+              ]
+            }
+          }
+        }
+    },
+    "info": {"unevaluatedProperties": false}
+  }
+}
diff --git a/schemas/participant.schema.json b/schemas/participant.schema.json
index 249944f4..70631eb1 100644
--- a/schemas/participant.schema.json
+++ b/schemas/participant.schema.json
@@ -27,10 +27,7 @@
               "description": "The prefeference score for this AK",
               "default": 0,
               "minimum": -1,
-              "maximum": 2,
-              "anyOf": [
-                {"const": -1}, {"const": 1}, {"const": 2}
-              ]
+              "maximum": 2
             }
           },
           "required": ["ak_id", "required", "preference_score"],
@@ -49,8 +46,7 @@
     "info": {
       "type": "object",
       "properties": {"name": {"description": "Name of the person", "type": "string"}},
-      "required": ["name"],
-      "additionalProperties": false
+      "required": ["name"]
     }
   },
   "required": ["id", "room_constraints", "time_constraints", "info"],
diff --git a/schemas/room-export.schema.json b/schemas/room-export.schema.json
new file mode 100644
index 00000000..bc14670a
--- /dev/null
+++ b/schemas/room-export.schema.json
@@ -0,0 +1,8 @@
+{
+  "$schema": "https://json-schema.org/draft/2020-12/schema",
+  "$id": "schemas/room-export.schema.json",
+  "allOf": [{ "$ref": "room.schema.json" }],
+  "properties": {
+    "info": {"unevaluatedProperties": false}
+  }
+}
diff --git a/schemas/room.schema.json b/schemas/room.schema.json
index f77d8fdb..dbf331f1 100644
--- a/schemas/room.schema.json
+++ b/schemas/room.schema.json
@@ -28,8 +28,7 @@
       "properties": {
         "name": {"description": "Name of the room", "type": "string"}
       },
-      "required": ["name"],
-      "additionalProperties": false
+      "required": ["name"]
     }
   },
   "required": ["id", "capacity", "fulfilled_room_constraints", "time_constraints", "info"],
diff --git a/schemas/solver-input-export.schema.json b/schemas/solver-input-export.schema.json
new file mode 100644
index 00000000..e870d688
--- /dev/null
+++ b/schemas/solver-input-export.schema.json
@@ -0,0 +1,12 @@
+{
+  "$schema": "https://json-schema.org/draft/2020-12/schema",
+  "$id": "schemas/solver-input-export.schema.json",
+  "allOf": [{ "$ref": "solver-input.schema.json"}],
+  "properties": {
+    "participants": {"items": {"$ref": "participant-export.schema.json"}},
+    "rooms": {"items": {"$ref": "room-export.schema.json"}},
+    "timeslots": {"items": {"$ref": "timeslot-export.schema.json"}},
+    "aks": {"items": {"$ref": "ak-export.schema.json"}},
+    "info": {"unevaluatedProperties": false}
+  }
+}
\ No newline at end of file
diff --git a/schemas/solver-input.schema.json b/schemas/solver-input.schema.json
index 95952d70..faece29b 100644
--- a/schemas/solver-input.schema.json
+++ b/schemas/solver-input.schema.json
@@ -14,8 +14,7 @@
           "slug": {"type": "string"},
           "place": {"type": "string"},
           "contact_email": {"type": "string"}
-        },
-        "additionalProperties": false
+        }
       }
   },
   "required": ["aks", "rooms", "participants", "timeslots", "info"],
diff --git a/schemas/timeslot-export.schema.json b/schemas/timeslot-export.schema.json
new file mode 100644
index 00000000..d0bef124
--- /dev/null
+++ b/schemas/timeslot-export.schema.json
@@ -0,0 +1,15 @@
+{
+  "$schema": "https://json-schema.org/draft/2020-12/schema",
+  "$id": "schemas/timeslot-export.schema.json",
+  "allOf": [{ "$ref": "timeslot.schema.json" }],
+  "properties": {
+    "info": {"unevaluatedProperties": false},
+    "blocks": {
+      "items": {
+        "items": {
+          "info": {"unevaluatedProperties": false}
+        }
+      }
+    }
+  }
+}
diff --git a/schemas/timeslot.schema.json b/schemas/timeslot.schema.json
index e6d5b828..2cd23cd0 100644
--- a/schemas/timeslot.schema.json
+++ b/schemas/timeslot.schema.json
@@ -20,8 +20,7 @@
           }
         }
       },
-      "required": ["duration"],
-      "additionalProperties": false
+      "required": ["duration"]
     },
     "blocks": {
       "type": "array",
@@ -43,8 +42,7 @@
                 "start": {"description": "Start datetime of the timeslot", "type": "string"},
                 "end": {"description": "End datetime of the timeslot", "type": "string"}
               },
-              "required": ["start", "end"],
-              "additionalProperties": false
+              "required": ["start", "end"]
             },
             "fulfilled_time_constraints": {
               "$ref": "common/constraints.schema.json",
-- 
GitLab