git.iko.soy/typeable/swagger2
on master help sign in
Fix #71
commit7433e9a4400af4c0608382fb9c01f6a5e5776ca1 authorOleg Grenrus <oleg.grenrus@iki.fi> dateTue 9 Aug 2016, 13:44 (10 years ago) parent4a42ff6
1 file changed+15−16
src/Data/Swagger/Internal/Schema.hs+15−16
src/Data/Swagger/Internal/Schema.hs+15−16
@@ -482,6 +482,21 @@ instance ToSchema a => ToSchema (IntMap a) where
482482 declareNamedSchema _ = declareNamedSchema (Proxy :: Proxy [(Int, a)])
483483
484484#if MIN_VERSION_aeson(1,0,0)
485+instance (ToJSONKey k, ToSchema k, ToSchema v) => ToSchema (Map k v) where
486+ declareNamedSchema _ = case toJSONKey :: ToJSONKeyFunction k of
487+ ToJSONKeyText _ _ -> declareObjectMapSchema
488+ ToJSONKeyValue _ _ -> declareNamedSchema (Proxy :: Proxy [(k, v)])
489+ where
490+ declareObjectMapSchema = do
491+ schema <- declareSchemaRef (Proxy :: Proxy v)
492+ return $ unnamed $ mempty
493+ & type_ .~ SwaggerObject
494+ & additionalProperties ?~ schema
495+
496+instance (ToJSONKey k, ToSchema k, ToSchema v) => ToSchema (HashMap k v) where
497+ declareNamedSchema _ = declareNamedSchema (Proxy :: Proxy (Map k v))
498+
499+#else
485500
486501instance ToSchema a => ToSchema (Map String a) where
487502 declareNamedSchema _ = do
@@ -497,22 +512,6 @@ instance ToSchema a => ToSchema (HashMap String a) where declareNamedSchema _ =
497512instance ToSchema a => ToSchema (HashMap T.Text a) where declareNamedSchema _ = declareNamedSchema (Proxy :: Proxy (Map String a))
498513instance ToSchema a => ToSchema (HashMap TL.Text a) where declareNamedSchema _ = declareNamedSchema (Proxy :: Proxy (Map String a))
499514
500−#else
501−
502−instance (ToJSONKey k, ToSchema k, ToSchema v) => ToSchema (Map k v) where
503− declareNamedSchema _ = case toJSONKey :: ToJSONKeyFunction v of
504− ToJSONKeyText _ _ -> declareObjectMapSchema
505− ToJSONKeyValue _ _ -> declareNamedSchema (Proxy :: Proxy [(k, v)])
506− where
507− declareObjectMapSchema = do
508− schema <- declareSchemaRef (Proxy :: Proxy v)
509− return $ unnamed $ mempty
510− & type_ .~ SwaggerObject
511− & additionalProperties ?~ schema
512−
513−instance (ToJSONKey k, ToSchema k, ToSchema v) => ToSchema (HashMap k v) where
514− declareNamedSchema _ = declareNamedSchema (Proxy :: Proxy (Map k v))
515−
516515#endif
517516
518517instance ToSchema a => ToSchema (V.Vector a) where declareNamedSchema _ = declareNamedSchema (Proxy :: Proxy [a])