APIDevTools / json-schema-ref-parser

Parse, Resolve, and Dereference JSON Schema $ref pointers in Node and browsers
https://apitools.dev/json-schema-ref-parser
MIT License
942 stars 226 forks source link

feat(errors): pointer additional info #332

Closed BerkeKaragoz closed 8 months ago

BerkeKaragoz commented 8 months ago

What

Adds some extra string to MissingPointerError and InvalidPointerError. But only gets used on one place. Which is when the token is not found.

- Expected
+ Received

  Token "foo" does not exist.
+
+ In the following schema: null
+

or

- Expected
+ Received

  Token "components" does not exist.
+
+ In the following schema: {
+ type: "string",
  ...

Why

I ended up with an issue where my refs could not get resolved and throwed out an error. However I got mislead and spent some time approaching the problem from the wrong direction.

The problem was completely my fault. However if I saw on which context it tried to resolve refs, I would've found the issue instantly.