-
Notifications
You must be signed in to change notification settings - Fork 29
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
Support internal non-pointer references #26
Comments
Hi @madbence , Two quick things:
This tool should support any fully-internal references. 😄 Let me know if that still does not work. |
@robertmassaioli I took the example from the spec, so I think it's valid (sure, the The
A more complex example that I was trying to examine: https://raw.githubusercontent.com/usnistgov/OSCAL/main/json/schema/oscal_assessment-results_schema.json The following change kinda resolved the issue (yes, it's an ugly hack, and doesn't care about the base URI, or nested definitions): --- a/src/lookup/index.ts
+++ b/src/lookup/index.ts
@@ -62,7 +62,10 @@ export class InternalLookup implements Lookup {
return undefined;
}
- const result = pointerGet(this.schema, ref.slice(1));
+ if (ref === '#') return this.getSchema(this.schema);
+
+ const result = ref.includes('/') ? pointerGet(this.schema, ref.slice(1)) : Object.values((this.schema as any).definitions).find(a => a['$id'] == ref) as any;
if (result === undefined) {
return undefined; |
Okay, I've had a sit down and read through the schema. Essentially, the That's fairly annoying but not impossible to replicate, we would just need to generate a map when we first load the schema for usage in follow-up references. |
According to 8.3.2,
$ref
might not be a JSON pointer, eg:Currently, the schema viewer errors with
Invalid JSON pointer.
(it's trying to resolve#item
as a JSON pointer, while in fact it's just an internal reference, pointing tohttp://example.net/root.json#item
)The text was updated successfully, but these errors were encountered: