@@ -9,9 +9,13 @@ module Data.Swagger.Schema.Internal where
99
1010import Control.Lens
1111import Data.Aeson
12+import Data.HashMap.Strict (HashMap)
13+import Data.HashSet (HashSet)
1214import Data.Int
15+import Data.Map (Map)
1316import Data.Monoid
1417import Data.Proxy
18+import Data.Set (Set)
1519import qualified Data.Text as T
1620import qualified Data.Text.Lazy as TL
1721import Data.Word
@@ -77,6 +81,24 @@ instance ToSchema T.Text where
7781instance ToSchema TL.Text where
7882 toSchema _ = toSchema (Proxy :: Proxy String)
7983
84+instance ToSchema a => ToSchema (Map String a) where
85+ toSchema _ = mempty
86+ & schemaType .~ SchemaObject
87+ & schemaAdditionalProperties ?~ toSchema (Proxy :: Proxy a)
88+
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))
91+
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))
95+
96+instance ToSchema a => ToSchema (Set a) where
97+ toSchema _ = toSchema (Proxy :: Proxy [a])
98+ & schemaUniqueItems ?~ True
99+
100+instance ToSchema a => ToSchema (HashSet a) where toSchema _ = toSchema (Proxy :: Proxy (Set a))
101+
80102toSchemaBoundedIntegral :: forall a proxy. (Bounded a, Integral a) => proxy a -> Schema
81103toSchemaBoundedIntegral _ = mempty
82104 & schemaType .~ SchemaInteger