Skip to content
This repository has been archived by the owner on May 2, 2020. It is now read-only.

Commit

Permalink
Fix embedFile issue.
Browse files Browse the repository at this point in the history
See here for someone with a similar problem: snoyberg/file-embed#18

hjsonschema now compiles even when referenced locally from another
project and `stack ghci` is used in that project.

Also update changelog and README.
  • Loading branch information
Ian Grant Jeffries committed Jul 6, 2016
1 parent 544e0bf commit 9c17003
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ A Haskell implementation of the current [JSON Schema](http://json-schema.org/) s

[Hackage](https://hackage.haskell.org/package/hjsonschema) / [GitHub](https://github.com/seagreen/hjsonschema) / [Travis CI](https://travis-ci.org/seagreen/hjsonschema)

Requires [pcre](http://www.pcre.org/) (`pkgs.pcre` in Nixpkgs).

NOTE: You CANNOT use untrusted JSON data to make schemas. Schemas with circular references can cause infinite loops. See the issue list for more info.

# Example
Expand Down
10 changes: 10 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
+ Add a new `referencesToValidity` function.
+ `checkSchema` now check referenced schema's validity in addition to the
starting schema's validity. This change bubbles up to the one-step validation
functions as well.
+ Switch most of the fetching code to use `URISchemaMap` instead of
`ReferencedSchemas`. It didn't need to know about the more complicated data
type.
+ Fix a misuse of the file-embed package that caused problem including
hjsonschema locally in other projects.

# 0.10.0.3

+ Bump http-client.
Expand Down
7 changes: 5 additions & 2 deletions src/Data/JsonSchema/Draft4.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ import Prelude
import Control.Applicative
import Control.Arrow (first, left)
import qualified Data.ByteString.Lazy as LBS
import Data.FileEmbed
import Data.FileEmbed (embedFile,
makeRelativeToProject)
import qualified Data.HashMap.Strict as H
import Data.List.NonEmpty (NonEmpty)
import qualified Data.List.NonEmpty as N
Expand Down Expand Up @@ -153,7 +154,9 @@ schemaValidity = IN.runValidate referenced (SchemaWithURI d4 Nothing) . toJSON
where
d4 :: Schema
d4 = fromMaybe (error "Schema decode failed (this should never happen)")
. decode . LBS.fromStrict $ $(embedFile "src/draft4.json")
. decode
. LBS.fromStrict
$ $(makeRelativeToProject "src/draft4.json" >>= embedFile)

referenced :: ReferencedSchemas Schema
referenced = ReferencedSchemas
Expand Down

0 comments on commit 9c17003

Please sign in to comment.