servant-openapi3-2.0.1.6: Generate a Swagger/OpenAPI/OAS 3.0 specification for your servant API.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Servant.OpenApi.Internal

Synopsis

Documentation

class HasOpenApi api where Source #

Generate a OpenApi specification for a servant API.

To generate OpenApi specification, your data types need ToParamSchema and/or ToSchema instances.

ToParamSchema is used for Capture, QueryParam and ResponseHeader. ToSchema is used for ReqBody and response data types.

You can easily derive those instances via Generic. For more information, refer to openapi3 documentation.

Example:

newtype Username = Username String deriving (Generic, ToText)

instance ToParamSchema Username

data User = User
  { username :: Username
  , fullname :: String
  } deriving (Generic)

instance ToJSON User
instance ToSchema User

type MyAPI = QueryParam "username" Username :> Get '[JSON] User

myOpenApi :: OpenApi
myOpenApi = toOpenApi (Proxy :: Proxy MyAPI)

Methods

toOpenApi :: Proxy api -> OpenApi Source #

Generate a OpenApi specification for a servant API.

Instances

Instances details
HasOpenApi EmptyAPI Source # 
Instance details

Defined in Servant.OpenApi.Internal

HasOpenApi Raw Source # 
Instance details

Defined in Servant.OpenApi.Internal

HasOpenApi (ToServantApi sub) => HasOpenApi (NamedRoutes sub :: Type) Source # 
Instance details

Defined in Servant.OpenApi.Internal

(HasOpenApi a, HasOpenApi b) => HasOpenApi (a :<|> b :: Type) Source # 
Instance details

Defined in Servant.OpenApi.Internal

Methods

toOpenApi :: Proxy (a :<|> b) -> OpenApi Source #

OpenApiMethod method => HasOpenApi (NoContentVerb method :: Type) Source # 
Instance details

Defined in Servant.OpenApi.Internal

(KnownSymbol sym, HasOpenApi sub) => HasOpenApi (sym :> sub :: Type) Source # 
Instance details

Defined in Servant.OpenApi.Internal

Methods

toOpenApi :: Proxy (sym :> sub) -> OpenApi Source #

HasOpenApi sub => HasOpenApi (HttpVersion :> sub :: Type) Source #

HttpVersion combinator does not change our specification at all.

Instance details

Defined in Servant.OpenApi.Internal

