{-# LANGUAGE OverloadedRecordDot #-}
{-# LANGUAGE StrictData #-}

-- This file is part of the Wire Server implementation.
--
-- Copyright (C) 2022 Wire Swiss GmbH <opensource@wire.com>
--
-- This program is free software: you can redistribute it and/or modify it under
-- the terms of the GNU Affero General Public License as published by the Free
-- Software Foundation, either version 3 of the License, or (at your option) any
-- later version.
--
-- This program is distributed in the hope that it will be useful, but WITHOUT
-- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
-- details.
--
-- You should have received a copy of the GNU Affero General Public License along
-- with this program. If not, see <https://www.gnu.org/licenses/>.

module Wire.API.Team.Invitation
  ( InvitationRequest (..),
    Invitation (..),
    InvitationList (..),
    InvitationLocation (..),
    AcceptTeamInvitation (..),
    HeadInvitationByEmailResult (..),
    HeadInvitationsResponses,
  )
where

import Control.Lens ((?~))
import Data.Aeson qualified as A
import Data.ByteString.Conversion
import Data.Id
import Data.Json.Util
import Data.Misc
import Data.OpenApi qualified as S
import Data.SOP
import Data.Schema
import Data.Text.Encoding qualified as TE
import Imports
import Servant (FromHttpApiData (..), ToHttpApiData (..))
import URI.ByteString
import Wire.API.Error
import Wire.API.Error.Brig
import Wire.API.Routes.MultiVerb
import Wire.API.Team.Role (Role, defaultRole)
import Wire.API.User
import Wire.Arbitrary (Arbitrary, GenericUniform (..))

--------------------------------------------------------------------------------
-- InvitationRequest

data InvitationRequest = InvitationRequest
  { InvitationRequest -> Maybe Locale
locale :: Maybe Locale,
    InvitationRequest -> Maybe Role
role :: Maybe Role,
    InvitationRequest -> Maybe Name
inviteeName :: Maybe Name,
    InvitationRequest -> EmailAddress
inviteeEmail :: EmailAddress
  }
  deriving stock (InvitationRequest -> InvitationRequest -> Bool
(InvitationRequest -> InvitationRequest -> Bool)
-> (InvitationRequest -> InvitationRequest -> Bool)
-> Eq InvitationRequest
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: InvitationRequest -> InvitationRequest -> Bool
== :: InvitationRequest -> InvitationRequest -> Bool
$c/= :: InvitationRequest -> InvitationRequest -> Bool
/= :: InvitationRequest -> InvitationRequest -> Bool
Eq, Int -> InvitationRequest -> ShowS
[InvitationRequest] -> ShowS
InvitationRequest -> String
(Int -> InvitationRequest -> ShowS)
-> (InvitationRequest -> String)
-> ([InvitationRequest] -> ShowS)
-> Show InvitationRequest
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> InvitationRequest -> ShowS
showsPrec :: Int -> InvitationRequest -> ShowS
$cshow :: InvitationRequest -> String
show :: InvitationRequest -> String
$cshowList :: [InvitationRequest] -> ShowS
showList :: [InvitationRequest] -> ShowS
Show, (forall x. InvitationRequest -> Rep InvitationRequest x)
-> (forall x. Rep InvitationRequest x -> InvitationRequest)
-> Generic InvitationRequest
forall x. Rep InvitationRequest x -> InvitationRequest
forall x. InvitationRequest -> Rep InvitationRequest x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. InvitationRequest -> Rep InvitationRequest x
from :: forall x. InvitationRequest -> Rep InvitationRequest x
$cto :: forall x. Rep InvitationRequest x -> InvitationRequest
to :: forall x. Rep InvitationRequest x -> InvitationRequest
Generic)
  deriving (Gen InvitationRequest
Gen InvitationRequest
-> (InvitationRequest -> [InvitationRequest])
-> Arbitrary InvitationRequest
InvitationRequest -> [InvitationRequest]
forall a. Gen a -> (a -> [a]) -> Arbitrary a
$carbitrary :: Gen InvitationRequest
arbitrary :: Gen InvitationRequest
$cshrink :: InvitationRequest -> [InvitationRequest]
shrink :: InvitationRequest -> [InvitationRequest]
Arbitrary) via (GenericUniform InvitationRequest)
  deriving (Value -> Parser [InvitationRequest]
Value -> Parser InvitationRequest
(Value -> Parser InvitationRequest)
-> (Value -> Parser [InvitationRequest])
-> FromJSON InvitationRequest
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
$cparseJSON :: Value -> Parser InvitationRequest
parseJSON :: Value -> Parser InvitationRequest
$cparseJSONList :: Value -> Parser [InvitationRequest]
parseJSONList :: Value -> Parser [InvitationRequest]
A.FromJSON, [InvitationRequest] -> Value
[InvitationRequest] -> Encoding
InvitationRequest -> Value
InvitationRequest -> Encoding
(InvitationRequest -> Value)
-> (InvitationRequest -> Encoding)
-> ([InvitationRequest] -> Value)
-> ([InvitationRequest] -> Encoding)
-> ToJSON InvitationRequest
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
$ctoJSON :: InvitationRequest -> Value
toJSON :: InvitationRequest -> Value
$ctoEncoding :: InvitationRequest -> Encoding
toEncoding :: InvitationRequest -> Encoding
$ctoJSONList :: [InvitationRequest] -> Value
toJSONList :: [InvitationRequest] -> Value
$ctoEncodingList :: [InvitationRequest] -> Encoding
toEncodingList :: [InvitationRequest] -> Encoding
A.ToJSON, Typeable InvitationRequest
Typeable InvitationRequest =>
(Proxy InvitationRequest
 -> Declare (Definitions Schema) NamedSchema)
-> ToSchema InvitationRequest
Proxy InvitationRequest -> Declare (Definitions Schema) NamedSchema
forall a.
Typeable a =>
(Proxy a -> Declare (Definitions Schema) NamedSchema) -> ToSchema a
$cdeclareNamedSchema :: Proxy InvitationRequest -> Declare (Definitions Schema) NamedSchema
declareNamedSchema :: Proxy InvitationRequest -> Declare (Definitions Schema) NamedSchema
S.ToSchema) via (Schema InvitationRequest)

instance ToSchema InvitationRequest where
  schema :: ValueSchema NamedSwaggerDoc InvitationRequest
schema =
    Text
-> (NamedSwaggerDoc -> NamedSwaggerDoc)
-> ObjectSchema SwaggerDoc InvitationRequest
-> ValueSchema NamedSwaggerDoc InvitationRequest
forall doc doc' a.
HasObject doc doc' =>
Text -> (doc' -> doc') -> ObjectSchema doc a -> ValueSchema doc' a
objectWithDocModifier Text
"InvitationRequest" ((Maybe Text -> Identity (Maybe Text))
-> NamedSwaggerDoc -> Identity NamedSwaggerDoc
forall s a. HasDescription s a => Lens' s a
Lens' NamedSwaggerDoc (Maybe Text)
description ((Maybe Text -> Identity (Maybe Text))
 -> NamedSwaggerDoc -> Identity NamedSwaggerDoc)
-> Text -> NamedSwaggerDoc -> NamedSwaggerDoc
forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ Text
"A request to join a team on Wire.") (ObjectSchema SwaggerDoc InvitationRequest
 -> ValueSchema NamedSwaggerDoc InvitationRequest)
-> ObjectSchema SwaggerDoc InvitationRequest
-> ValueSchema NamedSwaggerDoc InvitationRequest
forall a b. (a -> b) -> a -> b
$
      Maybe Locale
-> Maybe Role -> Maybe Name -> EmailAddress -> InvitationRequest
InvitationRequest
        (Maybe Locale
 -> Maybe Role -> Maybe Name -> EmailAddress -> InvitationRequest)
-> SchemaP
     SwaggerDoc Object [Pair] InvitationRequest (Maybe Locale)
-> SchemaP
     SwaggerDoc
     Object
     [Pair]
     InvitationRequest
     (Maybe Role -> Maybe Name -> EmailAddress -> InvitationRequest)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> InvitationRequest -> Maybe Locale
locale
          (InvitationRequest -> Maybe Locale)
-> SchemaP SwaggerDoc Object [Pair] (Maybe Locale) (Maybe Locale)
-> SchemaP
     SwaggerDoc Object [Pair] InvitationRequest (Maybe Locale)
forall (p :: * -> * -> *) a a' b.
Profunctor p =>
(a -> a') -> p a' b -> p a b
.= Text
-> (NamedSwaggerDoc -> NamedSwaggerDoc)
-> SchemaP NamedSwaggerDoc Value Value (Maybe Locale) Locale
-> SchemaP SwaggerDoc Object [Pair] (Maybe Locale) (Maybe Locale)
forall doc doc' a b.
(HasOpt doc, HasField doc' doc) =>
Text
-> (doc' -> doc')
-> SchemaP doc' Value Value a b
-> SchemaP doc Object [Pair] a (Maybe b)
optFieldWithDocModifier Text
"locale" ((Maybe Text -> Identity (Maybe Text))
-> NamedSwaggerDoc -> Identity NamedSwaggerDoc
forall s a. HasDescription s a => Lens' s a
Lens' NamedSwaggerDoc (Maybe Text)
description ((Maybe Text -> Identity (Maybe Text))
 -> NamedSwaggerDoc -> Identity NamedSwaggerDoc)
-> Text -> NamedSwaggerDoc -> NamedSwaggerDoc
forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ Text
"Locale to use for the invitation.") (Value
-> SchemaP NamedSwaggerDoc Value Value Locale Locale
-> SchemaP NamedSwaggerDoc Value Value (Maybe Locale) Locale
forall w d v a b.
w -> SchemaP d v w a b -> SchemaP d v w (Maybe a) b
maybeWithDefault Value
A.Null SchemaP NamedSwaggerDoc Value Value Locale Locale
forall a. ToSchema a => ValueSchema NamedSwaggerDoc a
schema)
        SchemaP
  SwaggerDoc
  Object
  [Pair]
  InvitationRequest
  (Maybe Role -> Maybe Name -> EmailAddress -> InvitationRequest)
-> SchemaP SwaggerDoc Object [Pair] InvitationRequest (Maybe Role)
-> SchemaP
     SwaggerDoc
     Object
     [Pair]
     InvitationRequest
     (Maybe Name -> EmailAddress -> InvitationRequest)
forall a b.
SchemaP SwaggerDoc Object [Pair] InvitationRequest (a -> b)
-> SchemaP SwaggerDoc Object [Pair] InvitationRequest a
-> SchemaP SwaggerDoc Object [Pair] InvitationRequest b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (.role)
          (InvitationRequest -> Maybe Role)
-> SchemaP SwaggerDoc Object [Pair] (Maybe Role) (Maybe Role)
-> SchemaP SwaggerDoc Object [Pair] InvitationRequest (Maybe Role)
forall (p :: * -> * -> *) a a' b.
Profunctor p =>
(a -> a') -> p a' b -> p a b
.= Text
-> (NamedSwaggerDoc -> NamedSwaggerDoc)
-> SchemaP NamedSwaggerDoc Value Value (Maybe Role) Role
-> SchemaP SwaggerDoc Object [Pair] (Maybe Role) (Maybe Role)
forall doc doc' a b.
(HasOpt doc, HasField doc' doc) =>
Text
-> (doc' -> doc')
-> SchemaP doc' Value Value a b
-> SchemaP doc Object [Pair] a (Maybe b)
optFieldWithDocModifier Text
"role" ((Maybe Text -> Identity (Maybe Text))
-> NamedSwaggerDoc -> Identity NamedSwaggerDoc
forall s a. HasDescription s a => Lens' s a
Lens' NamedSwaggerDoc (Maybe Text)
description ((Maybe Text -> Identity (Maybe Text))
 -> NamedSwaggerDoc -> Identity NamedSwaggerDoc)
-> Text -> NamedSwaggerDoc -> NamedSwaggerDoc
forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ Text
"Role of the invitee (invited user).") (Value
-> SchemaP NamedSwaggerDoc Value Value Role Role
-> SchemaP NamedSwaggerDoc Value Value (Maybe Role) Role
forall w d v a b.
w -> SchemaP d v w a b -> SchemaP d v w (Maybe a) b
maybeWithDefault Value
A.Null SchemaP NamedSwaggerDoc Value Value Role Role
forall a. ToSchema a => ValueSchema NamedSwaggerDoc a
schema)
        SchemaP
  SwaggerDoc
  Object
  [Pair]
  InvitationRequest
  (Maybe Name -> EmailAddress -> InvitationRequest)
-> SchemaP SwaggerDoc Object [Pair] InvitationRequest (Maybe Name)
-> SchemaP
     SwaggerDoc
     Object
     [Pair]
     InvitationRequest
     (EmailAddress -> InvitationRequest)
forall a b.
SchemaP SwaggerDoc Object [Pair] InvitationRequest (a -> b)
-> SchemaP SwaggerDoc Object [Pair] InvitationRequest a
-> SchemaP SwaggerDoc Object [Pair] InvitationRequest b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (.inviteeName)
          (InvitationRequest -> Maybe Name)
-> SchemaP SwaggerDoc Object [Pair] (Maybe Name) (Maybe Name)
-> SchemaP SwaggerDoc Object [Pair] InvitationRequest (Maybe Name)
forall (p :: * -> * -> *) a a' b.
Profunctor p =>
(a -> a') -> p a' b -> p a b
.= Text
-> (NamedSwaggerDoc -> NamedSwaggerDoc)
-> SchemaP NamedSwaggerDoc Value Value (Maybe Name) Name
-> SchemaP SwaggerDoc Object [Pair] (Maybe Name) (Maybe Name)
forall doc doc' a b.
(HasOpt doc, HasField doc' doc) =>
Text
-> (doc' -> doc')
-> SchemaP doc' Value Value a b
-> SchemaP doc Object [Pair] a (Maybe b)
optFieldWithDocModifier Text
"name" ((Maybe Text -> Identity (Maybe Text))
-> NamedSwaggerDoc -> Identity NamedSwaggerDoc
forall s a. HasDescription s a => Lens' s a
Lens' NamedSwaggerDoc (Maybe Text)
description ((Maybe Text -> Identity (Maybe Text))
 -> NamedSwaggerDoc -> Identity NamedSwaggerDoc)
-> Text -> NamedSwaggerDoc -> NamedSwaggerDoc
forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ Text
"Name of the invitee (1 - 128 characters).") (Value
-> SchemaP NamedSwaggerDoc Value Value Name Name
-> SchemaP NamedSwaggerDoc Value Value (Maybe Name) Name
forall w d v a b.
w -> SchemaP d v w a b -> SchemaP d v w (Maybe a) b
maybeWithDefault Value
A.Null SchemaP NamedSwaggerDoc Value Value Name Name
forall a. ToSchema a => ValueSchema NamedSwaggerDoc a
schema)
        SchemaP
  SwaggerDoc
  Object
  [Pair]
  InvitationRequest
  (EmailAddress -> InvitationRequest)
-> SchemaP SwaggerDoc Object [Pair] InvitationRequest EmailAddress
-> ObjectSchema SwaggerDoc InvitationRequest
forall a b.
SchemaP SwaggerDoc Object [Pair] InvitationRequest (a -> b)
-> SchemaP SwaggerDoc Object [Pair] InvitationRequest a
-> SchemaP SwaggerDoc Object [Pair] InvitationRequest b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (.inviteeEmail)
          (InvitationRequest -> EmailAddress)
-> SchemaP SwaggerDoc Object [Pair] EmailAddress EmailAddress
-> SchemaP SwaggerDoc Object [Pair] InvitationRequest EmailAddress
forall (p :: * -> * -> *) a a' b.
Profunctor p =>
(a -> a') -> p a' b -> p a b
.= Text
-> (NamedSwaggerDoc -> NamedSwaggerDoc)
-> SchemaP NamedSwaggerDoc Value Value EmailAddress EmailAddress
-> SchemaP SwaggerDoc Object [Pair] EmailAddress EmailAddress
forall doc' doc a b.
HasField doc' doc =>
Text
-> (doc' -> doc')
-> SchemaP doc' Value Value a b
-> SchemaP doc Object [Pair] a b
fieldWithDocModifier Text
"email" ((Maybe Text -> Identity (Maybe Text))
-> NamedSwaggerDoc -> Identity NamedSwaggerDoc
forall s a. HasDescription s a => Lens' s a
Lens' NamedSwaggerDoc (Maybe Text)
description ((Maybe Text -> Identity (Maybe Text))
 -> NamedSwaggerDoc -> Identity NamedSwaggerDoc)
-> Text -> NamedSwaggerDoc -> NamedSwaggerDoc
forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ Text
"Email of the invitee.") SchemaP NamedSwaggerDoc Value Value EmailAddress EmailAddress
forall a. ToSchema a => ValueSchema NamedSwaggerDoc a
schema

--------------------------------------------------------------------------------
-- Invitation

data Invitation = Invitation
  { Invitation -> TeamId
team :: TeamId,
    Invitation -> Role
role :: Role,
    Invitation -> InvitationId
invitationId :: InvitationId,
    Invitation -> UTCTimeMillis
createdAt :: UTCTimeMillis,
    -- | this is always 'Just' for new invitations, but for
    -- migration it is allowed to be 'Nothing'.
    Invitation -> Maybe UserId
createdBy :: Maybe UserId,
    Invitation -> EmailAddress
inviteeEmail :: EmailAddress,
    Invitation -> Maybe Name
inviteeName :: Maybe Name,
    Invitation -> Maybe (URIRef Absolute)
inviteeUrl :: Maybe (URIRef Absolute)
  }
  deriving stock (Invitation -> Invitation -> Bool
(Invitation -> Invitation -> Bool)
-> (Invitation -> Invitation -> Bool) -> Eq Invitation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Invitation -> Invitation -> Bool
== :: Invitation -> Invitation -> Bool
$c/= :: Invitation -> Invitation -> Bool
/= :: Invitation -> Invitation -> Bool
Eq, Int -> Invitation -> ShowS
[Invitation] -> ShowS
Invitation -> String
(Int -> Invitation -> ShowS)
-> (Invitation -> String)
-> ([Invitation] -> ShowS)
-> Show Invitation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Invitation -> ShowS
showsPrec :: Int -> Invitation -> ShowS
$cshow :: Invitation -> String
show :: Invitation -> String
$cshowList :: [Invitation] -> ShowS
showList :: [Invitation] -> ShowS
Show, (forall x. Invitation -> Rep Invitation x)
-> (forall x. Rep Invitation x -> Invitation) -> Generic Invitation
forall x. Rep Invitation x -> Invitation
forall x. Invitation -> Rep Invitation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Invitation -> Rep Invitation x
from :: forall x. Invitation -> Rep Invitation x
$cto :: forall x. Rep Invitation x -> Invitation
to :: forall x. Rep Invitation x -> Invitation
Generic)
  deriving (Gen Invitation
Gen Invitation
-> (Invitation -> [Invitation]) -> Arbitrary Invitation
Invitation -> [Invitation]
forall a. Gen a -> (a -> [a]) -> Arbitrary a
$carbitrary :: Gen Invitation
arbitrary :: Gen Invitation
$cshrink :: Invitation -> [Invitation]
shrink :: Invitation -> [Invitation]
Arbitrary) via (GenericUniform Invitation)
  deriving (Value -> Parser [Invitation]
Value -> Parser Invitation
(Value -> Parser Invitation)
-> (Value -> Parser [Invitation]) -> FromJSON Invitation
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
$cparseJSON :: Value -> Parser Invitation
parseJSON :: Value -> Parser Invitation
$cparseJSONList :: Value -> Parser [Invitation]
parseJSONList :: Value -> Parser [Invitation]
A.FromJSON, [Invitation] -> Value
[Invitation] -> Encoding
Invitation -> Value
Invitation -> Encoding
(Invitation -> Value)
-> (Invitation -> Encoding)
-> ([Invitation] -> Value)
-> ([Invitation] -> Encoding)
-> ToJSON Invitation
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
$ctoJSON :: Invitation -> Value
toJSON :: Invitation -> Value
$ctoEncoding :: Invitation -> Encoding
toEncoding :: Invitation -> Encoding
$ctoJSONList :: [Invitation] -> Value
toJSONList :: [Invitation] -> Value
$ctoEncodingList :: [Invitation] -> Encoding
toEncodingList :: [Invitation] -> Encoding
A.ToJSON, Typeable Invitation
Typeable Invitation =>
(Proxy Invitation -> Declare (Definitions Schema) NamedSchema)
-> ToSchema Invitation
Proxy Invitation -> Declare (Definitions Schema) NamedSchema
forall a.
Typeable a =>
(Proxy a -> Declare (Definitions Schema) NamedSchema) -> ToSchema a
$cdeclareNamedSchema :: Proxy Invitation -> Declare (Definitions Schema) NamedSchema
declareNamedSchema :: Proxy Invitation -> Declare (Definitions Schema) NamedSchema
S.ToSchema) via (Schema Invitation)

instance ToSchema Invitation where
  schema :: ValueSchema NamedSwaggerDoc Invitation
schema =
    Text
-> (NamedSwaggerDoc -> NamedSwaggerDoc)
-> ObjectSchema SwaggerDoc Invitation
-> ValueSchema NamedSwaggerDoc Invitation
forall doc doc' a.
HasObject doc doc' =>
Text -> (doc' -> doc') -> ObjectSchema doc a -> ValueSchema doc' a
objectWithDocModifier
      Text
"Invitation"
      ((Maybe Text -> Identity (Maybe Text))
-> NamedSwaggerDoc -> Identity NamedSwaggerDoc
forall s a. HasDescription s a => Lens' s a
Lens' NamedSwaggerDoc (Maybe Text)
description ((Maybe Text -> Identity (Maybe Text))
 -> NamedSwaggerDoc -> Identity NamedSwaggerDoc)
-> Text -> NamedSwaggerDoc -> NamedSwaggerDoc
forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ Text
"An invitation to join a team on Wire")
      (ObjectSchema SwaggerDoc Invitation
 -> ValueSchema NamedSwaggerDoc Invitation)
-> ObjectSchema SwaggerDoc Invitation
-> ValueSchema NamedSwaggerDoc Invitation
forall a b. (a -> b) -> a -> b
$ TeamId
-> Role
-> InvitationId
-> UTCTimeMillis
-> Maybe UserId
-> EmailAddress
-> Maybe Name
-> Maybe (URIRef Absolute)
-> Invitation
Invitation
        (TeamId
 -> Role
 -> InvitationId
 -> UTCTimeMillis
 -> Maybe UserId
 -> EmailAddress
 -> Maybe Name
 -> Maybe (URIRef Absolute)
 -> Invitation)
-> SchemaP SwaggerDoc Object [Pair] Invitation TeamId
-> SchemaP
     SwaggerDoc
     Object
     [Pair]
     Invitation
     (Role
      -> InvitationId
      -> UTCTimeMillis
      -> Maybe UserId
      -> EmailAddress
      -> Maybe Name
      -> Maybe (URIRef Absolute)
      -> Invitation)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (.team)
          (Invitation -> TeamId)
-> SchemaP SwaggerDoc Object [Pair] TeamId TeamId
-> SchemaP SwaggerDoc Object [Pair] Invitation TeamId
forall (p :: * -> * -> *) a a' b.
Profunctor p =>
(a -> a') -> p a' b -> p a b
.= Text
-> (NamedSwaggerDoc -> NamedSwaggerDoc)
-> SchemaP NamedSwaggerDoc Value Value TeamId TeamId
-> SchemaP SwaggerDoc Object [Pair] TeamId TeamId
forall doc' doc a b.
HasField doc' doc =>
Text
-> (doc' -> doc')
-> SchemaP doc' Value Value a b
-> SchemaP doc Object [Pair] a b
fieldWithDocModifier Text
"team" ((Maybe Text -> Identity (Maybe Text))
-> NamedSwaggerDoc -> Identity NamedSwaggerDoc
forall s a. HasDescription s a => Lens' s a
Lens' NamedSwaggerDoc (Maybe Text)
description ((Maybe Text -> Identity (Maybe Text))
 -> NamedSwaggerDoc -> Identity NamedSwaggerDoc)
-> Text -> NamedSwaggerDoc -> NamedSwaggerDoc
forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ Text
"Team ID of the inviting team") SchemaP NamedSwaggerDoc Value Value TeamId TeamId
forall a. ToSchema a => ValueSchema NamedSwaggerDoc a
schema
        SchemaP
  SwaggerDoc
  Object
  [Pair]
  Invitation
  (Role
   -> InvitationId
   -> UTCTimeMillis
   -> Maybe UserId
   -> EmailAddress
   -> Maybe Name
   -> Maybe (URIRef Absolute)
   -> Invitation)
-> SchemaP SwaggerDoc Object [Pair] Invitation Role
-> SchemaP
     SwaggerDoc
     Object
     [Pair]
     Invitation
     (InvitationId
      -> UTCTimeMillis
      -> Maybe UserId
      -> EmailAddress
      -> Maybe Name
      -> Maybe (URIRef Absolute)
      -> Invitation)
forall a b.
SchemaP SwaggerDoc Object [Pair] Invitation (a -> b)
-> SchemaP SwaggerDoc Object [Pair] Invitation a
-> SchemaP SwaggerDoc Object [Pair] Invitation b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (.role)
          -- clients, when leaving "role" empty, can leave the default role choice to us
          (Invitation -> Role)
-> SchemaP SwaggerDoc Object [Pair] Role Role
-> SchemaP SwaggerDoc Object [Pair] Invitation Role
forall (p :: * -> * -> *) a a' b.
Profunctor p =>
(a -> a') -> p a' b -> p a b
.= (Role -> Maybe Role -> Role
forall a. a -> Maybe a -> a
fromMaybe Role
defaultRole (Maybe Role -> Role)
-> SchemaP SwaggerDoc Object [Pair] Role (Maybe Role)
-> SchemaP SwaggerDoc Object [Pair] Role Role
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text
-> (NamedSwaggerDoc -> NamedSwaggerDoc)
-> SchemaP NamedSwaggerDoc Value Value Role Role
-> SchemaP SwaggerDoc Object [Pair] Role (Maybe Role)
forall doc doc' a b.
(HasOpt doc, HasField doc' doc) =>
Text
-> (doc' -> doc')
-> SchemaP doc' Value Value a b
-> SchemaP doc Object [Pair] a (Maybe b)
optFieldWithDocModifier Text
"role" ((Maybe Text -> Identity (Maybe Text))
-> NamedSwaggerDoc -> Identity NamedSwaggerDoc
forall s a. HasDescription s a => Lens' s a
Lens' NamedSwaggerDoc (Maybe Text)
description ((Maybe Text -> Identity (Maybe Text))
 -> NamedSwaggerDoc -> Identity NamedSwaggerDoc)
-> Text -> NamedSwaggerDoc -> NamedSwaggerDoc
forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ Text
"Role of the invited user") SchemaP NamedSwaggerDoc Value Value Role Role
forall a. ToSchema a => ValueSchema NamedSwaggerDoc a
schema)
        SchemaP
  SwaggerDoc
  Object
  [Pair]
  Invitation
  (InvitationId
   -> UTCTimeMillis
   -> Maybe UserId
   -> EmailAddress
   -> Maybe Name
   -> Maybe (URIRef Absolute)
   -> Invitation)
-> SchemaP SwaggerDoc Object [Pair] Invitation InvitationId
-> SchemaP
     SwaggerDoc
     Object
     [Pair]
     Invitation
     (UTCTimeMillis
      -> Maybe UserId
      -> EmailAddress
      -> Maybe Name
      -> Maybe (URIRef Absolute)
      -> Invitation)
forall a b.
SchemaP SwaggerDoc Object [Pair] Invitation (a -> b)
-> SchemaP SwaggerDoc Object [Pair] Invitation a
-> SchemaP SwaggerDoc Object [Pair] Invitation b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (.invitationId)
          (Invitation -> InvitationId)
-> SchemaP SwaggerDoc Object [Pair] InvitationId InvitationId
-> SchemaP SwaggerDoc Object [Pair] Invitation InvitationId
forall (p :: * -> * -> *) a a' b.
Profunctor p =>
(a -> a') -> p a' b -> p a b
.= Text
-> (NamedSwaggerDoc -> NamedSwaggerDoc)
-> SchemaP NamedSwaggerDoc Value Value InvitationId InvitationId
-> SchemaP SwaggerDoc Object [Pair] InvitationId InvitationId
forall doc' doc a b.
HasField doc' doc =>
Text
-> (doc' -> doc')
-> SchemaP doc' Value Value a b
-> SchemaP doc Object [Pair] a b
fieldWithDocModifier Text
"id" ((Maybe Text -> Identity (Maybe Text))
-> NamedSwaggerDoc -> Identity NamedSwaggerDoc
forall s a. HasDescription s a => Lens' s a
Lens' NamedSwaggerDoc (Maybe Text)
description ((Maybe Text -> Identity (Maybe Text))
 -> NamedSwaggerDoc -> Identity NamedSwaggerDoc)
-> Text -> NamedSwaggerDoc -> NamedSwaggerDoc
forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ Text
"UUID used to refer the invitation") SchemaP NamedSwaggerDoc Value Value InvitationId InvitationId
forall a. ToSchema a => ValueSchema NamedSwaggerDoc a
schema
        SchemaP
  SwaggerDoc
  Object
  [Pair]
  Invitation
  (UTCTimeMillis
   -> Maybe UserId
   -> EmailAddress
   -> Maybe Name
   -> Maybe (URIRef Absolute)
   -> Invitation)
-> SchemaP SwaggerDoc Object [Pair] Invitation UTCTimeMillis
-> SchemaP
     SwaggerDoc
     Object
     [Pair]
     Invitation
     (Maybe UserId
      -> EmailAddress
      -> Maybe Name
      -> Maybe (URIRef Absolute)
      -> Invitation)
forall a b.
SchemaP SwaggerDoc Object [Pair] Invitation (a -> b)
-> SchemaP SwaggerDoc Object [Pair] Invitation a
-> SchemaP SwaggerDoc Object [Pair] Invitation b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (.createdAt)
          (Invitation -> UTCTimeMillis)
-> SchemaP SwaggerDoc Object [Pair] UTCTimeMillis UTCTimeMillis
-> SchemaP SwaggerDoc Object [Pair] Invitation UTCTimeMillis
forall (p :: * -> * -> *) a a' b.
Profunctor p =>
(a -> a') -> p a' b -> p a b
.= Text
-> (NamedSwaggerDoc -> NamedSwaggerDoc)
-> SchemaP NamedSwaggerDoc Value Value UTCTimeMillis UTCTimeMillis
-> SchemaP SwaggerDoc Object [Pair] UTCTimeMillis UTCTimeMillis
forall doc' doc a b.
HasField doc' doc =>
Text
-> (doc' -> doc')
-> SchemaP doc' Value Value a b
-> SchemaP doc Object [Pair] a b
fieldWithDocModifier Text
"created_at" ((Maybe Text -> Identity (Maybe Text))
-> NamedSwaggerDoc -> Identity NamedSwaggerDoc
forall s a. HasDescription s a => Lens' s a
Lens' NamedSwaggerDoc (Maybe Text)
description ((Maybe Text -> Identity (Maybe Text))
 -> NamedSwaggerDoc -> Identity NamedSwaggerDoc)
-> Text -> NamedSwaggerDoc -> NamedSwaggerDoc
forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ Text
"Timestamp of invitation creation") SchemaP NamedSwaggerDoc Value Value UTCTimeMillis UTCTimeMillis
forall a. ToSchema a => ValueSchema NamedSwaggerDoc a
schema
        SchemaP
  SwaggerDoc
  Object
  [Pair]
  Invitation
  (Maybe UserId
   -> EmailAddress
   -> Maybe Name
   -> Maybe (URIRef Absolute)
   -> Invitation)
-> SchemaP SwaggerDoc Object [Pair] Invitation (Maybe UserId)
-> SchemaP
     SwaggerDoc
     Object
     [Pair]
     Invitation
     (EmailAddress
      -> Maybe Name -> Maybe (URIRef Absolute) -> Invitation)
forall a b.
SchemaP SwaggerDoc Object [Pair] Invitation (a -> b)
-> SchemaP SwaggerDoc Object [Pair] Invitation a
-> SchemaP SwaggerDoc Object [Pair] Invitation b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (.createdBy)
          (Invitation -> Maybe UserId)
-> SchemaP SwaggerDoc Object [Pair] (Maybe UserId) (Maybe UserId)
-> SchemaP SwaggerDoc Object [Pair] Invitation (Maybe UserId)
forall (p :: * -> * -> *) a a' b.
Profunctor p =>
(a -> a') -> p a' b -> p a b
.= Text
-> (NamedSwaggerDoc -> NamedSwaggerDoc)
-> SchemaP NamedSwaggerDoc Value Value (Maybe UserId) UserId
-> SchemaP SwaggerDoc Object [Pair] (Maybe UserId) (Maybe UserId)
forall doc doc' a b.
(HasOpt doc, HasField doc' doc) =>
Text
-> (doc' -> doc')
-> SchemaP doc' Value Value a b
-> SchemaP doc Object [Pair] a (Maybe b)
optFieldWithDocModifier Text
"created_by" ((Maybe Text -> Identity (Maybe Text))
-> NamedSwaggerDoc -> Identity NamedSwaggerDoc
forall s a. HasDescription s a => Lens' s a
Lens' NamedSwaggerDoc (Maybe Text)
description ((Maybe Text -> Identity (Maybe Text))
 -> NamedSwaggerDoc -> Identity NamedSwaggerDoc)
-> Text -> NamedSwaggerDoc -> NamedSwaggerDoc
forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ Text
"ID of the inviting user") (Value
-> SchemaP NamedSwaggerDoc Value Value UserId UserId
-> SchemaP NamedSwaggerDoc Value Value (Maybe UserId) UserId
forall w d v a b.
w -> SchemaP d v w a b -> SchemaP d v w (Maybe a) b
maybeWithDefault Value
A.Null SchemaP NamedSwaggerDoc Value Value UserId UserId
forall a. ToSchema a => ValueSchema NamedSwaggerDoc a
schema)
        SchemaP
  SwaggerDoc
  Object
  [Pair]
  Invitation
  (EmailAddress
   -> Maybe Name -> Maybe (URIRef Absolute) -> Invitation)
-> SchemaP SwaggerDoc Object [Pair] Invitation EmailAddress
-> SchemaP
     SwaggerDoc
     Object
     [Pair]
     Invitation
     (Maybe Name -> Maybe (URIRef Absolute) -> Invitation)
forall a b.
SchemaP SwaggerDoc Object [Pair] Invitation (a -> b)
-> SchemaP SwaggerDoc Object [Pair] Invitation a
-> SchemaP SwaggerDoc Object [Pair] Invitation b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (.inviteeEmail)
          (Invitation -> EmailAddress)
-> SchemaP SwaggerDoc Object [Pair] EmailAddress EmailAddress
-> SchemaP SwaggerDoc Object [Pair] Invitation EmailAddress
forall (p :: * -> * -> *) a a' b.
Profunctor p =>
(a -> a') -> p a' b -> p a b
.= Text
-> (NamedSwaggerDoc -> NamedSwaggerDoc)
-> SchemaP NamedSwaggerDoc Value Value EmailAddress EmailAddress
-> SchemaP SwaggerDoc Object [Pair] EmailAddress EmailAddress
forall doc' doc a b.
HasField doc' doc =>
Text
-> (doc' -> doc')
-> SchemaP doc' Value Value a b
-> SchemaP doc Object [Pair] a b
fieldWithDocModifier Text
"email" ((Maybe Text -> Identity (Maybe Text))
-> NamedSwaggerDoc -> Identity NamedSwaggerDoc
forall s a. HasDescription s a => Lens' s a
Lens' NamedSwaggerDoc (Maybe Text)
description ((Maybe Text -> Identity (Maybe Text))
 -> NamedSwaggerDoc -> Identity NamedSwaggerDoc)
-> Text -> NamedSwaggerDoc -> NamedSwaggerDoc
forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ Text
"Email of the invitee") SchemaP NamedSwaggerDoc Value Value EmailAddress EmailAddress
forall a. ToSchema a => ValueSchema NamedSwaggerDoc a
schema
        SchemaP
  SwaggerDoc
  Object
  [Pair]
  Invitation
  (Maybe Name -> Maybe (URIRef Absolute) -> Invitation)
-> SchemaP SwaggerDoc Object [Pair] Invitation (Maybe Name)
-> SchemaP
     SwaggerDoc
     Object
     [Pair]
     Invitation
     (Maybe (URIRef Absolute) -> Invitation)
forall a b.
SchemaP SwaggerDoc Object [Pair] Invitation (a -> b)
-> SchemaP SwaggerDoc Object [Pair] Invitation a
-> SchemaP SwaggerDoc Object [Pair] Invitation b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (.inviteeName)
          (Invitation -> Maybe Name)
-> SchemaP SwaggerDoc Object [Pair] (Maybe Name) (Maybe Name)
-> SchemaP SwaggerDoc Object [Pair] Invitation (Maybe Name)
forall (p :: * -> * -> *) a a' b.
Profunctor p =>
(a -> a') -> p a' b -> p a b
.= Text
-> (NamedSwaggerDoc -> NamedSwaggerDoc)
-> SchemaP NamedSwaggerDoc Value Value (Maybe Name) Name
-> SchemaP SwaggerDoc Object [Pair] (Maybe Name) (Maybe Name)
forall doc doc' a b.
(HasOpt doc, HasField doc' doc) =>
Text
-> (doc' -> doc')
-> SchemaP doc' Value Value a b
-> SchemaP doc Object [Pair] a (Maybe b)
optFieldWithDocModifier Text
"name" ((Maybe Text -> Identity (Maybe Text))
-> NamedSwaggerDoc -> Identity NamedSwaggerDoc
forall s a. HasDescription s a => Lens' s a
Lens' NamedSwaggerDoc (Maybe Text)
description ((Maybe Text -> Identity (Maybe Text))
 -> NamedSwaggerDoc -> Identity NamedSwaggerDoc)
-> Text -> NamedSwaggerDoc -> NamedSwaggerDoc
forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ Text
"Name of the invitee (1 - 128 characters)") (Value
-> SchemaP NamedSwaggerDoc Value Value Name Name
-> SchemaP NamedSwaggerDoc Value Value (Maybe Name) Name
forall w d v a b.
w -> SchemaP d v w a b -> SchemaP d v w (Maybe a) b
maybeWithDefault Value
A.Null SchemaP NamedSwaggerDoc Value Value Name Name
forall a. ToSchema a => ValueSchema NamedSwaggerDoc a
schema)
        SchemaP
  SwaggerDoc
  Object
  [Pair]
  Invitation
  (Maybe (URIRef Absolute) -> Invitation)
-> SchemaP
     SwaggerDoc Object [Pair] Invitation (Maybe (URIRef Absolute))
-> ObjectSchema SwaggerDoc Invitation
forall a b.
SchemaP SwaggerDoc Object [Pair] Invitation (a -> b)
-> SchemaP SwaggerDoc Object [Pair] Invitation a
-> SchemaP SwaggerDoc Object [Pair] Invitation b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ((URIRef Absolute -> Text) -> Maybe (URIRef Absolute) -> Maybe Text
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (ByteString -> Text
TE.decodeUtf8 (ByteString -> Text)
-> (URIRef Absolute -> ByteString) -> URIRef Absolute -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. URIRef Absolute -> ByteString
forall a. URIRef a -> ByteString
serializeURIRef') (Maybe (URIRef Absolute) -> Maybe Text)
-> (Invitation -> Maybe (URIRef Absolute))
-> Invitation
-> Maybe Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Invitation -> Maybe (URIRef Absolute)
inviteeUrl)
          (Invitation -> Maybe Text)
-> SchemaP
     SwaggerDoc Object [Pair] (Maybe Text) (Maybe (URIRef Absolute))
-> SchemaP
     SwaggerDoc Object [Pair] Invitation (Maybe (URIRef Absolute))
forall (p :: * -> * -> *) a a' b.
Profunctor p =>
(a -> a') -> p a' b -> p a b
.= Text
-> (NamedSwaggerDoc -> NamedSwaggerDoc)
-> SchemaP
     NamedSwaggerDoc Value Value (Maybe Text) (URIRef Absolute)
-> SchemaP
     SwaggerDoc Object [Pair] (Maybe Text) (Maybe (URIRef Absolute))
forall doc doc' a b.
(HasOpt doc, HasField doc' doc) =>
Text
-> (doc' -> doc')
-> SchemaP doc' Value Value a b
-> SchemaP doc Object [Pair] a (Maybe b)
optFieldWithDocModifier Text
"url" ((Maybe Text -> Identity (Maybe Text))
-> NamedSwaggerDoc -> Identity NamedSwaggerDoc
forall s a. HasDescription s a => Lens' s a
Lens' NamedSwaggerDoc (Maybe Text)
description ((Maybe Text -> Identity (Maybe Text))
 -> NamedSwaggerDoc -> Identity NamedSwaggerDoc)
-> Text -> NamedSwaggerDoc -> NamedSwaggerDoc
forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ Text
"URL of the invitation link to be sent to the invitee") (Value
-> SchemaP NamedSwaggerDoc Value Value Text (URIRef Absolute)
-> SchemaP
     NamedSwaggerDoc Value Value (Maybe Text) (URIRef Absolute)
forall w d v a b.
w -> SchemaP d v w a b -> SchemaP d v w (Maybe a) b
maybeWithDefault Value
A.Null SchemaP NamedSwaggerDoc Value Value Text (URIRef Absolute)
urlSchema)
    where
      urlSchema :: SchemaP NamedSwaggerDoc Value Value Text (URIRef Absolute)
urlSchema = Text
-> (Text -> Either String (URIRef Absolute))
-> SchemaP NamedSwaggerDoc Value Value Text (URIRef Absolute)
forall a.
Text
-> (Text -> Either String a)
-> SchemaP NamedSwaggerDoc Value Value Text a
parsedText Text
"URIRef Absolute" (Parser (URIRef Absolute)
-> ByteString -> Either String (URIRef Absolute)
forall a. Parser a -> ByteString -> Either String a
runParser (URIParserOptions -> Parser (URIRef Absolute)
uriParser URIParserOptions
strictURIParserOptions) (ByteString -> Either String (URIRef Absolute))
-> (Text -> ByteString) -> Text -> Either String (URIRef Absolute)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> ByteString
TE.encodeUtf8)

newtype InvitationLocation = InvitationLocation
  { InvitationLocation -> ByteString
unInvitationLocation :: ByteString
  }
  deriving stock (InvitationLocation -> InvitationLocation -> Bool
(InvitationLocation -> InvitationLocation -> Bool)
-> (InvitationLocation -> InvitationLocation -> Bool)
-> Eq InvitationLocation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: InvitationLocation -> InvitationLocation -> Bool
== :: InvitationLocation -> InvitationLocation -> Bool
$c/= :: InvitationLocation -> InvitationLocation -> Bool
/= :: InvitationLocation -> InvitationLocation -> Bool
Eq, Int -> InvitationLocation -> ShowS
[InvitationLocation] -> ShowS
InvitationLocation -> String
(Int -> InvitationLocation -> ShowS)
-> (InvitationLocation -> String)
-> ([InvitationLocation] -> ShowS)
-> Show InvitationLocation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> InvitationLocation -> ShowS
showsPrec :: Int -> InvitationLocation -> ShowS
$cshow :: InvitationLocation -> String
show :: InvitationLocation -> String
$cshowList :: [InvitationLocation] -> ShowS
showList :: [InvitationLocation] -> ShowS
Show, (forall x. InvitationLocation -> Rep InvitationLocation x)
-> (forall x. Rep InvitationLocation x -> InvitationLocation)
-> Generic InvitationLocation
forall x. Rep InvitationLocation x -> InvitationLocation
forall x. InvitationLocation -> Rep InvitationLocation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. InvitationLocation -> Rep InvitationLocation x
from :: forall x. InvitationLocation -> Rep InvitationLocation x
$cto :: forall x. Rep InvitationLocation x -> InvitationLocation
to :: forall x. Rep InvitationLocation x -> InvitationLocation
Generic)

instance S.ToParamSchema InvitationLocation where
  toParamSchema :: Proxy InvitationLocation -> Schema
toParamSchema Proxy InvitationLocation
_ =
    Schema
forall a. Monoid a => a
mempty
      Schema -> (Schema -> Schema) -> Schema
forall a b. a -> (a -> b) -> b
& (Maybe OpenApiType -> Identity (Maybe OpenApiType))
-> Schema -> Identity Schema
forall s a. HasType s a => Lens' s a
Lens' Schema (Maybe OpenApiType)
S.type_ ((Maybe OpenApiType -> Identity (Maybe OpenApiType))
 -> Schema -> Identity Schema)
-> OpenApiType -> Schema -> Schema
forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ OpenApiType
S.OpenApiString
      Schema -> (Schema -> Schema) -> Schema
forall a b. a -> (a -> b) -> b
& (Maybe Text -> Identity (Maybe Text)) -> Schema -> Identity Schema
forall s a. HasFormat s a => Lens' s a
Lens' Schema (Maybe Text)
S.format ((Maybe Text -> Identity (Maybe Text))
 -> Schema -> Identity Schema)
-> Text -> Schema -> Schema
forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ Text
"url"

instance FromHttpApiData InvitationLocation where
  parseUrlPiece :: Text -> Either Text InvitationLocation
parseUrlPiece = ByteString -> Either Text InvitationLocation
forall a. FromHttpApiData a => ByteString -> Either Text a
parseHeader (ByteString -> Either Text InvitationLocation)
-> (Text -> ByteString) -> Text -> Either Text InvitationLocation
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> ByteString
TE.encodeUtf8
  parseHeader :: ByteString -> Either Text InvitationLocation
parseHeader = InvitationLocation -> Either Text InvitationLocation
forall a. a -> Either Text a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (InvitationLocation -> Either Text InvitationLocation)
-> (ByteString -> InvitationLocation)
-> ByteString
-> Either Text InvitationLocation
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> InvitationLocation
InvitationLocation

instance ToHttpApiData InvitationLocation where
  toUrlPiece :: InvitationLocation -> Text
toUrlPiece = ByteString -> Text
TE.decodeUtf8 (ByteString -> Text)
-> (InvitationLocation -> ByteString) -> InvitationLocation -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. InvitationLocation -> ByteString
forall a. ToHttpApiData a => a -> ByteString
toHeader
  toHeader :: InvitationLocation -> ByteString
toHeader = InvitationLocation -> ByteString
unInvitationLocation

data HeadInvitationByEmailResult
  = InvitationByEmail
  | InvitationByEmailNotFound
  | InvitationByEmailMoreThanOne

type HeadInvitationsResponses =
  '[ ErrorResponse 'PendingInvitationNotFound,
     ErrorResponse 'ConflictingInvitations,
     RespondEmpty 200 "Pending invitation exists."
   ]

instance AsUnion HeadInvitationsResponses HeadInvitationByEmailResult where
  toUnion :: HeadInvitationByEmailResult
-> Union (ResponseTypes HeadInvitationsResponses)
toUnion HeadInvitationByEmailResult
InvitationByEmailNotFound = I DynError -> NS I '[DynError, DynError, ()]
forall {k} (a :: k -> *) (x :: k) (xs :: [k]). a x -> NS a (x : xs)
Z (DynError -> I DynError
forall a. a -> I a
I (forall (e :: StaticError). KnownError e => DynError
dynError @(MapError 'PendingInvitationNotFound)))
  toUnion HeadInvitationByEmailResult
InvitationByEmailMoreThanOne = NS I '[DynError, ()] -> NS I '[DynError, DynError, ()]
forall {k} (a :: k -> *) (xs :: [k]) (x :: k).
NS a xs -> NS a (x : xs)
S (I DynError -> NS I '[DynError, ()]
forall {k} (a :: k -> *) (x :: k) (xs :: [k]). a x -> NS a (x : xs)
Z (DynError -> I DynError
forall a. a -> I a
I (forall (e :: StaticError). KnownError e => DynError
dynError @(MapError 'ConflictingInvitations))))
  toUnion HeadInvitationByEmailResult
InvitationByEmail = NS I '[DynError, ()] -> NS I '[DynError, DynError, ()]
forall {k} (a :: k -> *) (xs :: [k]) (x :: k).
NS a xs -> NS a (x : xs)
S (NS I '[()] -> NS I '[DynError, ()]
forall {k} (a :: k -> *) (xs :: [k]) (x :: k).
NS a xs -> NS a (x : xs)
S (I () -> NS I '[()]
forall {k} (a :: k -> *) (x :: k) (xs :: [k]). a x -> NS a (x : xs)
Z (() -> I ()
forall a. a -> I a
I ())))

  fromUnion :: Union (ResponseTypes HeadInvitationsResponses)
-> HeadInvitationByEmailResult
fromUnion (Z (I x
_)) = HeadInvitationByEmailResult
InvitationByEmailNotFound
  fromUnion (S (Z (I x
_))) = HeadInvitationByEmailResult
InvitationByEmailMoreThanOne
  fromUnion (S (S (Z (I ())))) = HeadInvitationByEmailResult
InvitationByEmail
  fromUnion (S (S (S NS I xs
x))) = case NS I xs
x of {}

--------------------------------------------------------------------------------
-- InvitationList

data InvitationList = InvitationList
  { InvitationList -> [Invitation]
ilInvitations :: [Invitation],
    InvitationList -> Bool
ilHasMore :: Bool
  }
  deriving stock (InvitationList -> InvitationList -> Bool
(InvitationList -> InvitationList -> Bool)
-> (InvitationList -> InvitationList -> Bool) -> Eq InvitationList
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: InvitationList -> InvitationList -> Bool
== :: InvitationList -> InvitationList -> Bool
$c/= :: InvitationList -> InvitationList -> Bool
/= :: InvitationList -> InvitationList -> Bool
Eq, Int -> InvitationList -> ShowS
[InvitationList] -> ShowS
InvitationList -> String
(Int -> InvitationList -> ShowS)
-> (InvitationList -> String)
-> ([InvitationList] -> ShowS)
-> Show InvitationList
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> InvitationList -> ShowS
showsPrec :: Int -> InvitationList -> ShowS
$cshow :: InvitationList -> String
show :: InvitationList -> String
$cshowList :: [InvitationList] -> ShowS
showList :: [InvitationList] -> ShowS
Show, (forall x. InvitationList -> Rep InvitationList x)
-> (forall x. Rep InvitationList x -> InvitationList)
-> Generic InvitationList
forall x. Rep InvitationList x -> InvitationList
forall x. InvitationList -> Rep InvitationList x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. InvitationList -> Rep InvitationList x
from :: forall x. InvitationList -> Rep InvitationList x
$cto :: forall x. Rep InvitationList x -> InvitationList
to :: forall x. Rep InvitationList x -> InvitationList
Generic)
  deriving (Gen InvitationList
Gen InvitationList
-> (InvitationList -> [InvitationList]) -> Arbitrary InvitationList
InvitationList -> [InvitationList]
forall a. Gen a -> (a -> [a]) -> Arbitrary a
$carbitrary :: Gen InvitationList
arbitrary :: Gen InvitationList
$cshrink :: InvitationList -> [InvitationList]
shrink :: InvitationList -> [InvitationList]
Arbitrary) via (GenericUniform InvitationList)
  deriving (Value -> Parser [InvitationList]
Value -> Parser InvitationList
(Value -> Parser InvitationList)
-> (Value -> Parser [InvitationList]) -> FromJSON InvitationList
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
$cparseJSON :: Value -> Parser InvitationList
parseJSON :: Value -> Parser InvitationList
$cparseJSONList :: Value -> Parser [InvitationList]
parseJSONList :: Value -> Parser [InvitationList]
A.FromJSON, [InvitationList] -> Value
[InvitationList] -> Encoding
InvitationList -> Value
InvitationList -> Encoding
(InvitationList -> Value)
-> (InvitationList -> Encoding)
-> ([InvitationList] -> Value)
-> ([InvitationList] -> Encoding)
-> ToJSON InvitationList
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
$ctoJSON :: InvitationList -> Value
toJSON :: InvitationList -> Value
$ctoEncoding :: InvitationList -> Encoding
toEncoding :: InvitationList -> Encoding
$ctoJSONList :: [InvitationList] -> Value
toJSONList :: [InvitationList] -> Value
$ctoEncodingList :: [InvitationList] -> Encoding
toEncodingList :: [InvitationList] -> Encoding
A.ToJSON, Typeable InvitationList
Typeable InvitationList =>
(Proxy InvitationList -> Declare (Definitions Schema) NamedSchema)
-> ToSchema InvitationList
Proxy InvitationList -> Declare (Definitions Schema) NamedSchema
forall a.
Typeable a =>
(Proxy a -> Declare (Definitions Schema) NamedSchema) -> ToSchema a
$cdeclareNamedSchema :: Proxy InvitationList -> Declare (Definitions Schema) NamedSchema
declareNamedSchema :: Proxy InvitationList -> Declare (Definitions Schema) NamedSchema
S.ToSchema) via (Schema InvitationList)

instance ToSchema InvitationList where
  schema :: ValueSchema NamedSwaggerDoc InvitationList
schema =
    Text
-> (NamedSwaggerDoc -> NamedSwaggerDoc)
-> ObjectSchema SwaggerDoc InvitationList
-> ValueSchema NamedSwaggerDoc InvitationList
forall doc doc' a.
HasObject doc doc' =>
Text -> (doc' -> doc') -> ObjectSchema doc a -> ValueSchema doc' a
objectWithDocModifier Text
"InvitationList" ((Maybe Text -> Identity (Maybe Text))
-> NamedSwaggerDoc -> Identity NamedSwaggerDoc
forall s a. HasDescription s a => Lens' s a
Lens' NamedSwaggerDoc (Maybe Text)
description ((Maybe Text -> Identity (Maybe Text))
 -> NamedSwaggerDoc -> Identity NamedSwaggerDoc)
-> Text -> NamedSwaggerDoc -> NamedSwaggerDoc
forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ Text
"A list of sent team invitations.") (ObjectSchema SwaggerDoc InvitationList
 -> ValueSchema NamedSwaggerDoc InvitationList)
-> ObjectSchema SwaggerDoc InvitationList
-> ValueSchema NamedSwaggerDoc InvitationList
forall a b. (a -> b) -> a -> b
$
      [Invitation] -> Bool -> InvitationList
InvitationList
        ([Invitation] -> Bool -> InvitationList)
-> SchemaP SwaggerDoc Object [Pair] InvitationList [Invitation]
-> SchemaP
     SwaggerDoc Object [Pair] InvitationList (Bool -> InvitationList)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> InvitationList -> [Invitation]
ilInvitations
          (InvitationList -> [Invitation])
-> SchemaP SwaggerDoc Object [Pair] [Invitation] [Invitation]
-> SchemaP SwaggerDoc Object [Pair] InvitationList [Invitation]
forall (p :: * -> * -> *) a a' b.
Profunctor p =>
(a -> a') -> p a' b -> p a b
.= Text
-> SchemaP SwaggerDoc Value Value [Invitation] [Invitation]
-> SchemaP SwaggerDoc Object [Pair] [Invitation] [Invitation]
forall doc' doc a b.
HasField doc' doc =>
Text
-> SchemaP doc' Value Value a b -> SchemaP doc Object [Pair] a b
field Text
"invitations" (ValueSchema NamedSwaggerDoc Invitation
-> SchemaP SwaggerDoc Value Value [Invitation] [Invitation]
forall ndoc doc a.
(HasArray ndoc doc, HasName ndoc) =>
ValueSchema ndoc a -> ValueSchema doc [a]
array ValueSchema NamedSwaggerDoc Invitation
forall a. ToSchema a => ValueSchema NamedSwaggerDoc a
schema)
        SchemaP
  SwaggerDoc Object [Pair] InvitationList (Bool -> InvitationList)
-> SchemaP SwaggerDoc Object [Pair] InvitationList Bool
-> ObjectSchema SwaggerDoc InvitationList
forall a b.
SchemaP SwaggerDoc Object [Pair] InvitationList (a -> b)
-> SchemaP SwaggerDoc Object [Pair] InvitationList a
-> SchemaP SwaggerDoc Object [Pair] InvitationList b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> InvitationList -> Bool
ilHasMore
          (InvitationList -> Bool)
-> SchemaP SwaggerDoc Object [Pair] Bool Bool
-> SchemaP SwaggerDoc Object [Pair] InvitationList Bool
forall (p :: * -> * -> *) a a' b.
Profunctor p =>
(a -> a') -> p a' b -> p a b
.= Text
-> (NamedSwaggerDoc -> NamedSwaggerDoc)
-> SchemaP NamedSwaggerDoc Value Value Bool Bool
-> SchemaP SwaggerDoc Object [Pair] Bool Bool
forall doc' doc a b.
HasField doc' doc =>
Text
-> (doc' -> doc')
-> SchemaP doc' Value Value a b
-> SchemaP doc Object [Pair] a b
fieldWithDocModifier Text
"has_more" ((Maybe Text -> Identity (Maybe Text))
-> NamedSwaggerDoc -> Identity NamedSwaggerDoc
forall s a. HasDescription s a => Lens' s a
Lens' NamedSwaggerDoc (Maybe Text)
description ((Maybe Text -> Identity (Maybe Text))
 -> NamedSwaggerDoc -> Identity NamedSwaggerDoc)
-> Text -> NamedSwaggerDoc -> NamedSwaggerDoc
forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ Text
"Indicator that the server has more invitations than returned.") SchemaP NamedSwaggerDoc Value Value Bool Bool
forall a. ToSchema a => ValueSchema NamedSwaggerDoc a
schema

--------------------------------------------------------------------------------
-- AcceptTeamInvitation

data AcceptTeamInvitation = AcceptTeamInvitation
  { AcceptTeamInvitation -> InvitationCode
code :: InvitationCode,
    AcceptTeamInvitation -> PlainTextPassword6
password :: PlainTextPassword6
  }
  deriving stock (AcceptTeamInvitation -> AcceptTeamInvitation -> Bool
(AcceptTeamInvitation -> AcceptTeamInvitation -> Bool)
-> (AcceptTeamInvitation -> AcceptTeamInvitation -> Bool)
-> Eq AcceptTeamInvitation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: AcceptTeamInvitation -> AcceptTeamInvitation -> Bool
== :: AcceptTeamInvitation -> AcceptTeamInvitation -> Bool
$c/= :: AcceptTeamInvitation -> AcceptTeamInvitation -> Bool
/= :: AcceptTeamInvitation -> AcceptTeamInvitation -> Bool
Eq, Int -> AcceptTeamInvitation -> ShowS
[AcceptTeamInvitation] -> ShowS
AcceptTeamInvitation -> String
(Int -> AcceptTeamInvitation -> ShowS)
-> (AcceptTeamInvitation -> String)
-> ([AcceptTeamInvitation] -> ShowS)
-> Show AcceptTeamInvitation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AcceptTeamInvitation -> ShowS
showsPrec :: Int -> AcceptTeamInvitation -> ShowS
$cshow :: AcceptTeamInvitation -> String
show :: AcceptTeamInvitation -> String
$cshowList :: [AcceptTeamInvitation] -> ShowS
showList :: [AcceptTeamInvitation] -> ShowS
Show, (forall x. AcceptTeamInvitation -> Rep AcceptTeamInvitation x)
-> (forall x. Rep AcceptTeamInvitation x -> AcceptTeamInvitation)
-> Generic AcceptTeamInvitation
forall x. Rep AcceptTeamInvitation x -> AcceptTeamInvitation
forall x. AcceptTeamInvitation -> Rep AcceptTeamInvitation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. AcceptTeamInvitation -> Rep AcceptTeamInvitation x
from :: forall x. AcceptTeamInvitation -> Rep AcceptTeamInvitation x
$cto :: forall x. Rep AcceptTeamInvitation x -> AcceptTeamInvitation
to :: forall x. Rep AcceptTeamInvitation x -> AcceptTeamInvitation
Generic)
  deriving (Value -> Parser [AcceptTeamInvitation]
Value -> Parser AcceptTeamInvitation
(Value -> Parser AcceptTeamInvitation)
-> (Value -> Parser [AcceptTeamInvitation])
-> FromJSON AcceptTeamInvitation
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
$cparseJSON :: Value -> Parser AcceptTeamInvitation
parseJSON :: Value -> Parser AcceptTeamInvitation
$cparseJSONList :: Value -> Parser [AcceptTeamInvitation]
parseJSONList :: Value -> Parser [AcceptTeamInvitation]
A.FromJSON, [AcceptTeamInvitation] -> Value
[AcceptTeamInvitation] -> Encoding
AcceptTeamInvitation -> Value
AcceptTeamInvitation -> Encoding
(AcceptTeamInvitation -> Value)
-> (AcceptTeamInvitation -> Encoding)
-> ([AcceptTeamInvitation] -> Value)
-> ([AcceptTeamInvitation] -> Encoding)
-> ToJSON AcceptTeamInvitation
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
$ctoJSON :: AcceptTeamInvitation -> Value
toJSON :: AcceptTeamInvitation -> Value
$ctoEncoding :: AcceptTeamInvitation -> Encoding
toEncoding :: AcceptTeamInvitation -> Encoding
$ctoJSONList :: [AcceptTeamInvitation] -> Value
toJSONList :: [AcceptTeamInvitation] -> Value
$ctoEncodingList :: [AcceptTeamInvitation] -> Encoding
toEncodingList :: [AcceptTeamInvitation] -> Encoding
A.ToJSON, Typeable AcceptTeamInvitation
Typeable AcceptTeamInvitation =>
(Proxy AcceptTeamInvitation
 -> Declare (Definitions Schema) NamedSchema)
-> ToSchema AcceptTeamInvitation
Proxy AcceptTeamInvitation
-> Declare (Definitions Schema) NamedSchema
forall a.
Typeable a =>
(Proxy a -> Declare (Definitions Schema) NamedSchema) -> ToSchema a
$cdeclareNamedSchema :: Proxy AcceptTeamInvitation
-> Declare (Definitions Schema) NamedSchema
declareNamedSchema :: Proxy AcceptTeamInvitation
-> Declare (Definitions Schema) NamedSchema
S.ToSchema) via (Schema AcceptTeamInvitation)

instance ToSchema AcceptTeamInvitation where
  schema :: ValueSchema NamedSwaggerDoc AcceptTeamInvitation
schema =
    Text
-> (NamedSwaggerDoc -> NamedSwaggerDoc)
-> ObjectSchema SwaggerDoc AcceptTeamInvitation
-> ValueSchema NamedSwaggerDoc AcceptTeamInvitation
forall doc doc' a.
HasObject doc doc' =>
Text -> (doc' -> doc') -> ObjectSchema doc a -> ValueSchema doc' a
objectWithDocModifier Text
"AcceptTeamInvitation" ((Maybe Text -> Identity (Maybe Text))
-> NamedSwaggerDoc -> Identity NamedSwaggerDoc
forall s a. HasDescription s a => Lens' s a
Lens' NamedSwaggerDoc (Maybe Text)
description ((Maybe Text -> Identity (Maybe Text))
 -> NamedSwaggerDoc -> Identity NamedSwaggerDoc)
-> Text -> NamedSwaggerDoc -> NamedSwaggerDoc
forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ Text
"Accept an invitation to join a team on Wire.") (ObjectSchema SwaggerDoc AcceptTeamInvitation
 -> ValueSchema NamedSwaggerDoc AcceptTeamInvitation)
-> ObjectSchema SwaggerDoc AcceptTeamInvitation
-> ValueSchema NamedSwaggerDoc AcceptTeamInvitation
forall a b. (a -> b) -> a -> b
$
      InvitationCode -> PlainTextPassword6 -> AcceptTeamInvitation
AcceptTeamInvitation
        (InvitationCode -> PlainTextPassword6 -> AcceptTeamInvitation)
-> SchemaP
     SwaggerDoc Object [Pair] AcceptTeamInvitation InvitationCode
-> SchemaP
     SwaggerDoc
     Object
     [Pair]
     AcceptTeamInvitation
     (PlainTextPassword6 -> AcceptTeamInvitation)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> AcceptTeamInvitation -> InvitationCode
code (AcceptTeamInvitation -> InvitationCode)
-> SchemaP SwaggerDoc Object [Pair] InvitationCode InvitationCode
-> SchemaP
     SwaggerDoc Object [Pair] AcceptTeamInvitation InvitationCode
forall (p :: * -> * -> *) a a' b.
Profunctor p =>
(a -> a') -> p a' b -> p a b
.= Text
-> (NamedSwaggerDoc -> NamedSwaggerDoc)
-> SchemaP
     NamedSwaggerDoc Value Value InvitationCode InvitationCode
-> SchemaP SwaggerDoc Object [Pair] InvitationCode InvitationCode
forall doc' doc a b.
HasField doc' doc =>
Text
-> (doc' -> doc')
-> SchemaP doc' Value Value a b
-> SchemaP doc Object [Pair] a b
fieldWithDocModifier Text
"code" ((Maybe Text -> Identity (Maybe Text))
-> NamedSwaggerDoc -> Identity NamedSwaggerDoc
forall s a. HasDescription s a => Lens' s a
Lens' NamedSwaggerDoc (Maybe Text)
description ((Maybe Text -> Identity (Maybe Text))
 -> NamedSwaggerDoc -> Identity NamedSwaggerDoc)
-> Text -> NamedSwaggerDoc -> NamedSwaggerDoc
forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ Text
"Invitation code to accept.") SchemaP NamedSwaggerDoc Value Value InvitationCode InvitationCode
forall a. ToSchema a => ValueSchema NamedSwaggerDoc a
schema
        SchemaP
  SwaggerDoc
  Object
  [Pair]
  AcceptTeamInvitation
  (PlainTextPassword6 -> AcceptTeamInvitation)
-> SchemaP
     SwaggerDoc Object [Pair] AcceptTeamInvitation PlainTextPassword6
-> ObjectSchema SwaggerDoc AcceptTeamInvitation
forall a b.
SchemaP SwaggerDoc Object [Pair] AcceptTeamInvitation (a -> b)
-> SchemaP SwaggerDoc Object [Pair] AcceptTeamInvitation a
-> SchemaP SwaggerDoc Object [Pair] AcceptTeamInvitation b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> AcceptTeamInvitation -> PlainTextPassword6
password (AcceptTeamInvitation -> PlainTextPassword6)
-> SchemaP
     SwaggerDoc Object [Pair] PlainTextPassword6 PlainTextPassword6
-> SchemaP
     SwaggerDoc Object [Pair] AcceptTeamInvitation PlainTextPassword6
forall (p :: * -> * -> *) a a' b.
Profunctor p =>
(a -> a') -> p a' b -> p a b
.= Text
-> (NamedSwaggerDoc -> NamedSwaggerDoc)
-> SchemaP
     NamedSwaggerDoc Value Value PlainTextPassword6 PlainTextPassword6
-> SchemaP
     SwaggerDoc Object [Pair] PlainTextPassword6 PlainTextPassword6
forall doc' doc a b.
HasField doc' doc =>
Text
-> (doc' -> doc')
-> SchemaP doc' Value Value a b
-> SchemaP doc Object [Pair] a b
fieldWithDocModifier Text
"password" ((Maybe Text -> Identity (Maybe Text))
-> NamedSwaggerDoc -> Identity NamedSwaggerDoc
forall s a. HasDescription s a => Lens' s a
Lens' NamedSwaggerDoc (Maybe Text)
description ((Maybe Text -> Identity (Maybe Text))
 -> NamedSwaggerDoc -> Identity NamedSwaggerDoc)
-> Text -> NamedSwaggerDoc -> NamedSwaggerDoc
forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ Text
"The user account password.") SchemaP
  NamedSwaggerDoc Value Value PlainTextPassword6 PlainTextPassword6
forall a. ToSchema a => ValueSchema NamedSwaggerDoc a
schema