@@ -9,9 +9,13 @@ module Data.Swagger.Schema.Internal where
10import Control.Lens
10import Control.Lens
11import Data.Aeson
11import Data.Aeson
12+import Data.HashMap.Strict (HashMap)
13+import Data.HashSet (HashSet)
12import Data.Int
14import Data.Int
13import Data.Monoid
16import Data.Monoid
14import Data.Proxy
17import Data.Proxy
15import qualified Data.Text as T
19import qualified Data.Text as T
16import qualified Data.Text.Lazy as TL
20import qualified Data.Text.Lazy as TL
17import Data.Word
21import Data.Word
@@ -77,6 +81,24 @@ instance ToSchema T.Text where
77instance ToSchema TL.Text where
81instance ToSchema TL.Text where
78 toSchema _ = toSchema (Proxy :: Proxy String)
82 toSchema _ = toSchema (Proxy :: Proxy String)
84+instance ToSchema a => ToSchema (Map String a) where
86+ & schemaType .~ SchemaObject
87+ & schemaAdditionalProperties ?~ toSchema (Proxy :: Proxy a)
89+instance ToSchema a => ToSchema (Map T.Text a) where toSchema _ = toSchema (Proxy :: Proxy (Map String a))
90+instance ToSchema a => ToSchema (Map TL.Text a) where toSchema _ = toSchema (Proxy :: Proxy (Map String a))
92+instance ToSchema a => ToSchema (HashMap String a) where toSchema _ = toSchema (Proxy :: Proxy (Map String a))
93+instance ToSchema a => ToSchema (HashMap T.Text a) where toSchema _ = toSchema (Proxy :: Proxy (Map String a))
94+instance ToSchema a => ToSchema (HashMap TL.Text a) where toSchema _ = toSchema (Proxy :: Proxy (Map String a))
96+instance ToSchema a => ToSchema (Set a) where
97+ toSchema _ = toSchema (Proxy :: Proxy [a])
98+ & schemaUniqueItems ?~ True
100+instance ToSchema a => ToSchema (HashSet a) where toSchema _ = toSchema (Proxy :: Proxy (Set a))
80toSchemaBoundedIntegral :: forall a proxy. (Bounded a, Integral a) => proxy a -> Schema
102toSchemaBoundedIntegral :: forall a proxy. (Bounded a, Integral a) => proxy a -> Schema
81toSchemaBoundedIntegral _ = mempty
103toSchemaBoundedIntegral _ = mempty
82 & schemaType .~ SchemaInteger
104 & schemaType .~ SchemaInteger