{-# LANGUAGE ScopedTypeVariables #-}
module Jordan.OpenAPI
(
getFromNamed,
getToNamed,
getFromRef,
getToRef,
JordanFromJSONSchema (..),
JordanToJSONSchema (..),
)
where
import Data.Functor.Contravariant (contramap)
import Data.OpenApi.Schema (ToSchema (..))
import Data.Proxy (Proxy (..))
import Data.Typeable (Typeable (..))
import Jordan.FromJSON.Class (FromJSON (..))
import Jordan.OpenAPI.Internal (getFromNamed, getFromRef, getToNamed, getToRef)
import Jordan.ToJSON.Class (ToJSON (..))
newtype JordanFromJSONSchema a = JordanFromJSONSchema {JordanFromJSONSchema a -> a
getJordanFromJSONSchema :: a}
instance (FromJSON a) => FromJSON (JordanFromJSONSchema a) where
fromJSON :: f (JordanFromJSONSchema a)
fromJSON = a -> JordanFromJSONSchema a
forall a. a -> JordanFromJSONSchema a
JordanFromJSONSchema (a -> JordanFromJSONSchema a) -> f a -> f (JordanFromJSONSchema a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> f a
forall value (f :: * -> *).
(FromJSON value, JSONParser f) =>
f value
fromJSON
instance (Typeable a, FromJSON a) => ToSchema (JordanFromJSONSchema a) where
declareNamedSchema :: Proxy (JordanFromJSONSchema a)
-> Declare (Definitions Schema) NamedSchema
declareNamedSchema (Proxy (JordanFromJSONSchema a)
Proxy :: Proxy (JordanFromJSONSchema a)) = Proxy a -> Declare (Definitions Schema) NamedSchema
forall a.
FromJSON a =>
Proxy a -> Declare (Definitions Schema) NamedSchema
getFromNamed (Proxy a
forall k (t :: k). Proxy t
Proxy :: Proxy a)
newtype JordanToJSONSchema a = JordanToJSONSchema {JordanToJSONSchema a -> a
getJordanToJSONSchema :: a}
instance (ToJSON a) => ToJSON (JordanToJSONSchema a) where
toJSON :: f (JordanToJSONSchema a)
toJSON = (JordanToJSONSchema a -> a) -> f a -> f (JordanToJSONSchema a)
forall (f :: * -> *) a b. Contravariant f => (a -> b) -> f b -> f a
contramap JordanToJSONSchema a -> a
forall a. JordanToJSONSchema a -> a
getJordanToJSONSchema f a
forall v (f :: * -> *). (ToJSON v, JSONSerializer f) => f v
toJSON
instance (Typeable a, ToJSON a) => ToSchema (JordanToJSONSchema a) where
declareNamedSchema :: Proxy (JordanToJSONSchema a)
-> Declare (Definitions Schema) NamedSchema
declareNamedSchema (Proxy (JordanToJSONSchema a)
Proxy :: Proxy (JordanToJSONSchema a)) = Proxy a -> Declare (Definitions Schema) NamedSchema
forall a.
ToJSON a =>
Proxy a -> Declare (Definitions Schema) NamedSchema
getToNamed (Proxy a
forall k (t :: k). Proxy t
Proxy :: Proxy a)