@@ -12,7 +12,7 @@ import Prelude ()
12
12
import Prelude.Compat
13
13
14
14
import Data.Aeson
15
- (FromJSON , ToJSON (.. ), Value , decode , encode , object , (.=) )
15
+ (FromJSON , ToJSON (.. ), Value , decode , encode , object , (.=) , eitherDecode )
16
16
import Data.ByteString.Char8
17
17
(ByteString , append , pack )
18
18
import qualified Data.ByteString.Lazy as BSL
@@ -219,15 +219,13 @@ spec = describe "Servant.API.ContentTypes" $ do
219
219
handleCTypeH (Proxy :: Proxy '[JSONorText ]) " image/jpeg"
220
220
" foobar" `shouldBe` (Nothing :: Maybe (Either String Int ))
221
221
222
- -- aeson >= 0.9 decodes top-level strings
223
- describe " eitherDecodeLenient" $ do
222
+ describe " eitherDecode is lenient" $ do
224
223
224
+ -- Since servant-0.20.1 MimeUnrender JSON instance uses eitherDecode,
225
+ -- as aeson >= 0.9 supports decoding top-level strings and numbers.
225
226
it " parses top-level strings" $ do
226
- let toMaybe = either (const Nothing ) Just
227
- -- The Left messages differ, so convert to Maybe
228
- property $ \ x -> toMaybe (eitherDecodeLenient x)
229
- `shouldBe` (decode x :: Maybe String )
230
-
227
+ property $ \ x -> mimeUnrender (Proxy :: Proxy JSON ) x
228
+ `shouldBe` (eitherDecode x :: Either String String )
231
229
232
230
data SomeData = SomeData { record1 :: String , record2 :: Int }
233
231
deriving (Generic , Eq , Show )
0 commit comments