Closed gavinbarron closed 2 years ago
I'm not able to reproduce the problem. It works for me.
The error you are seeing doesn't appear to be related to your example schemas. It's telling you that you are using a JSON Pointer that starts with /definitions/Scope
, but the /definitions
location is undefined. That pointer doesn't appear anywhere in your schemas, so you must be running against some other schemas.
Your debugging points to be the problem that was fixed in v0.1.2. If you are actually running against v0.1.1, the error I would expect you to see is this.
const keywordId = ast[schemaUri][0];
^
TypeError: Cannot read properties of undefined (reading '0')
Can you check node_modules/@hyperjump/json-schema-bundle/package.json#/version
to be absolutely sure which version you are working with?
Dang it! despite me removing and re-adding yarn had me at v0.1.1 :(
The /definitions
path is created by the bunder as it imports the $refs
based on what I was seeing. Either way getting the upgraded package resolves the problem
Apologies for the churn here.
Opening this as a new issue related to #5
In my previous report I had mistakenly put the additionalProperties as a child of properties, not a sibling as it should be: ref
Using this loader code in webpack
With these schema
Results in this error:
Inspecting the site of the error,
const keywordId = ast[schemaUri][0];
, I see that schemaUri is an array when the error occurs:While the ast is an object with string keys:
At the next step up the call stack in keywords.js I can see that the nodes collection being iterated over contains an entry with the array that seems to be causing this issue:
The naïve fix is to add a typeof check on to the recursion in addition to collectExternalIds
But I have no idea what the side effects of this would be or if that's even properly addressing this issue