Skip to content
This repository was archived by the owner on Oct 29, 2021. It is now read-only.

Servant.Auth.Swagger: instances for Tokens? #180

@cdupont

Description

@cdupont

I'm using Servant.Auth.Swagger, which is very useful to get authorization displayed in Swagger.
However, in my API I also need to return JWTs:

type TokenAPI = ...   :> Post '[PlainText, JSON] Token

So I defined:

--- Wrapper for JWTs.
newtype Token = Token {unToken :: ByteString} deriving (Eq, Show, Generic)

instance ToJSON Token where
  toJSON (Token t) = String $ convertString t

instance ToSchema Token where
  declareNamedSchema _ = pure (NamedSchema (Just "Token") binarySchema)

instance MimeRender PlainText Token where
  mimeRender _ (Token tok) = tok

I'm wondering is this is already somewhere, or if this could be integrated in Servant.Auth.Swagger.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions