Sfoglia il codice sorgente

Disabling additionalProperties for things that shouldn't have them.
Moving spell element restrictions in spellbook.json into the definitions section.

Samuel Jaffe 8 anni fa
parent
commit
46c3d6fe68
3 ha cambiato i file con 73 aggiunte e 77 eliminazioni
  1. 8 7
      schema/inventory.json
  2. 8 4
      schema/spell.json
  3. 57 66
      schema/spellbook.json

+ 8 - 7
schema/inventory.json

@@ -31,10 +31,7 @@
             }
           },
           {
-            "properties": {
-              "weapon": false,
-              "armor": false
-            }
+            "properties": {"weapon": false, "armor": false}
           }
         ],
         "required": [
@@ -112,7 +109,8 @@
         "criticalThreat",
         "criticalDamage"
       ],
-      "type": "object"
+      "type": "object",
+      "additionalProperties": false
     },
     "armor": {
       "dependencies": {
@@ -135,7 +133,8 @@
         "checkPenalty",
         "spellFailure"
       ],
-      "type": "object"
+      "type": "object",
+      "additionalProperties": false
     },
     "money": {
       "properties": {
@@ -146,5 +145,7 @@
       },
       "type": "object"
     }
-  }
+  },
+  "type": "object",
+  "additionalProperties": false
 }

+ 8 - 4
schema/spell.json

@@ -10,13 +10,15 @@
           "properties":{
             "@type": {"const": "Line"},
             "distance": {"type": "integer"}
-          }
+          },
+          "additionalProperties": false
         },
         {
           "properties":{
             "@type": {"const": "Emission"},
             "emit": {"enum": ["BURST", "EMANATION", "SPREAD", "NONE"]}
-          }
+          },
+          "additionalProperties": false
         },
         {
           "properties":{
@@ -24,14 +26,16 @@
             "radius": {"type": "integer"},
             "emit": {"enum": ["BURST", "EMANATION", "SPREAD", "NONE"]},
             "aroundYou": {"type": "boolean"}
-          }
+          },
+          "additionalProperties": false
         },
         {
           "properties":{
             "@type": {"const": "Cylinder"},
             "radius": {"type": "integer"},
             "height": {"type": "integer"}
-          }
+          },
+          "additionalProperties": false
         }
       ]
     },

+ 57 - 66
schema/spellbook.json

@@ -4,6 +4,44 @@
     "names": {
       "items": {"type": "string"},
       "type": "array"
+    },
+    "Inspired": {
+      "patternProperties": {
+        "^[0-9]$": {
+          "properties": {
+            "spellsPerDayRemaining": false,
+            "spellsKnown": false
+          }
+        }
+      }
+    },
+    "Spontaneous": {
+      "patternProperties": {
+        "^[0-9]$": {
+          "properties": {
+            "spellsPrepared": false,
+            "spellsPreparedPreviously": false
+          }
+        }
+      }
+    },
+    "Researched": {
+      "patternProperties": {
+        "^[0-9]$": {
+          "properties": {
+            "spellsPerDayRemaining": false
+          }
+        }
+      }
+    },
+    "Retrieved": {
+      "patternProperties": {
+        "^[0-9]$": {
+          "properties": {
+            "spellsKnown": false
+          }
+        }
+      }
     }
   },
   "properties": {
@@ -20,17 +58,15 @@
         "8":["7"],
         "9":["8"]
       },
-      "patternProperties": {
-        "^[0-9]$": {
-          "properties": {
-            "spellsPerDay": {"type": "integer"},
-            "spellsPerDayRemaining": {"type": "integer"},
-            "spellsKnown": {"$ref": "#/definitions/names"},
-            "spellsPrepared": {"$ref": "#/definitions/names"},
-            "spellsPreparedPreviously": {"$ref": "#/definitions/names"}
-          },
-          "type": "object"
-        }
+      "propertyNames": {
+        "enum": ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
+      },
+      "additionalProperties": {
+        "spellsPerDay": {"type": "integer"},
+        "spellsPerDayRemaining": {"type": "integer"},
+        "spellsKnown": {"$ref": "#/definitions/names"},
+        "spellsPrepared": {"$ref": "#/definitions/names"},
+        "spellsPreparedPreviously": {"$ref": "#/definitions/names"}
       },
       "type": "object"
     }
@@ -38,73 +74,27 @@
   "oneOf": [
     {
       "properties": {
-        "@class": {
-          "const": "org.leumasjaffe.charsheet.model.magic.impl.Inspired"
-        },
-        "spellInfo": {
-          "^[0-9]$": {
-            "required": [
-              "spellsPerDay",
-              "spellsPrepared",
-              "spellsPreparedPreviously"
-            ],
-            "additionalProperties":false
-          }
-        }
+        "@class": {"const": "org.leumasjaffe.charsheet.model.magic.impl.Inspired"},
+        "spellInfo": {"$ref": "#/definitions/Inspired"}
       },
       "required": ["classRef"]
     },
     {
       "properties": {
-        "@class": {
-          "const": "org.leumasjaffe.charsheet.model.magic.impl.Spontaneous"
-        },
-        "spellInfo": {
-          "^[0-9]$": {
-            "required": [
-              "spellsPerDay",
-              "spellsPerDayRemaining",
-              "spellsKnown"
-            ],
-            "additionalProperties":false
-          }
-        }
+        "@class": {"const": "org.leumasjaffe.charsheet.model.magic.impl.Spontaneous"},
+        "spellInfo": {"$ref": "#/definitions/Spontaneous"}
       }
     },
     {
       "properties": {
-        "@class": {
-          "const": "org.leumasjaffe.charsheet.model.magic.impl.Researched"
-        },
-        "spellInfo": {
-          "^[0-9]$": {
-            "required": [
-              "spellsPerDay",
-              "spellsKnown",
-              "spellsPrepared",
-              "spellsPreparedPreviously"
-            ],
-            "additionalProperties":false
-          }
-        }
+        "@class": {"const": "org.leumasjaffe.charsheet.model.magic.impl.Researched"},
+        "spellInfo": {"$ref": "#/definitions/Researched"}
       }
     },
     {
       "properties": {
-        "@class": {
-          "const": "org.leumasjaffe.charsheet.model.magic.impl.Retrieved"
-        },
-        "spellInfo": {
-          "^[0-9]$": {
-            "required": [
-              "spellsPerDay",
-              "spellsPerDayRemaining",
-              "spellsPrepared",
-              "spellsPreparedPreviously"
-            ],
-            "additionalProperties":false
-          }
-        }
+        "@class": {"const": "org.leumasjaffe.charsheet.model.magic.impl.Retrieved"},
+        "spellInfo": {"$ref": "#/definitions/Retrieved"}
       },
       "required": ["classRef"]
     }
@@ -113,5 +103,6 @@
     "@class",
     "spellInfo"
   ],
-  "type": "object"
+  "type": "object",
+  "additionalProperties": false
 }