Commit a4f90541 authored by David Sveningsson's avatar David Sveningsson
Browse files

fix(schema): handle `$schema` in config and elements

in case the user manually have to specify url/path to schema
parent d483401f
......@@ -32,6 +32,7 @@ jest.mock(
import { Config } from "../config";
import { UserError } from "../error/user-error";
import { Parser } from "../parser";
import { MetaDataTable } from "./element";
import { MetaData, MetaTable } from ".";
class ConfigMock extends Config {
......@@ -75,6 +76,19 @@ describe("MetaTable", () => {
);
});
it("should ignore $schema property", () => {
expect.assertions(2);
const table = new MetaTable();
table.loadFromObject(({
$schema: "https://example.net/schema.json",
foo: {
flow: true,
},
} as unknown) as MetaDataTable);
expect(table.getMetaFor("foo")).toBeDefined();
expect(table.getMetaFor("$schema")).toBeNull();
});
describe("getMetaFor", () => {
let table: MetaTable;
......
......@@ -92,6 +92,7 @@ export class MetaTable {
}
for (const key of Object.keys(obj)) {
if (key === "$schema") continue;
this.addEntry(key, obj[key]);
}
}
......
......@@ -6,6 +6,10 @@
"type": "object",
"additionalProperties": false,
"properties": {
"$schema": {
"type": "string"
},
"root": {
"type": "boolean",
"title": "Mark as root configuration",
......
......@@ -4,6 +4,13 @@
"version": "1.0",
"type": "object",
"properties": {
"$schema": {
"type": "string"
}
},
"patternProperties": {
"^.*$": {
"type": "object",
......@@ -44,7 +51,7 @@
"requiredAncestors": { "$ref": "#/definitions/RequiredAncestors" },
"requiredContent": { "$ref": "#/definitions/RequiredContent" }
},
"additionalProperties": false
"additionalProperties": true
}
},
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment