servant-routes-0.1.0.0: Generate route descriptions from Servant APIs
Copyright(c) Frederick Pringle 2024
LicenseBSD-3-Clause
Maintainerfreddyjepringle@gmail.com
Safe HaskellSafe-Inferred
LanguageHaskell2010

Servant.API.Routes.Body

Description

The Body type lets us represent HTTP bodies that may have interpretations as several different types.

Synopsis

Documentation

data Body Source #

A more expressive sum-type than just a list. This can be useful in situations where a body (request or response) may have several interpretations.

For example, the UVerb combinator lets us represent an endpoint that may return one of several types: hence the _routeResponseType field needs to be able to contain several TypeReps as a disjunction.

On the other hand, if multiple ReqBody's are chained together with :>, the resulting type's HasServer instance would try to parse the request body as all of the relevant types. In this case the _routeRequestBody field needs to be able to contain several TypeReps as a conjunction.

Instances

Instances details
Monoid Body Source # 
Instance details

Defined in Servant.API.Routes.Internal.Body

Semigroup Body Source # 
Instance details

Defined in Servant.API.Routes.Internal.Body

Show Body Source # 
Instance details

Defined in Servant.API.Routes.Internal.Body

Eq Body Source # 
Instance details

Defined in Servant.API.Routes.Internal.Body

Methods

(==) :: Body -> Body -> Bool Source #

(/=) :: Body -> Body -> Bool Source #

noBody :: Body Source #

There is no request/response body. Equialent to Nothing or Null.

oneType :: forall a. Typeable a => Body Source #

The request/response body can only be of one type. Equivalent to a single ReqBody _ a.

manyTypes :: forall as. AllTypeable as => Body Source #

The body admits multiple representations. For more expressive aliases, use allOf or oneOf.

allOf :: forall as. AllTypeable as => Body Source #

The request body must satisfy several FromJSON instances. Equivalent to multiple ReqBody's chained with :>, or OpenApi's [allOf](https:/swagger.iodocsspecificationdata-modelsoneof-anyof-allof-not#allof).

Alias for manyTypes.

oneOf :: forall as. AllTypeable as => Body Source #

The response body could be one of several types. Equivalent to the UVerb combinator, or OpenApi's oneOf.

Alias for manyTypes.