packages feed

aeson-injector 1.1.1.0 → 1.1.2.0

raw patch · 5 files changed

+31/−26 lines, 5 filesdep ~basedep ~swagger2PVP ok

version bump matches the API change (PVP)

Dependency ranges changed: base, swagger2

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -1,3 +1,8 @@+1.1.2.0 +======= ++- Move to `swagger2-2.4` and `ghc-8.6`.+ 1.1.0.0 ======= 
aeson-injector.cabal view
@@ -1,5 +1,5 @@ name:                aeson-injector-version:             1.1.1.0+version:             1.1.2.0 synopsis:            Injecting fields into aeson values description:         See README.md license:             MIT@@ -32,14 +32,14 @@       Data.Aeson.WithField    build-depends:-      base                 >= 4.7     && < 4.12+      base                 >= 4.7     && < 4.13     , aeson                >= 0.11    && < 1.5     , bifunctors           >= 5.2     && < 6     , deepseq              >= 1.4     && < 2     , hashable             >= 1.0     && < 2.0     , lens                 >= 4.13    && < 5     , servant-docs         >= 0.7     && < 0.12-    , swagger2             >= 2.1.2.1 && < 3.0+    , swagger2             >= 2.4     && < 3.0     , text                 >= 1.2     && < 2.0     , unordered-containers >= 0.2.7   && < 0.3 
src/Data/Aeson/Unit.hs view
@@ -8,9 +8,9 @@ Stability   : experimental Portability : Portable -Common problem in REST interfaces when you need to return nothing as result, +Common problem in REST interfaces when you need to return nothing as result, usage of `()` will produce `[]` JSON. That causes problems in some JSON parsers-in other languages. +in other languages.  So, `Unit` serialises into empty JSON object: @@ -20,12 +20,12 @@ -} module Data.Aeson.Unit(     Unit(..)-  ) where +  ) where  import Control.Lens-import Data.Aeson +import Data.Aeson import Data.Swagger-import GHC.Generics +import GHC.Generics  -- | Data type that serialise into empty object in aeson --@@ -39,14 +39,14 @@ data Unit = Unit   deriving (Generic, Eq, Show, Read, Enum, Bounded) -instance ToJSON Unit where +instance ToJSON Unit where   toJSON _ = object [] --- | Always a success parse -instance FromJSON Unit where +-- | Always a success parse+instance FromJSON Unit where   parseJSON _ = pure Unit -instance ToSchema Unit where -  declareNamedSchema _ = do +instance ToSchema Unit where+  declareNamedSchema _ = do     return $ NamedSchema Nothing $ mempty-      & type_ .~ SwaggerObject+      & type_ .~ Just SwaggerObject
src/Data/Aeson/WithField.hs view
@@ -262,7 +262,7 @@ instance (KnownSymbol s, ToSchema a, ToSchema b) => ToSchema (WithField s a b) where   declareNamedSchema _ = do     NamedSchema n s <- declareNamedSchema (Proxy :: Proxy b)-    if s ^. type_ == SwaggerObject then inline n s+    if s ^. type_ == Just SwaggerObject then inline n s       else wrapper n s     where     field = T.pack $ symbolVal (Proxy :: Proxy s)@@ -270,7 +270,7 @@     wrapper n s = do       indexSchema <- declareSchema (Proxy :: Proxy a)       return $ NamedSchema (fmap (namePrefix <>) n) $ mempty-        & type_ .~ SwaggerObject+        & type_ .~ Just SwaggerObject         & properties .~             [ ("value", Inline s)             , (field, Inline indexSchema)@@ -381,18 +381,18 @@     NamedSchema na sa <- declareNamedSchema (Proxy :: Proxy a)     let newName = combinedName <$> na <*> nb     return . NamedSchema newName $ case (sa ^. type_ , sb ^. type_) of-      (SwaggerObject, SwaggerObject) -> sb <> sa-      (SwaggerObject, _) -> bwrapper sb <> sa-      (_, SwaggerObject) -> sb <> awrapper sa+      (Just SwaggerObject, Just SwaggerObject) -> sb <> sa+      (Just SwaggerObject, _) -> bwrapper sb <> sa+      (_, Just SwaggerObject) -> sb <> awrapper sa       _ -> bwrapper sb <> awrapper sa     where     combinedName a b = "WithFields_" <> a <> "_" <> b     awrapper nas = mempty-      & type_ .~ SwaggerObject+      & type_ .~ Just SwaggerObject       & properties .~ [ ("injected", Inline nas) ]       & required .~ [ "injected" ]     bwrapper nbs = mempty-      & type_ .~ SwaggerObject+      & type_ .~ Just SwaggerObject       & properties .~ [ ("value", Inline nbs) ]       & required .~ [ "value" ] @@ -437,7 +437,7 @@   declareNamedSchema _ = do     NamedSchema an as <- declareNamedSchema (Proxy :: Proxy a)     return $ NamedSchema (fmap ("OnlyField" <>) an) $ mempty-      & type_ .~ SwaggerObject+      & type_ .~ Just SwaggerObject       & properties .~ [(field, Inline as)]       & required .~ [field]     where
test/Main.hs view
@@ -80,7 +80,7 @@   declareNamedSchema prx = do     t <- declareSchema (Proxy :: Proxy Text)     return $ NamedSchema (Just "TestObj") $ mempty-      & type_ .~ SwaggerObject+      & type_ .~ Just SwaggerObject       & properties .~ [("field", Inline t)]       & required .~ ["field"] instance Arbitrary TestObj where@@ -230,7 +230,7 @@     t <- declareSchema (Proxy :: Proxy a)     let nm = pack . show $ typeRep (Proxy :: Proxy a)     return $ NamedSchema (Just $ "TestObj1'" <> nm) $ mempty-      & type_ .~ SwaggerObject+      & type_ .~ Just SwaggerObject       & properties .~ [("field1", Inline t)]       & required .~ ["field1"] instance Arbitrary a => Arbitrary (TestObj1 a) where@@ -248,7 +248,7 @@   declareNamedSchema prx = do     t <- declareSchema (Proxy :: Proxy Text)     return $ NamedSchema (Just "TestObj2") $ mempty-      & type_ .~ SwaggerObject+      & type_ .~ Just SwaggerObject       & properties .~ [("field2", Inline t)]       & required .~ ["field2"] instance Arbitrary TestObj2 where@@ -437,7 +437,7 @@     ]   testsToSchema = testGroup "ToSchema" [       testCase "Normal mode" $ do-        let expected = NamedSchema Nothing $ mempty & type_ .~ SwaggerObject+        let expected = NamedSchema Nothing $ mempty & type_ .~ Just SwaggerObject         let actual = toNamedSchema (Proxy :: Proxy Unit)         expected @=? actual     ]