schemas 0.2.0 → 0.2.0.1
raw patch · 4 files changed
+11/−8 lines, 4 files
Files
- CHANGELOG.md +3/−0
- schemas.cabal +1/−1
- src/Schemas/Untyped.hs +1/−1
- test/SchemasSpec.hs +6/−6
CHANGELOG.md view
@@ -1,5 +1,8 @@ # Revision history for schemas +## 0.2.0.1 -- 2019-10-02+* Fixed subtyping relation for arrays+ ## 0.2.0 -- 2019-09-29 * Add OpenApi2 encoding * Change the `Semigroup` instance for typed schemas
schemas.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.0 name: schemas-version: 0.2.0+version: 0.2.0.1 synopsis: schema guided serialization description: Schemas is a Haskell library for serializing and deserializing data in JSON.
src/Schemas/Untyped.hs view
@@ -234,7 +234,7 @@ go ctx (StringMap a) (StringMap b) = do f <- go ("Map" : ctx) a b pure $ over (_Object . traverse) f- go _tx a (Array b) | a == b = pure (A.Array . fromList . (: []))+ go _tx (Array a) b | a == b = pure (A.Array . fromList . (: [])) go ctx (Enum opts) (Enum opts') = case NE.nonEmpty $ NE.filter (`notElem` opts) opts' of Nothing -> pure id
test/SchemasSpec.hs view
@@ -49,8 +49,8 @@ Record [makeField "a" prim True] `shouldBeSubtypeOf` Record [makeField "a" prim False] it "subtypes can relax the type of a field" $ do- Record [makeField "a" (Array prim) True]- `shouldBeSubtypeOf` Record [makeField "a" prim True]+ Record [makeField "a" prim True]+ `shouldBeSubtypeOf` Record [makeField "a" (Array prim) True] it "subtypes cannot remove Required fields" $ do Record [makeField "def" prim True] `shouldNotBeSubtypeOf` Record [makeField "def" prim True, makeField "a" prim True]@@ -67,10 +67,10 @@ it "subtypes cannot add constructors" $ do Union [constructor' "A" prim, constructor' "B" Empty] `shouldNotBeSubtypeOf` Union [constructor' "A" (prim)]- it "subtypes can expand an array" $ do- Array prim `shouldBeSubtypeOf` prim- it "subtypes cannot drop an array" $ do- prim `shouldNotBeSubtypeOf` Array prim+ it "subtypes can drop an array" $ do+ prim `shouldBeSubtypeOf` Array prim+ it "subtypes cannot introduce an array" $ do+ Array prim `shouldNotBeSubtypeOf` prim describe "examples" $ do describe "Schemas" $ do prop "finite(schema @Schema) is a supertype of (schema @Schema)" $ \(SmallNatural n) ->