@@ -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#include "overlapping-compat.h"
17#include "overlapping-compat.h"
17module Data.Swagger.Internal.Schema where
18module Data.Swagger.Internal.Schema where
@@ -65,6 +66,13 @@ import Data.Swagger.SchemaOptions
65import Data.Swagger.Lens (name, schema)
66import Data.Swagger.Lens (name, schema)
69+#if __GLASGOW_HASKELL__ < 800
71+import qualified Data.ByteString as BS
72+import qualified Data.ByteString.Lazy as BSL
73+import GHC.TypeLits (TypeError, ErrorMessage(..))
68unnamed :: Schema -> NamedSchema
76unnamed :: Schema -> NamedSchema
69unnamed schema = NamedSchema Nothing schema
77unnamed schema = NamedSchema Nothing schema
@@ -475,6 +483,18 @@ instance ToSchema UTCTime where
475instance ToSchema T.Text where declareNamedSchema = plain . paramSchemaToSchema
483instance ToSchema T.Text where declareNamedSchema = plain . paramSchemaToSchema
476instance ToSchema TL.Text where declareNamedSchema = plain . paramSchemaToSchema
484instance ToSchema TL.Text where declareNamedSchema = plain . paramSchemaToSchema
486+#if __GLASGOW_HASKELL__ < 800
488+type family ToSchemaByteStringError bs where
489+ ToSchemaByteStringError bs = TypeError
490+ ( Text "Impossible to have an instance " :<>: ShowType (ToSchema bs) :<>: Text "."
491+ :$$: Text "Please, use a newtype wrapper around " :<>: ShowType bs :<>: Text " instead."
492+ :$$: Text "Consider using byteSchema or binarySchema templates." )
494+instance ToSchemaByteStringError BS.ByteString => ToSchema BS.ByteString where declareNamedSchema = error "impossible"
495+instance ToSchemaByteStringError BSL.ByteString => ToSchema BSL.ByteString where declareNamedSchema = error "impossible"
478instance ToSchema IntSet where declareNamedSchema _ = declareNamedSchema (Proxy :: Proxy (Set Int))
498instance ToSchema IntSet where declareNamedSchema _ = declareNamedSchema (Proxy :: Proxy (Set Int))
480-- | NOTE: This schema does not account for the uniqueness of keys.
500-- | NOTE: This schema does not account for the uniqueness of keys.