Skip to content
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

Fix keyword refs #160

Merged
merged 1 commit into from
Nov 28, 2023
Merged

Fix keyword refs #160

merged 1 commit into from
Nov 28, 2023

Conversation

davishmcclurg
Copy link
Owner

@davishmcclurg davishmcclurg commented Nov 23, 2023

This fixes two problems with JSON pointer refs and known keywords:

  • If the ref resolved to a Keyword object with a schema value (eg,
    #/items), unknown_schema! was called, which was only defined for
    UnknownKeyword. I changed the name to parsed_schema and defined it
    for all keywords, though it still feels brittle since it requires
    keywords to pre-parse their values into schema objects.

  • If the ref resolved through a Keyword object with a schema value
    (eg, #/items/not), fetch was called on the keyword's parsed
    schema, which wasn't defined. I settled on a fetch method for
    Keyword and Schema to find child objects by key/index. That way a
    keyword with a schema value will delegate fetch to its parsed schema
    object. UnknownKeyword also becomes less of a special case.

I also added a Schema type check after pointer resolution to help
people identify misdirected pointers.

Closes: #159

This fixes two problems with JSON pointer refs and known keywords:

- If the ref resolved to a `Keyword` object with a schema value (eg,
  `#/items`), `unknown_schema!` was called, which was only defined for
  `UnknownKeyword`. I changed the name to `parsed_schema` and defined it
  for all keywords, though it still feels brittle since it requires
  keywords to pre-parse their values into schema objects.

- If the ref resolved through a `Keyword` object with a schema value
  (eg, `#/items/not`), `fetch` was called on the keyword's parsed
  schema, which wasn't defined. I settled on a `fetch` method for
  `Keyword` and `Schema` to find child objects by key/index. That way a
  keyword with a schema value will delegate `fetch` to its parsed schema
  object. `UnknownKeyword` also becomes less of a special case.

I also added a `Schema` type check after pointer resolution to help
people identify misdirected pointers.

Closes: #159
@davishmcclurg davishmcclurg merged commit 1b05686 into main Nov 28, 2023
62 checks passed
@davishmcclurg davishmcclurg deleted the keyword-ref branch November 28, 2023 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Complex json schema appears to leave boxed Schema during token traversal
1 participant