hjsonschema-0.10.0.1: JSON Schema library

Safe HaskellNone
LanguageHaskell2010

Data.JsonSchema.Fetch

Contents

Synopsis

Types

data Spec schema Source

Constructors

Spec 

Fields

_ssEmbedded :: schema -> [schema]
 
_ssGetId :: schema -> Maybe Text
 
_ssGetRef :: schema -> Maybe Text
 

data SchemaWithURI schema Source

Constructors

SchemaWithURI 

Fields

_swSchema :: !schema
 
_swURI :: !(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.

Instances

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

type URISchemaMap schema = HashMap Text schema Source

Keys are URIs (without URI fragments).

data ReferencedSchemas schema Source

Constructors

ReferencedSchemas 

Fields

_rsStarting :: !schema

Used to resolve relative references.

_rsSchemaMap :: !(URISchemaMap schema)
 

Instances

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

Fetch via HTTP

referencesViaHTTP' :: forall schema. FromJSON schema => Spec schema -> SchemaWithURI schema -> IO (Either HTTPFailure (ReferencedSchemas schema)) Source

Take a schema. Retrieve every document either it or its subschemas include via the "$ref" keyword.

Fetch via Filesystem

referencesViaFilesystem' :: forall schema. FromJSON schema => Spec schema -> SchemaWithURI schema -> IO (Either FilesystemFailure (ReferencedSchemas schema)) Source

Method Agnostic Fetching Tools

referencesMethodAgnostic :: forall schema. FromJSON schema => (Text -> IO ByteString) -> Spec schema -> SchemaWithURI schema -> IO (Either Text (ReferencedSchemas 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.

foldFunction :: forall schema. FromJSON schema => (Text -> IO ByteString) -> Spec schema -> URISchemaMap schema -> SchemaWithURI schema -> IO (Either Text (URISchemaMap schema)) Source

includeSubschemas :: forall schema. Spec schema -> SchemaWithURI schema -> [SchemaWithURI schema] Source

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