@@ -13,6 +13,7 @@
13{-# LANGUAGE TypeFamilies #-}
13{-# LANGUAGE TypeFamilies #-}
14{-# LANGUAGE TypeOperators #-}
14{-# LANGUAGE TypeOperators #-}
15{-# LANGUAGE TypeSynonymInstances #-}
15{-# LANGUAGE TypeSynonymInstances #-}
16+{-# LANGUAGE UndecidableInstances #-}
16#if __GLASGOW_HASKELL__ >= 800
17#if __GLASGOW_HASKELL__ >= 800
17-- Few generics related redundant constraints
18-- Few generics related redundant constraints
18{-# OPTIONS_GHC -Wno-redundant-constraints #-}
19{-# OPTIONS_GHC -Wno-redundant-constraints #-}
@@ -66,6 +67,13 @@ import Data.Swagger.SchemaOptions
66import Data.Swagger.Lens (name, schema)
67import Data.Swagger.Lens (name, schema)
70+#if __GLASGOW_HASKELL__ < 800
72+import qualified Data.ByteString as BS
73+import qualified Data.ByteString.Lazy as BSL
74+import GHC.TypeLits (TypeError, ErrorMessage(..))
69unnamed :: Schema -> NamedSchema
77unnamed :: Schema -> NamedSchema
70unnamed schema = NamedSchema Nothing schema
78unnamed schema = NamedSchema Nothing schema
@@ -481,6 +489,18 @@ instance ToSchema UTCTime where
481instance ToSchema T.Text where declareNamedSchema = plain . paramSchemaToSchema
489instance ToSchema T.Text where declareNamedSchema = plain . paramSchemaToSchema
482instance ToSchema TL.Text where declareNamedSchema = plain . paramSchemaToSchema
490instance ToSchema TL.Text where declareNamedSchema = plain . paramSchemaToSchema
492+#if __GLASGOW_HASKELL__ < 800
494+type family ToSchemaByteStringError bs where
495+ ToSchemaByteStringError bs = TypeError
496+ ( Text "Impossible to have an instance " :<>: ShowType (ToSchema bs) :<>: Text "."
497+ :$$: Text "Please, use a newtype wrapper around " :<>: ShowType bs :<>: Text " instead."
498+ :$$: Text "Consider using byteSchema or binarySchema templates." )
500+instance ToSchemaByteStringError BS.ByteString => ToSchema BS.ByteString where declareNamedSchema = error "impossible"
501+instance ToSchemaByteStringError BSL.ByteString => ToSchema BSL.ByteString where declareNamedSchema = error "impossible"
484instance ToSchema IntSet where declareNamedSchema _ = declareNamedSchema (Proxy :: Proxy (Set Int))
504instance ToSchema IntSet where declareNamedSchema _ = declareNamedSchema (Proxy :: Proxy (Set Int))
486-- | NOTE: This schema does not account for the uniqueness of keys.
506-- | NOTE: This schema does not account for the uniqueness of keys.