| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Data.JsonSchema
- compile :: Spec -> Graph -> RawSchema -> Schema
- validate :: Schema -> Value -> Either (Vector ValErr) Value
- newtype Spec = Spec {}
- type Graph = HashMap Text (HashMap Text Value)
- type ValErr = Text
- newtype Schema = Schema {}
- type Validator = Value -> Vector ValErr
- type ValidatorGen = Spec -> Graph -> RawSchema -> Value -> Maybe Validator
- type EmbeddedSchemas = Text -> Value -> Vector RawSchema
- data RawSchema = RawSchema {}
- draft4 :: Spec
- isValidSchema :: RawSchema -> Either (Vector ValErr) Value
- compileDraft4 :: Graph -> RawSchema -> Either (Vector ValErr) Schema
- fetchRefs :: Spec -> RawSchema -> Graph -> IO (Either Text Graph)
Primary API
Types
Constructors
| Spec | |
Fields | |
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.
Draft 4 Specific
isValidSchema :: RawSchema -> Either (Vector ValErr) Value 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.