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

Validate extensions from schema URLs #664

Merged
merged 11 commits into from
Apr 14, 2021

Conversation

jisantuc
Copy link
Contributor

@jisantuc jisantuc commented Apr 8, 2021

Overview

This PR introduces mechanisms to read extension validators from JSON schemata. This flow involves handling a few distinct kinds of error:

  1. We might get a network error when reading the schema
  2. There might not be valid json at the URL
  3. The valid json might not be a valid JSON schema
  4. Even if it's valid, we might not be able to resolve links in the JSON schema (circe-json-schema is only into local files because the Everit loader is only into local files)
  5. The "uri" might not actually be a URI that sttp likes to make requests with despite sttp saying it's fine after parsing it

after all of this, we should eventually get a function using that Schema from Item => Item or Collection => Collection that we can use for validation on read.

This costly process is wrapped in a Ref (we're not on 3.x yet but the basics are the same) so that we don't have to try the same sequence of resolutions every time we see the special string.

Checklist

  • New tests have been added or existing tests have been modified

Notes

I've asked in STAC gitter about what others are doing about the json schema links. This might end up being a roll-our-own situation if we don't have good library support for resolving with links. I think we can do that on top of circe-json-schema without too much hassle though.

Testing Instructions

  • CI should be sufficient I think thanks to the validation spec

Copy link
Contributor

@pomadchin pomadchin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM and works locally! I left a couple of question in comments though.

@jisantuc jisantuc force-pushed the feature/js/validate-extensions-from-schemas branch from e5c95e8 to 1bc9ced Compare April 14, 2021 15:53
@jisantuc jisantuc merged commit ed56c68 into master Apr 14, 2021
@jisantuc jisantuc deleted the feature/js/validate-extensions-from-schemas branch April 14, 2021 16:37
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.

2 participants