hjsonschema-0.9.0.0: JSON Schema library

Safe HaskellNone
LanguageHaskell2010

Data.JsonSchema.Fetch

Synopsis

Documentation

data SchemaContext schema Source

Constructors

SchemaContext 

Fields

_scURI :: !(Maybe Text)

Must not include a URI fragment, e.g. use "http://example.com/foo" not "http://example.com/foo#bar".

This is the URI identifying the document containing the schema. It's different than the schema's "id" field, which controls scope when resolving references contained in the schema.

_scSchema :: !schema
 

Instances

Eq schema => Eq (SchemaContext schema) Source 
Show schema => Show (SchemaContext schema) Source 

type URISchemaMap schema = HashMap Text schema Source

Keys are URIs (without URI fragments).

data SchemaCache schema Source

Constructors

SchemaCache 

Fields

_startingSchema :: !schema

Used to resolve relative references.

_cachedSchemas :: !(URISchemaMap schema)
 

Instances

Eq schema => Eq (SchemaCache schema) Source 
Show schema => Show (SchemaCache schema) Source 

fetchReferencedSchemas :: forall schema. FromJSON schema => (schema -> [schema]) -> (schema -> Maybe Text) -> (schema -> Maybe Text) -> URISchemaMap schema -> SchemaContext schema -> IO (Either Text (SchemaCache schema)) Source

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

simpleGET :: Manager -> Text -> IO ByteString Source

Based on simpleHttp from http-conduit.

fetchReferencedSchemas' :: forall schema. FromJSON schema => (schema -> [schema]) -> (schema -> Maybe Text) -> (schema -> Maybe Text) -> (Text -> IO ByteString) -> URISchemaMap schema -> SchemaContext schema -> IO (SchemaCache schema) Source

A version of fetchReferencedSchemas where the function to fetch schemas is provided by the user. This allows restrictions to be added, e.g. rejecting non-local URIs.

includeSubschemas :: forall schema. (schema -> [schema]) -> (schema -> Maybe Text) -> SchemaContext schema -> [SchemaContext schema] Source

Return the schema passed in as an argument, as well as every subschema contained within it.