git.iko.soy/typeable/swagger2
on master help sign in
add Test for Schema
40d45acanneloreegger
test/Data/Swagger/SchemaSpec.hs+7−1
@@ -1,14 +1,16 @@
1{-# LANGUAGE DeriveGeneric #-}
1{-# LANGUAGE DeriveGeneric #-}
2+{-# LANGUAGE DataKinds #-}
2{-# LANGUAGE ScopedTypeVariables #-}
3{-# LANGUAGE ScopedTypeVariables #-}
3{-# LANGUAGE TemplateHaskell #-}
4{-# LANGUAGE TemplateHaskell #-}
4{-# LANGUAGE QuasiQuotes #-}
5{-# LANGUAGE QuasiQuotes #-}
6+{-# LANGUAGE OverloadedStrings #-}
5module Data.Swagger.SchemaSpec where
7module Data.Swagger.SchemaSpec where
6
8
7import Prelude ()
9import Prelude ()
8import Prelude.Compat
10import Prelude.Compat
9
11
10import Control.Lens ((^.))
12import Control.Lens ((^.))
11−import Data.Aeson (Value, ToJSON(..), ToJSONKey(..))
13+import Data.Aeson (Value, ToJSON(..), ToJSONKey(..), Value(Object), Value(String))
12import Data.Aeson.Types (toJSONKeyText)
14import Data.Aeson.Types (toJSONKeyText)
13import Data.Aeson.QQ.Simple
15import Data.Aeson.QQ.Simple
14import Data.Char
16import Data.Char
@@ -26,6 +28,9 @@ import Data.Swagger.CommonTestTypes
26import SpecCommon
28import SpecCommon
27import Test.Hspec
29import Test.Hspec
28
30
31+import qualified Data.HashMap.Strict as HM
32+import Data.Time
33+
29checkToSchema :: ToSchema a => Proxy a -> Value -> Spec
34checkToSchema :: ToSchema a => Proxy a -> Value -> Spec
30checkToSchema proxy js = toSchema proxy <=> js
35checkToSchema proxy js = toSchema proxy <=> js
31
36
@@ -110,6 +115,7 @@ spec = do
110 context "MyRoseTree' (inlineNonRecursiveSchemas)" $ checkInlinedRecSchema (Proxy :: Proxy MyRoseTree') myRoseTreeSchemaJSON'
115 context "MyRoseTree' (inlineNonRecursiveSchemas)" $ checkInlinedRecSchema (Proxy :: Proxy MyRoseTree') myRoseTreeSchemaJSON'
111 describe "Bounded Enum key mapping" $ do
116 describe "Bounded Enum key mapping" $ do
112 context "ButtonImages" $ checkToSchema (Proxy :: Proxy ButtonImages) buttonImagesSchemaJSON
117 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")]))
113
119
114main :: IO ()
120main :: IO ()
115main = hspec spec
121main = hspec spec