Implement validation#139
Merged
Merged
Conversation
Reading http and https can be accomplished via the stdlib; enable it in the STAC_IO.default_read_text_method and remove the override from the unittests.
Also import it into the top level package, so users can use as `pystac.STACObjectType`.
This makes it easier to pass information along to methods that need to work on serialized versions of the object. This was implemented in preperation of the `validate` method on STACObject
simonkassel
suggested changes
Aug 13, 2020
Contributor
simonkassel
left a comment
There was a problem hiding this comment.
We discussed this in person. I think just one change to validate moethods and some minor bug fixes, otherwise looks good.
Also remove the test version of SchemaValidator and move to the core PySTAC implementation in all unit tests.
This makes installing jsonschema along with PySTAC optional, keeping PySTAC lightweight for users that don't need validation.
Also fix up some API docs for pystac.serialization
984ade9 to
2167a47
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR implements validation in PySTAC.
Catalog,CollectionandItemhave avalidate()method that will validate their serialized versions against STAC schema json hosted at https://schemas.stacspec.org/. There's also apystac.validation.validate_jsonmethod that can validate STAC from earlier versions, back to 0.6.0.The design of this feature allows for users to write their own implementations of
STACValidatorand register it with PySTAC via thepystac.validation.set_validatormethod. Users can also override theDefaultSchemaUriMapto provide custom mappings between STAC object types and extensions to schema URIs.This feature requires
jsonschemato be installed if using the default validator. This can be accomplished by specifying the 'validation' extras on install:Also included in this PR is moving the
urllibcapability for readinghttpandhttpsURIs from the unit tests to the default implementations inSTAC_IO, and so allowinghttpandhttpsSTAC to be read by default without a custom read implementation.Fixes #118