diff --git a/schema/coreOwnership/v1.json b/schema/coreOwnership/v1.json index 16a9db6f..68c2fd31 100644 --- a/schema/coreOwnership/v1.json +++ b/schema/coreOwnership/v1.json @@ -6,7 +6,7 @@ "properties": { "schemaName": { "type": "string", - "enum": ["coreOwnership"] + "const": "coreOwnership" }, "action": { "type": "string" diff --git a/schema/device/v1.json b/schema/device/v1.json index 8abb9124..fe189111 100644 --- a/schema/device/v1.json +++ b/schema/device/v1.json @@ -6,7 +6,7 @@ "properties": { "schemaName": { "type": "string", - "enum": ["device"] + "const": "device" }, "action": { "type": "string" diff --git a/schema/field/v2.json b/schema/field/v2.json index 5bfa16ad..db36bd8b 100644 --- a/schema/field/v2.json +++ b/schema/field/v2.json @@ -8,7 +8,7 @@ "schemaName": { "description": "Must be `field`", "type": "string", - "enum": ["field"] + "const": "field" }, "tagKey": { "description": "They key in a tags object that this field applies to", diff --git a/schema/observation/v5.json b/schema/observation/v5.json index f8402ff9..912e7f40 100644 --- a/schema/observation/v5.json +++ b/schema/observation/v5.json @@ -51,7 +51,7 @@ "schemaName": { "description": "Must be `observation`", "type": "string", - "enum": ["observation"] + "const": "observation" }, "lat": { "description": "latitude of the observation", diff --git a/schema/preset/v2.json b/schema/preset/v2.json index 99364326..2852c2d3 100644 --- a/schema/preset/v2.json +++ b/schema/preset/v2.json @@ -49,7 +49,7 @@ "schemaName": { "description": "Must be `preset`", "type": "string", - "enum": ["preset"] + "const": "preset" }, "name": { "description": "Name for the feature in default language.", diff --git a/schema/project/v1.json b/schema/project/v1.json index df986e2b..a740a90f 100644 --- a/schema/project/v1.json +++ b/schema/project/v1.json @@ -7,7 +7,7 @@ "schemaName": { "description": "Must be `project`", "type": "string", - "enum": ["project"] + "const": "project" }, "name": { "description": "name of the project", diff --git a/schema/project/v2.json b/schema/project/v2.json index df986e2b..a740a90f 100644 --- a/schema/project/v2.json +++ b/schema/project/v2.json @@ -7,7 +7,7 @@ "schemaName": { "description": "Must be `project`", "type": "string", - "enum": ["project"] + "const": "project" }, "name": { "description": "name of the project", diff --git a/schema/role/v1.json b/schema/role/v1.json index 7e81b43d..698b1422 100644 --- a/schema/role/v1.json +++ b/schema/role/v1.json @@ -6,7 +6,7 @@ "properties": { "schemaName": { "type": "string", - "enum": ["role"] + "const": "role" }, "role": { "type": "string" diff --git a/scripts/lib/read-json-schema.js b/scripts/lib/read-json-schema.js index c6bee8b1..bbbbb6f3 100644 --- a/scripts/lib/read-json-schema.js +++ b/scripts/lib/read-json-schema.js @@ -31,8 +31,10 @@ export function readJSONSchema({ currentSchemaVersions }) { const jsonSchema = readJSON(filepath) const { dir, name } = path.parse(filepath) const folderName = path.basename(dir) - // @ts-ignore - enum not defined on JSONSchema v7 - const schemaName = jsonSchema.properties?.schemaName?.enum[0] + const schemaName = + typeof jsonSchema.properties?.schemaName !== 'boolean' + ? jsonSchema.properties?.schemaName.const + : undefined if (folderName !== schemaName) { throw new Error(`Unexpected schemaName '${schemaName}' in ${filepath}`) }