packages feed

aeson-injector 1.1.3.0 → 1.1.4.0

raw patch · 4 files changed

+13/−2 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -1,3 +1,8 @@+1.1.4.0+=======++- Disambiguate OnlyField schema with for one type (https://github.com/NCrashed/aeson-injector/pull/7)+ 1.1.3.0 ======= 
aeson-injector.cabal view
@@ -1,5 +1,5 @@ name:                aeson-injector-version:             1.1.3.0+version:             1.1.4.0 synopsis:            Injecting fields into aeson values description:         It is small utility library that is intented to be used in RESTful APIs, especially with [servant](http://haskell-servant.readthedocs.io/en/stable/) and [Swagger](http://swagger.io/). Its main purpose is simple injection of fields into JSONs produced by [aeson](https://hackage.haskell.org/package/aeson) library. license:             MIT
src/Data/Aeson/WithField.hs view
@@ -436,7 +436,8 @@ instance (KnownSymbol s, ToSchema a) => ToSchema (OnlyField s a) where   declareNamedSchema _ = do     NamedSchema an as <- declareNamedSchema (Proxy :: Proxy a)-    return $ NamedSchema (fmap ("OnlyField" <>) an) $ mempty+    let namePrefix = "OnlyField '" <> field <> "' "+    return $ NamedSchema (fmap (namePrefix <>) an) $ mempty       & type_ .~ Just SwaggerObject       & properties .~ [(field, Inline as)]       & required .~ [field]
test/Main.hs view
@@ -15,6 +15,7 @@ import Data.Proxy import Data.Scientific (scientific) import Data.Swagger+import Data.Swagger.Lens import Data.Swagger.Internal.Schema import Data.Text import Data.Text.Arbitrary@@ -414,6 +415,10 @@                 ("a", Inline $ toSchema (Proxy :: Proxy Int)) ]         let actual = toSchema (Proxy :: Proxy (OnlyField "a" Int))         expected @=? (actual ^. properties)+    , testCase "Distinct names" $ do+        let idA = toNamedSchema (Proxy :: Proxy (OnlyField "idA" TestObj))+        let idB = toNamedSchema (Proxy :: Proxy (OnlyField "idB" TestObj))+        idA ^. name /= idB ^. name @? "Different OnlyField fields produce schemas with equal names"     ]  unitDataTests :: TestTree