hjsonschema-0.5.2.2: JSON Schema Draft 4 library

Safe HaskellNone
LanguageHaskell2010

Data.JsonSchema

Contents

Synopsis

Primary API

Types

newtype Spec Source

type Graph = HashMap Text (HashMap Text Value) Source

Set of potentially mutually recursive schemas.

type EmbeddedSchemas = Text -> Value -> Vector RawSchema Source

Return a schema's immediate subschemas.

This is used by fetchRefs to find all the subschemas in a document. This allows it to process only "$ref"s and "id"s that are actual schema keywords.

data RawSchema Source

Constructors

RawSchema 

Draft 4 Specific

isValidSchema :: RawSchema -> Vector ValErr Source

Check if a RawSchema is valid Draft 4 schema.

This is just a convenience function built by preloading validate with the spec schema that describes valid Draft 4 schemas.

NOTE: It's not actually required to run isValidSchema on prospective draft 4 schemas at all. However, it's a good way to catch unintentional mistakes in schema documents.

compileDraft4 :: Graph -> RawSchema -> Either (Vector ValErr) Schema Source

Check that a RawSchema conforms to the JSON Schema Draft 4 master schema document. Compile it if it does.

This is just a convenience function built by combining isValidSchema and compile.

Graph Builder

TODO: It would be nice to have a few other functions for building out Graphs depending on the situation. For instance, there could be a function that only fetched "$ref"s which use the "file://" scheme.

fetchRefs :: Spec -> RawSchema -> Graph -> IO (Either Text Graph) Source

Take a schema. Retrieve every document either it or its subschemas include via the "$ref" keyword. Load a Graph out with them.

TODO: This function's URL processing is hacky and needs improvement.