From 3f98df2d75ce65db8ebdc2cdbf9c90fa2d2500ef Mon Sep 17 00:00:00 2001 From: Mike Hansen Date: Mon, 17 Jul 2023 19:45:04 -0400 Subject: [PATCH] Fix definitions, to match other schema yml definitions Signed-off-by: Mike Hansen --- schema/definitions.yml | 2 +- schemareader.uc | 156 ++++++++++++++++++++--------------------- ucentral.schema.json | 92 ++++++++++++------------ 3 files changed, 125 insertions(+), 125 deletions(-) diff --git a/schema/definitions.yml b/schema/definitions.yml index 01efdde..daed0cd 100644 --- a/schema/definitions.yml +++ b/schema/definitions.yml @@ -11,5 +11,5 @@ properties: by the corresponding property name. patternProperties: ".+": - $ref: "#/$defs/interface.ssid.encryption" + $ref: "https://ucentral.io/schema/v1/interface/ssid/encryption/" additionalProperties: false diff --git a/schemareader.uc b/schemareader.uc index cb5a875..0469512 100644 --- a/schemareader.uc +++ b/schemareader.uc @@ -369,6 +369,84 @@ function instantiateGlobals(location, value, errors) { return value; } +function instantiateInterfaceSsidEncryption(location, value, errors) { + if (type(value) == "object") { + let obj = {}; + + function parseProto(location, value, errors) { + if (type(value) != "string") + push(errors, [ location, "must be of type string" ]); + + if (!(value in [ "none", "owe", "owe-transition", "psk", "psk2", "psk-mixed", "psk2-radius", "wpa", "wpa2", "wpa-mixed", "sae", "sae-mixed", "wpa3", "wpa3-192", "wpa3-mixed" ])) + push(errors, [ location, "must be one of \"none\", \"owe\", \"owe-transition\", \"psk\", \"psk2\", \"psk-mixed\", \"psk2-radius\", \"wpa\", \"wpa2\", \"wpa-mixed\", \"sae\", \"sae-mixed\", \"wpa3\", \"wpa3-192\" or \"wpa3-mixed\"" ]); + + return value; + } + + if (exists(value, "proto")) { + obj.proto = parseProto(location + "/proto", value["proto"], errors); + } + + function parseKey(location, value, errors) { + if (type(value) == "string") { + if (length(value) > 63) + push(errors, [ location, "must be at most 63 characters long" ]); + + if (length(value) < 8) + push(errors, [ location, "must be at least 8 characters long" ]); + + } + + if (type(value) != "string") + push(errors, [ location, "must be of type string" ]); + + return value; + } + + if (exists(value, "key")) { + obj.key = parseKey(location + "/key", value["key"], errors); + } + + function parseIeee80211w(location, value, errors) { + if (type(value) != "string") + push(errors, [ location, "must be of type string" ]); + + if (!(value in [ "disabled", "optional", "required" ])) + push(errors, [ location, "must be one of \"disabled\", \"optional\" or \"required\"" ]); + + return value; + } + + if (exists(value, "ieee80211w")) { + obj.ieee80211w = parseIeee80211w(location + "/ieee80211w", value["ieee80211w"], errors); + } + else { + obj.ieee80211w = "disabled"; + } + + function parseKeyCaching(location, value, errors) { + if (type(value) != "bool") + push(errors, [ location, "must be of type boolean" ]); + + return value; + } + + if (exists(value, "key-caching")) { + obj.key_caching = parseKeyCaching(location + "/key-caching", value["key-caching"], errors); + } + else { + obj.key_caching = true; + } + + return obj; + } + + if (type(value) != "object") + push(errors, [ location, "must be of type object" ]); + + return value; +} + function instantiateDefinitions(location, value, errors) { if (type(value) == "object") { let obj = {}; @@ -2335,84 +2413,6 @@ function instantiateInterfaceBroadBand(location, value, errors) { return value; } -function instantiateInterfaceSsidEncryption(location, value, errors) { - if (type(value) == "object") { - let obj = {}; - - function parseProto(location, value, errors) { - if (type(value) != "string") - push(errors, [ location, "must be of type string" ]); - - if (!(value in [ "none", "owe", "owe-transition", "psk", "psk2", "psk-mixed", "psk2-radius", "wpa", "wpa2", "wpa-mixed", "sae", "sae-mixed", "wpa3", "wpa3-192", "wpa3-mixed" ])) - push(errors, [ location, "must be one of \"none\", \"owe\", \"owe-transition\", \"psk\", \"psk2\", \"psk-mixed\", \"psk2-radius\", \"wpa\", \"wpa2\", \"wpa-mixed\", \"sae\", \"sae-mixed\", \"wpa3\", \"wpa3-192\" or \"wpa3-mixed\"" ]); - - return value; - } - - if (exists(value, "proto")) { - obj.proto = parseProto(location + "/proto", value["proto"], errors); - } - - function parseKey(location, value, errors) { - if (type(value) == "string") { - if (length(value) > 63) - push(errors, [ location, "must be at most 63 characters long" ]); - - if (length(value) < 8) - push(errors, [ location, "must be at least 8 characters long" ]); - - } - - if (type(value) != "string") - push(errors, [ location, "must be of type string" ]); - - return value; - } - - if (exists(value, "key")) { - obj.key = parseKey(location + "/key", value["key"], errors); - } - - function parseIeee80211w(location, value, errors) { - if (type(value) != "string") - push(errors, [ location, "must be of type string" ]); - - if (!(value in [ "disabled", "optional", "required" ])) - push(errors, [ location, "must be one of \"disabled\", \"optional\" or \"required\"" ]); - - return value; - } - - if (exists(value, "ieee80211w")) { - obj.ieee80211w = parseIeee80211w(location + "/ieee80211w", value["ieee80211w"], errors); - } - else { - obj.ieee80211w = "disabled"; - } - - function parseKeyCaching(location, value, errors) { - if (type(value) != "bool") - push(errors, [ location, "must be of type boolean" ]); - - return value; - } - - if (exists(value, "key-caching")) { - obj.key_caching = parseKeyCaching(location + "/key-caching", value["key-caching"], errors); - } - else { - obj.key_caching = true; - } - - return obj; - } - - if (type(value) != "object") - push(errors, [ location, "must be of type object" ]); - - return value; -} - function instantiateInterfaceSsidMultiPsk(location, value, errors) { if (type(value) == "object") { let obj = {}; diff --git a/ucentral.schema.json b/ucentral.schema.json index 89a6e40..61ef5e7 100644 --- a/ucentral.schema.json +++ b/ucentral.schema.json @@ -191,6 +191,52 @@ } } }, + "interface.ssid.encryption": { + "type": "object", + "properties": { + "proto": { + "type": "string", + "enum": [ + "none", + "owe", + "owe-transition", + "psk", + "psk2", + "psk-mixed", + "psk2-radius", + "wpa", + "wpa2", + "wpa-mixed", + "sae", + "sae-mixed", + "wpa3", + "wpa3-192", + "wpa3-mixed" + ], + "examples": [ + "psk2" + ] + }, + "key": { + "type": "string", + "maxLength": 63, + "minLength": 8 + }, + "ieee80211w": { + "type": "string", + "enum": [ + "disabled", + "optional", + "required" + ], + "default": "disabled" + }, + "key-caching": { + "type": "boolean", + "default": true + } + } + }, "definitions": { "type": "object", "properties": { @@ -975,52 +1021,6 @@ } ] }, - "interface.ssid.encryption": { - "type": "object", - "properties": { - "proto": { - "type": "string", - "enum": [ - "none", - "owe", - "owe-transition", - "psk", - "psk2", - "psk-mixed", - "psk2-radius", - "wpa", - "wpa2", - "wpa-mixed", - "sae", - "sae-mixed", - "wpa3", - "wpa3-192", - "wpa3-mixed" - ], - "examples": [ - "psk2" - ] - }, - "key": { - "type": "string", - "maxLength": 63, - "minLength": 8 - }, - "ieee80211w": { - "type": "string", - "enum": [ - "disabled", - "optional", - "required" - ], - "default": "disabled" - }, - "key-caching": { - "type": "boolean", - "default": true - } - } - }, "interface.ssid.multi-psk": { "type": "object", "properties": {