git.iko.soy/typeable/hjsonschema
on master help sign in
0.5.2.2. Bump hjsonpointer; make relevent changes.

This was also pushed to Hackage by accident as 0.5.1.3, even though the current version of the package on Hackage was 0.5.2.1. Apparently Hackage accepts versions of a package that are older than the current version, and just slips them into the version history.

commit54e39060572d484bd2fbd3145f09844190b69424 authorIan Grant Jeffries <ian@housejeffries.com> dateThu 26 Mar 2015, 19:44 (12 years ago) parent7aedb29
3 files changed+9−4
hjsonschema.cabal+2−2 src/Data/JsonSchema/Helpers.hs+4 src/Data/JsonSchema/Validators.hs+3−2
hjsonschema.cabal+2−2
@@ -1,5 +1,5 @@
11name: hjsonschema
2−version: 0.5.2.1
2+version: 0.5.2.2
33synopsis: JSON Schema Draft 4 library
44homepage: https://github.com/seagreen/hjsonschema
55license: MIT
@@ -31,7 +31,7 @@ library
3131 , bytestring >= 0.10 && < 0.11
3232 , file-embed >= 0.0.8 && < 0.0.9
3333 , hashable >= 1.2 && < 1.3
34− , hjsonpointer >= 0.1 && < 0.2
34+ , hjsonpointer >= 0.2 && < 0.3
3535 , http-conduit >= 2.1.5 && < 2.2
3636 , http-types >= 0.8 && < 0.9
3737 , regexpr >= 0.5 && < 0.6
src/Data/JsonSchema/Helpers.hs+4
@@ -124,6 +124,10 @@ isJsonType x xs =
124124-- * Utils
125125--------------------------------------------------
126126
127+eitherToMaybe :: Either a b -> Maybe b
128+eitherToMaybe (Left _) = Nothing
129+eitherToMaybe (Right a) = Just a
130+
127131vectorOfElems :: HashMap k a -> Vector a
128132vectorOfElems = V.fromList . H.elems
129133
src/Data/JsonSchema/Validators.hs+3−2
@@ -426,8 +426,9 @@ ref :: ValidatorGen
426426ref spec g s (String val) = do
427427 (reference, pointer) <- refAndPointer (_rsURI s `combineIdAndRef` val)
428428 r <- RawSchema reference <$> H.lookup reference g
429− let p = decodeUtf8 . urlDecode True . encodeUtf8 $ pointer
430− case jsonPointer p >>= resolvePointer (Object $ _rsObject r) of
429+ let urlDecoded = decodeUtf8 . urlDecode True . encodeUtf8 $ pointer
430+ p <- eitherToMaybe $ jsonPointer urlDecoded
431+ case resolvePointer p (Object $ _rsObject r) of
431432 Right (Object o) ->
432433 Just $ validate $ compile spec g $ RawSchema (_rsURI r) o
433434 _ -> Nothing