Skip to content

Commit 39989b6

Browse files
committed
Fix bugs in annotatedWith
1 parent b6d11f6 commit 39989b6

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

annotations/annotated-instance.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export const annotate = (instance, keyword, value) => {
3737
export const annotatedWith = (instance, keyword, dialectId = defaultDialectId) => {
3838
const instances = [];
3939

40-
const keywordId = getKeywordId(dialectId, keyword);
40+
const keywordId = getKeywordId(keyword, dialectId);
4141
for (const instancePointer in instance.annotations) {
4242
if (keywordId in instance.annotations[instancePointer]) {
4343
instances.push(get(`#${instancePointer}`, instance));

lib/keywords.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,14 @@ import { toAbsoluteUri } from "./common.js";
22

33

44
const _keywords = {};
5-
export const getKeyword = (id) => _keywords[toAbsoluteUri(id)];
5+
export const getKeyword = (id) => {
6+
if (id.indexOf("#") !== -1) {
7+
const absoluteId = toAbsoluteUri(id);
8+
return { ..._keywords[absoluteId], id };
9+
}
10+
11+
return _keywords[id];
12+
};
613

714
export const getKeywordByName = (keyword, dialectId) => {
815
const keywordId = getKeywordId(keyword, dialectId);

lib/keywords/requireAllExcept.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const id = "https://json-schema.org/keyword/requireAllExcept";
77

88
const compile = async (schema, _ast, parentSchema) => {
99
const requireAllExcept = await Browser.value(schema);
10-
const propertiesKeyword = getKeywordName(schema.dialectId, "https://json-schema.org/keyword/properties");
10+
const propertiesKeyword = getKeywordName(schema.document.dialectId, "https://json-schema.org/keyword/properties");
1111
const propertiesSchema = await Browser.step(propertiesKeyword, parentSchema);
1212
const propertyNames = Browser.typeOf(propertiesSchema) === "object" ? Browser.keys(propertiesSchema) : [];
1313

0 commit comments

Comments
 (0)