Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: change schemaName from enum to const #95

Merged
merged 1 commit into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion schema/coreOwnership/v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"properties": {
"schemaName": {
"type": "string",
"enum": ["coreOwnership"]
"const": "coreOwnership"
},
"action": {
"type": "string"
Expand Down
2 changes: 1 addition & 1 deletion schema/device/v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"properties": {
"schemaName": {
"type": "string",
"enum": ["device"]
"const": "device"
},
"action": {
"type": "string"
Expand Down
2 changes: 1 addition & 1 deletion schema/field/v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion schema/observation/v5.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"schemaName": {
"description": "Must be `observation`",
"type": "string",
"enum": ["observation"]
"const": "observation"
},
"lat": {
"description": "latitude of the observation",
Expand Down
2 changes: 1 addition & 1 deletion schema/preset/v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"schemaName": {
"description": "Must be `preset`",
"type": "string",
"enum": ["preset"]
"const": "preset"
},
"name": {
"description": "Name for the feature in default language.",
Expand Down
2 changes: 1 addition & 1 deletion schema/project/v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"schemaName": {
"description": "Must be `project`",
"type": "string",
"enum": ["project"]
"const": "project"
},
"name": {
"description": "name of the project",
Expand Down
2 changes: 1 addition & 1 deletion schema/project/v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"schemaName": {
"description": "Must be `project`",
"type": "string",
"enum": ["project"]
"const": "project"
},
"name": {
"description": "name of the project",
Expand Down
2 changes: 1 addition & 1 deletion schema/role/v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"properties": {
"schemaName": {
"type": "string",
"enum": ["role"]
"const": "role"
},
"role": {
"type": "string"
Expand Down
6 changes: 4 additions & 2 deletions scripts/lib/read-json-schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`)
}
Expand Down