@@ -54,6 +54,7 @@ import qualified Data.Vector.Storable as VS
5454import qualified Data.Vector.Unboxed as VU
5555import Data.Word
5656import GHC.Generics
57+import qualified Data.UUID.Types as UUID
5758
5859import Data.Swagger.Declare
5960import Data.Swagger.Internal
@@ -441,6 +442,11 @@ instance (ToSchema a, ToSchema b) => ToSchema (Either a b)
441442instance ToSchema () where
442443 declareNamedSchema _ = pure (NamedSchema Nothing nullarySchema)
443444
445+-- | For 'ToJSON' instance, see <http://hackage.haskell.org/package/uuid-aeson uuid-aeson> package.
446+instance ToSchema UUID.UUID where
447+ declareNamedSchema p = pure $ named "UUID" $ paramSchemaToSchema p
448+ & example ?~ toJSON (UUID.toText UUID.nil)
449+
444450instance (ToSchema a, ToSchema b) => ToSchema (a, b)
445451instance (ToSchema a, ToSchema b, ToSchema c) => ToSchema (a, b, c)
446452instance (ToSchema a, ToSchema b, ToSchema c, ToSchema d) => ToSchema (a, b, c, d)
@@ -502,6 +508,21 @@ instance ToSchema a => ToSchema (IntMap a) where
502508 declareNamedSchema _ = declareNamedSchema (Proxy :: Proxy [(Int, a)])
503509
504510#if MIN_VERSION_aeson(1,0,0)
511+instance (ToJSONKey k, ToSchema k, ToSchema v) => ToSchema (Map k v) where
512+ declareNamedSchema _ = case toJSONKey :: ToJSONKeyFunction k of
513+ ToJSONKeyText _ _ -> declareObjectMapSchema
514+ ToJSONKeyValue _ _ -> declareNamedSchema (Proxy :: Proxy [(k, v)])
515+ where
516+ declareObjectMapSchema = do
517+ schema <- declareSchemaRef (Proxy :: Proxy v)
518+ return $ unnamed $ mempty
519+ & type_ .~ SwaggerObject
520+ & additionalProperties ?~ schema
521+
522+instance (ToJSONKey k, ToSchema k, ToSchema v) => ToSchema (HashMap k v) where
523+ declareNamedSchema _ = declareNamedSchema (Proxy :: Proxy (Map k v))
524+
525+#else
505526
506527instance ToSchema a => ToSchema (Map String a) where
507528 declareNamedSchema _ = do
@@ -517,22 +538,6 @@ instance ToSchema a => ToSchema (HashMap String a) where declareNamedSchema _ =
517538instance ToSchema a => ToSchema (HashMap T.Text a) where declareNamedSchema _ = declareNamedSchema (Proxy :: Proxy (Map String a))
518539instance ToSchema a => ToSchema (HashMap TL.Text a) where declareNamedSchema _ = declareNamedSchema (Proxy :: Proxy (Map String a))
519540
520−#else
521−
522−instance (ToJSONKey k, ToSchema k, ToSchema v) => ToSchema (Map k v) where
523− declareNamedSchema _ = case toJSONKey :: ToJSONKeyFunction v of
524− ToJSONKeyText _ _ -> declareObjectMapSchema
525− ToJSONKeyValue _ _ -> declareNamedSchema (Proxy :: Proxy [(k, v)])
526− where
527− declareObjectMapSchema = do
528− schema <- declareSchemaRef (Proxy :: Proxy v)
529− return $ unnamed $ mempty
530− & type_ .~ SwaggerObject
531− & additionalProperties ?~ schema
532−
533−instance (ToJSONKey k, ToSchema k, ToSchema v) => ToSchema (HashMap k v) where
534− declareNamedSchema _ = declareNamedSchema (Proxy :: Proxy (Map k v))
535−
536541#endif
537542
538543instance ToSchema a => ToSchema (V.Vector a) where declareNamedSchema _ = declareNamedSchema (Proxy :: Proxy [a])