{-# OPTIONS_GHC -Wno-orphans #-}
{-# OPTIONS_GHC -Wno-unused-imports #-}

-- | Functions and instances for authentication
module WebGear.OpenApi.Trait.Auth () where

import Control.Lens ((?~))
import Data.Function ((&))
import Data.OpenApi (
  Definitions,
  HasType (type_),
  NamedSchema,
  Schema,
  ToParamSchema (..),
  ToSchema (..),
  paramSchemaToSchema,
 )
import Data.OpenApi.Declare (Declare)
import Data.OpenApi.Internal.Schema (plain)
import Data.Proxy (Proxy (..))
import GHC.TypeLits (KnownSymbol)
import WebGear.Core.Trait.Auth.Common (AuthToken)

instance (KnownSymbol scheme) => ToSchema (AuthToken scheme) where
  declareNamedSchema :: Proxy (AuthToken scheme) -> Declare (Definitions Schema) NamedSchema
  declareNamedSchema :: Proxy (AuthToken scheme)
-> Declare (Definitions Schema) NamedSchema
declareNamedSchema Proxy (AuthToken scheme)
_ = Proxy String -> Declare (Definitions Schema) NamedSchema
forall a.
ToSchema a =>
Proxy a -> Declare (Definitions Schema) NamedSchema
declareNamedSchema (Proxy String -> Declare (Definitions Schema) NamedSchema)
-> Proxy String -> Declare (Definitions Schema) NamedSchema
forall a b. (a -> b) -> a -> b
$ forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @String