Skip to content
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
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ cabal.project.local:
c: treefmt c-fast

.PHONY: c
c-fast:
c-fast:
cabal build $(WIRE_CABAL_BUILD_OPTIONS) $(package) || ( make clean-hint; false )
ifeq ($(test), 1)
./hack/bin/cabal-run-tests.sh $(package) $(testargs)
Expand Down Expand Up @@ -173,7 +173,7 @@ lint-all: formatc hlint-check-all lint-common
# The extra 'hlint-check-pr' has been witnessed to be necessary due to
# some bu in `hlint-inplace-pr`. Details got lost in history.
.PHONY: lint-all-shallow
lint-all-shallow: lint-common formatf hlint-inplace-pr hlint-check-pr
lint-all-shallow: lint-common formatf hlint-inplace-pr hlint-check-pr

.PHONY: lint-common
lint-common: check-local-nix-derivations treefmt-check # weeder (does not work on CI yet)
Expand Down Expand Up @@ -602,3 +602,8 @@ upload-bombon:
--project-version $(HELM_SEMVER) \
--api-key $(DEPENDENCY_TRACK_API_KEY) \
--auto-create

.PHONY: openapi-validate
openapi-validate:
@echo -e "Make sure you are running the backend in another terminal (make cr)\n"
vacuum lint -a -d -w <(curl http://localhost:8082/v7/api/swagger.json)
1 change: 1 addition & 0 deletions changelog.d/4-docs/openapi-validation
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix openapi validation errors
12 changes: 6 additions & 6 deletions libs/types-common/src/Data/Range.hs
Original file line number Diff line number Diff line change
Expand Up @@ -225,20 +225,20 @@ instance (ToParamSchema a, KnownNat n, KnownNat m) => ToParamSchema (Range n m [
instance (KnownNat n, KnownNat m) => ToParamSchema (Range n m String) where
toParamSchema _ =
toParamSchema (Proxy @String)
& S.maxLength ?~ fromKnownNat (Proxy @n)
& S.minLength ?~ fromKnownNat (Proxy @m)
& S.minLength ?~ fromKnownNat (Proxy @n)
& S.maxLength ?~ fromKnownNat (Proxy @m)

instance (KnownNat n, KnownNat m) => ToParamSchema (Range n m T.Text) where
toParamSchema _ =
toParamSchema (Proxy @T.Text)
& S.maxLength ?~ fromKnownNat (Proxy @n)
& S.minLength ?~ fromKnownNat (Proxy @m)
& S.minLength ?~ fromKnownNat (Proxy @n)
& S.maxLength ?~ fromKnownNat (Proxy @m)

instance (KnownNat n, KnownNat m) => ToParamSchema (Range n m TL.Text) where
toParamSchema _ =
toParamSchema (Proxy @TL.Text)
& S.maxLength ?~ fromKnownNat (Proxy @n)
& S.minLength ?~ fromKnownNat (Proxy @m)
& S.minLength ?~ fromKnownNat (Proxy @n)
& S.maxLength ?~ fromKnownNat (Proxy @m)

instance (KnownNat n, S.ToSchema a, KnownNat m) => S.ToSchema (Range n m a) where
declareNamedSchema _ =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ data Versioned v name

instance {-# OVERLAPPING #-} (RenderableSymbol a) => RenderableSymbol (Versioned v a) where
renderSymbol = renderSymbol @a
renderOperationId = renderOperationId @a

type family FedPath (name :: k) :: Symbol

Expand Down
4 changes: 2 additions & 2 deletions libs/wire-api/src/Wire/API/Call/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ mkSFTUsername shared expires rnd =
}

instance ToSchema SFTUsername where
schema = toText .= parsedText "" fromText
schema = toText .= parsedText "SFTUsername" fromText
where
fromText :: Text -> Either String SFTUsername
fromText = parseOnly (parseSFTUsername <* endOfInput)
Expand Down Expand Up @@ -543,7 +543,7 @@ turnUsername expires rnd =
}

instance ToSchema TurnUsername where
schema = toText .= parsedText "" fromText
schema = toText .= parsedText "TurnUsername" fromText
where
fromText :: Text -> Either String TurnUsername
fromText = parseOnly (parseTurnUsername <* endOfInput)
Expand Down
2 changes: 1 addition & 1 deletion libs/wire-api/src/Wire/API/Conversation/Protocol.hs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ optionalActiveMLSConversationDataSchema (Just v)
(description ?~ "The epoch number of the corresponding MLS group")
schema
<*> fmap (.epochTimestamp)
.= field "epoch_timestamp" (named "Epoch Timestamp" . nullable . unnamed $ utcTimeSchema)
.= field "epoch_timestamp" (named "EpochTimestamp" . nullable . unnamed $ utcTimeSchema)
<*> maybe MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519 (.ciphersuite)
.= fieldWithDocModifier
"cipher_suite"
Expand Down
2 changes: 1 addition & 1 deletion libs/wire-api/src/Wire/API/Event/Conversation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ taggedEventDataSchema =

memberLeaveSchema :: ValueSchema NamedSwaggerDoc (EdMemberLeftReason, QualifiedUserIdList)
memberLeaveSchema =
object "QualifiedUserIdList with EdMemberLeftReason" $
object "QualifiedUserIdList_with_EdMemberLeftReason" $
(,) <$> fst .= field "reason" schema <*> snd .= qualifiedUserIdListObjectSchema

instance ToSchema Event where
Expand Down
2 changes: 1 addition & 1 deletion libs/wire-api/src/Wire/API/Provider/Service.hs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ data ServiceProfilePage = ServiceProfilePage

instance ToSchema ServiceProfilePage where
schema =
object "ServiceProfile" $
object "ServiceProfilePage" $
ServiceProfilePage
<$> serviceProfilePageHasMore .= field "has_more" schema
<*> serviceProfilePageResults .= field "services" (array schema)
Expand Down
2 changes: 1 addition & 1 deletion libs/wire-api/src/Wire/API/Provider/Service/Tag.hs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ instance ToByteString ServiceTag where
builder WeatherTag = "weather"

instance ToSchema ServiceTag where
schema = enum @Text "" . mconcat $ (\a -> element (decodeUtf8With lenientDecode $ toStrict $ toByteString a) a) <$> [minBound ..]
schema = enum @Text "ServiceTag" . mconcat $ (\a -> element (decodeUtf8With lenientDecode $ toStrict $ toByteString a) a) <$> [minBound ..]

instance S.ToParamSchema ServiceTag where
toParamSchema _ =
Expand Down
8 changes: 7 additions & 1 deletion libs/wire-api/src/Wire/API/Routes/Named.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

module Wire.API.Routes.Named where

import Control.Lens ((%~))
import Control.Lens ((%~), (?~))
import Data.Kind
import Data.Metrics.Servant
import Data.OpenApi.Lens hiding (HasServer)
Expand All @@ -42,17 +42,22 @@ newtype Named name x = Named {unnamed :: x}
-- types other than string literals in some places.
class RenderableSymbol a where
renderSymbol :: Text
renderOperationId :: Text
renderOperationId = renderSymbol @a

instance (KnownSymbol a) => RenderableSymbol a where
renderSymbol = T.pack . show $ symbolVal (Proxy @a)
renderOperationId = T.pack $ symbolVal (Proxy @a)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is renderSymbol still used now? if not you could just change its behavior instead of adding another method to the class.


instance (RenderableSymbol a, RenderableSymbol b) => RenderableSymbol '(a, b) where
renderSymbol = "(" <> (renderSymbol @a) <> ", " <> (renderSymbol @b) <> ")"
renderOperationId = renderOperationId @a <> "_" <> renderOperationId @b

newtype RenderableTypeName a = RenderableTypeName a

instance (GRenderableSymbol (Rep a)) => RenderableSymbol (RenderableTypeName a) where
renderSymbol = grenderSymbol @(Rep a)
renderOperationId = grenderSymbol @(Rep a)

class GRenderableSymbol f where
grenderSymbol :: Text
Expand All @@ -64,6 +69,7 @@ instance (HasOpenApi api, RenderableSymbol name) => HasOpenApi (Named name api)
toOpenApi _ =
toOpenApi (Proxy @api)
& allOperations . description %~ (Just (dscr <> "\n\n") <>)
& allOperations . operationId ?~ renderOperationId @name
where
dscr :: Text
dscr =
Expand Down
8 changes: 4 additions & 4 deletions libs/wire-api/src/Wire/API/Routes/Public/Brig/Bot.hs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ type BotAPI =
:> ZAccess
:> ZConn
:> "conversations"
:> Capture "Conversation ID" ConvId
:> Capture "conv" ConvId
:> "bots"
:> ReqBody '[JSON] AddBot
:> MultiVerb1 'POST '[JSON] (Respond 201 "" AddBotResponse)
Expand All @@ -65,9 +65,9 @@ type BotAPI =
:> ZAccess
:> ZConn
:> "conversations"
:> Capture "Conversation ID" ConvId
:> Capture "conv" ConvId
:> "bots"
:> Capture "Bot ID" BotId
:> Capture "bot" BotId
:> MultiVerb 'DELETE '[JSON] DeleteResponses (Maybe RemoveBotResponse)
)
:<|> Named
Expand Down Expand Up @@ -178,7 +178,7 @@ type BotAPI =
:> ZBot
:> "bot"
:> "users"
:> Capture "User ID" UserId
:> Capture "user" UserId
:> "clients"
:> Get '[JSON] [PubClient]
)
Loading