git.iko.soy/typeable/openapi3
on master help sign in
Merge pull request #70 from GetShopTV/aeson-1

Support aeson-1.0.0.0

commit5ae9644ee3210b9b0eec9f8b9c2dc606497baf5b authorNickolay Kudasov <fizruk@users.noreply.github.com> dateTue 9 Aug 2016, 12:55 (10 years ago) parent9cfef587b962c8
3 files changed+24−2
src/Data/Swagger/Internal/Schema.hs+20 stack.yaml+3−1 swagger2.cabal+1−1
src/Data/Swagger/Internal/Schema.hs+20
@@ -481,6 +481,8 @@ instance ToSchema IntSet where declareNamedSchema _ = declareNamedSchema (Proxy
481481instance ToSchema a => ToSchema (IntMap a) where
482482 declareNamedSchema _ = declareNamedSchema (Proxy :: Proxy [(Int, a)])
483483
484+#if MIN_VERSION_aeson(1,0,0)
485+
484486instance ToSchema a => ToSchema (Map String a) where
485487 declareNamedSchema _ = do
486488 schema <- declareSchemaRef (Proxy :: Proxy a)
@@ -495,6 +497,24 @@ instance ToSchema a => ToSchema (HashMap String a) where declareNamedSchema _ =
495497instance ToSchema a => ToSchema (HashMap T.Text a) where declareNamedSchema _ = declareNamedSchema (Proxy :: Proxy (Map String a))
496498instance ToSchema a => ToSchema (HashMap TL.Text a) where declareNamedSchema _ = declareNamedSchema (Proxy :: Proxy (Map String a))
497499
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+
498518instance ToSchema a => ToSchema (V.Vector a) where declareNamedSchema _ = declareNamedSchema (Proxy :: Proxy [a])
499519instance ToSchema a => ToSchema (VU.Vector a) where declareNamedSchema _ = declareNamedSchema (Proxy :: Proxy [a])
500520instance ToSchema a => ToSchema (VS.Vector a) where declareNamedSchema _ = declareNamedSchema (Proxy :: Proxy [a])
stack.yaml+3−1
@@ -1,5 +1,7 @@
11flags: {}
22packages:
33- '.'
4−extra-deps: []
4+extra-deps:
5+- aeson-1.0.0.0
6+- insert-ordered-containers-0.2.0.0
57resolver: nightly-2016-07-15
swagger2.cabal+1−1
@@ -46,7 +46,7 @@ library
4646 , hashable
4747 , generics-sop >=0.2 && <0.3
4848 , http-media
49− , insert-ordered-containers >=0.1.0.0 && <0.2
49+ , insert-ordered-containers >=0.1.0.0 && <0.3
5050 , lens
5151 , mtl
5252 , network