Skip to content

Commit 276d869

Browse files
FloEdelmannfxedel
authored andcommitted
Use "format" in JSON schemas (#904)
* Fix large fixtures being tested twice in HTTP status test * Use full format validation mode * Use formats uri, date and regex in schema * Use const instead of enum where possible * Update schema version to 11.3.1
1 parent b004144 commit 276d869

File tree

12 files changed

+79
-94
lines changed

12 files changed

+79
-94
lines changed

lib/schema-properties.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const physicalProperties = fixtureProperties.physical.properties;
1010

1111
const capabilityTypes = {};
1212
capabilitySchema.allOf.forEach(ifThenClause => {
13-
const type = ifThenClause[`if`].properties.type.enum[0];
13+
const type = ifThenClause[`if`].properties.type.const;
1414
capabilityTypes[type] = ifThenClause.then;
1515
});
1616

plugins/millumin/exportTests/json-schema-conformity.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,13 @@ const schemaPromises = getSchemas();
1818
**/
1919
module.exports = async function testSchemaConformity(exportFile) {
2020
const schemas = await schemaPromises;
21-
const ajv = new Ajv({ schemas });
21+
const ajv = new Ajv({
22+
schemas,
23+
format: `full`,
24+
formats: {
25+
'color-hex': ``
26+
}
27+
});
2228
const schemaValidate = ajv.getSchema(`https://raw.githubusercontent.com/OpenLightingProject/open-fixture-library/master/schemas/fixture.json`);
2329

2430
const schemaValid = schemaValidate(JSON.parse(exportFile.content));
@@ -46,7 +52,8 @@ async function getSchemas() {
4652
fixtureSchema.properties.oflURL = true;
4753

4854
// allow changed schema property
49-
fixtureSchema.patternProperties[`^\\$schema$`].enum[0] = `${SCHEMA_BASE_URL}fixture.json`;
55+
fixtureSchema.patternProperties[`^\\$schema$`].const = `${SCHEMA_BASE_URL}fixture.json`;
56+
fixtureSchema.patternProperties[`^\\$schema$`].enum = undefined;
5057

5158
// allow new colors from schema version 11.1.0
5259
// see https://github.com/OpenLightingProject/open-fixture-library/pull/763

plugins/plugins.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
},
4141
"ofl": {
4242
"name": "Open Fixture Library JSON",
43-
"exportPluginVersion": "11.3.0",
43+
"exportPluginVersion": "11.3.1",
4444
"exportTests": []
4545
},
4646
"op-z": {

0 commit comments

Comments
 (0)