@@ -0,0 +1,56 @@
1+{-# LANGUAGE OverloadedStrings #-}
2+{-# LANGUAGE QuasiQuotes #-}
3+module Data.SwaggerSpec where
4+
5+import Data.Aeson
6+import Data.Aeson.QQ
7+import Data.Swagger
8+
9+import Test.Hspec
10+import Test.Hspec.HUnit
11+
12+infoExample :: SwaggerInfo
13+infoExample = SwaggerInfo
14+ { swaggerInfoTitle = "Swagger Sample App"
15+ , swaggerInfoDescription = Just "This is a sample server Petstore server."
16+ , swaggerInfoTermsOfService = Just "http://swagger.io/terms/"
17+ , swaggerInfoContact = Just contact
18+ , swaggerInfoLicense = Just license
19+ , swaggerInfoVersion = "1.0.1" }
20+ where
21+ contact = SwaggerContact
22+ { swaggerContactName = Just "API Support"
23+ , swaggerContactUrl = Just (URL "http://www.swagger.io/support")
24+ , swaggerContactEmail = Just "support@swagger.io" }
25+ license = SwaggerLicense
26+ { swaggerLicenseName = "Apache 2.0"
27+ , swaggerLicenseUrl = Just (URL "http://www.apache.org/licenses/LICENSE-2.0.html") }
28+
29+infoExampleJSON :: Value
30+infoExampleJSON = [aesonQQ|
31+{
32+ "title": "Swagger Sample App",
33+ "description": "This is a sample server Petstore server.",
34+ "termsOfService": "http://swagger.io/terms/",
35+ "contact": {
36+ "name": "API Support",
37+ "url": "http://www.swagger.io/support",
38+ "email": "support@swagger.io"
39+ },
40+ "license": {
41+ "name": "Apache 2.0",
42+ "url": "http://www.apache.org/licenses/LICENSE-2.0.html"
43+ },
44+ "version": "1.0.1"
45+}
46+|]
47+
48+spec :: Spec
49+spec = do
50+ describe "Info Object" $ do
51+ it "encodes correctly" $ do
52+ toJSON infoExample `shouldBe` infoExampleJSON
53+
54+main :: IO ()
55+main = hspec spec
56+