@@ -1,14 +1,16 @@
11{-# LANGUAGE DeriveGeneric #-}
2+{-# LANGUAGE DataKinds #-}
23{-# LANGUAGE ScopedTypeVariables #-}
34{-# LANGUAGE TemplateHaskell #-}
45{-# LANGUAGE QuasiQuotes #-}
6+{-# LANGUAGE OverloadedStrings #-}
57module Data.Swagger.SchemaSpec where
68
79import Prelude ()
810import Prelude.Compat
911
1012import Control.Lens ((^.))
11−import Data.Aeson (Value, ToJSON(..), ToJSONKey(..))
13+import Data.Aeson (Value, ToJSON(..), ToJSONKey(..), Value(Object), Value(String))
1214import Data.Aeson.Types (toJSONKeyText)
1315import Data.Aeson.QQ.Simple
1416import Data.Char
@@ -26,6 +28,9 @@ import Data.Swagger.CommonTestTypes
2628import SpecCommon
2729import Test.Hspec
2830
31+import qualified Data.HashMap.Strict as HM
32+import Data.Time
33+
2934checkToSchema :: ToSchema a => Proxy a -> Value -> Spec
3035checkToSchema proxy js = toSchema proxy <=> js
3136
@@ -110,6 +115,7 @@ spec = do
110115 context "MyRoseTree' (inlineNonRecursiveSchemas)" $ checkInlinedRecSchema (Proxy :: Proxy MyRoseTree') myRoseTreeSchemaJSON'
111116 describe "Bounded Enum key mapping" $ do
112117 context "ButtonImages" $ checkToSchema (Proxy :: Proxy ButtonImages) buttonImagesSchemaJSON
118+ context "TimeOfDay" $ checkToSchema (Proxy :: Proxy TimeOfDay ) (Object (HM.fromList [("example",String "12:33:15"),("format",String "hh:MM:ss"),("type",String "string")]))
113119
114120main :: IO ()
115121main = hspec spec