git.iko.soy/typeable/swagger2
on master help sign in
extract schema and paramSchema's JSON Value into CommonTestTypes
bd00ca5anneloreegger
test/Data/Swagger/CommonTestTypes.hs+29
@@ -650,3 +650,32 @@ singleMaybeFieldSchemaJSON = [aesonQQ|
650 }
650 }
651}
651}
652|]
652|]
653+
654+
655+-- ========================================================================
656+-- TimeOfDay
657+-- ========================================================================
658+data TimeOfDay
659+ = Int
660+ | Pico
661+ deriving (Generic)
662+instance ToSchema TimeOfDay
663+instance ToParamSchema TimeOfDay
664+
665+
666+timeOfDaySchemaJSON :: Value
667+timeOfDaySchemaJSON = [aesonQQ|
668+{
669+ "example": "12:33:15",
670+ "type": "string",
671+ "format": "hh:MM:ss"
672+}
673+|]
674+
675+timeOfDayParamSchemaJSON :: Value
676+timeOfDayParamSchemaJSON = [aesonQQ|
677+{
678+ "type": "string",
679+ "format": "hh:MM:ss"
680+}
681+|]
test/Data/Swagger/ParamSchemaSpec.hs+1−1
@@ -34,7 +34,7 @@ spec = do
34 context "Unary records" $ do
34 context "Unary records" $ do
35 context "Email (unary record)" $ checkToParamSchema (Proxy :: Proxy Email) emailSchemaJSON
35 context "Email (unary record)" $ checkToParamSchema (Proxy :: Proxy Email) emailSchemaJSON
36 context "UserId (non-record newtype)" $ checkToParamSchema (Proxy :: Proxy UserId) userIdSchemaJSON
36 context "UserId (non-record newtype)" $ checkToParamSchema (Proxy :: Proxy UserId) userIdSchemaJSON
37− context "TimeOfDay" $ checkToParamSchema (Proxy :: Proxy TimeOfDay) (Object (HM.fromList [("format",String "hh:MM:ss"),("type",String "string")]))
37+ context "TimeOfDay" $ checkToParamSchema (Proxy :: Proxy Data.Time.LocalTime.TimeOfDay) timeOfDayParamSchemaJSON
38
38
39main :: IO ()
39main :: IO ()
40main = hspec spec
40main = hspec spec
test/Data/Swagger/SchemaSpec.hs+2−2
@@ -29,7 +29,7 @@ import SpecCommon
29import Test.Hspec
29import Test.Hspec
30
30
31import qualified Data.HashMap.Strict as HM
31import qualified Data.HashMap.Strict as HM
32−import Data.Time
32+import Data.Time.LocalTime
33
33
34checkToSchema :: ToSchema a => Proxy a -> Value -> Spec
34checkToSchema :: ToSchema a => Proxy a -> Value -> Spec
35checkToSchema proxy js = toSchema proxy <=> js
35checkToSchema proxy js = toSchema proxy <=> js
@@ -115,7 +115,7 @@ spec = do
115 context "MyRoseTree' (inlineNonRecursiveSchemas)" $ checkInlinedRecSchema (Proxy :: Proxy MyRoseTree') myRoseTreeSchemaJSON'
115 context "MyRoseTree' (inlineNonRecursiveSchemas)" $ checkInlinedRecSchema (Proxy :: Proxy MyRoseTree') myRoseTreeSchemaJSON'
116 describe "Bounded Enum key mapping" $ do
116 describe "Bounded Enum key mapping" $ do
117 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")]))
118+ context "TimeOfDay" $ checkToSchema (Proxy :: Proxy Data.Time.LocalTime.TimeOfDay ) timeOfDaySchemaJSON
119
119
120main :: IO ()
120main :: IO ()
121main = hspec spec
121main = hspec spec