hjsonschema-1.9.0: JSON Schema library

Safe HaskellNone
LanguageHaskell2010

JSONSchema.Fetch

Contents

Synopsis

Types

data FetchInfo schema Source #

This is all the fetching functions need to know about a particular JSON Schema draft, e.g. JSON Schema Draft 4.

Constructors

FetchInfo 

Fields

newtype URISchemaMap schema Source #

Keys are URIs (without URI fragments).

Constructors

URISchemaMap 

Fields

Instances

Eq schema => Eq (URISchemaMap schema) Source # 

Methods

(==) :: URISchemaMap schema -> URISchemaMap schema -> Bool #

(/=) :: URISchemaMap schema -> URISchemaMap schema -> Bool #

Show schema => Show (URISchemaMap schema) Source # 

Methods

showsPrec :: Int -> URISchemaMap schema -> ShowS #

show :: URISchemaMap schema -> String #

showList :: [URISchemaMap schema] -> ShowS #

Semigroup (URISchemaMap schema) Source # 

Methods

(<>) :: URISchemaMap schema -> URISchemaMap schema -> URISchemaMap schema #

sconcat :: NonEmpty (URISchemaMap schema) -> URISchemaMap schema #

stimes :: Integral b => b -> URISchemaMap schema -> URISchemaMap schema #

Monoid (URISchemaMap schema) Source # 

Methods

mempty :: URISchemaMap schema #

mappend :: URISchemaMap schema -> URISchemaMap schema -> URISchemaMap schema #

mconcat :: [URISchemaMap schema] -> URISchemaMap schema #

data SchemaWithURI schema Source #

A top-level schema along with its location.

Constructors

SchemaWithURI 

Fields

  • _swSchema :: !schema
     
  • _swURI :: !(Maybe Text)

    This is the URI from which the document was originally fetched. 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 # 

Methods

(==) :: SchemaWithURI schema -> SchemaWithURI schema -> Bool #

(/=) :: SchemaWithURI schema -> SchemaWithURI schema -> Bool #

Show schema => Show (SchemaWithURI schema) Source # 

Methods

showsPrec :: Int -> SchemaWithURI schema -> ShowS #

show :: SchemaWithURI schema -> String #

showList :: [SchemaWithURI schema] -> ShowS #

getReference :: URISchemaMap schema -> Text -> Maybe schema Source #

Fetch via HTTP

referencesViaHTTP' :: forall schema. FromJSON schema => FetchInfo schema -> SchemaWithURI schema -> IO (Either HTTPFailure (URISchemaMap 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 => FetchInfo schema -> SchemaWithURI schema -> IO (Either FilesystemFailure (URISchemaMap schema)) Source #

Method Agnostic Fetching Tools

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

getRecursiveReferences :: forall schema. FromJSON schema => (Text -> IO ByteString) -> FetchInfo schema -> URISchemaMap schema -> SchemaWithURI schema -> IO (Either Text (URISchemaMap schema)) Source #

includeSubschemas :: forall schema. FetchInfo schema -> SchemaWithURI schema -> [SchemaWithURI schema] Source #

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