git.iko.soy/typeable/swagger2
on master help sign in
Merge pull request #70 from GetShopTV/aeson-1
5ae9644Nickolay Kudasov
src/Data/Swagger/Internal/Schema.hs+20
@@ -481,6 +481,8 @@ instance ToSchema IntSet where declareNamedSchema _ = declareNamedSchema (Proxy
481instance ToSchema a => ToSchema (IntMap a) where
481instance ToSchema a => ToSchema (IntMap a) where
482 declareNamedSchema _ = declareNamedSchema (Proxy :: Proxy [(Int, a)])
482 declareNamedSchema _ = declareNamedSchema (Proxy :: Proxy [(Int, a)])
483
483
484+#if MIN_VERSION_aeson(1,0,0)
485+
484instance ToSchema a => ToSchema (Map String a) where
486instance ToSchema a => ToSchema (Map String a) where
485 declareNamedSchema _ = do
487 declareNamedSchema _ = do
486 schema <- declareSchemaRef (Proxy :: Proxy a)
488 schema <- declareSchemaRef (Proxy :: Proxy a)
@@ -495,6 +497,24 @@ instance ToSchema a => ToSchema (HashMap String a) where declareNamedSchema _ =
495instance ToSchema a => ToSchema (HashMap T.Text a) where declareNamedSchema _ = declareNamedSchema (Proxy :: Proxy (Map String a))
497instance ToSchema a => ToSchema (HashMap T.Text a) where declareNamedSchema _ = declareNamedSchema (Proxy :: Proxy (Map String a))
496instance ToSchema a => ToSchema (HashMap TL.Text a) where declareNamedSchema _ = declareNamedSchema (Proxy :: Proxy (Map String a))
498instance ToSchema a => ToSchema (HashMap TL.Text a) where declareNamedSchema _ = declareNamedSchema (Proxy :: Proxy (Map String a))
497
499
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+
516+#endif
517+
498instance ToSchema a => ToSchema (V.Vector a) where declareNamedSchema _ = declareNamedSchema (Proxy :: Proxy [a])
518instance ToSchema a => ToSchema (V.Vector a) where declareNamedSchema _ = declareNamedSchema (Proxy :: Proxy [a])
499instance ToSchema a => ToSchema (VU.Vector a) where declareNamedSchema _ = declareNamedSchema (Proxy :: Proxy [a])
519instance ToSchema a => ToSchema (VU.Vector a) where declareNamedSchema _ = declareNamedSchema (Proxy :: Proxy [a])
500instance ToSchema a => ToSchema (VS.Vector a) where declareNamedSchema _ = declareNamedSchema (Proxy :: Proxy [a])
520instance ToSchema a => ToSchema (VS.Vector a) where declareNamedSchema _ = declareNamedSchema (Proxy :: Proxy [a])
stack.yaml+3−1
@@ -1,5 +1,7 @@
1flags: {}
1flags: {}
2packages:
2packages:
3- '.'
3- '.'
4−extra-deps: []
4+extra-deps:
5+- aeson-1.0.0.0
6+- insert-ordered-containers-0.2.0.0
5resolver: nightly-2016-07-15
7resolver: nightly-2016-07-15
swagger2.cabal+1−1
@@ -46,7 +46,7 @@ library
46 , hashable
46 , hashable
47 , generics-sop >=0.2 && <0.3
47 , generics-sop >=0.2 && <0.3
48 , http-media
48 , http-media
49− , insert-ordered-containers >=0.1.0.0 && <0.2
49+ , insert-ordered-containers >=0.1.0.0 && <0.3
50 , lens
50 , lens
51 , mtl
51 , mtl
52 , network
52 , network