(KnownSymbol sym, ToParamSchema a, HasOpenApi sub, KnownSymbol (FoldDescription mods)) => HasOpenApi (Capture' mods sym a :> sub :: Type) Source # 
Instance details

Defined in Servant.OpenApi.Internal

Methods

toOpenApi :: Proxy (Capture' mods sym a :> sub) -> OpenApi Source #

(KnownSymbol sym, ToParamSchema a, HasOpenApi sub) => HasOpenApi (CaptureAll sym a :> sub :: Type) Source #

OpenApi Spec doesn't have a notion of CaptureAll, this instance is the best effort.

Instance details

Defined in Servant.OpenApi.Internal

Methods

toOpenApi :: Proxy (CaptureAll sym a :> sub) -> OpenApi Source #

(KnownSymbol desc, HasOpenApi api) => HasOpenApi (Description desc :> api :: Type) Source # 
Instance details

Defined in Servant.OpenApi.Internal

Methods

toOpenApi :: Proxy (Description desc :> api) -> OpenApi Source #

(KnownSymbol desc, HasOpenApi api) => HasOpenApi (Summary desc :> api :: Type) Source # 
Instance details

Defined in Servant.OpenApi.Internal

Methods

toOpenApi :: Proxy (Summary desc :> api) -> OpenApi Source #

HasOpenApi sub => HasOpenApi (Fragment a :> sub :: Type) Source # 
Instance details

Defined in Servant.OpenApi.Internal

Methods

toOpenApi :: Proxy (Fragment a :> sub) -> OpenApi Source #

(KnownSymbol sym, ToParamSchema a, HasOpenApi sub, SBoolI (FoldRequired mods), KnownSymbol (FoldDescription mods)) => HasOpenApi (Header' mods sym a :> sub :: Type) Source # 
Instance details

Defined in Servant.OpenApi.Internal

Methods

toOpenApi :: Proxy (Header' mods sym a :> sub) -> OpenApi Source #

HasOpenApi sub => HasOpenApi (IsSecure :> sub :: Type) Source #

IsSecure combinator does not change our specification at all.

Instance details

Defined in Servant.OpenApi.Internal

(KnownSymbol sym, HasOpenApi sub) => HasOpenApi (QueryFlag sym :> sub :: Type) Source # 
Instance details

Defined in Servant.OpenApi.Internal

Methods

toOpenApi :: Proxy (QueryFlag sym :> sub) -> OpenApi Source #

(KnownSymbol sym, ToParamSchema a, HasOpenApi sub, SBoolI (FoldRequired mods), KnownSymbol (FoldDescription mods)) => HasOpenApi (QueryParam' mods sym a :> sub :: Type) Source # 
Instance details

Defined in Servant.OpenApi.Internal

Methods

toOpenApi :: Proxy (QueryParam' mods sym a :> sub) -> OpenApi Source #

(KnownSymbol sym, ToParamSchema a, HasOpenApi sub) => HasOpenApi (QueryParams sym a :> sub :: Type) Source # 
Instance details

Defined in Servant.OpenApi.Internal

Methods

toOpenApi :: Proxy (QueryParams sym a :> sub) -> OpenApi Source #

HasOpenApi sub => HasOpenApi (RemoteHost :> sub :: Type) Source #

RemoteHost combinator does not change our specification at all.

Instance details

Defined in Servant.OpenApi.Internal

(ToSchema a, AllAccept cs, HasOpenApi sub, KnownSymbol (FoldDescription mods)) => HasOpenApi (ReqBody' mods cs a :> sub :: Type) Source # 
Instance details

Defined in Servant.OpenApi.Internal

Methods

toOpenApi :: Proxy (ReqBody' mods cs a :> sub) -> OpenApi Source #

(ToSchema a, Accept ct, HasOpenApi sub, KnownSymbol (FoldDescription mods)) => HasOpenApi (StreamBody' mods fr ct a :> sub :: Type) Source #

This instance is an approximation.

Since: 1.1.7

Instance details

Defined in Servant.OpenApi.Internal

Methods

toOpenApi :: Proxy (StreamBody' mods fr ct a :> sub) -> OpenApi Source #

HasOpenApi sub => HasOpenApi (WithResource res :> sub :: Type) Source #

WithResource combinator does not change our specification at all.

Instance details

Defined in Servant.OpenApi.Internal

Methods

toOpenApi :: Proxy (WithResource res :> sub) -> OpenApi Source #

HasOpenApi sub => HasOpenApi (Vault :> sub :: Type) Source #

Vault combinator does not change our specification at all.

Instance details

Defined in Servant.OpenApi.Internal

Methods

toOpenApi :: Proxy (Vault :> sub) -> OpenApi Source #

(ToSchema a, HasStatus a, AllAccept cs, OpenApiMethod method, HasOpenApi (UVerb method cs as)) => HasOpenApi (UVerb method cs (a ': as) :: Type) Source #

@since 2.0.1.0

Instance details

Defined in Servant.OpenApi.Internal

Methods

toOpenApi :: Proxy (UVerb method cs (a ': as)) -> OpenApi Source #

HasOpenApi (UVerb method cs ('[] :: [Type]) :: Type) Source # 
Instance details

Defined in Servant.OpenApi.Internal

Methods

toOpenApi :: Proxy (UVerb method cs '[]) -> OpenApi Source #

HasOpenApi sub => HasOpenApi (WithNamedContext x c sub :: Type) Source #

WithNamedContext combinator does not change our specification at all.

Instance details

Defined in Servant.OpenApi.Internal

(AllAccept cs, KnownNat status, OpenApiMethod method) => HasOpenApi (Verb method status cs NoContent :: Type) Source # 
Instance details

Defined in Servant.OpenApi.Internal

Methods

toOpenApi :: Proxy (Verb method status cs NoContent) -> OpenApi Source #

(AllAccept cs, AllToResponseHeader hs, KnownNat status, OpenApiMethod method) => HasOpenApi (Verb method status cs (Headers hs NoContent) :: Type) Source # 
Instance details

Defined in Servant.OpenApi.Internal

Methods

toOpenApi :: Proxy (Verb method status cs (Headers hs NoContent)) -> OpenApi Source #

(ToSchema a, AllAccept cs, AllToResponseHeader hs, KnownNat status, OpenApiMethod method) => HasOpenApi (Verb method status cs (Headers hs a) :: Type) Source # 
Instance details

Defined in Servant.OpenApi.Internal

Methods

toOpenApi :: Proxy (Verb method status cs (Headers hs a)) -> OpenApi Source #

(ToSchema a, AllAccept cs, KnownNat status, OpenApiMethod method) => HasOpenApi (Verb method status cs a :: Type) Source # 
Instance details

Defined in Servant.OpenApi.Internal

Methods

toOpenApi :: Proxy (Verb method status cs a) -> OpenApi Source #

(ToSchema a, Accept ct, KnownNat status, OpenApiMethod method) => HasOpenApi (Stream method status fr ct a :: Type) Source #

Since: 1.1.7

Instance details

Defined in Servant.OpenApi.Internal

Methods

toOpenApi :: Proxy (Stream method status fr ct a) -> OpenApi Source #

subOperations Source #

Arguments

:: (IsSubAPI sub api, HasOpenApi sub) 
=> Proxy sub

Part of a servant API.

-> Proxy api

The whole servant API.

-> Traversal' OpenApi Operation 

All operations of sub API. This is similar to operationsOf but ensures that operations indeed belong to the API at compile time.

mkEndpoint Source #

Arguments

:: forall a cs hs proxy method status. (ToSchema a, AllAccept cs, AllToResponseHeader hs, OpenApiMethod method, KnownNat status) 
=> FilePath

Endpoint path.

-> proxy (Verb method status cs (Headers hs a))

Method, content-types, headers and response.

-> OpenApi 

Make a singleton OpenApi spec (with only one endpoint). For endpoints with no content see mkEndpointNoContent.

mkEndpointNoContent Source #

Arguments

:: forall nocontent cs hs proxy method status. (AllAccept cs, AllToResponseHeader hs, OpenApiMethod method, KnownNat status) 
=> FilePath

Endpoint path.

-> proxy (Verb method status cs (Headers hs nocontent))

Method, content-types, headers and response.

-> OpenApi 

Make a singletone OpenApi spec (with only one endpoint) and with no content schema.

mkEndpointWithSchemaRef :: forall cs hs proxy method status a. (AllAccept cs, AllToResponseHeader hs, OpenApiMethod method, KnownNat status) => Maybe (Referenced Schema) -> FilePath -> proxy (Verb method status cs (Headers hs a)) -> OpenApi Source #

Like mkEndpoint but with explicit schema reference. Unlike mkEndpoint this function does not update definitions.

mkEndpointNoContentVerb Source #

Arguments

:: forall proxy method. OpenApiMethod method 
=> FilePath

Endpoint path.

-> proxy (NoContentVerb method)

Method

-> OpenApi 

addParam :: Param -> OpenApi -> OpenApi Source #

Add parameter to every operation in the spec.

addRequestBody :: RequestBody -> OpenApi -> OpenApi Source #

Add RequestBody to every operations in the spec.

markdownCode :: Text -> Text Source #

Format given text as inline code in Markdown.

class OpenApiMethod method where Source #

Methods, available for OpenApi.

Methods

openApiMethod :: proxy method -> Lens' PathItem (Maybe Operation) Source #

Instances

Instances details
OpenApiMethod 'DELETE Source # 
Instance details

Defined in Servant.OpenApi.Internal

OpenApiMethod 'GET Source # 
Instance details

Defined in Servant.OpenApi.Internal

OpenApiMethod 'HEAD Source # 
Instance details

Defined in Servant.OpenApi.Internal

OpenApiMethod 'OPTIONS Source # 
Instance details

Defined in Servant.OpenApi.Internal

OpenApiMethod 'PATCH Source # 
Instance details

Defined in Servant.OpenApi.Internal

OpenApiMethod 'POST Source # 
Instance details

Defined in Servant.OpenApi.Internal

OpenApiMethod 'PUT Source # 
Instance details

Defined in Servant.OpenApi.Internal

class AllAccept cs where Source #

Instances

Instances details
AllAccept ('[] :: [k]) Source # 
Instance details

Defined in Servant.OpenApi.Internal

(Accept c, AllAccept cs) => AllAccept (c ': cs :: [a]) Source # 
Instance details

Defined in Servant.OpenApi.Internal

Methods

allContentType :: Proxy (c ': cs) -> [MediaType] Source #

class ToResponseHeader h where Source #

Instances

Instances details
(KnownSymbol sym, ToParamSchema a) => ToResponseHeader (Header sym a :: Type) Source # 
Instance details

Defined in Servant.OpenApi.Internal

Orphan instances