Skip to content

Commit

Permalink
Expose swagger docs for brig's internal (servantified) endpoints
Browse files Browse the repository at this point in the history
Start the ToSchema party with brig and cannon

Remove unnecessary module qualifier

Fix type error

Fix

Create instance `ToSchema List1`

Add swagger tags (resulting in sections)

Replace over with %~

Introduce SwaggerTag combinator

Use lens

Add some documentation text

Test RawJson FromJSON/ToJSON

Cleanup

Delete unused endpoint

Align title with cannon's swagger title

Delete Won't-do ToDos

Add changelog

Remove superfluous comment

Add docs about Swagger

Describe the swagger URL pattern better

Use versions in swagger endpoint

Update docs

Move example section

Fix typo

Update swagger.md

Old Swagger is now gone.

Update services/brig/src/Brig/API/Public.hs

Co-authored-by: fisx <mf@zerobuzz.net>

Update services/brig/docs/swagger-internal-endpoints.md

Co-authored-by: fisx <mf@zerobuzz.net>

Update changelog.d/2-features/internal-endpoints-swagger

Co-authored-by: fisx <mf@zerobuzz.net>

Update libs/wire-api/src/Wire/API/SwaggerServant.hs

Co-authored-by: fisx <mf@zerobuzz.net>

Update libs/wire-api/test/unit/Test/Wire/API/Roundtrip/Aeson.hs

Co-authored-by: fisx <mf@zerobuzz.net>

Remove redundant constraint

Simplify operations tagging with allOperations Traversal

Use LText as data store of RawJson

Replace ToSchema instance with function

Increase lazy-ness of ToSchema RawJson instance

Remove ToSchema for internal data structures

Swagger docs for internal endpoints of Legalhold and Cargohold

Move galley's internal endpoint to wire-api

Swagger for internal Galley endpoints

Add spar's internal endpoints
  • Loading branch information
supersven committed Feb 15, 2023
1 parent 607d93e commit 4eba89f
Show file tree
Hide file tree
Showing 39 changed files with 588 additions and 469 deletions.
2 changes: 0 additions & 2 deletions libs/galley-types/galley-types.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@ library
Galley.Types
Galley.Types.Bot
Galley.Types.Bot.Service
Galley.Types.Conversations.Intra
Galley.Types.Conversations.Members
Galley.Types.Conversations.One2One
Galley.Types.Conversations.Roles
Galley.Types.Teams
Galley.Types.Teams.Intra

other-modules: Paths_galley_types
hs-source-dirs: src
Expand Down
2 changes: 0 additions & 2 deletions libs/galley-types/test/unit/Test/Galley/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import Control.Lens
import Data.Set hiding (drop)
import qualified Data.Set as Set
import Galley.Types.Teams
import Galley.Types.Teams.Intra (GuardLegalholdPolicyConflicts)
import Imports
import Test.Galley.Roundtrip (testRoundTrip)
import qualified Test.QuickCheck as QC
Expand All @@ -49,7 +48,6 @@ tests =
assertBool "owner.self" ((rolePermissions r2 ^. self) `isSubsetOf` (rolePermissions r1 ^. self))
assertBool "owner.copy" ((rolePermissions r2 ^. copy) `isSubsetOf` (rolePermissions r1 ^. copy)),
testRoundTrip @FeatureFlags,
testRoundTrip @GuardLegalholdPolicyConflicts,
testGroup
"permissionsRole, rolePermissions"
[ testCase "'Role' maps to expected permissions" $ do
Expand Down
10 changes: 10 additions & 0 deletions libs/types-common/src/Data/Json/Util.hs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ import qualified Data.ByteString.Base64.URL as B64U
import qualified Data.ByteString.Builder as BB
import qualified Data.ByteString.Conversion as BS
import qualified Data.ByteString.Lazy as L
import qualified Data.Currency as Currency
import Data.Fixed
import Data.Schema
import Data.String.Conversions (cs)
Expand Down Expand Up @@ -269,3 +270,12 @@ fromBase64Text = B64.decode . Text.encodeUtf8

toBase64Text :: ByteString -> Text
toBase64Text = Text.decodeUtf8 . B64.encode

-- TODO: Find a better module for this
instance ToSchema Currency.Alpha where
schema = mkSchema docs parseJSON (pure . toJSON)
where
docs =
swaggerDoc @Text
& S.schema . S.description ?~ "ISO 4217 alphabetic codes"
& S.schema . S.example ?~ "EUR"
15 changes: 14 additions & 1 deletion libs/wire-api/src/Wire/API/Routes/Internal/Cargohold.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,21 @@

module Wire.API.Routes.Internal.Cargohold where

import Control.Lens
import Data.Swagger
import Imports
import Servant
import Servant.Swagger
import Wire.API.Routes.MultiVerb
import Wire.API.SwaggerServant

type InternalAPI =
"i" :> "status" :> MultiVerb 'GET '() '[RespondEmpty 200 "OK"] ()
SwaggerTag "cargohold"
:> "i"
:> "status"
:> MultiVerb 'GET '() '[RespondEmpty 200 "OK"] ()

swaggerDoc :: Swagger
swaggerDoc =
toSwagger (Proxy @InternalAPI)
& info . title .~ "Wire-Server internal cargohold API"
Loading

0 comments on commit 4eba89f

Please sign in to comment.