Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update swagger #598

Merged
merged 2 commits into from
Jan 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 24 additions & 60 deletions libs/brig-types/src/Brig/Types/Swagger.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@ brigModels =
, connection
, connectionRequest
, connectionUpdate
, invitationRequest
, invitation
, connectionList
, invitationList

-- Account Activation
, activate
Expand Down Expand Up @@ -358,72 +355,25 @@ connectionRequest = defineModel "ConnectionRequest" $ do
property "message" string' $
description "The initial message in the request (1 - 256 characters)."

invitationRequest :: Model
invitationRequest = defineModel "InvitationRequest" $ do
description "A request to join Wire. Note that either email or phone must be given."
property "inviter_name" string' $
description "Name of the inviter (1 - 128 characters)"
property "email" string' $ do
description "Email of the invitee"
optional
property "phone" string' $ do
description "Phone of the invitee"
optional
property "invitee_name" string' $
description "Name of the invitee (1 - 128 characters)"
property "message" string' $
description "Message (1 - 256 characters)"
property "locale" string' $ do
description "Locale to use for the invitation."
optional

role :: DataType
role = Model.Prim $ Model.Primitive
{ Model.primType = Model.PrimString
, Model.defaultValue = Just defaultRole
, Model.enum = Just [minBound..]
, Model.minVal = Just minBound
, Model.maxVal = Just maxBound
}

invitation :: Model
invitation = defineModel "Invitation" $ do
description "An invitation to join Wire"
property "inviter" bytes' $
description "User ID of the inviter"
property "role" role $ do
description "Role of the invited user"
optional
property "id" bytes' $
description "UUID used to refer to the invitation"
property "email" string' $ do
description "Email of the invitee"
optional
property "phone" string' $ do
description "Phone of the invitee"
optional
property "created_at" dateTime' $
description "Timestamp of invitation creation"
property "name" string' $
description "Name of the invitee"

connectionList :: Model
connectionList = defineModel "UserConnectionList" $ do
description "A list of user connections."
property "connections" (unique $ array (ref connection)) end
property "has_more" bool' $
description "Indicator that the server has more connections than returned."

invitationList :: Model
invitationList = defineModel "InvitationList" $ do
description "A list of sent invitations."
property "invitations" (unique $ array (ref invitation)) end
property "has_more" bool' $
description "Indicator that the server has more invitations than returned."

-------------------------------------------------------------------------------
-- Team invitation Models

role :: DataType
role = Model.Prim $ Model.Primitive
{ Model.primType = Model.PrimString
, Model.defaultValue = Just defaultRole
, Model.enum = Just [minBound..]
, Model.minVal = Just minBound
, Model.maxVal = Just maxBound
}

teamInvitationRequest :: Model
teamInvitationRequest = defineModel "TeamInvitationRequest" $ do
description "A request to join a team on Wire."
Expand All @@ -434,25 +384,39 @@ teamInvitationRequest = defineModel "TeamInvitationRequest" $ do
property "locale" string' $ do
description "Locale to use for the invitation."
optional
property "role" role $ do
description "Role of the invited user"
optional

-- | This is *not* the swagger model for the 'TeamInvitation' type (which does not exist), but
-- for the use of 'Invitation' under @/teams/{tid}/invitations@.
--
-- TODO: swagger should be replaced by something more type-safe at some point so this will be
-- forcibly resolved and won't happen again.
teamInvitation :: Model
teamInvitation = defineModel "TeamInvitation" $ do
description "An invitation to join a team on Wire"
property "team" bytes' $
description "Team ID of the inviting team"
property "role" role $ do
description "Role of the invited user"
optional
property "id" bytes' $
description "UUID used to refer the invitation"
property "email" string' $
description "Email of the invitee"
property "created_at" dateTime' $
description "Timestamp of invitation creation"
property "created_by" bytes' $ do
description "ID of the inviting user"
optional
property "name" string' $
description "Name of the invitee"

teamInvitationList :: Model
teamInvitationList = defineModel "TeamInvitationList" $ do
description "A list of sent team invitations."
property "invitations" (unique $ array (ref invitation)) end
property "invitations" (unique $ array (ref teamInvitation)) end
property "has_more" bool' $
description "Indicator that the server has more invitations than returned."

Expand Down
2 changes: 0 additions & 2 deletions libs/brig-types/test/unit/Test/Brig/Types/User.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE ViewPatterns #-}

{-# OPTIONS_GHC -Wno-orphans #-}

module Test.Brig.Types.User where

import Imports
Expand Down
6 changes: 6 additions & 0 deletions libs/galley-types/src/Galley/Types/Teams/Swagger.hs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ teamMember = defineModel "TeamMember" $ do
-- servant, we could probably just add a helper type for this.)
-- TODO: even without servant, it would be nicer to introduce
-- a type with optional permissions.
property "created_at" dateTime' $ do
description "Timestamp of invitation creation. Requires created_by."
optional
property "created_by" bytes' $ do
description "ID of the inviting user. Requires created_at."
optional

permissions :: Model
permissions = defineModel "Permissions" $ do
Expand Down