Skip to content

Commit

Permalink
Use "format" in JSON schemas (#904)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
FloEdelmann authored and fxedel committed May 17, 2019
1 parent b004144 commit 276d869
Show file tree
Hide file tree
Showing 12 changed files with 79 additions and 94 deletions.
2 changes: 1 addition & 1 deletion lib/schema-properties.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const physicalProperties = fixtureProperties.physical.properties;

const capabilityTypes = {};
capabilitySchema.allOf.forEach(ifThenClause => {
const type = ifThenClause[`if`].properties.type.enum[0];
const type = ifThenClause[`if`].properties.type.const;
capabilityTypes[type] = ifThenClause.then;
});

Expand Down
11 changes: 9 additions & 2 deletions plugins/millumin/exportTests/json-schema-conformity.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ const schemaPromises = getSchemas();
**/
module.exports = async function testSchemaConformity(exportFile) {
const schemas = await schemaPromises;
const ajv = new Ajv({ schemas });
const ajv = new Ajv({
schemas,
format: `full`,
formats: {
'color-hex': ``
}
});
const schemaValidate = ajv.getSchema(`https://raw.githubusercontent.com/OpenLightingProject/open-fixture-library/master/schemas/fixture.json`);

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

// allow changed schema property
fixtureSchema.patternProperties[`^\\$schema$`].enum[0] = `${SCHEMA_BASE_URL}fixture.json`;
fixtureSchema.patternProperties[`^\\$schema$`].const = `${SCHEMA_BASE_URL}fixture.json`;
fixtureSchema.patternProperties[`^\\$schema$`].enum = undefined;

// allow new colors from schema version 11.1.0
// see https://github.com/OpenLightingProject/open-fixture-library/pull/763
Expand Down
2 changes: 1 addition & 1 deletion plugins/plugins.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
},
"ofl": {
"name": "Open Fixture Library JSON",
"exportPluginVersion": "11.3.0",
"exportPluginVersion": "11.3.1",
"exportTests": []
},
"op-z": {
Expand Down
Loading

0 comments on commit 276d869

Please sign in to comment.