@@ -1,5 +1,6 @@
11{-# OPTIONS_GHC -Wno-orphans #-}
22{-# LANGUAGE CPP #-}
3+
34module Text.Email.Extra
45 ( validateEmail
56 , emailToText
@@ -24,6 +25,10 @@ import Database.PostgreSQL.Simple.ToField as PG
2425import Control.Monad
2526import Data.Aeson
2627#endif
28+#ifdef SCHEMA
29+import Data.OpenApi
30+import Data.Proxy
31+#endif
2732
2833-- | Validate that the domain part in this email address is
2934-- in fact a domain name.
@@ -105,3 +110,11 @@ instance ToJSON EmailAddress where
105110instance FromJSON EmailAddress where
106111 parseJSON = parseJSON >=> either fail pure . validateEmail . Text.encodeUtf8
107112#endif
113+
114+#ifdef SCHEMA
115+instance ToSchema EmailAddress where
116+ declareNamedSchema _ = declareNamedSchema (Proxy :: Proxy Text)
117+
118+instance ToParamSchema EmailAddress where
119+ toParamSchema _ = toParamSchema (Proxy :: Proxy Text)
120+#endif