| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Mig
Description
Main module to write servers
Server is a function from response to request. Request is wrapped into monad. Library supports IO-monad and ReaderT over IO like monads.
We can build servers from parts with flexible combinators. Let's build hello-world server:
main :: IO () main = runServer 8080 server server :: Server IO server = "api" /. "v1" /. "hello" /. handleHello handleHello :: Get IO (Resp Text Text) handleHello = Send $ pure $ ok "Hello World"
We can iuse monoids to combine servers and newtype-wrappers to read various inputs. See readme of the repo for tutorial and docs.
Synopsis
- newtype Server (m :: Type -> Type) = Server {}
- data Api a
- newtype Path = Path {}
- data PathItem
- data Route (m :: Type -> Type) = Route {}
- data Json
- data AnyMedia
- data FormUrlEncoded
- data OctetStream
- class ToServer a where
- class MonadIO (MonadOf a) => ToRoute a where
- toRouteInfo :: RouteInfo -> RouteInfo
- toRouteFun :: a -> ServerFun (MonadOf a)
- data MediaType
- class ToMediaType (a :: k) where
- class ToMediaType ty => ToRespBody (ty :: k) b where
- toRespBody :: b -> ByteString
- class ToMediaType ty => FromReqBody (ty :: k) b where
- fromReqBody :: ByteString -> Either Text b
- class IsResp a where
- type RespBody a
- type RespError a
- type RespMedia a
- ok :: RespBody a -> a
- bad :: Status -> RespError a -> a
- noContent :: Status -> a
- addHeaders :: ResponseHeaders -> a -> a
- getHeaders :: a -> ResponseHeaders
- setStatus :: Status -> a -> a
- getRespBody :: a -> Maybe (RespBody a)
- getRespError :: a -> Maybe (RespError a)
- getStatus :: a -> Status
- setMedia :: MediaType -> a -> a
- getMedia :: MediaType
- toResponse :: a -> Response
- badReq :: IsResp a => RespError a -> a
- internalServerError :: IsResp a => RespError a -> a
- notImplemented :: IsResp a => RespError a -> a
- redirect :: IsResp a => Text -> a
- setHeader :: (IsResp a, ToHttpApiData h) => HeaderName -> h -> a -> a
- setCookie :: (ToForm cookie, IsResp resp) => SetCookie cookie -> resp -> resp
- data SetCookie a = SetCookie {}
- defCookie :: a -> SetCookie a
- newtype Send (method :: k) (m :: k1 -> Type) (a :: k1) = Send {
- unSend :: m a
- type Get (m :: k -> Type) (a :: k) = Send GET m a
- type Post (m :: k -> Type) (a :: k) = Send POST m a
- type Put (m :: k -> Type) (a :: k) = Send PUT m a
- type Delete (m :: k -> Type) (a :: k) = Send DELETE m a
- type Patch (m :: k -> Type) (a :: k) = Send PATCH m a
- type Options (m :: k -> Type) (a :: k) = Send OPTIONS m a
- type Head (m :: k -> Type) (a :: k) = Send HEAD m a
- type Trace (m :: k -> Type) (a :: k) = Send TRACE m a
- class IsMethod (a :: k) where
- data GET
- data POST
- data PUT
- data DELETE
- data PATCH
- data OPTIONS
- data HEAD
- data TRACE
- type family UrlOf a where ...
- class ToUrl a where
- data Url = Url {}
- renderUrl :: IsString a => Url -> a
- data a :| b = a :| b
- (/.) :: ToServer a => Path -> a -> Server (MonadOf a)
- newtype Capture (sym :: Symbol) a = Capture a
- newtype Query (sym :: Symbol) a = Query a
- newtype QueryFlag (sym :: Symbol) = QueryFlag Bool
- newtype Optional (sym :: Symbol) a = Optional (Maybe a)
- newtype Body (media :: k) a = Body a
- newtype OptionalHeader (sym :: Symbol) a = OptionalHeader (Maybe a)
- newtype Cookie a = Cookie (Maybe a)
- newtype Header (sym :: Symbol) a = Header a
- newtype PathInfo = PathInfo [Text]
- newtype FullPathInfo = FullPathInfo Text
- newtype RawRequest = RawRequest Request
- data Resp media a = Resp {}
- newtype RespOr ty err a = RespOr {}
- staticFiles :: forall (m :: Type -> Type). MonadIO m => [(FilePath, ByteString)] -> Server m
- data Plugin (m :: Type -> Type) = Plugin {}
- type PluginFun (m :: Type -> Type) = ServerFun m -> ServerFun m
- class MonadIO (MonadOf f) => ToPlugin f where
- toPluginInfo :: RouteInfo -> RouteInfo
- toPluginFun :: f -> ServerFun (MonadOf f) -> ServerFun (MonadOf f)
- applyPlugin :: ToPlugin f => f -> Server (MonadOf f) -> Server (MonadOf f)
- ($:) :: ToPlugin f => f -> Server (MonadOf f) -> Server (MonadOf f)
- prependServerAction :: MonadIO m => m () -> Plugin m
- appendServerAction :: MonadIO m => m () -> Plugin m
- processResponse :: MonadIO m => (m (Maybe Response) -> m (Maybe Response)) -> Plugin m
- data Request
- data Response
- okResponse :: forall {k} (mime :: k) a. ToRespBody mime a => a -> Response
- badResponse :: forall {k} (mime :: k) a. ToRespBody mime a => Status -> a -> Response
- type ServerFun (m :: Type -> Type) = Request -> m (Maybe Response)
- runServer :: Int -> Server IO -> IO ()
- runServer' :: ServerConfig -> Int -> Server IO -> IO ()
- data ServerConfig = ServerConfig {}
- data FindRouteType
- data CacheConfig = CacheConfig {
- size :: Int
- cacheFilter :: CacheKey -> Bool
- toApplication :: ServerConfig -> Server IO -> Application
- class Monad m => HasServer (m :: Type -> Type) where
- type ServerResult (m :: Type -> Type)
- renderServer :: Server m -> ServerResult m
- fromReader :: env -> Server (ReaderT env IO) -> Server IO
- class ToText a where
- badRequest :: forall {k} (media :: k) a. ToRespBody media a => a -> Response
- mapRouteInfo :: forall (m :: Type -> Type). (RouteInfo -> RouteInfo) -> Server m -> Server m
- mapServerFun :: (ServerFun m -> ServerFun n) -> Server m -> Server n
- mapResponse :: forall (m :: Type -> Type). Functor m => (Response -> Response) -> Server m -> Server m
- atPath :: forall (m :: Type -> Type). Path -> Server m -> Server m
- filterPath :: forall (m :: Type -> Type). (Path -> Bool) -> Server m -> Server m
- getServerPaths :: forall (m :: Type -> Type). Server m -> [Path]
- addPathLink :: forall (m :: Type -> Type). Path -> Path -> Server m -> Server m
- toOpenApi :: forall (m :: Type -> Type). Server m -> OpenApi
- setDescription :: forall (m :: Type -> Type). Text -> Server m -> Server m
- describeInputs :: forall (m :: Type -> Type). [(Text, Text)] -> Server m -> Server m
- setSummary :: forall (m :: Type -> Type). Text -> Server m -> Server m
- module Control.Monad.IO.Class
- module Control.Monad.Trans.Class
- module Data.Default
- module Data.Maybe
- module Data.String
- module Mig.Extra.Derive
- module Network.HTTP.Types.Status
- module Web.FormUrlEncoded
- module Web.HttpApiData
- class Generic a
- class FromJSON a where
- parseJSON :: Value -> Parser a
- parseJSONList :: Value -> Parser [a]
- omittedField :: Maybe a
- class ToJSON a where
- toJSON :: a -> Value
- toEncoding :: a -> Encoding
- toJSONList :: [a] -> Value
- toEncodingList :: [a] -> Encoding
- omitField :: a -> Bool
- data Text
- type Html = Markup
- class ToMarkup a where
- toMarkup :: a -> Markup
- preEscapedToMarkup :: a -> Markup
- type ResponseHeaders = [Header]
- type RequestHeaders = [Header]
- data OpenApi
- class ToParamSchema a where
- toParamSchema :: Proxy a -> Schema
- class Typeable a => ToSchema a where
- declareNamedSchema :: Proxy a -> Declare (Definitions Schema) NamedSchema
- withSwagger :: forall (m :: Type -> Type). MonadIO m => SwaggerConfig m -> Server m -> Server m
- swagger :: MonadIO m => SwaggerConfig m -> m OpenApi -> Server m
- data DefaultInfo = DefaultInfo {}
- addDefaultInfo :: DefaultInfo -> OpenApi -> OpenApi
- writeOpenApi :: forall (m :: Type -> Type). FilePath -> Server m -> IO ()
- printOpenApi :: forall (m :: Type -> Type). Server m -> IO ()
types
newtype Server (m :: Type -> Type) #
Server type. It is a function fron request to response. Some servers does not return valid value. We use it to find right path.
Example:
server :: Server IO
server =
"api/v1" /.
[ "foo" /. handleFoo
, "bar" /. handleBar
]
handleFoo :: Query "name" Int -> Get IO (Resp Json Text)
handleBar :: Post Json IO TextNote that server is monoid and it can be constructed with Monoid functions and
path constructor (/.). To pass inputs for handler we can use special newtype wrappers:
Query- for required query parametersOptional- for optional query parametersQueryFlag- for boolean query flagsCapture- for parsing elements of URIHeader- for parsing headersOptionalHeader- for parsing optional headersBody- fot request-body input
and other request types.
To distinguish by HTTP-method we use corresponding constructors: Get, Post, Put, etc. Let's discuss the structure of the constructor. Let's take Get for example:
type Get m a = Send GET m a newtype Send method m a = Send (m a)
Let's look at the arguments of he type
method- type tag of the HTTP-method (GET, POST, PUT, DELETE, etc.)m- underlying server monada- response type. It should be convertible to the type of the response (seeIsRespclass).
HTTP API container
Constructors
| Append (Api a) (Api a) | alternative between two API's |
| Empty | an empty API that does nothing |
| WithPath Path (Api a) | path prefix for an API |
| HandleRoute a | handle route |
Instances
| Foldable Api | |
Defined in Mig.Core.Api Methods fold :: Monoid m => Api m -> m # foldMap :: Monoid m => (a -> m) -> Api a -> m # foldMap' :: Monoid m => (a -> m) -> Api a -> m # foldr :: (a -> b -> b) -> b -> Api a -> b # foldr' :: (a -> b -> b) -> b -> Api a -> b # foldl :: (b -> a -> b) -> b -> Api a -> b # foldl' :: (b -> a -> b) -> b -> Api a -> b # foldr1 :: (a -> a -> a) -> Api a -> a # foldl1 :: (a -> a -> a) -> Api a -> a # elem :: Eq a => a -> Api a -> Bool # maximum :: Ord a => Api a -> a # | |
| Traversable Api | |
| Functor Api | |
| Monoid (Api a) | |
| Semigroup (Api a) | |
| Show a => Show (Api a) | |
| Eq a => Eq (Api a) | |
Path is a chain of elements which can be static types or capture.
There is IsString instance which allows us to create paths from strings. Examples:
"api/v1/foo" ==> Path [StaticPath "api", StaticPath "v1", StaticPath "foo"] "api/v1/*" ==> Path [StaticPath "api", StaticPath "v1", CapturePath "*"]
Instances
| IsString Path | |
Defined in Mig.Core.Api Methods fromString :: String -> Path # | |
| Monoid Path | |
| Semigroup Path | |
| Show Path | |
| Eq Path | |
| Ord Path | |
| ToHttpApiData Path | |
Defined in Mig.Core.Api Methods toUrlPiece :: Path -> Text # toEncodedUrlPiece :: Path -> Builder # toHeader :: Path -> ByteString # toQueryParam :: Path -> Text # toEncodedQueryParam :: Path -> Builder # | |
Path can be a static item or capture with a name
Constructors
| StaticPath Text | |
| CapturePath Text |
Instances
| Show PathItem | |
| Eq PathItem | |
| Ord PathItem | |
Defined in Mig.Core.Api | |
| ToHttpApiData PathItem | |
Defined in Mig.Core.Api Methods toUrlPiece :: PathItem -> Text # toEncodedUrlPiece :: PathItem -> Builder # toHeader :: PathItem -> ByteString # toQueryParam :: PathItem -> Text # toEncodedQueryParam :: PathItem -> Builder # | |
data Route (m :: Type -> Type) #
Route contains API-info and how to run it
Constructors
| Route | |
Instances
| MonadIO m => ToRoute (Route m) | |
Defined in Mig.Core.Class.Route Methods toRouteInfo :: RouteInfo -> RouteInfo # | |
DSL
Type-level tag for JSON media type It is converted to "application/json"
Instances
| ToMediaType Json | |
Defined in Mig.Core.Class.MediaType Methods | |
| FromJSON a => FromReqBody Json a | |
Defined in Mig.Core.Class.MediaType Methods fromReqBody :: ByteString -> Either Text a # | |
| ToJSON a => ToRespBody Json a | |
Defined in Mig.Core.Class.MediaType Methods toRespBody :: a -> ByteString # | |
Signifies any media. It prescribes the server renderer to lookup media-type at run-time in the "Conten-Type" header. As media-type it is rendered to "*/*".
It is useful for values for which we want to derive content type from run-time values. For example it is used for static file servers to get media type from file extension.
Instances
| ToMediaType AnyMedia | |
Defined in Mig.Core.Class.MediaType Methods | |
| ToRespBody AnyMedia ByteString | |
Defined in Mig.Core.Class.MediaType Methods toRespBody :: ByteString -> ByteString # | |
| ToRespBody AnyMedia ByteString | |
Defined in Mig.Core.Class.MediaType Methods toRespBody :: ByteString -> ByteString # | |
data FormUrlEncoded #
Type-level tag for FORM url encoded media-type. It is converted to "application/x-www-form-urlencoded"
Instances
| ToMediaType FormUrlEncoded | |
Defined in Mig.Core.Class.MediaType Methods | |
| FromForm a => FromReqBody FormUrlEncoded a | |
Defined in Mig.Core.Class.MediaType Methods fromReqBody :: ByteString -> Either Text a # | |
| ToForm a => ToRespBody FormUrlEncoded a | |
Defined in Mig.Core.Class.MediaType Methods toRespBody :: a -> ByteString # | |
data OctetStream #
Media type octet stream is for passing raw byte-strings in the request body. It is converted to "application/octet-stream"
Instances
| ToMediaType OctetStream | |
Defined in Mig.Core.Class.MediaType Methods | |
| FromReqBody OctetStream ByteString | |
Defined in Mig.Core.Class.MediaType Methods fromReqBody :: ByteString -> Either Text ByteString # | |
| FromReqBody OctetStream ByteString | |
Defined in Mig.Core.Class.MediaType Methods fromReqBody :: ByteString -> Either Text ByteString # | |
| ToRespBody OctetStream ByteString | |
Defined in Mig.Core.Class.MediaType Methods toRespBody :: ByteString -> ByteString # | |
| ToRespBody OctetStream ByteString | |
Defined in Mig.Core.Class.MediaType Methods toRespBody :: ByteString -> ByteString # | |
Values that can be converted to server
Instances
| ToRoute a => ToServer a | |
Defined in Mig.Core.Class.Server | |
| ToServer (Server m) | |
| ToServer a => ToServer [a] | |
Defined in Mig.Core.Class.Server | |
class MonadIO (MonadOf a) => ToRoute a where #
Values that represent routes. A route is a function of arbitrary number of arguments. Where each argument is one of the special newtype-wrappers that read type-safe information from HTTP-request and return type of the route function is a value of something convertible to HTTP-request.
Methods
toRouteInfo :: RouteInfo -> RouteInfo #
Update API info
toRouteFun :: a -> ServerFun (MonadOf a) #
Convert to route
Instances
An HTTP media type, consisting of the type, subtype, and parameters.
Instances
| IsString MediaType | |
Defined in Network.HTTP.Media.MediaType.Internal Methods fromString :: String -> MediaType # | |
| Show MediaType | |
| Eq MediaType | |
| Ord MediaType | |
Defined in Network.HTTP.Media.MediaType.Internal | |
| Accept MediaType | |
Defined in Network.HTTP.Media.MediaType.Internal Methods parseAccept :: ByteString -> Maybe MediaType # matches :: MediaType -> MediaType -> Bool # moreSpecificThan :: MediaType -> MediaType -> Bool # | |
| RenderHeader MediaType | |
Defined in Network.HTTP.Media.MediaType.Internal Methods renderHeader :: MediaType -> ByteString # | |
| HasContentType Encoding (Maybe MediaType) | |
Defined in Data.OpenApi.Lens | |
| HasContent RequestBody (InsOrdHashMap MediaType MediaTypeObject) | |
Defined in Data.OpenApi.Lens Methods content :: Lens' RequestBody (InsOrdHashMap MediaType MediaTypeObject) # | |
| HasContent Response (InsOrdHashMap MediaType MediaTypeObject) | |
Defined in Data.OpenApi.Lens Methods content :: Lens' Response (InsOrdHashMap MediaType MediaTypeObject) # | |
class ToMediaType (a :: k) where #
Conversion of type-level tags to media type values
Methods
Instances
| ToMediaType Html | |
Defined in Mig.Core.Class.MediaType Methods | |
| ToMediaType ByteString | |
Defined in Mig.Core.Class.MediaType Methods | |
| ToMediaType AnyMedia | |
Defined in Mig.Core.Class.MediaType Methods | |
| ToMediaType FormUrlEncoded | |
Defined in Mig.Core.Class.MediaType Methods | |
| ToMediaType Json | |
Defined in Mig.Core.Class.MediaType Methods | |
| ToMediaType OctetStream | |
Defined in Mig.Core.Class.MediaType Methods | |
| ToMediaType Text | |
Defined in Mig.Core.Class.MediaType Methods | |
class ToMediaType ty => ToRespBody (ty :: k) b where #
Values that can be rendered to response body byte string.
Methods
toRespBody :: b -> ByteString #
Instances
| ToMarkup a => ToRespBody Html a | |
Defined in Mig.Core.Class.MediaType Methods toRespBody :: a -> ByteString # | |
| ToRespBody AnyMedia ByteString | |
Defined in Mig.Core.Class.MediaType Methods toRespBody :: ByteString -> ByteString # | |
| ToRespBody AnyMedia ByteString | |
Defined in Mig.Core.Class.MediaType Methods toRespBody :: ByteString -> ByteString # | |
| ToForm a => ToRespBody FormUrlEncoded a | |
Defined in Mig.Core.Class.MediaType Methods toRespBody :: a -> ByteString # | |
| ToJSON a => ToRespBody Json a | |
Defined in Mig.Core.Class.MediaType Methods toRespBody :: a -> ByteString # | |
| ToRespBody OctetStream ByteString | |
Defined in Mig.Core.Class.MediaType Methods toRespBody :: ByteString -> ByteString # | |
| ToRespBody OctetStream ByteString | |
Defined in Mig.Core.Class.MediaType Methods toRespBody :: ByteString -> ByteString # | |
| ToRespBody Text Text | |
Defined in Mig.Core.Class.MediaType Methods toRespBody :: Text -> ByteString # | |
| ToRespBody Text Text | |
Defined in Mig.Core.Class.MediaType Methods toRespBody :: Text -> ByteString # | |
class ToMediaType ty => FromReqBody (ty :: k) b where #
Values that can be parsed from request byte string.
Methods
fromReqBody :: ByteString -> Either Text b #
Instances
| FromForm a => FromReqBody FormUrlEncoded a | |
Defined in Mig.Core.Class.MediaType Methods fromReqBody :: ByteString -> Either Text a # | |
| FromJSON a => FromReqBody Json a | |
Defined in Mig.Core.Class.MediaType Methods fromReqBody :: ByteString -> Either Text a # | |
| FromReqBody OctetStream ByteString | |
Defined in Mig.Core.Class.MediaType Methods fromReqBody :: ByteString -> Either Text ByteString # | |
| FromReqBody OctetStream ByteString | |
Defined in Mig.Core.Class.MediaType Methods fromReqBody :: ByteString -> Either Text ByteString # | |
| FromReqBody Text Text | |
Defined in Mig.Core.Class.MediaType Methods fromReqBody :: ByteString -> Either Text Text # | |
response
Values that can be converted to low-level response.
The repsonse value is usually one of two cases:
Resp a-- for routes which always produce a valueRespOr err a- for routes that can also produce an error or value.Response- low-level HTTP-response.
Minimal complete definition
ok, bad, noContent, addHeaders, getHeaders, setStatus, getRespBody, getRespError, getStatus, getMedia, toResponse
Associated Types
the type of response body value
the type of an error
the media tpye of resp
Methods
Returns valid repsonse with 200 status
bad :: Status -> RespError a -> a #
Returns an error with given status
response with no content
addHeaders :: ResponseHeaders -> a -> a #
Add some header to the response
getHeaders :: a -> ResponseHeaders #
Get response headers
setStatus :: Status -> a -> a #
Sets repsonse status
getRespBody :: a -> Maybe (RespBody a) #
Get response body
getRespError :: a -> Maybe (RespError a) #
Get response error
Get response status
setMedia :: MediaType -> a -> a #
Set the media type of the response
Reads the media type by response type
toResponse :: a -> Response #
Converts value to low-level response
Instances
internalServerError :: IsResp a => RespError a -> a #
Internal server error. The bad response with 500 status.
notImplemented :: IsResp a => RespError a -> a #
Not implemented route. The bad response with 501 status.
redirect :: IsResp a => Text -> a #
Redirect to url. It is bad response with 302 status and set header of Location to a given URL.
setHeader :: (IsResp a, ToHttpApiData h) => HeaderName -> h -> a -> a #
Set header for response
setCookie :: (ToForm cookie, IsResp resp) => SetCookie cookie -> resp -> resp #
Set cookie as http header from form url encoded value
Set cookie params. For explanation see an article https://web.archive.org/web/20170122122852/https://www.nczonline.net/blog/2009/05/05/http-cookies-explained/
Constructors
| SetCookie | |
methods
newtype Send (method :: k) (m :: k1 -> Type) (a :: k1) #
Route response type. It encodes the route method in the type and which monad is used and which type the response has.
The repsonse value is usually one of two cases:
Resp media a-- for routes which always produce a valueRespOr media err a- for routes that can also produce an error or value.
See the class IsResp for more details on response types.
Instances
| MonadTrans (Send method :: (Type -> Type) -> Type -> Type) | |||||
Defined in Mig.Core.Types.Route | |||||
| MonadIO m => MonadIO (Send method m) | |||||
Defined in Mig.Core.Types.Route | |||||
| Applicative m => Applicative (Send method m) | |||||
Defined in Mig.Core.Types.Route Methods pure :: a -> Send method m a # (<*>) :: Send method m (a -> b) -> Send method m a -> Send method m b # liftA2 :: (a -> b -> c) -> Send method m a -> Send method m b -> Send method m c # (*>) :: Send method m a -> Send method m b -> Send method m b # (<*) :: Send method m a -> Send method m b -> Send method m a # | |||||
| Functor m => Functor (Send method m) | |||||
| Monad m => Monad (Send method m) | |||||
| (MonadIO m, IsResp a, IsMethod method) => ToRoute (Send method m a) | |||||
Defined in Mig.Core.Class.Route Methods toRouteInfo :: RouteInfo -> RouteInfo # toRouteFun :: Send method m a -> ServerFun (MonadOf (Send method m a)) # | |||||
| (ToRespBody (RespMedia a) (RespError a), IsResp a) => FromClient (Send method Client a) | |||||
Defined in Mig.Client Associated Types
Methods fromClient :: Send method Client a -> ClientResult (Send method Client a) # | |||||
| MapRequest (Send method Client a) | |||||
Defined in Mig.Client Methods mapRequest :: (Request -> Request) -> Send method Client a -> Send method Client a mapCapture :: (CaptureMap -> CaptureMap) -> Send method Client a -> Send method Client a | |||||
| (IsMethod method, FromReqBody (RespMedia a) (RespBody a), IsResp a) => ToClient (Send method Client a) | |||||
| type ClientResult (Send method Client a) | |||||
Defined in Mig.Client | |||||
class IsMethod (a :: k) where #
Converts type-level tag for methods to value
Instances
| IsMethod DELETE | |
Defined in Mig.Core.Types.Route | |
| IsMethod GET | |
Defined in Mig.Core.Types.Route | |
| IsMethod HEAD | |
Defined in Mig.Core.Types.Route | |
| IsMethod OPTIONS | |
Defined in Mig.Core.Types.Route | |
| IsMethod PATCH | |
Defined in Mig.Core.Types.Route | |
| IsMethod POST | |
Defined in Mig.Core.Types.Route | |
| IsMethod PUT | |
Defined in Mig.Core.Types.Route | |
| IsMethod TRACE | |
Defined in Mig.Core.Types.Route | |
type-level GET-method tag
type-level POST-method tag
type-level PUT-method tag
type-level DELETE-method tag
type-level PATCH-method tag
type-level OPTIONS-method tag
type-level HEAD-method tag
type-level TRACE-method tag
safe URLs
type family UrlOf a where ... #
Converts route type to URL function
Equations
| UrlOf (Send method m a) = Url | |
| UrlOf (Query name value -> b) = Query name value -> UrlOf b | |
| UrlOf (Optional name value -> b) = Optional name value -> UrlOf b | |
| UrlOf (Capture name value -> b) = Capture name value -> UrlOf b | |
| UrlOf (QueryFlag name -> b) = QueryFlag name -> UrlOf b | |
| UrlOf (Header name value -> b) = UrlOf b | |
| UrlOf (OptionalHeader name value -> b) = UrlOf b | |
| UrlOf (Body media value -> b) = UrlOf b | |
| UrlOf (Cookie value -> b) = UrlOf b | |
| UrlOf (PathInfo -> b) = UrlOf b | |
| UrlOf (FullPathInfo -> b) = UrlOf b | |
| UrlOf (RawRequest -> b) = UrlOf b | |
| UrlOf (IsSecure -> b) = UrlOf b | |
| UrlOf (a, b) = (UrlOf a, UrlOf b) | |
| UrlOf (a, b, c) = (UrlOf a, UrlOf b, UrlOf c) | |
| UrlOf (a, b, c, d) = (UrlOf a, UrlOf b, UrlOf c, UrlOf d) | |
| UrlOf (a, b, c, d, e) = (UrlOf a, UrlOf b, UrlOf c, UrlOf d, UrlOf e) | |
| UrlOf (a, b, c, d, e, f) = (UrlOf a, UrlOf b, UrlOf c, UrlOf d, UrlOf e, UrlOf f) | |
| UrlOf (a :| b) = UrlOf a :| UrlOf b |
Converts server to safe url. We can use it to generate safe URL constructors to be used in HTML templates An example of how we can create safe URL's. Note that order of URL's should be the same as in server definition:
type GreetingRoute = Get Html
type BlogPostRoute = Optional "id" BlogPostId -> Get Html
type ListPostsRoute = Get Html
data Routes = Routes
{ greeting :: GreetingRoute
, blogPost :: BlogPostRoute
, listPosts :: ListPostsRoute
}
-- URLs
data Urls = Urls
{ greeting :: UrlOf GreetingRoute
, blogPost :: UrlOf BlogPostRoute
, listPosts :: UrlOf ListPostsRoute
}
{\-| Site URL's
URL's should be listed in the same order as they appear in the server
-\}
urls :: Urls
urls = Urls{..}
where
greeting
:| blogPost
:| listPosts
toUrl (server undefined)Instances
| ToUrl Url | |
| (ToUrl a, ToUrl b) => ToUrl (a :| b) | |
| (ToUrl a, ToUrl b) => ToUrl (a, b) | |
| (KnownSymbol sym, ToHttpApiData a, ToUrl b) => ToUrl (Capture sym a -> b) | |
| (KnownSymbol sym, ToHttpApiData a, ToUrl b) => ToUrl (Optional sym a -> b) | |
| (KnownSymbol sym, ToHttpApiData a, ToUrl b) => ToUrl (Query sym a -> b) | |
| (KnownSymbol sym, ToUrl b) => ToUrl (QueryFlag sym -> b) | |
| (ToUrl a, ToUrl b, ToUrl c) => ToUrl (a, b, c) | |
| (ToUrl a, ToUrl b, ToUrl c, ToUrl d) => ToUrl (a, b, c, d) | |
Infix synonym for pair. It can be useful to stack together
many client functions in the output of toClient function.
Constructors
| a :| b |
Instances
| (ToUrl a, ToUrl b) => ToUrl (a :| b) | |
| (MapRequest a, MapRequest b) => MapRequest (a :| b) | |
Defined in Mig.Client Methods mapRequest :: (Request -> Request) -> (a :| b) -> a :| b mapCapture :: (CaptureMap -> CaptureMap) -> (a :| b) -> a :| b | |
| (ToClient a, ToClient b) => ToClient (a :| b) | |
Defined in Mig.Client | |
path and query
Build API for routes with queries and captures. Use monoid to combine several routes together.
(/.) :: ToServer a => Path -> a -> Server (MonadOf a) infixr 4 #
Constructs server which can handle given path. Example:
"api/v1/get/info" /. handleInfo
For captures we use wild-cards:
"api/v1/get/info/*" /. handleInfo
And handle info has capture argument:
handleInfo :: Capture "nameA" -> Get IO (Resp Json value)
The name for the capture is derived from the type signature of the route handler. Note that if capture is in the last position of the path we can omit wild cards. The proper amount of captures will be derived from the type signature of the handler.
newtype Capture (sym :: Symbol) a #
Argument of capture from the query.
"api/route/{foo} if api/route/bar passed" ==> (Capture bar) :: Capture "Foo" barTypeConstructors
| Capture a |
Instances
| (FromHttpApiData a, ToParamSchema a, ToPlugin b, KnownSymbol sym) => ToPlugin (Capture sym a -> b) | |||||
Defined in Mig.Core.Class.Plugin | |||||
| (FromHttpApiData a, ToParamSchema a, ToRoute b, KnownSymbol sym) => ToRoute (Capture sym a -> b) | |||||
Defined in Mig.Core.Class.Route Methods toRouteInfo :: RouteInfo -> RouteInfo # toRouteFun :: (Capture sym a -> b) -> ServerFun (MonadOf (Capture sym a -> b)) # | |||||
| (KnownSymbol sym, ToHttpApiData a, ToUrl b) => ToUrl (Capture sym a -> b) | |||||
| FromClient b => FromClient (Capture sym a -> b) | |||||
Defined in Mig.Client Associated Types
Methods fromClient :: (Capture sym a -> b) -> ClientResult (Capture sym a -> b) # | |||||
| (KnownSymbol sym, ToHttpApiData a, ToClient b) => ToClient (Capture sym a -> b) | |||||
Defined in Mig.Client | |||||
| type ClientResult (Capture sym a -> b) | |||||
Defined in Mig.Client | |||||
newtype Query (sym :: Symbol) a #
Required URL parameter query.
"api/route?foo=bar" ==> (Query bar) :: Query "foo" a
Constructors
| Query a |
Instances
| (FromHttpApiData a, ToParamSchema a, ToPlugin b, KnownSymbol sym) => ToPlugin (Query sym a -> b) | |||||
Defined in Mig.Core.Class.Plugin | |||||
| (FromHttpApiData a, ToParamSchema a, ToRoute b, KnownSymbol sym) => ToRoute (Query sym a -> b) | |||||
Defined in Mig.Core.Class.Route Methods toRouteInfo :: RouteInfo -> RouteInfo # toRouteFun :: (Query sym a -> b) -> ServerFun (MonadOf (Query sym a -> b)) # | |||||
| (KnownSymbol sym, ToHttpApiData a, ToUrl b) => ToUrl (Query sym a -> b) | |||||
| FromClient b => FromClient (Query sym a -> b) | |||||
Defined in Mig.Client Associated Types
Methods fromClient :: (Query sym a -> b) -> ClientResult (Query sym a -> b) # | |||||
| (KnownSymbol sym, ToHttpApiData a, ToClient b) => ToClient (Query sym a -> b) | |||||
Defined in Mig.Client | |||||
| type ClientResult (Query sym a -> b) | |||||
Defined in Mig.Client | |||||
newtype QueryFlag (sym :: Symbol) #
Query flag. It is a boolean value in the URL-query. If it is missing
it is False if it is in the query but does not have any value it is True.
Also it can have values true/false in the query.
Instances
| (ToPlugin b, KnownSymbol sym) => ToPlugin (QueryFlag sym -> b) | |||||
Defined in Mig.Core.Class.Plugin | |||||
| (ToRoute b, KnownSymbol sym) => ToRoute (QueryFlag sym -> b) | |||||
Defined in Mig.Core.Class.Route Methods toRouteInfo :: RouteInfo -> RouteInfo # toRouteFun :: (QueryFlag sym -> b) -> ServerFun (MonadOf (QueryFlag sym -> b)) # | |||||
| (KnownSymbol sym, ToUrl b) => ToUrl (QueryFlag sym -> b) | |||||
| FromClient b => FromClient (QueryFlag a -> b) | |||||
Defined in Mig.Client Associated Types
Methods fromClient :: (QueryFlag a -> b) -> ClientResult (QueryFlag a -> b) # | |||||
| (KnownSymbol sym, ToClient b) => ToClient (QueryFlag sym -> b) | |||||
Defined in Mig.Client | |||||
| type ClientResult (QueryFlag a -> b) | |||||
Defined in Mig.Client | |||||
newtype Optional (sym :: Symbol) a #
Optional URL parameter query.
"api/route?foo=bar" ==> (Optional maybeBar) :: Query "foo" a
Instances
| (FromHttpApiData a, ToParamSchema a, ToPlugin b, KnownSymbol sym) => ToPlugin (Optional sym a -> b) | |||||
Defined in Mig.Core.Class.Plugin | |||||
| (FromHttpApiData a, ToParamSchema a, ToRoute b, KnownSymbol sym) => ToRoute (Optional sym a -> b) | |||||
Defined in Mig.Core.Class.Route Methods toRouteInfo :: RouteInfo -> RouteInfo # toRouteFun :: (Optional sym a -> b) -> ServerFun (MonadOf (Optional sym a -> b)) # | |||||
| (KnownSymbol sym, ToHttpApiData a, ToUrl b) => ToUrl (Optional sym a -> b) | |||||
| FromClient b => FromClient (Optional sym a -> b) | |||||
Defined in Mig.Client Associated Types
Methods fromClient :: (Optional sym a -> b) -> ClientResult (Optional sym a -> b) # | |||||
| (KnownSymbol sym, ToHttpApiData a, ToClient b) => ToClient (Optional sym a -> b) | |||||
Defined in Mig.Client | |||||
| type ClientResult (Optional sym a -> b) | |||||
Defined in Mig.Client | |||||
Generic case for request body. The type encodes a media type and value of the request body.
Constructors
| Body a |
Instances
| (FromReqBody ty a, ToSchema a, ToPlugin b) => ToPlugin (Body ty a -> b) | |||||
Defined in Mig.Core.Class.Plugin | |||||
| (ToSchema a, FromReqBody media a, ToRoute b) => ToRoute (Body media a -> b) | |||||
Defined in Mig.Core.Class.Route Methods toRouteInfo :: RouteInfo -> RouteInfo # toRouteFun :: (Body media a -> b) -> ServerFun (MonadOf (Body media a -> b)) # | |||||
| FromClient b => FromClient (Body media a -> b) | |||||
Defined in Mig.Client Associated Types
Methods fromClient :: (Body media a -> b) -> ClientResult (Body media a -> b) # | |||||
| (ToRespBody media a, ToClient b) => ToClient (Body media a -> b) | |||||
Defined in Mig.Client | |||||
| type ClientResult (Body media a -> b) | |||||
Defined in Mig.Client | |||||
newtype OptionalHeader (sym :: Symbol) a #
Reads value from the optional header by name. For example if the request has header:
"foo": "bar"
It reads the value:
(OptionalHeader (Just bar)) :: OptionalHeader "foo" barType
Constructors
| OptionalHeader (Maybe a) |
Instances
| (FromHttpApiData a, ToParamSchema a, ToPlugin b, KnownSymbol sym) => ToPlugin (OptionalHeader sym a -> b) | |||||
Defined in Mig.Core.Class.Plugin Methods toPluginInfo :: RouteInfo -> RouteInfo # toPluginFun :: (OptionalHeader sym a -> b) -> ServerFun (MonadOf (OptionalHeader sym a -> b)) -> ServerFun (MonadOf (OptionalHeader sym a -> b)) # | |||||
| (FromHttpApiData a, ToParamSchema a, ToRoute b, KnownSymbol sym) => ToRoute (OptionalHeader sym a -> b) | |||||
Defined in Mig.Core.Class.Route Methods toRouteInfo :: RouteInfo -> RouteInfo # toRouteFun :: (OptionalHeader sym a -> b) -> ServerFun (MonadOf (OptionalHeader sym a -> b)) # | |||||
| FromClient b => FromClient (OptionalHeader sym a -> b) | |||||
Defined in Mig.Client Associated Types
Methods fromClient :: (OptionalHeader sym a -> b) -> ClientResult (OptionalHeader sym a -> b) # | |||||
| (KnownSymbol sym, ToHttpApiData a, ToClient b) => ToClient (OptionalHeader sym a -> b) | |||||
Defined in Mig.Client Methods toClient :: forall (m :: Type -> Type). Server m -> OptionalHeader sym a -> b # clientArity :: Int # | |||||
| type ClientResult (OptionalHeader sym a -> b) | |||||
Defined in Mig.Client | |||||
Reads a cookie. It's an optional header with name Cookie. The cookie is URL-encoded and read with instnace of FromForm class.
data MyCookie = MyCookie
{ secret :: Text
, count :: Int
}
deriving (Generic, FromForm)
> "secret=lolkek&count=101"
(Cookie (Just (MyCookie { secret = "lolkek", count = 101 }))) :: Cookie MyCookieInstances
| (FromForm a, ToPlugin b) => ToPlugin (Cookie a -> b) | |
Defined in Mig.Core.Class.Plugin | |
| (FromForm a, ToRoute b) => ToRoute (Cookie a -> b) | |
Defined in Mig.Core.Class.Route Methods toRouteInfo :: RouteInfo -> RouteInfo # toRouteFun :: (Cookie a -> b) -> ServerFun (MonadOf (Cookie a -> b)) # | |
newtype Header (sym :: Symbol) a #
Reads value from the required header by name. For example if the request has header:
"foo": "bar"
It reads the value:
(Header bar) :: Header "foo" barType
Constructors
| Header a |
Instances
| (FromHttpApiData a, ToParamSchema a, ToPlugin b, KnownSymbol sym) => ToPlugin (Header sym a -> b) | |||||
Defined in Mig.Core.Class.Plugin | |||||
| (FromHttpApiData a, ToParamSchema a, ToRoute b, KnownSymbol sym) => ToRoute (Header sym a -> b) | |||||
Defined in Mig.Core.Class.Route Methods toRouteInfo :: RouteInfo -> RouteInfo # toRouteFun :: (Header sym a -> b) -> ServerFun (MonadOf (Header sym a -> b)) # | |||||
| FromClient b => FromClient (Header sym a -> b) | |||||
Defined in Mig.Client Associated Types
Methods fromClient :: (Header sym a -> b) -> ClientResult (Header sym a -> b) # | |||||
| (KnownSymbol sym, ToHttpApiData a, ToClient b) => ToClient (Header sym a -> b) | |||||
Defined in Mig.Client | |||||
| type ClientResult (Header sym a -> b) | |||||
Defined in Mig.Client | |||||
Reads current path info.
"api/foo/bar" ==> PathInfo ["foo", "bar"]
Instances
| ToPlugin a => ToPlugin (PathInfo -> a) | |||||
Defined in Mig.Core.Class.Plugin | |||||
| ToRoute b => ToRoute (PathInfo -> b) | |||||
Defined in Mig.Core.Class.Route Methods toRouteInfo :: RouteInfo -> RouteInfo # toRouteFun :: (PathInfo -> b) -> ServerFun (MonadOf (PathInfo -> b)) # | |||||
| FromClient b => FromClient (PathInfo -> b) | |||||
Defined in Mig.Client Associated Types
Methods fromClient :: (PathInfo -> b) -> ClientResult (PathInfo -> b) # | |||||
| ToClient b => ToClient (PathInfo -> b) | |||||
Defined in Mig.Client | |||||
| type ClientResult (PathInfo -> b) | |||||
Defined in Mig.Client | |||||
newtype FullPathInfo #
Reads current full-path info with queries.
"api/foo/bar?param=value" ==> FullPathInfo "api/foo/bar?param=value"
Constructors
| FullPathInfo Text |
Instances
| ToPlugin a => ToPlugin (FullPathInfo -> a) | |
Defined in Mig.Core.Class.Plugin Methods toPluginInfo :: RouteInfo -> RouteInfo # toPluginFun :: (FullPathInfo -> a) -> ServerFun (MonadOf (FullPathInfo -> a)) -> ServerFun (MonadOf (FullPathInfo -> a)) # | |
| ToRoute b => ToRoute (FullPathInfo -> b) | |
Defined in Mig.Core.Class.Route Methods toRouteInfo :: RouteInfo -> RouteInfo # toRouteFun :: (FullPathInfo -> b) -> ServerFun (MonadOf (FullPathInfo -> b)) # | |
newtype RawRequest #
Read low-level request. Note that it does not affect the API schema
Constructors
| RawRequest Request |
Instances
| ToPlugin a => ToPlugin (RawRequest -> a) | |||||
Defined in Mig.Core.Class.Plugin Methods toPluginInfo :: RouteInfo -> RouteInfo # toPluginFun :: (RawRequest -> a) -> ServerFun (MonadOf (RawRequest -> a)) -> ServerFun (MonadOf (RawRequest -> a)) # | |||||
| ToRoute b => ToRoute (RawRequest -> b) | |||||
Defined in Mig.Core.Class.Route Methods toRouteInfo :: RouteInfo -> RouteInfo # toRouteFun :: (RawRequest -> b) -> ServerFun (MonadOf (RawRequest -> b)) # | |||||
| FromClient b => FromClient (RawRequest -> b) | |||||
Defined in Mig.Client Associated Types
Methods fromClient :: (RawRequest -> b) -> ClientResult (RawRequest -> b) # | |||||
| ToClient b => ToClient (RawRequest -> b) | |||||
Defined in Mig.Client | |||||
| type ClientResult (RawRequest -> b) | |||||
Defined in Mig.Client | |||||
response
How to modify response and attach specific info to it
Response with info on the media-type encoded as type.
Constructors
| Resp | |
Instances
| Functor (Resp media) | |||||||||||||
| Show a => Show (Resp media a) | |||||||||||||
| Eq a => Eq (Resp media a) | |||||||||||||
| ToRespBody ty a => IsResp (Resp ty a) | |||||||||||||
Defined in Mig.Core.Class.Response Associated Types
Methods ok :: RespBody (Resp ty a) -> Resp ty a # bad :: Status -> RespError (Resp ty a) -> Resp ty a # noContent :: Status -> Resp ty a # addHeaders :: ResponseHeaders -> Resp ty a -> Resp ty a # getHeaders :: Resp ty a -> ResponseHeaders # setStatus :: Status -> Resp ty a -> Resp ty a # getRespBody :: Resp ty a -> Maybe (RespBody (Resp ty a)) # getRespError :: Resp ty a -> Maybe (RespError (Resp ty a)) # getStatus :: Resp ty a -> Status # setMedia :: MediaType -> Resp ty a -> Resp ty a # toResponse :: Resp ty a -> Response # | |||||||||||||
| type RespBody (Resp ty a) | |||||||||||||
Defined in Mig.Core.Class.Response | |||||||||||||
| type RespError (Resp ty a) | |||||||||||||
Defined in Mig.Core.Class.Response | |||||||||||||
| type RespMedia (Resp ty a) | |||||||||||||
Defined in Mig.Core.Class.Response | |||||||||||||
Response that can contain an error. The error is represented with left case of an Either-type.
Instances
| Functor (RespOr ty err) | |||||||||||||
| (Show err, Show a) => Show (RespOr ty err a) | |||||||||||||
| (Eq err, Eq a) => Eq (RespOr ty err a) | |||||||||||||
| (ToRespBody ty err, ToRespBody ty a) => IsResp (RespOr ty err a) | |||||||||||||
Defined in Mig.Core.Class.Response Associated Types
Methods ok :: RespBody (RespOr ty err a) -> RespOr ty err a # bad :: Status -> RespError (RespOr ty err a) -> RespOr ty err a # noContent :: Status -> RespOr ty err a # addHeaders :: ResponseHeaders -> RespOr ty err a -> RespOr ty err a # getHeaders :: RespOr ty err a -> ResponseHeaders # setStatus :: Status -> RespOr ty err a -> RespOr ty err a # getRespBody :: RespOr ty err a -> Maybe (RespBody (RespOr ty err a)) # getRespError :: RespOr ty err a -> Maybe (RespError (RespOr ty err a)) # getStatus :: RespOr ty err a -> Status # setMedia :: MediaType -> RespOr ty err a -> RespOr ty err a # toResponse :: RespOr ty err a -> Response # | |||||||||||||
| type RespBody (RespOr ty err a) | |||||||||||||
Defined in Mig.Core.Class.Response | |||||||||||||
| type RespError (RespOr ty err a) | |||||||||||||
Defined in Mig.Core.Class.Response | |||||||||||||
| type RespMedia (RespOr ty err a) | |||||||||||||
Defined in Mig.Core.Class.Response | |||||||||||||
specific cases
staticFiles :: forall (m :: Type -> Type). MonadIO m => [(FilePath, ByteString)] -> Server m #
Serves static files. The file path is a path to where to server the file. The media-type is derived from the extension. There is a special case if we need to server the file from the rooot of the server we can omit everything from the path but keep extension. Otherwise it is not able to derive the media type.
It is convenient to use it with function embedRecursiveDir from the library file-embed or file-embed-lzma.
Plugins
data Plugin (m :: Type -> Type) #
Plugin can convert all routes of the server.
It is wrapper on top of ServerFun m -> ServerFun m.
We can apply plugins to servers with applyPlugin function
also plugin has Monoid instance which is like Monoid.Endo or functional composition (.).
Constructors
| Plugin | |
class MonadIO (MonadOf f) => ToPlugin f where #
Values that can represent a plugin. We use various newtype-wrappers to query type-safe info from request.
Methods
toPluginInfo :: RouteInfo -> RouteInfo #
toPluginFun :: f -> ServerFun (MonadOf f) -> ServerFun (MonadOf f) #
Instances
| MonadIO m => ToPlugin (Plugin m) | |
Defined in Mig.Core.Class.Plugin | |
| MonadIO m => ToPlugin (PluginFun m) | |
Defined in Mig.Core.Class.Plugin | |
| ToPlugin a => ToPlugin (RawResponse -> a) | |
Defined in Mig.Core.Class.Plugin Methods toPluginInfo :: RouteInfo -> RouteInfo # toPluginFun :: (RawResponse -> a) -> ServerFun (MonadOf (RawResponse -> a)) -> ServerFun (MonadOf (RawResponse -> a)) # | |
| (FromReqBody ty a, ToSchema a, ToPlugin b) => ToPlugin (Body ty a -> b) | |
Defined in Mig.Core.Class.Plugin | |
| (FromHttpApiData a, ToParamSchema a, ToPlugin b, KnownSymbol sym) => ToPlugin (Capture sym a -> b) | |
Defined in Mig.Core.Class.Plugin | |
| (FromForm a, ToPlugin b) => ToPlugin (Cookie a -> b) | |
Defined in Mig.Core.Class.Plugin | |
| ToPlugin a => ToPlugin (FullPathInfo -> a) | |
Defined in Mig.Core.Class.Plugin Methods toPluginInfo :: RouteInfo -> RouteInfo # toPluginFun :: (FullPathInfo -> a) -> ServerFun (MonadOf (FullPathInfo -> a)) -> ServerFun (MonadOf (FullPathInfo -> a)) # | |
| (FromHttpApiData a, ToParamSchema a, ToPlugin b, KnownSymbol sym) => ToPlugin (Header sym a -> b) | |
Defined in Mig.Core.Class.Plugin | |
| ToPlugin a => ToPlugin (IsSecure -> a) | |
Defined in Mig.Core.Class.Plugin | |
| (FromHttpApiData a, ToParamSchema a, ToPlugin b, KnownSymbol sym) => ToPlugin (Optional sym a -> b) | |
Defined in Mig.Core.Class.Plugin | |
| (FromHttpApiData a, ToParamSchema a, ToPlugin b, KnownSymbol sym) => ToPlugin (OptionalHeader sym a -> b) | |
Defined in Mig.Core.Class.Plugin Methods toPluginInfo :: RouteInfo -> RouteInfo # toPluginFun :: (OptionalHeader sym a -> b) -> ServerFun (MonadOf (OptionalHeader sym a -> b)) -> ServerFun (MonadOf (OptionalHeader sym a -> b)) # | |
| ToPlugin a => ToPlugin (PathInfo -> a) | |
Defined in Mig.Core.Class.Plugin | |
| (FromHttpApiData a, ToParamSchema a, ToPlugin b, KnownSymbol sym) => ToPlugin (Query sym a -> b) | |
Defined in Mig.Core.Class.Plugin | |
| (ToPlugin b, KnownSymbol sym) => ToPlugin (QueryFlag sym -> b) | |
Defined in Mig.Core.Class.Plugin | |
| ToPlugin a => ToPlugin (RawRequest -> a) | |
Defined in Mig.Core.Class.Plugin Methods toPluginInfo :: RouteInfo -> RouteInfo # toPluginFun :: (RawRequest -> a) -> ServerFun (MonadOf (RawRequest -> a)) -> ServerFun (MonadOf (RawRequest -> a)) # | |
| (FromJSON a, ToSchema a, ToPlugin b) => ToPlugin (Body a -> b) | |
Defined in Mig.Extra.Server.Json | |
applyPlugin :: ToPlugin f => f -> Server (MonadOf f) -> Server (MonadOf f) #
Applies plugin to all routes of the server.
prependServerAction :: MonadIO m => m () -> Plugin m #
Prepends action to the server
appendServerAction :: MonadIO m => m () -> Plugin m #
Post appends action to the server
processResponse :: MonadIO m => (m (Maybe Response) -> m (Maybe Response)) -> Plugin m #
Applies transformation to the response
Low-level types
Http request
Http response
Instances
| Show Response | |||||||||||||
| Eq Response | |||||||||||||
| IsResp Response | |||||||||||||
Defined in Mig.Core.Class.Response Associated Types
Methods ok :: RespBody Response -> Response # bad :: Status -> RespError Response -> Response # noContent :: Status -> Response # addHeaders :: ResponseHeaders -> Response -> Response # getHeaders :: Response -> ResponseHeaders # setStatus :: Status -> Response -> Response # getRespBody :: Response -> Maybe (RespBody Response) # getRespError :: Response -> Maybe (RespError Response) # getStatus :: Response -> Status # setMedia :: MediaType -> Response -> Response # toResponse :: Response -> Response # | |||||||||||||
| MonadIO m => ToPlugin (PluginFun m) | |||||||||||||
Defined in Mig.Core.Class.Plugin | |||||||||||||
| type RespBody Response | |||||||||||||
Defined in Mig.Core.Class.Response | |||||||||||||
| type RespError Response | |||||||||||||
Defined in Mig.Core.Class.Response | |||||||||||||
| type RespMedia Response | |||||||||||||
Defined in Mig.Core.Class.Response | |||||||||||||
okResponse :: forall {k} (mime :: k) a. ToRespBody mime a => a -> Response #
Respond with ok 200-status
badResponse :: forall {k} (mime :: k) a. ToRespBody mime a => Status -> a -> Response #
Bad response qith given status
type ServerFun (m :: Type -> Type) = Request -> m (Maybe Response) #
Low-level representation of the server.
Missing route for a given request returns Nothing.
Run server application
runServer' :: ServerConfig -> Int -> Server IO -> IO () Source #
data ServerConfig #
Server config
Constructors
| ServerConfig | |
Fields
| |
Instances
| Default ServerConfig | |
Defined in Mig.Server.Wai Methods def :: ServerConfig # | |
data FindRouteType #
Algorithm to find route handlers by path
Constructors
| TreeFinder | converts api to tree-like structure (prefer it for servers with many routes) |
| PlainFinder | no optimization (prefer it for small servers) |
data CacheConfig #
Cache config
Constructors
| CacheConfig | |
Fields
| |
toApplication :: ServerConfig -> Server IO -> Application #
Converts mig server to WAI-application.
Note that only IO-based servers are supported. To use custom monad
we can use hoistServer function which renders monad to IO based or
the class HasServer which defines such transformatio for several useful cases.
Render
Render Reader-IO monad servers to IO servers.
class Monad m => HasServer (m :: Type -> Type) where #
Class contains types which can be converted to IO-based server to run as with WAI-interface.
We can run plain IO-servers and ReaderT over IO based servers. Readers can be wrapped in newtypes.
In that case we can derive automatically HasServer instance.
Associated Types
type ServerResult (m :: Type -> Type) #
Methods
renderServer :: Server m -> ServerResult m #
Instances
| HasServer IO | |||||
Defined in Mig.Core.Class.Server Associated Types
Methods renderServer :: Server IO -> ServerResult IO # | |||||
| HasServer (ReaderT env IO) | |||||
Defined in Mig.Core.Class.Server Associated Types
Methods renderServer :: Server (ReaderT env IO) -> ServerResult (ReaderT env IO) # | |||||
| HasServer (ReaderT env (ExceptT Text IO)) | |||||
Defined in Mig.Core.Class.Server Associated Types
| |||||
Convertes
Values convertible to lazy text
Instances
| ToText Text | |
Defined in Mig.Core.Types.Http | |
| ToText Text | |
Defined in Mig.Core.Types.Http | |
| ToText String | |
Defined in Mig.Core.Types.Http | |
| ToText Float | |
Defined in Mig.Core.Types.Http | |
| ToText Int | |
Defined in Mig.Core.Types.Http | |
utils
badRequest :: forall {k} (media :: k) a. ToRespBody media a => a -> Response #
Bad request response
Server
mapRouteInfo :: forall (m :: Type -> Type). (RouteInfo -> RouteInfo) -> Server m -> Server m #
Maps over route API-information
mapServerFun :: (ServerFun m -> ServerFun n) -> Server m -> Server n #
Applies server function to all routes
mapResponse :: forall (m :: Type -> Type). Functor m => (Response -> Response) -> Server m -> Server m #
Mapps response of the server
atPath :: forall (m :: Type -> Type). Path -> Server m -> Server m #
Sub-server for a server on given path it might be usefule to emulate links from one route to another within the server or reuse part of the server inside another server.
getServerPaths :: forall (m :: Type -> Type). Server m -> [Path] #
Returns a list of all paths in the server
addPathLink :: forall (m :: Type -> Type). Path -> Path -> Server m -> Server m #
Links one route of the server to another so that every call to first path is redirected to the second path
OpenApi
setDescription :: forall (m :: Type -> Type). Text -> Server m -> Server m #
Sets description of the route
describeInputs :: forall (m :: Type -> Type). [(Text, Text)] -> Server m -> Server m #
Appends descriptiton for the inputs. It passes pairs for (input-name, input-description).
special name request-body is dedicated to request body input
nd raw-input is dedicated to raw input
module Control.Monad.IO.Class
module Control.Monad.Trans.Class
module Data.Default
module Data.Maybe
module Data.String
module Mig.Extra.Derive
module Network.HTTP.Types.Status
module Web.FormUrlEncoded
module Web.HttpApiData
Representable types of kind *.
This class is derivable in GHC with the DeriveGeneric flag on.
A Generic instance must satisfy the following laws:
from.to≡idto.from≡id
Instances
| Generic Value | |||||
Defined in Data.Aeson.Types.Internal Associated Types
| |||||
| Generic Version | |||||
Defined in Data.Version Associated Types
| |||||
| Generic Void | |||||
| Generic ByteOrder | |||||
Defined in GHC.ByteOrder | |||||
| Generic Fingerprint | |||||
Defined in GHC.Generics Associated Types
| |||||
| Generic Associativity | |||||
Defined in GHC.Generics Associated Types
| |||||
| Generic DecidedStrictness | |||||
Defined in GHC.Generics Associated Types
Methods from :: DecidedStrictness -> Rep DecidedStrictness x # to :: Rep DecidedStrictness x -> DecidedStrictness # | |||||
| Generic Fixity | |||||
Defined in GHC.Generics Associated Types
| |||||
| Generic SourceStrictness | |||||
Defined in GHC.Generics Associated Types
Methods from :: SourceStrictness -> Rep SourceStrictness x # to :: Rep SourceStrictness x -> SourceStrictness # | |||||
| Generic SourceUnpackedness | |||||
Defined in GHC.Generics Associated Types
Methods from :: SourceUnpackedness -> Rep SourceUnpackedness x # to :: Rep SourceUnpackedness x -> SourceUnpackedness # | |||||
| Generic ExitCode | |||||
Defined in GHC.IO.Exception Associated Types
| |||||
| Generic CCFlags | |||||
Defined in GHC.RTS.Flags Associated Types
| |||||
| Generic ConcFlags | |||||
Defined in GHC.RTS.Flags Associated Types
| |||||
| Generic DebugFlags | |||||
Defined in GHC.RTS.Flags Associated Types
| |||||
| Generic DoCostCentres | |||||
Defined in GHC.RTS.Flags Associated Types
| |||||
| Generic DoHeapProfile | |||||
Defined in GHC.RTS.Flags Associated Types
| |||||
| Generic DoTrace | |||||
Defined in GHC.RTS.Flags Associated Types
| |||||
| Generic GCFlags | |||||
Defined in GHC.RTS.Flags Associated Types
| |||||
| Generic GiveGCStats | |||||
Defined in GHC.RTS.Flags Associated Types
| |||||
| Generic MiscFlags | |||||
Defined in GHC.RTS.Flags Associated Types
| |||||
| Generic ParFlags | |||||
Defined in GHC.RTS.Flags Associated Types
| |||||
| Generic ProfFlags | |||||
Defined in GHC.RTS.Flags Associated Types
| |||||
| Generic RTSFlags | |||||
Defined in GHC.RTS.Flags Associated Types
| |||||
| Generic TickyFlags | |||||
Defined in GHC.RTS.Flags Associated Types
| |||||
| Generic TraceFlags | |||||
Defined in GHC.RTS.Flags Associated Types
| |||||
| Generic SrcLoc | |||||
Defined in GHC.Generics Associated Types
| |||||
| Generic GCDetails | |||||
Defined in GHC.Stats Associated Types
| |||||
| Generic RTSStats | |||||
Defined in GHC.Stats Associated Types
| |||||
| Generic GeneralCategory | |||||
Defined in GHC.Generics Associated Types
Methods from :: GeneralCategory -> Rep GeneralCategory x # to :: Rep GeneralCategory x -> GeneralCategory # | |||||
| Generic Ordering | |||||
Defined in GHC.Generics | |||||
| Generic Form | |||||
Defined in Web.Internal.FormUrlEncoded Associated Types
| |||||
| Generic ByteRange | |||||
Defined in Network.HTTP.Types.Header Associated Types
| |||||
| Generic StdMethod | |||||
Defined in Network.HTTP.Types.Method Associated Types
| |||||
| Generic Status | |||||
Defined in Network.HTTP.Types.Status Associated Types
| |||||
| Generic HttpVersion | |||||
Defined in Network.HTTP.Types.Version Associated Types
| |||||
| Generic IP | |||||
Defined in Data.IP.Addr Associated Types
| |||||
| Generic IPv4 | |||||
Defined in Data.IP.Addr Associated Types
| |||||
| Generic IPv6 | |||||
Defined in Data.IP.Addr Associated Types
| |||||
| Generic IPRange | |||||
Defined in Data.IP.Range Associated Types
| |||||
| Generic Link | |||||
Defined in Mig.Extra.Server.Html Associated Types
| |||||
| Generic URI | |||||
Defined in Network.URI Associated Types
| |||||
| Generic URIAuth | |||||
Defined in Network.URI Associated Types
| |||||
| Generic ApiKeyLocation | |||||
Defined in Data.OpenApi.Internal Associated Types
Methods from :: ApiKeyLocation -> Rep ApiKeyLocation x # to :: Rep ApiKeyLocation x -> ApiKeyLocation # | |||||
| Generic ApiKeyParams | |||||
Defined in Data.OpenApi.Internal Associated Types
| |||||
| Generic Callback | |||||
Defined in Data.OpenApi.Internal Associated Types
| |||||
| Generic Components | |||||
Defined in Data.OpenApi.Internal Associated Types
| |||||
| Generic Contact | |||||
Defined in Data.OpenApi.Internal Associated Types
| |||||
| Generic Discriminator | |||||
Defined in Data.OpenApi.Internal Associated Types
| |||||
| Generic Encoding | |||||
Defined in Data.OpenApi.Internal Associated Types
| |||||
| Generic Example | |||||
Defined in Data.OpenApi.Internal Associated Types
| |||||
| Generic ExpressionOrValue | |||||
Defined in Data.OpenApi.Internal Associated Types
Methods from :: ExpressionOrValue -> Rep ExpressionOrValue x # to :: Rep ExpressionOrValue x -> ExpressionOrValue # | |||||
| Generic ExternalDocs | |||||
Defined in Data.OpenApi.Internal Associated Types
| |||||
| Generic Header | |||||
Defined in Data.OpenApi.Internal Associated Types
| |||||
| Generic HttpSchemeType | |||||
Defined in Data.OpenApi.Internal Associated Types
Methods from :: HttpSchemeType -> Rep HttpSchemeType x # to :: Rep HttpSchemeType x -> HttpSchemeType # | |||||
| Generic Info | |||||
Defined in Data.OpenApi.Internal Associated Types
| |||||
| Generic License | |||||
Defined in Data.OpenApi.Internal Associated Types
| |||||
| Generic Link | |||||
Defined in Data.OpenApi.Internal Associated Types
| |||||
| Generic MediaTypeObject | |||||
Defined in Data.OpenApi.Internal Associated Types
Methods from :: MediaTypeObject -> Rep MediaTypeObject x # to :: Rep MediaTypeObject x -> MediaTypeObject # | |||||
| Generic NamedSchema | |||||
Defined in Data.OpenApi.Internal Associated Types
| |||||
| Generic OAuth2AuthorizationCodeFlow | |||||
Defined in Data.OpenApi.Internal Associated Types
Methods from :: OAuth2AuthorizationCodeFlow -> Rep OAuth2AuthorizationCodeFlow x # to :: Rep OAuth2AuthorizationCodeFlow x -> OAuth2AuthorizationCodeFlow # | |||||
| Generic OAuth2ClientCredentialsFlow | |||||
Defined in Data.OpenApi.Internal Associated Types
Methods from :: OAuth2ClientCredentialsFlow -> Rep OAuth2ClientCredentialsFlow x # to :: Rep OAuth2ClientCredentialsFlow x -> OAuth2ClientCredentialsFlow # | |||||
| Generic OAuth2Flows | |||||
Defined in Data.OpenApi.Internal Associated Types
| |||||
| Generic OAuth2ImplicitFlow | |||||
Defined in Data.OpenApi.Internal Associated Types
Methods from :: OAuth2ImplicitFlow -> Rep OAuth2ImplicitFlow x # to :: Rep OAuth2ImplicitFlow x -> OAuth2ImplicitFlow # | |||||
| Generic OAuth2PasswordFlow | |||||
Defined in Data.OpenApi.Internal Associated Types
Methods from :: OAuth2PasswordFlow -> Rep OAuth2PasswordFlow x # to :: Rep OAuth2PasswordFlow x -> OAuth2PasswordFlow # | |||||
| Generic OpenApi | |||||
Defined in Data.OpenApi.Internal Associated Types
| |||||
| Generic OpenApiSpecVersion | |||||
Defined in Data.OpenApi.Internal Associated Types
Methods from :: OpenApiSpecVersion -> Rep OpenApiSpecVersion x # to :: Rep OpenApiSpecVersion x -> OpenApiSpecVersion # | |||||
| Generic OpenApiType | |||||
Defined in Data.OpenApi.Internal Associated Types
| |||||
| Generic Operation | |||||
Defined in Data.OpenApi.Internal Associated Types
| |||||
| Generic Param | |||||
Defined in Data.OpenApi.Internal Associated Types
| |||||
| Generic ParamLocation | |||||
Defined in Data.OpenApi.Internal Associated Types
| |||||
| Generic PathItem | |||||
Defined in Data.OpenApi.Internal Associated Types
| |||||
| Generic RequestBody | |||||
Defined in Data.OpenApi.Internal Associated Types
| |||||
| Generic Response | |||||
Defined in Data.OpenApi.Internal Associated Types
| |||||
| Generic Responses | |||||
Defined in Data.OpenApi.Internal Associated Types
| |||||
| Generic Schema | |||||
Defined in Data.OpenApi.Internal Associated Types
| |||||
| Generic SecurityDefinitions | |||||
Defined in Data.OpenApi.Internal Associated Types
Methods from :: SecurityDefinitions -> Rep SecurityDefinitions x # to :: Rep SecurityDefinitions x -> SecurityDefinitions # | |||||
| Generic SecurityScheme | |||||
Defined in Data.OpenApi.Internal Associated Types
Methods from :: SecurityScheme -> Rep SecurityScheme x # to :: Rep SecurityScheme x -> SecurityScheme # | |||||
| Generic SecuritySchemeType | |||||
Defined in Data.OpenApi.Internal Associated Types
Methods from :: SecuritySchemeType -> Rep SecuritySchemeType x # to :: Rep SecuritySchemeType x -> SecuritySchemeType # | |||||
| Generic Server | |||||
Defined in Data.OpenApi.Internal Associated Types
| |||||
| Generic ServerVariable | |||||
Defined in Data.OpenApi.Internal Associated Types
Methods from :: ServerVariable -> Rep ServerVariable x # to :: Rep ServerVariable x -> ServerVariable # | |||||
| Generic Style | |||||
Defined in Data.OpenApi.Internal Associated Types
| |||||
| Generic Tag | |||||
Defined in Data.OpenApi.Internal Associated Types
| |||||
| Generic Xml | |||||
Defined in Data.OpenApi.Internal Associated Types
| |||||
| Generic ConstructorInfo | |||||
Defined in Language.Haskell.TH.Datatype Associated Types
Methods from :: ConstructorInfo -> Rep ConstructorInfo x # to :: Rep ConstructorInfo x -> ConstructorInfo # | |||||
| Generic ConstructorVariant | |||||
Defined in Language.Haskell.TH.Datatype Associated Types
Methods from :: ConstructorVariant -> Rep ConstructorVariant x # to :: Rep ConstructorVariant x -> ConstructorVariant # | |||||
| Generic DatatypeInfo | |||||
Defined in Language.Haskell.TH.Datatype Associated Types
| |||||
| Generic DatatypeVariant | |||||
Defined in Language.Haskell.TH.Datatype Associated Types
Methods from :: DatatypeVariant -> Rep DatatypeVariant x # to :: Rep DatatypeVariant x -> DatatypeVariant # | |||||
| Generic FieldStrictness | |||||
Defined in Language.Haskell.TH.Datatype Associated Types
Methods from :: FieldStrictness -> Rep FieldStrictness x # to :: Rep FieldStrictness x -> FieldStrictness # | |||||
| Generic Strictness | |||||
Defined in Language.Haskell.TH.Datatype Associated Types
| |||||
| Generic Unpackedness | |||||
Defined in Language.Haskell.TH.Datatype Associated Types
| |||||
| Generic UnixTime | |||||
Defined in Data.UnixTime.Types Associated Types
| |||||
| Generic CompressParams | |||||
Defined in Codec.Compression.Zlib.Internal Associated Types
Methods from :: CompressParams -> Rep CompressParams x # to :: Rep CompressParams x -> CompressParams # | |||||
| Generic DecompressError | |||||
Defined in Codec.Compression.Zlib.Internal Associated Types
Methods from :: DecompressError -> Rep DecompressError x # to :: Rep DecompressError x -> DecompressError # | |||||
| Generic DecompressParams | |||||
Defined in Codec.Compression.Zlib.Internal Associated Types
Methods from :: DecompressParams -> Rep DecompressParams x # to :: Rep DecompressParams x -> DecompressParams # | |||||
| Generic CompressionLevel | |||||
Defined in Codec.Compression.Zlib.Stream Associated Types
Methods from :: CompressionLevel -> Rep CompressionLevel x # to :: Rep CompressionLevel x -> CompressionLevel # | |||||
| Generic CompressionStrategy | |||||
Defined in Codec.Compression.Zlib.Stream Associated Types
Methods from :: CompressionStrategy -> Rep CompressionStrategy x # to :: Rep CompressionStrategy x -> CompressionStrategy # | |||||
| Generic Format | |||||
Defined in Codec.Compression.Zlib.Stream Associated Types
| |||||
| Generic MemoryLevel | |||||
Defined in Codec.Compression.Zlib.Stream Associated Types
| |||||
| Generic Method | |||||
Defined in Codec.Compression.Zlib.Stream | |||||
| Generic WindowBits | |||||
Defined in Codec.Compression.Zlib.Stream Associated Types
| |||||
| Generic () | |||||
| Generic Bool | |||||
Defined in GHC.Generics | |||||
| Generic (ZipList a) | |||||
Defined in Control.Applicative Associated Types
| |||||
| Generic (Complex a) | |||||
Defined in Data.Complex Associated Types
| |||||
| Generic (Identity a) | |||||
Defined in Data.Functor.Identity Associated Types
| |||||
| Generic (First a) | |||||
Defined in Data.Monoid Associated Types
| |||||
| Generic (Last a) | |||||
Defined in Data.Monoid Associated Types
| |||||
| Generic (Down a) | |||||
Defined in GHC.Generics Associated Types
| |||||
| Generic (First a) | |||||
Defined in Data.Semigroup Associated Types
| |||||
| Generic (Last a) | |||||
Defined in Data.Semigroup Associated Types
| |||||
| Generic (Max a) | |||||
Defined in Data.Semigroup Associated Types
| |||||
| Generic (Min a) | |||||
Defined in Data.Semigroup Associated Types
| |||||
| Generic (WrappedMonoid m) | |||||
Defined in Data.Semigroup Associated Types
Methods from :: WrappedMonoid m -> Rep (WrappedMonoid m) x # to :: Rep (WrappedMonoid m) x -> WrappedMonoid m # | |||||
| Generic (NonEmpty a) | |||||
Defined in GHC.Generics Associated Types
| |||||
| Generic (Par1 p) | |||||
Defined in GHC.Generics Associated Types
| |||||
| Generic (Fix f) | |||||
| Generic (HistoriedResponse body) | |||||
Defined in Network.HTTP.Client Associated Types
Methods from :: HistoriedResponse body -> Rep (HistoriedResponse body) x # to :: Rep (HistoriedResponse body) x -> HistoriedResponse body # | |||||
| Generic (AddrRange a) | |||||
Defined in Data.IP.Range Associated Types
| |||||
| Generic (OAuth2Flow p) | |||||
Defined in Data.OpenApi.Internal Associated Types
| |||||
| Generic (I a) | |||||
Defined in Data.SOP.BasicFunctors Associated Types
| |||||
| Generic (Maybe a) | |||||
Defined in Data.Strict.Maybe Associated Types
| |||||
| Generic (Maybe a) | |||||
Defined in GHC.Generics Associated Types
| |||||
| Generic (Solo a) | |||||
Defined in GHC.Generics Associated Types
| |||||
| Generic [a] | |||||
Defined in GHC.Generics Associated Types
| |||||
| Generic (WrappedMonad m a) | |||||
Defined in Control.Applicative Associated Types
Methods from :: WrappedMonad m a -> Rep (WrappedMonad m a) x # to :: Rep (WrappedMonad m a) x -> WrappedMonad m a # | |||||
| Generic (Either a b) | |||||
Defined in GHC.Generics Associated Types
| |||||
| Generic (Proxy t) | |||||
Defined in GHC.Generics | |||||
| Generic (Arg a b) | |||||
Defined in Data.Semigroup Associated Types
| |||||
| Generic (U1 p) | |||||
| Generic (V1 p) | |||||
| Generic (Cofree f a) | |||||
Defined in Control.Comonad.Cofree Associated Types
| |||||
| Generic (Free f a) | |||||
Defined in Control.Monad.Free Associated Types
| |||||
| Generic (Either a b) | |||||
Defined in Data.Strict.Either Associated Types
| |||||
| Generic (These a b) | |||||
Defined in Data.Strict.These Associated Types
| |||||
| Generic (Pair a b) | |||||
Defined in Data.Strict.Tuple Associated Types
| |||||
| Generic (These a b) | |||||
Defined in Data.These Associated Types
| |||||
| Generic (Lift f a) | |||||
Defined in Control.Applicative.Lift Associated Types
| |||||
| Generic (MaybeT m a) | |||||
Defined in Control.Monad.Trans.Maybe Associated Types
| |||||
| Generic (a, b) | |||||
Defined in GHC.Generics Associated Types
| |||||
| Generic (WrappedArrow a b c) | |||||
Defined in Control.Applicative Associated Types
Methods from :: WrappedArrow a b c -> Rep (WrappedArrow a b c) x # to :: Rep (WrappedArrow a b c) x -> WrappedArrow a b c # | |||||
| Generic (Kleisli m a b) | |||||
Defined in Control.Arrow Associated Types
| |||||
| Generic (Const a b) | |||||
Defined in Data.Functor.Const Associated Types
| |||||
| Generic (Ap f a) | |||||
Defined in Data.Monoid Associated Types
| |||||
| Generic (Rec1 f p) | |||||
Defined in GHC.Generics Associated Types
| |||||
| Generic (URec (Ptr ()) p) | |||||
Defined in GHC.Generics Associated Types
| |||||
| Generic (URec Char p) | |||||
Defined in GHC.Generics Associated Types
| |||||
| Generic (URec Double p) | |||||
Defined in GHC.Generics Associated Types
| |||||
| Generic (URec Float p) | |||||
Defined in GHC.Generics Associated Types
| |||||
| Generic (URec Int p) | |||||
Defined in GHC.Generics Associated Types
| |||||
| Generic (URec Word p) | |||||
Defined in GHC.Generics Associated Types
| |||||
| Generic (Fix p a) | |||||
Defined in Data.Bifunctor.Fix Associated Types
| |||||
| Generic (Join p a) | |||||
Defined in Data.Bifunctor.Join Associated Types
| |||||
| Generic (CofreeF f a b) | |||||
Defined in Control.Comonad.Trans.Cofree Associated Types
| |||||
| Generic (FreeF f a b) | |||||
Defined in Control.Monad.Trans.Free Associated Types
| |||||
| Generic (K a b) | |||||
Defined in Data.SOP.BasicFunctors Associated Types
| |||||
| Generic (Tagged s b) | |||||
Defined in Data.Tagged Associated Types
| |||||
| Generic (These1 f g a) | |||||
Defined in Data.Functor.These Associated Types
| |||||
| Generic (Backwards f a) | |||||
Defined in Control.Applicative.Backwards Associated Types
| |||||
| Generic (AccumT w m a) | |||||
Defined in Control.Monad.Trans.Accum Associated Types
| |||||
| Generic (ExceptT e m a) | |||||
Defined in Control.Monad.Trans.Except Associated Types
| |||||
| Generic (IdentityT f a) | |||||
Defined in Control.Monad.Trans.Identity Associated Types
| |||||
| Generic (ReaderT r m a) | |||||
Defined in Control.Monad.Trans.Reader Associated Types
| |||||
| Generic (SelectT r m a) | |||||
Defined in Control.Monad.Trans.Select Associated Types
| |||||
| Generic (StateT s m a) | |||||
Defined in Control.Monad.Trans.State.Lazy Associated Types
| |||||
| Generic (StateT s m a) | |||||
Defined in Control.Monad.Trans.State.Strict Associated Types
| |||||
| Generic (WriterT w m a) | |||||
Defined in Control.Monad.Trans.Writer.CPS Associated Types
| |||||
| Generic (WriterT w m a) | |||||
Defined in Control.Monad.Trans.Writer.Lazy Associated Types
| |||||
| Generic (WriterT w m a) | |||||
Defined in Control.Monad.Trans.Writer.Strict Associated Types
| |||||
| Generic (Constant a b) | |||||
Defined in Data.Functor.Constant Associated Types
| |||||
| Generic (Reverse f a) | |||||
Defined in Data.Functor.Reverse Associated Types
| |||||
| Generic (a, b, c) | |||||
Defined in GHC.Generics Associated Types
| |||||
| Generic (Product f g a) | |||||
Defined in Data.Functor.Product Associated Types
| |||||
| Generic (Sum f g a) | |||||
Defined in Data.Functor.Sum Associated Types
| |||||
| Generic ((f :*: g) p) | |||||
Defined in GHC.Generics Associated Types
| |||||
| Generic ((f :+: g) p) | |||||
Defined in GHC.Generics Associated Types
| |||||
| Generic (K1 i c p) | |||||
Defined in GHC.Generics Associated Types
| |||||
| Generic (ContT r m a) | |||||
Defined in Control.Monad.Trans.Cont Associated Types
| |||||
| Generic (a, b, c, d) | |||||
Defined in GHC.Generics Associated Types
| |||||
| Generic (Compose f g a) | |||||
Defined in Data.Functor.Compose Associated Types
| |||||
| Generic ((f :.: g) p) | |||||
Defined in GHC.Generics Associated Types
| |||||
| Generic (M1 i c f p) | |||||
Defined in GHC.Generics Associated Types
| |||||
| Generic (Clown f a b) | |||||
Defined in Data.Bifunctor.Clown Associated Types
| |||||
| Generic (Flip p a b) | |||||
Defined in Data.Bifunctor.Flip Associated Types
| |||||
| Generic (Joker g a b) | |||||
Defined in Data.Bifunctor.Joker Associated Types
| |||||
| Generic (WrappedBifunctor p a b) | |||||
Defined in Data.Bifunctor.Wrapped Associated Types
Methods from :: WrappedBifunctor p a b -> Rep (WrappedBifunctor p a b) x # to :: Rep (WrappedBifunctor p a b) x -> WrappedBifunctor p a b # | |||||
| Generic ((f :.: g) p) | |||||
Defined in Data.SOP.BasicFunctors Associated Types
| |||||
| Generic (RWST r w s m a) | |||||
Defined in Control.Monad.Trans.RWS.CPS Associated Types
| |||||
| Generic (RWST r w s m a) | |||||
Defined in Control.Monad.Trans.RWS.Lazy Associated Types
| |||||
| Generic (RWST r w s m a) | |||||
Defined in Control.Monad.Trans.RWS.Strict Associated Types
| |||||
| Generic (a, b, c, d, e) | |||||
Defined in GHC.Generics Associated Types
| |||||
| Generic (Product f g a b) | |||||
Defined in Data.Bifunctor.Product Associated Types
| |||||
| Generic (Sum p q a b) | |||||
Defined in Data.Bifunctor.Sum Associated Types
| |||||
| Generic (a, b, c, d, e, f) | |||||
Defined in GHC.Generics Associated Types
| |||||
| Generic (Tannen f p a b) | |||||
Defined in Data.Bifunctor.Tannen Associated Types
| |||||
| Generic (a, b, c, d, e, f, g) | |||||
Defined in GHC.Generics Associated Types
| |||||
| Generic (a, b, c, d, e, f, g, h) | |||||
Defined in GHC.Generics Associated Types
| |||||
| Generic (Biff p f g a b) | |||||
Defined in Data.Bifunctor.Biff Associated Types
| |||||
| Generic (a, b, c, d, e, f, g, h, i) | |||||
Defined in GHC.Generics Associated Types
| |||||
| Generic (a, b, c, d, e, f, g, h, i, j) | |||||
Defined in GHC.Generics Associated Types
| |||||
| Generic (a, b, c, d, e, f, g, h, i, j, k) | |||||
Defined in GHC.Generics Associated Types
| |||||
| Generic (a, b, c, d, e, f, g, h, i, j, k, l) | |||||
Defined in GHC.Generics Associated Types
| |||||
| Generic (a, b, c, d, e, f, g, h, i, j, k, l, m) | |||||
Defined in GHC.Generics Associated Types
| |||||
| Generic (a, b, c, d, e, f, g, h, i, j, k, l, m, n) | |||||
Defined in GHC.Generics Associated Types
| |||||
| Generic (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) | |||||
Defined in GHC.Generics Associated Types
| |||||
A type that can be converted from JSON, with the possibility of failure.
In many cases, you can get the compiler to generate parsing code for you (see below). To begin, let's cover writing an instance by hand.
There are various reasons a conversion could fail. For example, an
Object could be missing a required key, an Array could be of
the wrong size, or a value could be of an incompatible type.
The basic ways to signal a failed conversion are as follows:
failyields a custom error message: it is the recommended way of reporting a failure;empty(ormzero) is uninformative: use it when the error is meant to be caught by some(;<|>)typeMismatchcan be used to report a failure when the encountered value is not of the expected JSON type;unexpectedis an appropriate alternative when more than one type may be expected, or to keep the expected type implicit.
prependFailure (or modifyFailure) add more information to a parser's
error messages.
An example type and instance using typeMismatch and prependFailure:
-- Allow ourselves to writeTextliterals. {-# LANGUAGE OverloadedStrings #-} data Coord = Coord { x :: Double, y :: Double } instanceFromJSONCoord whereparseJSON(Objectv) = Coord<$>v.:"x"<*>v.:"y" -- We do not expect a non-Objectvalue here. -- We could useemptyto fail, buttypeMismatch-- gives a much more informative error message.parseJSONinvalid =prependFailure"parsing Coord failed, " (typeMismatch"Object" invalid)
For this common case of only being concerned with a single
type of JSON value, the functions withObject, withScientific, etc.
are provided. Their use is to be preferred when possible, since
they are more terse. Using withObject, we can rewrite the above instance
(assuming the same language extension and data type) as:
instanceFromJSONCoord whereparseJSON=withObject"Coord" $ \v -> Coord<$>v.:"x"<*>v.:"y"
Instead of manually writing your FromJSON instance, there are two options
to do it automatically:
- Data.Aeson.TH provides Template Haskell functions which will derive an instance at compile time. The generated instance is optimized for your type so it will probably be more efficient than the following option.
- The compiler can provide a default generic implementation for
parseJSON.
To use the second, simply add a deriving clause to your
datatype and declare a GenericFromJSON instance for your datatype without giving
a definition for parseJSON.
For example, the previous example can be simplified to just:
{-# LANGUAGE DeriveGeneric #-}
import GHC.Generics
data Coord = Coord { x :: Double, y :: Double } deriving Generic
instance FromJSON Coord
or using the DerivingVia extension
deriving viaGenericallyCoord instanceFromJSONCoord
The default implementation will be equivalent to
parseJSON = ; if you need different
options, you can customize the generic decoding by defining:genericParseJSON defaultOptions
customOptions =defaultOptions{fieldLabelModifier=maptoUpper} instanceFromJSONCoord whereparseJSON=genericParseJSONcustomOptions
Minimal complete definition
Nothing
Methods
parseJSON :: Value -> Parser a #
parseJSONList :: Value -> Parser [a] #
omittedField :: Maybe a #
Default value for optional fields.
Used by ( operator, and Generics and TH deriving
with .:?=) (default).allowOmittedFields = True
Since: aeson-2.2.0.0
Instances
| FromJSON Key | |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON DotNetTime | |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON Value | |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON All | Since: aeson-2.2.3.0 |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON Any | Since: aeson-2.2.3.0 |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON Version | |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON CTime | |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON Void | |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON Int16 | |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON Int32 | |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON Int64 | |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON Int8 | |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON Word16 | |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON Word32 | |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON Word64 | |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON Word8 | |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON IntSet | |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON Ordering | |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON URI | Since: aeson-2.2.0.0 |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON AdditionalProperties | |
Defined in Data.OpenApi.Internal Methods parseJSON :: Value -> Parser AdditionalProperties # parseJSONList :: Value -> Parser [AdditionalProperties] # | |
| FromJSON ApiKeyLocation | |
Defined in Data.OpenApi.Internal Methods parseJSON :: Value -> Parser ApiKeyLocation # parseJSONList :: Value -> Parser [ApiKeyLocation] # | |
| FromJSON ApiKeyParams | |
Defined in Data.OpenApi.Internal | |
| FromJSON Callback | |
Defined in Data.OpenApi.Internal | |
| FromJSON Components | |
Defined in Data.OpenApi.Internal | |
| FromJSON Contact | |
Defined in Data.OpenApi.Internal | |
| FromJSON Discriminator | |
Defined in Data.OpenApi.Internal Methods parseJSON :: Value -> Parser Discriminator # parseJSONList :: Value -> Parser [Discriminator] # | |
| FromJSON Encoding | |
Defined in Data.OpenApi.Internal | |
| FromJSON Example | |
Defined in Data.OpenApi.Internal | |
| FromJSON ExpressionOrValue | All strings are parsed as expressions |
Defined in Data.OpenApi.Internal Methods parseJSON :: Value -> Parser ExpressionOrValue # parseJSONList :: Value -> Parser [ExpressionOrValue] # | |
| FromJSON ExternalDocs | |
Defined in Data.OpenApi.Internal | |
| FromJSON Header | |
Defined in Data.OpenApi.Internal | |
| FromJSON Info | |
Defined in Data.OpenApi.Internal | |
| FromJSON License | |
Defined in Data.OpenApi.Internal | |
| FromJSON Link | |
Defined in Data.OpenApi.Internal | |
| FromJSON MediaTypeObject | |
Defined in Data.OpenApi.Internal Methods parseJSON :: Value -> Parser MediaTypeObject # parseJSONList :: Value -> Parser [MediaTypeObject] # | |
| FromJSON MimeList | |
Defined in Data.OpenApi.Internal | |
| FromJSON OAuth2AuthorizationCodeFlow | |
Defined in Data.OpenApi.Internal | |
| FromJSON OAuth2ClientCredentialsFlow | |
Defined in Data.OpenApi.Internal | |
| FromJSON OAuth2Flows | |
Defined in Data.OpenApi.Internal | |
| FromJSON OAuth2ImplicitFlow | |
Defined in Data.OpenApi.Internal Methods parseJSON :: Value -> Parser OAuth2ImplicitFlow # parseJSONList :: Value -> Parser [OAuth2ImplicitFlow] # | |
| FromJSON OAuth2PasswordFlow | |
Defined in Data.OpenApi.Internal Methods parseJSON :: Value -> Parser OAuth2PasswordFlow # parseJSONList :: Value -> Parser [OAuth2PasswordFlow] # | |
| FromJSON OpenApi | |
Defined in Data.OpenApi.Internal | |
| FromJSON OpenApiItems | |
Defined in Data.OpenApi.Internal | |
| FromJSON OpenApiSpecVersion | |
Defined in Data.OpenApi.Internal Methods parseJSON :: Value -> Parser OpenApiSpecVersion # parseJSONList :: Value -> Parser [OpenApiSpecVersion] # | |
| FromJSON OpenApiType | |
Defined in Data.OpenApi.Internal | |
| FromJSON Operation | |
Defined in Data.OpenApi.Internal | |
| FromJSON Param | |
Defined in Data.OpenApi.Internal | |
| FromJSON ParamLocation | |
Defined in Data.OpenApi.Internal Methods parseJSON :: Value -> Parser ParamLocation # parseJSONList :: Value -> Parser [ParamLocation] # | |
| FromJSON PathItem | |
Defined in Data.OpenApi.Internal | |
| FromJSON Reference | |
Defined in Data.OpenApi.Internal | |
| FromJSON RequestBody | |
Defined in Data.OpenApi.Internal | |
| FromJSON Response | |
Defined in Data.OpenApi.Internal | |
| FromJSON Responses | |
Defined in Data.OpenApi.Internal | |
| FromJSON Schema | |
Defined in Data.OpenApi.Internal | |
| FromJSON SecurityDefinitions | |
Defined in Data.OpenApi.Internal Methods parseJSON :: Value -> Parser SecurityDefinitions # parseJSONList :: Value -> Parser [SecurityDefinitions] # | |
| FromJSON SecurityRequirement | |
Defined in Data.OpenApi.Internal Methods parseJSON :: Value -> Parser SecurityRequirement # parseJSONList :: Value -> Parser [SecurityRequirement] # | |
| FromJSON SecurityScheme | |
Defined in Data.OpenApi.Internal Methods parseJSON :: Value -> Parser SecurityScheme # parseJSONList :: Value -> Parser [SecurityScheme] # | |
| FromJSON SecuritySchemeType | |
Defined in Data.OpenApi.Internal Methods parseJSON :: Value -> Parser SecuritySchemeType # parseJSONList :: Value -> Parser [SecuritySchemeType] # | |
| FromJSON Server | |
Defined in Data.OpenApi.Internal | |
| FromJSON ServerVariable | |
Defined in Data.OpenApi.Internal Methods parseJSON :: Value -> Parser ServerVariable # parseJSONList :: Value -> Parser [ServerVariable] # | |
| FromJSON Style | |
Defined in Data.OpenApi.Internal | |
| FromJSON Tag | |
Defined in Data.OpenApi.Internal | |
| FromJSON URL | |
Defined in Data.OpenApi.Internal | |
| FromJSON Xml | |
Defined in Data.OpenApi.Internal | |
| FromJSON Scientific | |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON Text | |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON Text | |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON ShortText | Since: aeson-2.0.2.0 |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON CalendarDiffDays | |
Defined in Data.Aeson.Types.FromJSON Methods parseJSON :: Value -> Parser CalendarDiffDays # parseJSONList :: Value -> Parser [CalendarDiffDays] # | |
| FromJSON Day | |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON Month | |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON Quarter | |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON QuarterOfYear | |
Defined in Data.Aeson.Types.FromJSON Methods parseJSON :: Value -> Parser QuarterOfYear # parseJSONList :: Value -> Parser [QuarterOfYear] # | |
| FromJSON DayOfWeek | |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON DiffTime | This instance includes a bounds check to prevent maliciously
large inputs to fill up the memory of the target system. You can
newtype |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON NominalDiffTime | This instance includes a bounds check to prevent maliciously
large inputs to fill up the memory of the target system. You can
newtype |
Defined in Data.Aeson.Types.FromJSON Methods parseJSON :: Value -> Parser NominalDiffTime # parseJSONList :: Value -> Parser [NominalDiffTime] # | |
| FromJSON SystemTime | |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON UTCTime | |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON CalendarDiffTime | |
Defined in Data.Aeson.Types.FromJSON Methods parseJSON :: Value -> Parser CalendarDiffTime # parseJSONList :: Value -> Parser [CalendarDiffTime] # | |
| FromJSON LocalTime | |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON TimeOfDay | |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON ZonedTime | Supported string formats:
The first space may instead be a |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON UUID | |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON Integer | This instance includes a bounds check to prevent maliciously
large inputs to fill up the memory of the target system. You can
newtype |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON Natural | |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON () | |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON Bool | |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON Char | |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON Double | |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON Float | |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON Int | |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON Word | |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON v => FromJSON (KeyMap v) | Since: aeson-2.0.1.0 |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON a => FromJSON (Identity a) | |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON a => FromJSON (First a) | |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON a => FromJSON (Last a) | |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON a => FromJSON (Down a) | Since: aeson-2.2.0.0 |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON a => FromJSON (First a) | |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON a => FromJSON (Last a) | |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON a => FromJSON (Max a) | |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON a => FromJSON (Min a) | |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON a => FromJSON (WrappedMonoid a) | |
Defined in Data.Aeson.Types.FromJSON Methods parseJSON :: Value -> Parser (WrappedMonoid a) # parseJSONList :: Value -> Parser [WrappedMonoid a] # omittedField :: Maybe (WrappedMonoid a) # | |
| FromJSON a => FromJSON (Dual a) | |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON a => FromJSON (Product a) | Since: aeson-2.2.3.0 |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON a => FromJSON (Sum a) | Since: aeson-2.2.3.0 |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON a => FromJSON (NonEmpty a) | |
Defined in Data.Aeson.Types.FromJSON | |
| (Generic a, GFromJSON Zero (Rep a)) => FromJSON (Generically a) | Since: aeson-2.1.0.0 |
Defined in Data.Aeson.Types.FromJSON Methods parseJSON :: Value -> Parser (Generically a) # parseJSONList :: Value -> Parser [Generically a] # omittedField :: Maybe (Generically a) # | |
| (FromJSON a, Integral a) => FromJSON (Ratio a) | |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON a => FromJSON (IntMap a) | |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON a => FromJSON (Seq a) | |
Defined in Data.Aeson.Types.FromJSON | |
| (Ord a, FromJSON a) => FromJSON (Set a) | |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON v => FromJSON (Tree v) | |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON1 f => FromJSON (Fix f) | Since: aeson-1.5.3.0 |
Defined in Data.Aeson.Types.FromJSON | |
| (FromJSON1 f, Functor f) => FromJSON (Mu f) | Since: aeson-1.5.3.0 |
Defined in Data.Aeson.Types.FromJSON | |
| (FromJSON1 f, Functor f) => FromJSON (Nu f) | Since: aeson-1.5.3.0 |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON a => FromJSON (DNonEmpty a) | Since: aeson-1.5.3.0 |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON a => FromJSON (DList a) | |
Defined in Data.Aeson.Types.FromJSON | |
| (Eq a, Hashable a, FromJSON a) => FromJSON (InsOrdHashSet a) | |
Defined in Data.HashSet.InsOrd Methods parseJSON :: Value -> Parser (InsOrdHashSet a) # parseJSONList :: Value -> Parser [InsOrdHashSet a] # omittedField :: Maybe (InsOrdHashSet a) # | |
| (Eq p, FromJSON p, AesonDefaultValue p) => FromJSON (OAuth2Flow p) | |
Defined in Data.OpenApi.Internal Methods parseJSON :: Value -> Parser (OAuth2Flow p) # parseJSONList :: Value -> Parser [OAuth2Flow p] # omittedField :: Maybe (OAuth2Flow p) # | |
| FromJSON (Referenced Callback) | |
Defined in Data.OpenApi.Internal Methods parseJSON :: Value -> Parser (Referenced Callback) # parseJSONList :: Value -> Parser [Referenced Callback] # omittedField :: Maybe (Referenced Callback) # | |
| FromJSON (Referenced Example) | |
Defined in Data.OpenApi.Internal Methods parseJSON :: Value -> Parser (Referenced Example) # parseJSONList :: Value -> Parser [Referenced Example] # omittedField :: Maybe (Referenced Example) # | |
| FromJSON (Referenced Header) | |
Defined in Data.OpenApi.Internal Methods parseJSON :: Value -> Parser (Referenced Header) # parseJSONList :: Value -> Parser [Referenced Header] # omittedField :: Maybe (Referenced Header) # | |
| FromJSON (Referenced Link) | |
Defined in Data.OpenApi.Internal Methods parseJSON :: Value -> Parser (Referenced Link) # parseJSONList :: Value -> Parser [Referenced Link] # omittedField :: Maybe (Referenced Link) # | |
| FromJSON (Referenced Param) | |
Defined in Data.OpenApi.Internal Methods parseJSON :: Value -> Parser (Referenced Param) # parseJSONList :: Value -> Parser [Referenced Param] # omittedField :: Maybe (Referenced Param) # | |
| FromJSON (Referenced RequestBody) | |
Defined in Data.OpenApi.Internal Methods parseJSON :: Value -> Parser (Referenced RequestBody) # parseJSONList :: Value -> Parser [Referenced RequestBody] # | |
| FromJSON (Referenced Response) | |
Defined in Data.OpenApi.Internal Methods parseJSON :: Value -> Parser (Referenced Response) # parseJSONList :: Value -> Parser [Referenced Response] # omittedField :: Maybe (Referenced Response) # | |
| FromJSON (Referenced Schema) | |
Defined in Data.OpenApi.Internal Methods parseJSON :: Value -> Parser (Referenced Schema) # parseJSONList :: Value -> Parser [Referenced Schema] # omittedField :: Maybe (Referenced Schema) # | |
| FromJSON a => FromJSON (Array a) | |
Defined in Data.Aeson.Types.FromJSON | |
| (Prim a, FromJSON a) => FromJSON (PrimArray a) | |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON a => FromJSON (SmallArray a) | |
Defined in Data.Aeson.Types.FromJSON Methods parseJSON :: Value -> Parser (SmallArray a) # parseJSONList :: Value -> Parser [SmallArray a] # omittedField :: Maybe (SmallArray a) # | |
| FromJSON a => FromJSON (Maybe a) | Since: aeson-1.5.3.0 |
Defined in Data.Aeson.Types.FromJSON | |
| (Eq a, Hashable a, FromJSON a) => FromJSON (HashSet a) | |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON a => FromJSON (Vector a) | |
Defined in Data.Aeson.Types.FromJSON | |
| (Prim a, FromJSON a) => FromJSON (Vector a) | |
Defined in Data.Aeson.Types.FromJSON | |
| (Storable a, FromJSON a) => FromJSON (Vector a) | |
Defined in Data.Aeson.Types.FromJSON | |
| (Vector Vector a, FromJSON a) => FromJSON (Vector a) | |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON a => FromJSON (Maybe a) | |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON a => FromJSON (Solo a) | Since: aeson-2.0.2.0 |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON a => FromJSON [a] | |
Defined in Data.Aeson.Types.FromJSON | |
| (FromJSON a, FromJSON b) => FromJSON (Either a b) | |
Defined in Data.Aeson.Types.FromJSON | |
| HasResolution a => FromJSON (Fixed a) | This instance includes a bounds check to prevent maliciously
large inputs to fill up the memory of the target system. You can
newtype |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON (Proxy a) | |
Defined in Data.Aeson.Types.FromJSON | |
| (FromJSONKey k, Ord k, FromJSON v) => FromJSON (Map k v) | |
Defined in Data.Aeson.Types.FromJSON | |
| (Eq k, Hashable k, FromJSONKey k, FromJSON v) => FromJSON (InsOrdHashMap k v) | |
Defined in Data.HashMap.Strict.InsOrd Methods parseJSON :: Value -> Parser (InsOrdHashMap k v) # parseJSONList :: Value -> Parser [InsOrdHashMap k v] # omittedField :: Maybe (InsOrdHashMap k v) # | |
| (FromJSON a, FromJSON b) => FromJSON (Either a b) | Since: aeson-1.5.3.0 |
Defined in Data.Aeson.Types.FromJSON | |
| (FromJSON a, FromJSON b) => FromJSON (These a b) | Since: aeson-1.5.3.0 |
Defined in Data.Aeson.Types.FromJSON | |
| (FromJSON a, FromJSON b) => FromJSON (Pair a b) | Since: aeson-1.5.3.0 |
Defined in Data.Aeson.Types.FromJSON | |
| (FromJSON a, FromJSON b) => FromJSON (These a b) | Since: aeson-1.5.1.0 |
Defined in Data.Aeson.Types.FromJSON | |
| (FromJSON v, FromJSONKey k, Eq k, Hashable k) => FromJSON (HashMap k v) | |
Defined in Data.Aeson.Types.FromJSON | |
| (FromJSON a, FromJSON b) => FromJSON (a, b) | |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON a => FromJSON (Const a b) | |
Defined in Data.Aeson.Types.FromJSON | |
| FromJSON b => FromJSON (Tagged a b) | |
Defined in Data.Aeson.Types.FromJSON | |
| (FromJSON1 f, FromJSON1 g, FromJSON a) => FromJSON (These1 f g a) | Since: aeson-1.5.1.0 |
Defined in Data.Aeson.Types.FromJSON | |
| (FromJSON a, FromJSON b, FromJSON c) => FromJSON (a, b, c) | |
Defined in Data.Aeson.Types.FromJSON | |
| (FromJSON1 f, FromJSON1 g, FromJSON a) => FromJSON (Product f g a) | |
Defined in Data.Aeson.Types.FromJSON | |
| (FromJSON1 f, FromJSON1 g, FromJSON a) => FromJSON (Sum f g a) | |
Defined in Data.Aeson.Types.FromJSON | |
| (FromJSON a, FromJSON b, FromJSON c, FromJSON d) => FromJSON (a, b, c, d) | |
Defined in Data.Aeson.Types.FromJSON | |
| (FromJSON1 f, FromJSON1 g, FromJSON a) => FromJSON (Compose f g a) | |
Defined in Data.Aeson.Types.FromJSON | |
| (FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e) => FromJSON (a, b, c, d, e) | |
Defined in Data.Aeson.Types.FromJSON | |
| (FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e, FromJSON f) => FromJSON (a, b, c, d, e, f) | |
Defined in Data.Aeson.Types.FromJSON | |
| (FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e, FromJSON f, FromJSON g) => FromJSON (a, b, c, d, e, f, g) | |
Defined in Data.Aeson.Types.FromJSON | |
| (FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e, FromJSON f, FromJSON g, FromJSON h) => FromJSON (a, b, c, d, e, f, g, h) | |
Defined in Data.Aeson.Types.FromJSON | |
| (FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e, FromJSON f, FromJSON g, FromJSON h, FromJSON i) => FromJSON (a, b, c, d, e, f, g, h, i) | |
Defined in Data.Aeson.Types.FromJSON | |
| (FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e, FromJSON f, FromJSON g, FromJSON h, FromJSON i, FromJSON j) => FromJSON (a, b, c, d, e, f, g, h, i, j) | |
Defined in Data.Aeson.Types.FromJSON | |
| (FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e, FromJSON f, FromJSON g, FromJSON h, FromJSON i, FromJSON j, FromJSON k) => FromJSON (a, b, c, d, e, f, g, h, i, j, k) | |
Defined in Data.Aeson.Types.FromJSON | |
| (FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e, FromJSON f, FromJSON g, FromJSON h, FromJSON i, FromJSON j, FromJSON k, FromJSON l) => FromJSON (a, b, c, d, e, f, g, h, i, j, k, l) | |
Defined in Data.Aeson.Types.FromJSON | |
| (FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e, FromJSON f, FromJSON g, FromJSON h, FromJSON i, FromJSON j, FromJSON k, FromJSON l, FromJSON m) => FromJSON (a, b, c, d, e, f, g, h, i, j, k, l, m) | |
Defined in Data.Aeson.Types.FromJSON | |
| (FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e, FromJSON f, FromJSON g, FromJSON h, FromJSON i, FromJSON j, FromJSON k, FromJSON l, FromJSON m, FromJSON n) => FromJSON (a, b, c, d, e, f, g, h, i, j, k, l, m, n) | |
Defined in Data.Aeson.Types.FromJSON | |
| (FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e, FromJSON f, FromJSON g, FromJSON h, FromJSON i, FromJSON j, FromJSON k, FromJSON l, FromJSON m, FromJSON n, FromJSON o) => FromJSON (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) | |
Defined in Data.Aeson.Types.FromJSON | |
A type that can be converted to JSON.
Instances in general must specify toJSON and should (but don't need
to) specify toEncoding.
An example type and instance:
-- Allow ourselves to writeTextliterals. {-# LANGUAGE OverloadedStrings #-} data Coord = Coord { x :: Double, y :: Double } instanceToJSONCoord wheretoJSON(Coord x y) =object["x".=x, "y".=y]toEncoding(Coord x y) =pairs("x".=x<>"y".=y)
Instead of manually writing your ToJSON instance, there are two options
to do it automatically:
- Data.Aeson.TH provides Template Haskell functions which will derive an instance at compile time. The generated instance is optimized for your type so it will probably be more efficient than the following option.
- The compiler can provide a default generic implementation for
toJSON.
To use the second, simply add a deriving clause to your
datatype and declare a GenericToJSON instance. If you require nothing other than
defaultOptions, it is sufficient to write (and this is the only
alternative where the default toJSON implementation is sufficient):
{-# LANGUAGE DeriveGeneric #-}
import GHC.Generics
data Coord = Coord { x :: Double, y :: Double } deriving Generic
instance ToJSON Coord where
toEncoding = genericToEncoding defaultOptions
or more conveniently using the DerivingVia extension
deriving viaGenericallyCoord instanceToJSONCoord
If on the other hand you wish to customize the generic decoding, you have to implement both methods:
customOptions =defaultOptions{fieldLabelModifier=maptoUpper} instanceToJSONCoord wheretoJSON=genericToJSONcustomOptionstoEncoding=genericToEncodingcustomOptions
Previous versions of this library only had the toJSON method. Adding
toEncoding had two reasons:
toEncodingis more efficient for the common case that the output oftoJSONis directly serialized to aByteString. Further, expressing either method in terms of the other would be non-optimal.- The choice of defaults allows a smooth transition for existing users:
Existing instances that do not define
toEncodingstill compile and have the correct semantics. This is ensured by making the default implementation oftoEncodingusetoJSON. This produces correct results, but since it performs an intermediate conversion to aValue, it will be less efficient than directly emitting anEncoding. (this also means that specifying nothing more thaninstance ToJSON Coordwould be sufficient as a generically decoding instance, but there probably exists no good reason to not specifytoEncodingin new instances.)
Minimal complete definition
Nothing
Methods
Convert a Haskell value to a JSON-friendly intermediate type.
toEncoding :: a -> Encoding #
Encode a Haskell value as JSON.
The default implementation of this method creates an
intermediate Value using toJSON. This provides
source-level compatibility for people upgrading from older
versions of this library, but obviously offers no performance
advantage.
To benefit from direct encoding, you must provide an
implementation for this method. The easiest way to do so is by
having your types implement Generic using the DeriveGeneric
extension, and then have GHC generate a method body as follows.
instanceToJSONCoord wheretoEncoding=genericToEncodingdefaultOptions
toJSONList :: [a] -> Value #
toEncodingList :: [a] -> Encoding #
Defines when it is acceptable to omit a field of this type from a record.
Used by ( operator, and Generics and TH deriving
with .?=).omitNothingFields = True
Since: aeson-2.2.0.0
Instances
| ToJSON Key | |
| ToJSON DotNetTime | |
Defined in Data.Aeson.Types.ToJSON Methods toJSON :: DotNetTime -> Value # toEncoding :: DotNetTime -> Encoding # toJSONList :: [DotNetTime] -> Value # toEncodingList :: [DotNetTime] -> Encoding # omitField :: DotNetTime -> Bool # | |
| ToJSON Value | |
| ToJSON All | Since: aeson-2.2.3.0 |
| ToJSON Any | Since: aeson-2.2.3.0 |
| ToJSON Version | |
| ToJSON CTime | |
| ToJSON Void | |
| ToJSON Int16 | |
| ToJSON Int32 | |
| ToJSON Int64 | |
| ToJSON Int8 | |
| ToJSON Word16 | |
| ToJSON Word32 | |
| ToJSON Word64 | |
| ToJSON Word8 | |
| ToJSON IntSet | |
| ToJSON Ordering | |
| ToJSON Url | |
| ToJSON Link | |
| ToJSON URI | Since: aeson-2.2.0.0 |
| ToJSON AdditionalProperties | |
Defined in Data.OpenApi.Internal Methods toJSON :: AdditionalProperties -> Value # toEncoding :: AdditionalProperties -> Encoding # toJSONList :: [AdditionalProperties] -> Value # toEncodingList :: [AdditionalProperties] -> Encoding # omitField :: AdditionalProperties -> Bool # | |
| ToJSON ApiKeyLocation | |
Defined in Data.OpenApi.Internal Methods toJSON :: ApiKeyLocation -> Value # toEncoding :: ApiKeyLocation -> Encoding # toJSONList :: [ApiKeyLocation] -> Value # toEncodingList :: [ApiKeyLocation] -> Encoding # omitField :: ApiKeyLocation -> Bool # | |
| ToJSON ApiKeyParams | |
Defined in Data.OpenApi.Internal Methods toJSON :: ApiKeyParams -> Value # toEncoding :: ApiKeyParams -> Encoding # toJSONList :: [ApiKeyParams] -> Value # toEncodingList :: [ApiKeyParams] -> Encoding # omitField :: ApiKeyParams -> Bool # | |
| ToJSON Callback | |
| ToJSON Components | |
Defined in Data.OpenApi.Internal Methods toJSON :: Components -> Value # toEncoding :: Components -> Encoding # toJSONList :: [Components] -> Value # toEncodingList :: [Components] -> Encoding # omitField :: Components -> Bool # | |
| ToJSON Contact | |
| ToJSON Discriminator | |
Defined in Data.OpenApi.Internal Methods toJSON :: Discriminator -> Value # toEncoding :: Discriminator -> Encoding # toJSONList :: [Discriminator] -> Value # toEncodingList :: [Discriminator] -> Encoding # omitField :: Discriminator -> Bool # | |
| ToJSON Encoding | |
| ToJSON Example | |
| ToJSON ExpressionOrValue | |
Defined in Data.OpenApi.Internal Methods toJSON :: ExpressionOrValue -> Value # toEncoding :: ExpressionOrValue -> Encoding # toJSONList :: [ExpressionOrValue] -> Value # toEncodingList :: [ExpressionOrValue] -> Encoding # omitField :: ExpressionOrValue -> Bool # | |
| ToJSON ExternalDocs | |
Defined in Data.OpenApi.Internal Methods toJSON :: ExternalDocs -> Value # toEncoding :: ExternalDocs -> Encoding # toJSONList :: [ExternalDocs] -> Value # toEncodingList :: [ExternalDocs] -> Encoding # omitField :: ExternalDocs -> Bool # | |
| ToJSON Header | |
| ToJSON Info | |
| ToJSON License | |
| ToJSON Link | |
| ToJSON MediaTypeObject | |
Defined in Data.OpenApi.Internal Methods toJSON :: MediaTypeObject -> Value # toEncoding :: MediaTypeObject -> Encoding # toJSONList :: [MediaTypeObject] -> Value # toEncodingList :: [MediaTypeObject] -> Encoding # omitField :: MediaTypeObject -> Bool # | |
| ToJSON MimeList | |
| ToJSON OAuth2AuthorizationCodeFlow | |
Defined in Data.OpenApi.Internal Methods toJSON :: OAuth2AuthorizationCodeFlow -> Value # toEncoding :: OAuth2AuthorizationCodeFlow -> Encoding # toJSONList :: [OAuth2AuthorizationCodeFlow] -> Value # toEncodingList :: [OAuth2AuthorizationCodeFlow] -> Encoding # | |
| ToJSON OAuth2ClientCredentialsFlow | |
Defined in Data.OpenApi.Internal Methods toJSON :: OAuth2ClientCredentialsFlow -> Value # toEncoding :: OAuth2ClientCredentialsFlow -> Encoding # toJSONList :: [OAuth2ClientCredentialsFlow] -> Value # toEncodingList :: [OAuth2ClientCredentialsFlow] -> Encoding # | |
| ToJSON OAuth2Flows | |
Defined in Data.OpenApi.Internal Methods toJSON :: OAuth2Flows -> Value # toEncoding :: OAuth2Flows -> Encoding # toJSONList :: [OAuth2Flows] -> Value # toEncodingList :: [OAuth2Flows] -> Encoding # omitField :: OAuth2Flows -> Bool # | |
| ToJSON OAuth2ImplicitFlow | |
Defined in Data.OpenApi.Internal Methods toJSON :: OAuth2ImplicitFlow -> Value # toEncoding :: OAuth2ImplicitFlow -> Encoding # toJSONList :: [OAuth2ImplicitFlow] -> Value # toEncodingList :: [OAuth2ImplicitFlow] -> Encoding # omitField :: OAuth2ImplicitFlow -> Bool # | |
| ToJSON OAuth2PasswordFlow | |
Defined in Data.OpenApi.Internal Methods toJSON :: OAuth2PasswordFlow -> Value # toEncoding :: OAuth2PasswordFlow -> Encoding # toJSONList :: [OAuth2PasswordFlow] -> Value # toEncodingList :: [OAuth2PasswordFlow] -> Encoding # omitField :: OAuth2PasswordFlow -> Bool # | |
| ToJSON OpenApi | |
| ToJSON OpenApiItems | As for nullary schema for 0-arity type constructors, see https://github.com/GetShopTV/swagger2/issues/167.
|
Defined in Data.OpenApi.Internal Methods toJSON :: OpenApiItems -> Value # toEncoding :: OpenApiItems -> Encoding # toJSONList :: [OpenApiItems] -> Value # toEncodingList :: [OpenApiItems] -> Encoding # omitField :: OpenApiItems -> Bool # | |
| ToJSON OpenApiSpecVersion | |
Defined in Data.OpenApi.Internal Methods toJSON :: OpenApiSpecVersion -> Value # toEncoding :: OpenApiSpecVersion -> Encoding # toJSONList :: [OpenApiSpecVersion] -> Value # toEncodingList :: [OpenApiSpecVersion] -> Encoding # omitField :: OpenApiSpecVersion -> Bool # | |
| ToJSON OpenApiType | |
Defined in Data.OpenApi.Internal Methods toJSON :: OpenApiType -> Value # toEncoding :: OpenApiType -> Encoding # toJSONList :: [OpenApiType] -> Value # toEncodingList :: [OpenApiType] -> Encoding # omitField :: OpenApiType -> Bool # | |
| ToJSON Operation | |
| ToJSON Param | |
| ToJSON ParamLocation | |
Defined in Data.OpenApi.Internal Methods toJSON :: ParamLocation -> Value # toEncoding :: ParamLocation -> Encoding # toJSONList :: [ParamLocation] -> Value # toEncodingList :: [ParamLocation] -> Encoding # omitField :: ParamLocation -> Bool # | |
| ToJSON PathItem | |
| ToJSON Reference | |
| ToJSON RequestBody | |
Defined in Data.OpenApi.Internal Methods toJSON :: RequestBody -> Value # toEncoding :: RequestBody -> Encoding # toJSONList :: [RequestBody] -> Value # toEncodingList :: [RequestBody] -> Encoding # omitField :: RequestBody -> Bool # | |
| ToJSON Response | |
| ToJSON Responses | |
| ToJSON Schema | |
| ToJSON SecurityDefinitions | |
Defined in Data.OpenApi.Internal Methods toJSON :: SecurityDefinitions -> Value # toEncoding :: SecurityDefinitions -> Encoding # toJSONList :: [SecurityDefinitions] -> Value # toEncodingList :: [SecurityDefinitions] -> Encoding # omitField :: SecurityDefinitions -> Bool # | |
| ToJSON SecurityRequirement | |
Defined in Data.OpenApi.Internal Methods toJSON :: SecurityRequirement -> Value # toEncoding :: SecurityRequirement -> Encoding # toJSONList :: [SecurityRequirement] -> Value # toEncodingList :: [SecurityRequirement] -> Encoding # omitField :: SecurityRequirement -> Bool # | |
| ToJSON SecurityScheme | |
Defined in Data.OpenApi.Internal Methods toJSON :: SecurityScheme -> Value # toEncoding :: SecurityScheme -> Encoding # toJSONList :: [SecurityScheme] -> Value # toEncodingList :: [SecurityScheme] -> Encoding # omitField :: SecurityScheme -> Bool # | |
| ToJSON SecuritySchemeType | |
Defined in Data.OpenApi.Internal Methods toJSON :: SecuritySchemeType -> Value # toEncoding :: SecuritySchemeType -> Encoding # toJSONList :: [SecuritySchemeType] -> Value # toEncodingList :: [SecuritySchemeType] -> Encoding # omitField :: SecuritySchemeType -> Bool # | |
| ToJSON Server | |
| ToJSON ServerVariable | |
Defined in Data.OpenApi.Internal Methods toJSON :: ServerVariable -> Value # toEncoding :: ServerVariable -> Encoding # toJSONList :: [ServerVariable] -> Value # toEncodingList :: [ServerVariable] -> Encoding # omitField :: ServerVariable -> Bool # | |
| ToJSON Style | |
| ToJSON Tag | |
| ToJSON URL | |
| ToJSON Xml | |
| ToJSON Scientific | |
Defined in Data.Aeson.Types.ToJSON Methods toJSON :: Scientific -> Value # toEncoding :: Scientific -> Encoding # toJSONList :: [Scientific] -> Value # toEncodingList :: [Scientific] -> Encoding # omitField :: Scientific -> Bool # | |
| ToJSON Text | |
| ToJSON Text | |
| ToJSON ShortText | Since: aeson-2.0.2.0 |
| ToJSON CalendarDiffDays | |
Defined in Data.Aeson.Types.ToJSON Methods toJSON :: CalendarDiffDays -> Value # toEncoding :: CalendarDiffDays -> Encoding # toJSONList :: [CalendarDiffDays] -> Value # toEncodingList :: [CalendarDiffDays] -> Encoding # omitField :: CalendarDiffDays -> Bool # | |
| ToJSON Day | |
| ToJSON Month | |
| ToJSON Quarter | |
| ToJSON QuarterOfYear | |
Defined in Data.Aeson.Types.ToJSON Methods toJSON :: QuarterOfYear -> Value # toEncoding :: QuarterOfYear -> Encoding # toJSONList :: [QuarterOfYear] -> Value # toEncodingList :: [QuarterOfYear] -> Encoding # omitField :: QuarterOfYear -> Bool # | |
| ToJSON DayOfWeek | |
| ToJSON DiffTime | |
| ToJSON NominalDiffTime | |
Defined in Data.Aeson.Types.ToJSON Methods toJSON :: NominalDiffTime -> Value # toEncoding :: NominalDiffTime -> Encoding # toJSONList :: [NominalDiffTime] -> Value # toEncodingList :: [NominalDiffTime] -> Encoding # omitField :: NominalDiffTime -> Bool # | |
| ToJSON SystemTime | Encoded as number |
Defined in Data.Aeson.Types.ToJSON Methods toJSON :: SystemTime -> Value # toEncoding :: SystemTime -> Encoding # toJSONList :: [SystemTime] -> Value # toEncodingList :: [SystemTime] -> Encoding # omitField :: SystemTime -> Bool # | |
| ToJSON UTCTime | |
| ToJSON CalendarDiffTime | |
Defined in Data.Aeson.Types.ToJSON Methods toJSON :: CalendarDiffTime -> Value # toEncoding :: CalendarDiffTime -> Encoding # toJSONList :: [CalendarDiffTime] -> Value # toEncodingList :: [CalendarDiffTime] -> Encoding # omitField :: CalendarDiffTime -> Bool # | |
| ToJSON LocalTime | |
| ToJSON TimeOfDay | |
| ToJSON ZonedTime | |
| ToJSON UUID | |
| ToJSON Integer | |
| ToJSON Natural | |
| ToJSON () | |
Defined in Data.Aeson.Types.ToJSON Methods toEncoding :: () -> Encoding # toJSONList :: [()] -> Value # toEncodingList :: [()] -> Encoding # | |
| ToJSON Bool | |
| ToJSON Char | |
| ToJSON Double | |
| ToJSON Float | |
| ToJSON Int | |
| ToJSON Word | |
| ToJSON v => ToJSON (KeyMap v) | |
| ToJSON a => ToJSON (Identity a) | |
| ToJSON a => ToJSON (First a) | |
| ToJSON a => ToJSON (Last a) | |
| ToJSON a => ToJSON (Down a) | Since: aeson-2.2.0.0 |
| ToJSON a => ToJSON (First a) | |
| ToJSON a => ToJSON (Last a) | |
| ToJSON a => ToJSON (Max a) | |
| ToJSON a => ToJSON (Min a) | |
| ToJSON a => ToJSON (WrappedMonoid a) | |
Defined in Data.Aeson.Types.ToJSON Methods toJSON :: WrappedMonoid a -> Value # toEncoding :: WrappedMonoid a -> Encoding # toJSONList :: [WrappedMonoid a] -> Value # toEncodingList :: [WrappedMonoid a] -> Encoding # omitField :: WrappedMonoid a -> Bool # | |
| ToJSON a => ToJSON (Dual a) | |
| ToJSON a => ToJSON (Product a) | Since: aeson-2.2.3.0 |
| ToJSON a => ToJSON (Sum a) | Since: aeson-2.2.3.0 |
| ToJSON a => ToJSON (NonEmpty a) | |
| (Generic a, GToJSON' Value Zero (Rep a), GToJSON' Encoding Zero (Rep a)) => ToJSON (Generically a) | Since: aeson-2.1.0.0 |
Defined in Data.Aeson.Types.ToJSON Methods toJSON :: Generically a -> Value # toEncoding :: Generically a -> Encoding # toJSONList :: [Generically a] -> Value # toEncodingList :: [Generically a] -> Encoding # omitField :: Generically a -> Bool # | |
| (ToJSON a, Integral a) => ToJSON (Ratio a) | |
| ToJSON a => ToJSON (IntMap a) | |
| ToJSON a => ToJSON (Seq a) | |
| ToJSON a => ToJSON (Set a) | |
| ToJSON v => ToJSON (Tree v) | |
| ToJSON1 f => ToJSON (Fix f) | Since: aeson-1.5.3.0 |
| (ToJSON1 f, Functor f) => ToJSON (Mu f) | Since: aeson-1.5.3.0 |
| (ToJSON1 f, Functor f) => ToJSON (Nu f) | Since: aeson-1.5.3.0 |
| ToJSON a => ToJSON (DNonEmpty a) | Since: aeson-1.5.3.0 |
| ToJSON a => ToJSON (DList a) | |
| ToJSON a => ToJSON (InsOrdHashSet a) | |
Defined in Data.HashSet.InsOrd Methods toJSON :: InsOrdHashSet a -> Value # toEncoding :: InsOrdHashSet a -> Encoding # toJSONList :: [InsOrdHashSet a] -> Value # toEncodingList :: [InsOrdHashSet a] -> Encoding # omitField :: InsOrdHashSet a -> Bool # | |
| (Eq p, ToJSON p, AesonDefaultValue p) => ToJSON (OAuth2Flow p) | |
Defined in Data.OpenApi.Internal Methods toJSON :: OAuth2Flow p -> Value # toEncoding :: OAuth2Flow p -> Encoding # toJSONList :: [OAuth2Flow p] -> Value # toEncodingList :: [OAuth2Flow p] -> Encoding # omitField :: OAuth2Flow p -> Bool # | |
| ToJSON (Referenced Callback) | |
Defined in Data.OpenApi.Internal Methods toJSON :: Referenced Callback -> Value # toEncoding :: Referenced Callback -> Encoding # toJSONList :: [Referenced Callback] -> Value # toEncodingList :: [Referenced Callback] -> Encoding # omitField :: Referenced Callback -> Bool # | |
| ToJSON (Referenced Example) | |
Defined in Data.OpenApi.Internal Methods toJSON :: Referenced Example -> Value # toEncoding :: Referenced Example -> Encoding # toJSONList :: [Referenced Example] -> Value # toEncodingList :: [Referenced Example] -> Encoding # omitField :: Referenced Example -> Bool # | |
| ToJSON (Referenced Header) | |
Defined in Data.OpenApi.Internal Methods toJSON :: Referenced Header -> Value # toEncoding :: Referenced Header -> Encoding # toJSONList :: [Referenced Header] -> Value # toEncodingList :: [Referenced Header] -> Encoding # omitField :: Referenced Header -> Bool # | |
| ToJSON (Referenced Link) | |
Defined in Data.OpenApi.Internal Methods toJSON :: Referenced Link -> Value # toEncoding :: Referenced Link -> Encoding # toJSONList :: [Referenced Link] -> Value # toEncodingList :: [Referenced Link] -> Encoding # omitField :: Referenced Link -> Bool # | |
| ToJSON (Referenced Param) | |
Defined in Data.OpenApi.Internal Methods toJSON :: Referenced Param -> Value # toEncoding :: Referenced Param -> Encoding # toJSONList :: [Referenced Param] -> Value # toEncodingList :: [Referenced Param] -> Encoding # omitField :: Referenced Param -> Bool # | |
| ToJSON (Referenced RequestBody) | |
Defined in Data.OpenApi.Internal Methods toJSON :: Referenced RequestBody -> Value # toEncoding :: Referenced RequestBody -> Encoding # toJSONList :: [Referenced RequestBody] -> Value # toEncodingList :: [Referenced RequestBody] -> Encoding # omitField :: Referenced RequestBody -> Bool # | |
| ToJSON (Referenced Response) | |
Defined in Data.OpenApi.Internal Methods toJSON :: Referenced Response -> Value # toEncoding :: Referenced Response -> Encoding # toJSONList :: [Referenced Response] -> Value # toEncodingList :: [Referenced Response] -> Encoding # omitField :: Referenced Response -> Bool # | |
| ToJSON (Referenced Schema) | |
Defined in Data.OpenApi.Internal Methods toJSON :: Referenced Schema -> Value # toEncoding :: Referenced Schema -> Encoding # toJSONList :: [Referenced Schema] -> Value # toEncodingList :: [Referenced Schema] -> Encoding # omitField :: Referenced Schema -> Bool # | |
| ToJSON a => ToJSON (Array a) | |
| (Prim a, ToJSON a) => ToJSON (PrimArray a) | |
| ToJSON a => ToJSON (SmallArray a) | |
Defined in Data.Aeson.Types.ToJSON Methods toJSON :: SmallArray a -> Value # toEncoding :: SmallArray a -> Encoding # toJSONList :: [SmallArray a] -> Value # toEncodingList :: [SmallArray a] -> Encoding # omitField :: SmallArray a -> Bool # | |
| ToJSON a => ToJSON (Maybe a) | Since: aeson-1.5.3.0 |
| ToJSON a => ToJSON (HashSet a) | |
| ToJSON a => ToJSON (Vector a) | |
Defined in Data.Aeson.Types.ToJSON Methods toEncoding :: Vector a -> Encoding # toJSONList :: [Vector a] -> Value # toEncodingList :: [Vector a] -> Encoding # | |
| (Prim a, ToJSON a) => ToJSON (Vector a) | |
Defined in Data.Aeson.Types.ToJSON Methods toEncoding :: Vector a -> Encoding # toJSONList :: [Vector a] -> Value # toEncodingList :: [Vector a] -> Encoding # | |
| (Storable a, ToJSON a) => ToJSON (Vector a) | |
Defined in Data.Aeson.Types.ToJSON Methods toEncoding :: Vector a -> Encoding # toJSONList :: [Vector a] -> Value # toEncodingList :: [Vector a] -> Encoding # | |
| (Vector Vector a, ToJSON a) => ToJSON (Vector a) | |
| ToJSON a => ToJSON (Maybe a) | |
| ToJSON a => ToJSON (Solo a) | Since: aeson-2.0.2.0 |
| ToJSON a => ToJSON [a] | |
Defined in Data.Aeson.Types.ToJSON Methods toEncoding :: [a] -> Encoding # toJSONList :: [[a]] -> Value # toEncodingList :: [[a]] -> Encoding # | |
| (ToJSON a, ToJSON b) => ToJSON (Either a b) | |
| HasResolution a => ToJSON (Fixed a) | |
| ToJSON (Proxy a) | |
| (ToJSON v, ToJSONKey k) => ToJSON (Map k v) | |
| (ToJSONKey k, ToJSON v) => ToJSON (InsOrdHashMap k v) | |
Defined in Data.HashMap.Strict.InsOrd Methods toJSON :: InsOrdHashMap k v -> Value # toEncoding :: InsOrdHashMap k v -> Encoding # toJSONList :: [InsOrdHashMap k v] -> Value # toEncodingList :: [InsOrdHashMap k v] -> Encoding # omitField :: InsOrdHashMap k v -> Bool # | |
| (ToJSON a, ToJSON b) => ToJSON (Either a b) | Since: aeson-1.5.3.0 |
| (ToJSON a, ToJSON b) => ToJSON (These a b) | Since: aeson-1.5.3.0 |
| (ToJSON a, ToJSON b) => ToJSON (Pair a b) | Since: aeson-1.5.3.0 |
| (ToJSON a, ToJSON b) => ToJSON (These a b) | Since: aeson-1.5.1.0 |
| (ToJSON v, ToJSONKey k) => ToJSON (HashMap k v) | |
| (ToJSON a, ToJSON b) => ToJSON (a, b) | |
Defined in Data.Aeson.Types.ToJSON Methods toEncoding :: (a, b) -> Encoding # toJSONList :: [(a, b)] -> Value # toEncodingList :: [(a, b)] -> Encoding # | |
| ToJSON a => ToJSON (Const a b) | |
| ToJSON b => ToJSON (Tagged a b) | |
| (ToJSON1 f, ToJSON1 g, ToJSON a) => ToJSON (These1 f g a) | Since: aeson-1.5.1.0 |
| (ToJSON a, ToJSON b, ToJSON c) => ToJSON (a, b, c) | |
Defined in Data.Aeson.Types.ToJSON Methods toJSON :: (a, b, c) -> Value # toEncoding :: (a, b, c) -> Encoding # toJSONList :: [(a, b, c)] -> Value # toEncodingList :: [(a, b, c)] -> Encoding # | |
| (ToJSON1 f, ToJSON1 g, ToJSON a) => ToJSON (Product f g a) | |
| (ToJSON1 f, ToJSON1 g, ToJSON a) => ToJSON (Sum f g a) | |
| (ToJSON a, ToJSON b, ToJSON c, ToJSON d) => ToJSON (a, b, c, d) | |
Defined in Data.Aeson.Types.ToJSON Methods toJSON :: (a, b, c, d) -> Value # toEncoding :: (a, b, c, d) -> Encoding # toJSONList :: [(a, b, c, d)] -> Value # toEncodingList :: [(a, b, c, d)] -> Encoding # | |
| (ToJSON1 f, ToJSON1 g, ToJSON a) => ToJSON (Compose f g a) | |
| (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e) => ToJSON (a, b, c, d, e) | |
Defined in Data.Aeson.Types.ToJSON Methods toJSON :: (a, b, c, d, e) -> Value # toEncoding :: (a, b, c, d, e) -> Encoding # toJSONList :: [(a, b, c, d, e)] -> Value # toEncodingList :: [(a, b, c, d, e)] -> Encoding # | |
| (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f) => ToJSON (a, b, c, d, e, f) | |
Defined in Data.Aeson.Types.ToJSON Methods toJSON :: (a, b, c, d, e, f) -> Value # toEncoding :: (a, b, c, d, e, f) -> Encoding # toJSONList :: [(a, b, c, d, e, f)] -> Value # toEncodingList :: [(a, b, c, d, e, f)] -> Encoding # | |
| (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g) => ToJSON (a, b, c, d, e, f, g) | |
Defined in Data.Aeson.Types.ToJSON Methods toJSON :: (a, b, c, d, e, f, g) -> Value # toEncoding :: (a, b, c, d, e, f, g) -> Encoding # toJSONList :: [(a, b, c, d, e, f, g)] -> Value # toEncodingList :: [(a, b, c, d, e, f, g)] -> Encoding # | |
| (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h) => ToJSON (a, b, c, d, e, f, g, h) | |
Defined in Data.Aeson.Types.ToJSON Methods toJSON :: (a, b, c, d, e, f, g, h) -> Value # toEncoding :: (a, b, c, d, e, f, g, h) -> Encoding # toJSONList :: [(a, b, c, d, e, f, g, h)] -> Value # toEncodingList :: [(a, b, c, d, e, f, g, h)] -> Encoding # | |
| (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h, ToJSON i) => ToJSON (a, b, c, d, e, f, g, h, i) | |
Defined in Data.Aeson.Types.ToJSON Methods toJSON :: (a, b, c, d, e, f, g, h, i) -> Value # toEncoding :: (a, b, c, d, e, f, g, h, i) -> Encoding # toJSONList :: [(a, b, c, d, e, f, g, h, i)] -> Value # toEncodingList :: [(a, b, c, d, e, f, g, h, i)] -> Encoding # | |
| (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h, ToJSON i, ToJSON j) => ToJSON (a, b, c, d, e, f, g, h, i, j) | |
Defined in Data.Aeson.Types.ToJSON Methods toJSON :: (a, b, c, d, e, f, g, h, i, j) -> Value # toEncoding :: (a, b, c, d, e, f, g, h, i, j) -> Encoding # toJSONList :: [(a, b, c, d, e, f, g, h, i, j)] -> Value # toEncodingList :: [(a, b, c, d, e, f, g, h, i, j)] -> Encoding # | |
| (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h, ToJSON i, ToJSON j, ToJSON k) => ToJSON (a, b, c, d, e, f, g, h, i, j, k) | |
Defined in Data.Aeson.Types.ToJSON Methods toJSON :: (a, b, c, d, e, f, g, h, i, j, k) -> Value # toEncoding :: (a, b, c, d, e, f, g, h, i, j, k) -> Encoding # toJSONList :: [(a, b, c, d, e, f, g, h, i, j, k)] -> Value # toEncodingList :: [(a, b, c, d, e, f, g, h, i, j, k)] -> Encoding # | |
| (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h, ToJSON i, ToJSON j, ToJSON k, ToJSON l) => ToJSON (a, b, c, d, e, f, g, h, i, j, k, l) | |
Defined in Data.Aeson.Types.ToJSON Methods toJSON :: (a, b, c, d, e, f, g, h, i, j, k, l) -> Value # toEncoding :: (a, b, c, d, e, f, g, h, i, j, k, l) -> Encoding # toJSONList :: [(a, b, c, d, e, f, g, h, i, j, k, l)] -> Value # toEncodingList :: [(a, b, c, d, e, f, g, h, i, j, k, l)] -> Encoding # | |
| (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h, ToJSON i, ToJSON j, ToJSON k, ToJSON l, ToJSON m) => ToJSON (a, b, c, d, e, f, g, h, i, j, k, l, m) | |
Defined in Data.Aeson.Types.ToJSON Methods toJSON :: (a, b, c, d, e, f, g, h, i, j, k, l, m) -> Value # toEncoding :: (a, b, c, d, e, f, g, h, i, j, k, l, m) -> Encoding # toJSONList :: [(a, b, c, d, e, f, g, h, i, j, k, l, m)] -> Value # toEncodingList :: [(a, b, c, d, e, f, g, h, i, j, k, l, m)] -> Encoding # omitField :: (a, b, c, d, e, f, g, h, i, j, k, l, m) -> Bool # | |
| (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h, ToJSON i, ToJSON j, ToJSON k, ToJSON l, ToJSON m, ToJSON n) => ToJSON (a, b, c, d, e, f, g, h, i, j, k, l, m, n) | |
Defined in Data.Aeson.Types.ToJSON Methods toJSON :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> Value # toEncoding :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> Encoding # toJSONList :: [(a, b, c, d, e, f, g, h, i, j, k, l, m, n)] -> Value # toEncodingList :: [(a, b, c, d, e, f, g, h, i, j, k, l, m, n)] -> Encoding # omitField :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> Bool # | |
| (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h, ToJSON i, ToJSON j, ToJSON k, ToJSON l, ToJSON m, ToJSON n, ToJSON o) => ToJSON (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) | |
Defined in Data.Aeson.Types.ToJSON Methods toJSON :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> Value # toEncoding :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> Encoding # toJSONList :: [(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)] -> Value # toEncodingList :: [(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)] -> Encoding # omitField :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> Bool # | |
A space efficient, packed, unboxed Unicode text type.
Instances
| FromJSON Text | |||||
Defined in Data.Aeson.Types.FromJSON | |||||
| FromJSONKey Text | |||||
Defined in Data.Aeson.Types.FromJSON | |||||
| ToJSON Text | |||||
| ToJSONKey Text | |||||
Defined in Data.Aeson.Types.ToJSON | |||||
| Chunk Text | |||||
Defined in Data.Attoparsec.Internal.Types Associated Types
| |||||
| ToMarkup Text | |||||
Defined in Text.Blaze | |||||
| ToValue Text | |||||
Defined in Text.Blaze | |||||
| FoldCase Text | |||||
Defined in Data.CaseInsensitive.Internal | |||||
| FromFormKey Text | |||||
Defined in Web.Internal.FormUrlEncoded | |||||
| ToFormKey Text | |||||
Defined in Web.Internal.FormUrlEncoded | |||||
| FromHttpApiData Text | |||||
Defined in Web.Internal.HttpApiData | |||||
| ToHttpApiData Text | |||||
Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Text -> Text # toEncodedUrlPiece :: Text -> Builder # toHeader :: Text -> ByteString # toQueryParam :: Text -> Text # toEncodedQueryParam :: Text -> Builder # | |||||
| QueryKeyLike Text | |||||
Defined in Network.HTTP.Types.QueryLike Methods toQueryKey :: Text -> ByteString # | |||||
| QueryValueLike Text | |||||
Defined in Network.HTTP.Types.QueryLike Methods toQueryValue :: Text -> Maybe ByteString # | |||||
| Ixed Text | |||||
Defined in Control.Lens.At | |||||
| ToText Text | |||||
Defined in Mig.Core.Types.Http | |||||
| AesonDefaultValue Text | |||||
Defined in Data.OpenApi.Internal.AesonUtils Methods defaultValue :: Maybe Text # | |||||
| ToParamSchema Text | |||||
Defined in Data.OpenApi.Internal.ParamSchema Methods toParamSchema :: Proxy Text -> Schema # | |||||
| ToSchema Text | |||||
Defined in Data.OpenApi.Internal.Schema Methods declareNamedSchema :: Proxy Text -> Declare (Definitions Schema) NamedSchema # | |||||
| SwaggerMonoid Text | |||||
Defined in Data.OpenApi.Internal.Utils | |||||
| ToMediaType Text | |||||
Defined in Mig.Core.Class.MediaType Methods | |||||
| HasAuthorizationUrl OAuth2AuthorizationCodeFlow AuthorizationURL | |||||
Defined in Data.OpenApi.Lens | |||||
| HasAuthorizationUrl OAuth2ImplicitFlow AuthorizationURL | |||||
Defined in Data.OpenApi.Lens Methods authorizationUrl :: Lens' OAuth2ImplicitFlow AuthorizationURL # | |||||
| HasDescription Response Text | |||||
Defined in Data.OpenApi.Lens Methods | |||||
| HasName License Text | |||||
| HasName Param Text | |||||
| HasName Tag TagName | |||||
| HasPropertyName Discriminator Text | |||||
Defined in Data.OpenApi.Lens Methods | |||||
| HasTitle Info Text | |||||
| HasTokenUrl OAuth2AuthorizationCodeFlow TokenURL | |||||
Defined in Data.OpenApi.Lens Methods | |||||
| HasTokenUrl OAuth2ClientCredentialsFlow TokenURL | |||||
Defined in Data.OpenApi.Lens Methods | |||||
| HasTokenUrl OAuth2PasswordFlow TokenURL | |||||
Defined in Data.OpenApi.Lens Methods | |||||
| HasUrl Server Text | |||||
| HasVersion Info Text | |||||
| FromReqBody Text Text | |||||
Defined in Mig.Core.Class.MediaType Methods fromReqBody :: ByteString -> Either Text Text # | |||||
| ToRespBody Text Text | |||||
Defined in Mig.Core.Class.MediaType Methods toRespBody :: Text -> ByteString # | |||||
| ToRespBody Text Text | |||||
Defined in Mig.Core.Class.MediaType Methods toRespBody :: Text -> ByteString # | |||||
| HasCallbacks Components (Definitions Callback) | |||||
Defined in Data.OpenApi.Lens Methods | |||||
| HasDescription Example (Maybe Text) | |||||
Defined in Data.OpenApi.Lens | |||||
| HasDescription ExternalDocs (Maybe Text) | |||||
Defined in Data.OpenApi.Lens Methods description :: Lens' ExternalDocs (Maybe Text) # | |||||
| HasDescription Header (Maybe HeaderName) | |||||
Defined in Data.OpenApi.Lens Methods description :: Lens' Header (Maybe HeaderName) # | |||||
| HasDescription Info (Maybe Text) | |||||
Defined in Data.OpenApi.Lens | |||||
| HasDescription Link (Maybe Text) | |||||
Defined in Data.OpenApi.Lens | |||||
| HasDescription Operation (Maybe Text) | |||||
Defined in Data.OpenApi.Lens | |||||
| HasDescription Param (Maybe Text) | |||||
Defined in Data.OpenApi.Lens | |||||
| HasDescription PathItem (Maybe Text) | |||||
Defined in Data.OpenApi.Lens | |||||
| HasDescription RequestBody (Maybe Text) | |||||
Defined in Data.OpenApi.Lens Methods description :: Lens' RequestBody (Maybe Text) # | |||||
| HasDescription Schema (Maybe Text) | |||||
Defined in Data.OpenApi.Lens | |||||
| HasDescription SecurityScheme (Maybe Text) | |||||
Defined in Data.OpenApi.Lens Methods description :: Lens' SecurityScheme (Maybe Text) # | |||||
| HasDescription Server (Maybe Text) | |||||
Defined in Data.OpenApi.Lens | |||||
| HasDescription Tag (Maybe Text) | |||||
Defined in Data.OpenApi.Lens | |||||
| HasEmail Contact (Maybe Text) | |||||
| HasExamples Components (Definitions Example) | |||||
Defined in Data.OpenApi.Lens Methods | |||||
| HasFormat Schema (Maybe Format) | |||||
| HasSchema s Schema => HasFormat s (Maybe Format) | |||||
| HasHeaders Components (Definitions Header) | |||||
Defined in Data.OpenApi.Lens Methods headers :: Lens' Components (Definitions Header) # | |||||
| HasLinks Components (Definitions Link) | |||||
Defined in Data.OpenApi.Lens Methods links :: Lens' Components (Definitions Link) # | |||||
| HasName Contact (Maybe Text) | |||||
| HasName NamedSchema (Maybe Text) | |||||
Defined in Data.OpenApi.Lens | |||||
| HasName Xml (Maybe Text) | |||||
| HasNamespace Xml (Maybe Text) | |||||
| HasOperationId Link (Maybe Text) | |||||
Defined in Data.OpenApi.Lens | |||||
| HasOperationId Operation (Maybe Text) | |||||
Defined in Data.OpenApi.Lens | |||||
| HasOperationRef Link (Maybe Text) | |||||
Defined in Data.OpenApi.Lens | |||||
| HasParameters Components (Definitions Param) | |||||
Defined in Data.OpenApi.Lens Methods | |||||
| HasPattern Schema (Maybe Pattern) | |||||
| HasSchema s Schema => HasPattern s (Maybe Text) | |||||
| HasPrefix Xml (Maybe Text) | |||||
| HasRequestBodies Components (Definitions RequestBody) | |||||
Defined in Data.OpenApi.Lens Methods requestBodies :: Lens' Components (Definitions RequestBody) # | |||||
| HasRequired Schema [ParamName] | |||||
| HasResponses Components (Definitions Response) | |||||
Defined in Data.OpenApi.Lens Methods | |||||
| HasSchemas Components (Definitions Schema) | |||||
Defined in Data.OpenApi.Lens Methods schemas :: Lens' Components (Definitions Schema) # | |||||
| HasSummary Example (Maybe Text) | |||||
| HasSummary Operation (Maybe Text) | |||||
| HasSummary PathItem (Maybe Text) | |||||
| HasTags Operation (InsOrdHashSet TagName) | |||||
Defined in Data.OpenApi.Lens | |||||
| HasTermsOfService Info (Maybe Text) | |||||
Defined in Data.OpenApi.Lens | |||||
| HasTitle Schema (Maybe Text) | |||||
| HasCallbacks Operation (InsOrdHashMap Text (Referenced Callback)) | |||||
Defined in Data.OpenApi.Lens Methods callbacks :: Lens' Operation (InsOrdHashMap Text (Referenced Callback)) # | |||||
| HasEncoding MediaTypeObject (InsOrdHashMap Text Encoding) | |||||
Defined in Data.OpenApi.Lens Methods encoding :: Lens' MediaTypeObject (InsOrdHashMap Text Encoding) # | |||||
| HasExamples Header (InsOrdHashMap Text (Referenced Example)) | |||||
Defined in Data.OpenApi.Lens Methods examples :: Lens' Header (InsOrdHashMap Text (Referenced Example)) # | |||||
| HasExamples MediaTypeObject (InsOrdHashMap Text (Referenced Example)) | |||||
Defined in Data.OpenApi.Lens Methods examples :: Lens' MediaTypeObject (InsOrdHashMap Text (Referenced Example)) # | |||||
| HasExamples Param (InsOrdHashMap Text (Referenced Example)) | |||||
Defined in Data.OpenApi.Lens Methods examples :: Lens' Param (InsOrdHashMap Text (Referenced Example)) # | |||||
| HasHeaders Encoding (InsOrdHashMap Text (Referenced Header)) | |||||
Defined in Data.OpenApi.Lens Methods headers :: Lens' Encoding (InsOrdHashMap Text (Referenced Header)) # | |||||
| HasHeaders Response (InsOrdHashMap HeaderName (Referenced Header)) | |||||
Defined in Data.OpenApi.Lens Methods headers :: Lens' Response (InsOrdHashMap HeaderName (Referenced Header)) # | |||||
| HasLinks Response (InsOrdHashMap Text (Referenced Link)) | |||||
Defined in Data.OpenApi.Lens Methods links :: Lens' Response (InsOrdHashMap Text (Referenced Link)) # | |||||
| HasMapping Discriminator (InsOrdHashMap Text Text) | |||||
Defined in Data.OpenApi.Lens Methods | |||||
| HasParameters Link (InsOrdHashMap Text ExpressionOrValue) | |||||
Defined in Data.OpenApi.Lens Methods parameters :: Lens' Link (InsOrdHashMap Text ExpressionOrValue) # | |||||
| HasProperties Schema (InsOrdHashMap Text (Referenced Schema)) | |||||
Defined in Data.OpenApi.Lens Methods properties :: Lens' Schema (InsOrdHashMap Text (Referenced Schema)) # | |||||
| HasVariables Server (InsOrdHashMap Text ServerVariable) | |||||
Defined in Data.OpenApi.Lens Methods variables :: Lens' Server (InsOrdHashMap Text ServerVariable) # | |||||
| HasServer (ReaderT env (ExceptT Text IO)) | |||||
Defined in Mig.Core.Class.Server Associated Types
| |||||
| type ChunkElem Text | |||||
Defined in Data.Attoparsec.Internal.Types | |||||
| type State Text | |||||
Defined in Data.Attoparsec.Internal.Types | |||||
| type Item Text | |||||
| type Index Text | |||||
Defined in Control.Lens.At | |||||
| type IxValue Text | |||||
Defined in Control.Lens.At | |||||
| type Index Text | |||||
| type IxKind Text | |||||
Defined in Optics.At | |||||
| type IxValue Text | |||||
| type ServerResult (ReaderT env (ExceptT Text IO)) | |||||
Defined in Mig.Core.Class.Server | |||||
Class allowing us to use a single function for Markup values
Minimal complete definition
Methods
Convert a value to Markup.
preEscapedToMarkup :: a -> Markup #
Convert a value to Markup without escaping
Instances
| ToMarkup Int32 | |
Defined in Text.Blaze | |
| ToMarkup Int64 | |
Defined in Text.Blaze | |
| ToMarkup Word32 | |
Defined in Text.Blaze | |
| ToMarkup Word64 | |
Defined in Text.Blaze | |
| ToMarkup Markup | |
Defined in Text.Blaze | |
| ToMarkup Link | |
Defined in Mig.Extra.Server.Html | |
| ToMarkup Text | |
Defined in Text.Blaze | |
| ToMarkup Builder | |
Defined in Text.Blaze | |
| ToMarkup Text | |
Defined in Text.Blaze | |
| ToMarkup String | |
Defined in Text.Blaze | |
| ToMarkup Integer | |
Defined in Text.Blaze | |
| ToMarkup Natural | |
Defined in Text.Blaze | |
| ToMarkup Bool | |
Defined in Text.Blaze | |
| ToMarkup Char | |
Defined in Text.Blaze | |
| ToMarkup Double | |
Defined in Text.Blaze | |
| ToMarkup Float | |
Defined in Text.Blaze | |
| ToMarkup Int | |
Defined in Text.Blaze | |
| ToMarkup Word | |
Defined in Text.Blaze | |
| ToMarkup (NonEmpty Char) | |
| ToMarkup [Markup] | |
Defined in Text.Blaze | |
type ResponseHeaders = [Header] #
A list of Headers.
Same type as RequestHeaders, but useful to differentiate in type signatures.
type RequestHeaders = [Header] #
A list of Headers.
Same type as ResponseHeaders, but useful to differentiate in type signatures.
This is the root document object for the API specification.
Instances
| FromJSON OpenApi | |||||
Defined in Data.OpenApi.Internal | |||||
| ToJSON OpenApi | |||||
| Data OpenApi | |||||
Defined in Data.OpenApi.Internal Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> OpenApi -> c OpenApi # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c OpenApi # toConstr :: OpenApi -> Constr # dataTypeOf :: OpenApi -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c OpenApi) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c OpenApi) # gmapT :: (forall b. Data b => b -> b) -> OpenApi -> OpenApi # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> OpenApi -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> OpenApi -> r # gmapQ :: (forall d. Data d => d -> u) -> OpenApi -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> OpenApi -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> OpenApi -> m OpenApi # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> OpenApi -> m OpenApi # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> OpenApi -> m OpenApi # | |||||
| Monoid OpenApi | |||||
| Semigroup OpenApi | |||||
| Generic OpenApi | |||||
Defined in Data.OpenApi.Internal Associated Types
| |||||
| Show OpenApi | |||||
| Generic OpenApi | |||||
Defined in Data.OpenApi.Internal Associated Types
| |||||
| HasDatatypeInfo OpenApi | |||||
Defined in Data.OpenApi.Internal Associated Types
Methods datatypeInfo :: proxy OpenApi -> DatatypeInfo (Code OpenApi) # | |||||
| Eq OpenApi | |||||
| HasSwaggerAesonOptions OpenApi | |||||
Defined in Data.OpenApi.Internal Methods swaggerAesonOptions :: Proxy OpenApi -> SwaggerAesonOptions # aesonDefaults :: Proxy OpenApi -> POP Maybe (Code OpenApi) # | |||||
| HasComponents OpenApi Components | |||||
Defined in Data.OpenApi.Lens Methods | |||||
| HasInfo OpenApi Info | |||||
| HasOpenapi OpenApi OpenApiSpecVersion | |||||
Defined in Data.OpenApi.Lens Methods | |||||
| HasExternalDocs OpenApi (Maybe ExternalDocs) | |||||
Defined in Data.OpenApi.Lens Methods | |||||
| HasSecurity OpenApi [SecurityRequirement] | |||||
Defined in Data.OpenApi.Lens Methods | |||||
| HasServers OpenApi [Server] | |||||
| HasTags OpenApi (InsOrdHashSet Tag) | |||||
Defined in Data.OpenApi.Lens | |||||
| HasPaths OpenApi (InsOrdHashMap FilePath PathItem) | |||||
Defined in Data.OpenApi.Lens | |||||
| type Rep OpenApi | |||||
Defined in Data.OpenApi.Internal type Rep OpenApi = D1 ('MetaData "OpenApi" "Data.OpenApi.Internal" "openapi3-3.2.4-6mQ1n1ZYzYp30iNIc3Ctov" 'False) (C1 ('MetaCons "OpenApi" 'PrefixI 'True) (((S1 ('MetaSel ('Just "_openApiInfo") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Info) :*: S1 ('MetaSel ('Just "_openApiServers") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Server])) :*: (S1 ('MetaSel ('Just "_openApiPaths") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (InsOrdHashMap FilePath PathItem)) :*: S1 ('MetaSel ('Just "_openApiComponents") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Components))) :*: ((S1 ('MetaSel ('Just "_openApiSecurity") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [SecurityRequirement]) :*: S1 ('MetaSel ('Just "_openApiTags") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (InsOrdHashSet Tag))) :*: (S1 ('MetaSel ('Just "_openApiExternalDocs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe ExternalDocs)) :*: S1 ('MetaSel ('Just "_openApiOpenapi") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 OpenApiSpecVersion))))) | |||||
| type Code OpenApi | |||||
Defined in Data.OpenApi.Internal type Code OpenApi = '['[Info, [Server], InsOrdHashMap FilePath PathItem, Components, [SecurityRequirement], InsOrdHashSet Tag, Maybe ExternalDocs, OpenApiSpecVersion]] | |||||
| type DatatypeInfoOf OpenApi | |||||
Defined in Data.OpenApi.Internal type DatatypeInfoOf OpenApi = 'ADT "Data.OpenApi.Internal" "OpenApi" '['Record "OpenApi" '['FieldInfo "_openApiInfo", 'FieldInfo "_openApiServers", 'FieldInfo "_openApiPaths", 'FieldInfo "_openApiComponents", 'FieldInfo "_openApiSecurity", 'FieldInfo "_openApiTags", 'FieldInfo "_openApiExternalDocs", 'FieldInfo "_openApiOpenapi"]] '['['StrictnessInfo 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy, 'StrictnessInfo 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy, 'StrictnessInfo 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy, 'StrictnessInfo 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy, 'StrictnessInfo 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy, 'StrictnessInfo 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy, 'StrictnessInfo 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy, 'StrictnessInfo 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy]] | |||||
class ToParamSchema a where #
Convert a type into a plain .Schema
In previous versions of the package there was a separate type called ParamSchema, which was
included in a greater Schema. Now this is a single class, but distinction for schema generators
for "simple" types is preserved.
ToParamSchema is suited only for primitive-like types without nested fields and such.
An example type and instance:
{-# LANGUAGE OverloadedStrings #-} -- allows to write Text literals
import Control.Lens
data Direction = Up | Down
instance ToParamSchema Direction where
toParamSchema _ = mempty
& type_ ?~ OpenApiString
& enum_ ?~ [ "Up", "Down" ]
Instead of manually writing your instance you can
use a default generic implementation of ToParamSchema.toParamSchema
To do that, simply add deriving clause to your datatype
and declare a Generic instance for your datatype without
giving definition for ToParamSchema.toParamSchema
For instance, the previous example can be simplified into this:
{-# LANGUAGE DeriveGeneric #-}
import GHC.Generics (Generic)
data Direction = Up | Down deriving Generic
instance ToParamSchema Direction
Minimal complete definition
Nothing
Methods
toParamSchema :: Proxy a -> Schema #
Convert a type into a plain parameter schema.
>>>BSL.putStrLn $ encodePretty $ toParamSchema (Proxy :: Proxy Integer){ "type": "integer" }
default toParamSchema :: (Generic a, GToParamSchema (Rep a)) => Proxy a -> Schema #
Instances
| ToParamSchema All | |
Defined in Data.OpenApi.Internal.ParamSchema Methods toParamSchema :: Proxy All -> Schema # | |
| ToParamSchema Any | |
Defined in Data.OpenApi.Internal.ParamSchema Methods toParamSchema :: Proxy Any -> Schema # | |
| ToParamSchema Version | |
Defined in Data.OpenApi.Internal.ParamSchema Methods toParamSchema :: Proxy Version -> Schema # | |
| ToParamSchema Int16 | |
Defined in Data.OpenApi.Internal.ParamSchema Methods toParamSchema :: Proxy Int16 -> Schema # | |
| ToParamSchema Int32 | |
Defined in Data.OpenApi.Internal.ParamSchema Methods toParamSchema :: Proxy Int32 -> Schema # | |
| ToParamSchema Int64 | |
Defined in Data.OpenApi.Internal.ParamSchema Methods toParamSchema :: Proxy Int64 -> Schema # | |
| ToParamSchema Int8 | |
Defined in Data.OpenApi.Internal.ParamSchema Methods toParamSchema :: Proxy Int8 -> Schema # | |
| ToParamSchema Word16 | |
Defined in Data.OpenApi.Internal.ParamSchema Methods toParamSchema :: Proxy Word16 -> Schema # | |
| ToParamSchema Word32 | |
Defined in Data.OpenApi.Internal.ParamSchema Methods toParamSchema :: Proxy Word32 -> Schema # | |
| ToParamSchema Word64 | |
Defined in Data.OpenApi.Internal.ParamSchema Methods toParamSchema :: Proxy Word64 -> Schema # | |
| ToParamSchema Word8 | |
Defined in Data.OpenApi.Internal.ParamSchema Methods toParamSchema :: Proxy Word8 -> Schema # | |
| (ToParamSchemaByteStringError ByteString :: Constraint) => ToParamSchema ByteString | |
Defined in Data.OpenApi.Internal.ParamSchema Methods toParamSchema :: Proxy ByteString -> Schema # | |
| (ToParamSchemaByteStringError ByteString :: Constraint) => ToParamSchema ByteString | |
Defined in Data.OpenApi.Internal.ParamSchema Methods toParamSchema :: Proxy ByteString -> Schema # | |
| ToParamSchema SetCookie | |
Defined in Data.OpenApi.Internal.ParamSchema Methods toParamSchema :: Proxy SetCookie -> Schema # | |
| ToParamSchema Scientific | |
Defined in Data.OpenApi.Internal.ParamSchema Methods toParamSchema :: Proxy Scientific -> Schema # | |
| ToParamSchema Text | |
Defined in Data.OpenApi.Internal.ParamSchema Methods toParamSchema :: Proxy Text -> Schema # | |
| ToParamSchema Text | |
Defined in Data.OpenApi.Internal.ParamSchema Methods toParamSchema :: Proxy Text -> Schema # | |
| ToParamSchema Day | Format |
Defined in Data.OpenApi.Internal.ParamSchema Methods toParamSchema :: Proxy Day -> Schema # | |
| ToParamSchema NominalDiffTime | |
Defined in Data.OpenApi.Internal.ParamSchema Methods toParamSchema :: Proxy NominalDiffTime -> Schema # | |
| ToParamSchema UTCTime |
|
Defined in Data.OpenApi.Internal.ParamSchema Methods toParamSchema :: Proxy UTCTime -> Schema # | |
| ToParamSchema LocalTime |
|
Defined in Data.OpenApi.Internal.ParamSchema Methods toParamSchema :: Proxy LocalTime -> Schema # | |
| ToParamSchema TimeOfDay |
|
Defined in Data.OpenApi.Internal.ParamSchema Methods toParamSchema :: Proxy TimeOfDay -> Schema # | |
| ToParamSchema ZonedTime |
|
Defined in Data.OpenApi.Internal.ParamSchema Methods toParamSchema :: Proxy ZonedTime -> Schema # | |
| ToParamSchema UUID | |
Defined in Data.OpenApi.Internal.ParamSchema Methods toParamSchema :: Proxy UUID -> Schema # | |
| ToParamSchema String | |
Defined in Data.OpenApi.Internal.ParamSchema Methods toParamSchema :: Proxy String -> Schema # | |
| ToParamSchema Integer | |
Defined in Data.OpenApi.Internal.ParamSchema Methods toParamSchema :: Proxy Integer -> Schema # | |
| ToParamSchema Natural | |
Defined in Data.OpenApi.Internal.ParamSchema Methods toParamSchema :: Proxy Natural -> Schema # | |
| ToParamSchema () |
|
Defined in Data.OpenApi.Internal.ParamSchema Methods toParamSchema :: Proxy () -> Schema # | |
| ToParamSchema Bool | |
Defined in Data.OpenApi.Internal.ParamSchema Methods toParamSchema :: Proxy Bool -> Schema # | |
| ToParamSchema Char | |
Defined in Data.OpenApi.Internal.ParamSchema Methods toParamSchema :: Proxy Char -> Schema # | |
| ToParamSchema Double | |
Defined in Data.OpenApi.Internal.ParamSchema Methods toParamSchema :: Proxy Double -> Schema # | |
| ToParamSchema Float | |
Defined in Data.OpenApi.Internal.ParamSchema Methods toParamSchema :: Proxy Float -> Schema # | |
| ToParamSchema Int | |
Defined in Data.OpenApi.Internal.ParamSchema Methods toParamSchema :: Proxy Int -> Schema # | |
| ToParamSchema Word | |
Defined in Data.OpenApi.Internal.ParamSchema Methods toParamSchema :: Proxy Word -> Schema # | |
| ToParamSchema a => ToParamSchema (Identity a) | |
Defined in Data.OpenApi.Internal.ParamSchema Methods toParamSchema :: Proxy (Identity a) -> Schema # | |
| ToParamSchema a => ToParamSchema (First a) | |
Defined in Data.OpenApi.Internal.ParamSchema Methods toParamSchema :: Proxy (First a) -> Schema # | |
| ToParamSchema a => ToParamSchema (Last a) | |
Defined in Data.OpenApi.Internal.ParamSchema Methods toParamSchema :: Proxy (Last a) -> Schema # | |
| ToParamSchema a => ToParamSchema (Dual a) | |
Defined in Data.OpenApi.Internal.ParamSchema Methods toParamSchema :: Proxy (Dual a) -> Schema # | |
| ToParamSchema a => ToParamSchema (Product a) | |
Defined in Data.OpenApi.Internal.ParamSchema Methods toParamSchema :: Proxy (Product a) -> Schema # | |
| ToParamSchema a => ToParamSchema (Sum a) | |
Defined in Data.OpenApi.Internal.ParamSchema Methods toParamSchema :: Proxy (Sum a) -> Schema # | |
| ToParamSchema a => ToParamSchema (Set a) | |
Defined in Data.OpenApi.Internal.ParamSchema Methods toParamSchema :: Proxy (Set a) -> Schema # | |
| ToParamSchema a => ToParamSchema (HashSet a) | |
Defined in Data.OpenApi.Internal.ParamSchema Methods toParamSchema :: Proxy (HashSet a) -> Schema # | |
| ToParamSchema a => ToParamSchema (Vector a) | |
Defined in Data.OpenApi.Internal.ParamSchema Methods toParamSchema :: Proxy (Vector a) -> Schema # | |
| ToParamSchema a => ToParamSchema (Vector a) | |
Defined in Data.OpenApi.Internal.ParamSchema Methods toParamSchema :: Proxy (Vector a) -> Schema # | |
| ToParamSchema a => ToParamSchema (Vector a) | |
Defined in Data.OpenApi.Internal.ParamSchema Methods toParamSchema :: Proxy (Vector a) -> Schema # | |
| ToParamSchema a => ToParamSchema (Vector a) | |
Defined in Data.OpenApi.Internal.ParamSchema Methods toParamSchema :: Proxy (Vector a) -> Schema # | |
| ToParamSchema a => ToParamSchema [a] | |
Defined in Data.OpenApi.Internal.ParamSchema Methods toParamSchema :: Proxy [a] -> Schema # | |
| HasResolution a => ToParamSchema (Fixed a) | |
Defined in Data.OpenApi.Internal.ParamSchema Methods toParamSchema :: Proxy (Fixed a) -> Schema # | |
class Typeable a => ToSchema a where #
Convert a type into .Schema
An example type and instance:
{-# LANGUAGE OverloadedStrings #-} -- allows to write Text literals
{-# LANGUAGE OverloadedLists #-} -- allows to write Map and HashMap as lists
import Control.Lens
import Data.Proxy
import Data.OpenApi
data Coord = Coord { x :: Double, y :: Double }
instance ToSchema Coord where
declareNamedSchema _ = do
doubleSchema <- declareSchemaRef (Proxy :: Proxy Double)
return $ NamedSchema (Just "Coord") $ mempty
& type_ ?~ OpenApiObject
& properties .~
[ ("x", doubleSchema)
, ("y", doubleSchema)
]
& required .~ [ "x", "y" ]
Instead of manually writing your instance you can
use a default generic implementation of ToSchema.declareNamedSchema
To do that, simply add deriving clause to your datatype
and declare a Generic instance for your datatype without
giving definition for ToSchema.declareNamedSchema
For instance, the previous example can be simplified into this:
{-# LANGUAGE DeriveGeneric #-}
import GHC.Generics (Generic)
data Coord = Coord { x :: Double, y :: Double } deriving Generic
instance ToSchema Coord
Minimal complete definition
Nothing
Methods
declareNamedSchema :: Proxy a -> Declare (Definitions Schema) NamedSchema #
Convert a type into an optionally named schema together with all used definitions. Note that the schema itself is included in definitions only if it is recursive (and thus needs its definition in scope).
default declareNamedSchema :: (Generic a, GToSchema (Rep a)) => Proxy a -> Declare (Definitions Schema) NamedSchema #
Instances
| ToSchema Object | |
Defined in Data.OpenApi.Internal.Schema Methods declareNamedSchema :: Proxy Object -> Declare (Definitions Schema) NamedSchema # | |
| ToSchema All | |
Defined in Data.OpenApi.Internal.Schema Methods declareNamedSchema :: Proxy All -> Declare (Definitions Schema) NamedSchema # | |
| ToSchema Any | |
Defined in Data.OpenApi.Internal.Schema Methods declareNamedSchema :: Proxy Any -> Declare (Definitions Schema) NamedSchema # | |
| ToSchema Version | |
Defined in Data.OpenApi.Internal.Schema Methods declareNamedSchema :: Proxy Version -> Declare (Definitions Schema) NamedSchema # | |
| ToSchema Int16 | |
Defined in Data.OpenApi.Internal.Schema Methods declareNamedSchema :: Proxy Int16 -> Declare (Definitions Schema) NamedSchema # | |
| ToSchema Int32 | |
Defined in Data.OpenApi.Internal.Schema Methods declareNamedSchema :: Proxy Int32 -> Declare (Definitions Schema) NamedSchema # | |
| ToSchema Int64 | |
Defined in Data.OpenApi.Internal.Schema Methods declareNamedSchema :: Proxy Int64 -> Declare (Definitions Schema) NamedSchema # | |
| ToSchema Int8 | |
Defined in Data.OpenApi.Internal.Schema Methods declareNamedSchema :: Proxy Int8 -> Declare (Definitions Schema) NamedSchema # | |
| ToSchema Word16 | |
Defined in Data.OpenApi.Internal.Schema Methods declareNamedSchema :: Proxy Word16 -> Declare (Definitions Schema) NamedSchema # | |
| ToSchema Word32 | |
Defined in Data.OpenApi.Internal.Schema Methods declareNamedSchema :: Proxy Word32 -> Declare (Definitions Schema) NamedSchema # | |
| ToSchema Word64 | |
Defined in Data.OpenApi.Internal.Schema Methods declareNamedSchema :: Proxy Word64 -> Declare (Definitions Schema) NamedSchema # | |
| ToSchema Word8 | |
Defined in Data.OpenApi.Internal.Schema Methods declareNamedSchema :: Proxy Word8 -> Declare (Definitions Schema) NamedSchema # | |
| (ToSchemaByteStringError ByteString :: Constraint) => ToSchema ByteString | |
Defined in Data.OpenApi.Internal.Schema Methods declareNamedSchema :: Proxy ByteString -> Declare (Definitions Schema) NamedSchema # | |
| (ToSchemaByteStringError ByteString :: Constraint) => ToSchema ByteString | |
Defined in Data.OpenApi.Internal.Schema Methods declareNamedSchema :: Proxy ByteString -> Declare (Definitions Schema) NamedSchema # | |
| ToSchema IntSet | |
Defined in Data.OpenApi.Internal.Schema Methods declareNamedSchema :: Proxy IntSet -> Declare (Definitions Schema) NamedSchema # | |
| ToSchema Scientific | |
Defined in Data.OpenApi.Internal.Schema Methods declareNamedSchema :: Proxy Scientific -> Declare (Definitions Schema) NamedSchema # | |
| ToSchema Text | |
Defined in Data.OpenApi.Internal.Schema Methods declareNamedSchema :: Proxy Text -> Declare (Definitions Schema) NamedSchema # | |
| ToSchema Text | |
Defined in Data.OpenApi.Internal.Schema Methods declareNamedSchema :: Proxy Text -> Declare (Definitions Schema) NamedSchema # | |
| ToSchema Day | Format |
Defined in Data.OpenApi.Internal.Schema Methods declareNamedSchema :: Proxy Day -> Declare (Definitions Schema) NamedSchema # | |
| ToSchema NominalDiffTime | |
Defined in Data.OpenApi.Internal.Schema Methods declareNamedSchema :: Proxy NominalDiffTime -> Declare (Definitions Schema) NamedSchema # | |
| ToSchema UTCTime |
|
Defined in Data.OpenApi.Internal.Schema Methods declareNamedSchema :: Proxy UTCTime -> Declare (Definitions Schema) NamedSchema # | |
| ToSchema LocalTime |
|
Defined in Data.OpenApi.Internal.Schema Methods declareNamedSchema :: Proxy LocalTime -> Declare (Definitions Schema) NamedSchema # | |
| ToSchema TimeOfDay | |
Defined in Data.OpenApi.Internal.Schema Methods declareNamedSchema :: Proxy TimeOfDay -> Declare (Definitions Schema) NamedSchema # | |
| ToSchema ZonedTime | Format |
Defined in Data.OpenApi.Internal.Schema Methods declareNamedSchema :: Proxy ZonedTime -> Declare (Definitions Schema) NamedSchema # | |
| ToSchema UUID | For |
Defined in Data.OpenApi.Internal.Schema Methods declareNamedSchema :: Proxy UUID -> Declare (Definitions Schema) NamedSchema # | |
| ToSchema String | |
Defined in Data.OpenApi.Internal.Schema Methods declareNamedSchema :: Proxy String -> Declare (Definitions Schema) NamedSchema # | |
| ToSchema Integer | |
Defined in Data.OpenApi.Internal.Schema Methods declareNamedSchema :: Proxy Integer -> Declare (Definitions Schema) NamedSchema # | |
| ToSchema Natural | |
Defined in Data.OpenApi.Internal.Schema Methods declareNamedSchema :: Proxy Natural -> Declare (Definitions Schema) NamedSchema # | |
| ToSchema () | |
Defined in Data.OpenApi.Internal.Schema Methods declareNamedSchema :: Proxy () -> Declare (Definitions Schema) NamedSchema # | |
| ToSchema Bool | |
Defined in Data.OpenApi.Internal.Schema Methods declareNamedSchema :: Proxy Bool -> Declare (Definitions Schema) NamedSchema # | |
| ToSchema Char | |
Defined in Data.OpenApi.Internal.Schema Methods declareNamedSchema :: Proxy Char -> Declare (Definitions Schema) NamedSchema # | |
| ToSchema Double | |
Defined in Data.OpenApi.Internal.Schema Methods declareNamedSchema :: Proxy Double -> Declare (Definitions Schema) NamedSchema # | |
| ToSchema Float | |
Defined in Data.OpenApi.Internal.Schema Methods declareNamedSchema :: Proxy Float -> Declare (Definitions Schema) NamedSchema # | |
| ToSchema Int | |
Defined in Data.OpenApi.Internal.Schema Methods declareNamedSchema :: Proxy Int -> Declare (Definitions Schema) NamedSchema # | |
| ToSchema Word | |
Defined in Data.OpenApi.Internal.Schema Methods declareNamedSchema :: Proxy Word -> Declare (Definitions Schema) NamedSchema # | |
| ToSchema a => ToSchema (Identity a) | |
Defined in Data.OpenApi.Internal.Schema Methods declareNamedSchema :: Proxy (Identity a) -> Declare (Definitions Schema) NamedSchema # | |
| ToSchema a => ToSchema (First a) | |
Defined in Data.OpenApi.Internal.Schema Methods declareNamedSchema :: Proxy (First a) -> Declare (Definitions Schema) NamedSchema # | |
| ToSchema a => ToSchema (Last a) | |
Defined in Data.OpenApi.Internal.Schema Methods declareNamedSchema :: Proxy (Last a) -> Declare (Definitions Schema) NamedSchema # | |
| ToSchema a => ToSchema (Dual a) | |
Defined in Data.OpenApi.Internal.Schema Methods declareNamedSchema :: Proxy (Dual a) -> Declare (Definitions Schema) NamedSchema # | |
| ToSchema a => ToSchema (Product a) | |
Defined in Data.OpenApi.Internal.Schema Methods declareNamedSchema :: Proxy (Product a) -> Declare (Definitions Schema) NamedSchema # | |
| ToSchema a => ToSchema (Sum a) | |
Defined in Data.OpenApi.Internal.Schema Methods declareNamedSchema :: Proxy (Sum a) -> Declare (Definitions Schema) NamedSchema # | |
| ToSchema a => ToSchema (NonEmpty a) | Since: openapi3-2.2.1 |
Defined in Data.OpenApi.Internal.Schema Methods declareNamedSchema :: Proxy (NonEmpty a) -> Declare (Definitions Schema) NamedSchema # | |
| ToSchema a => ToSchema (IntMap a) | NOTE: This schema does not account for the uniqueness of keys. |
Defined in Data.OpenApi.Internal.Schema Methods declareNamedSchema :: Proxy (IntMap a) -> Declare (Definitions Schema) NamedSchema # | |
| ToSchema a => ToSchema (Set a) | |
Defined in Data.OpenApi.Internal.Schema Methods declareNamedSchema :: Proxy (Set a) -> Declare (Definitions Schema) NamedSchema # | |
| ToSchema a => ToSchema (HashSet a) | |
Defined in Data.OpenApi.Internal.Schema Methods declareNamedSchema :: Proxy (HashSet a) -> Declare (Definitions Schema) NamedSchema # | |
| ToSchema a => ToSchema (Vector a) | |
Defined in Data.OpenApi.Internal.Schema Methods declareNamedSchema :: Proxy (Vector a) -> Declare (Definitions Schema) NamedSchema # | |
| ToSchema a => ToSchema (Vector a) | |
Defined in Data.OpenApi.Internal.Schema Methods declareNamedSchema :: Proxy (Vector a) -> Declare (Definitions Schema) NamedSchema # | |
| ToSchema a => ToSchema (Vector a) | |
Defined in Data.OpenApi.Internal.Schema Methods declareNamedSchema :: Proxy (Vector a) -> Declare (Definitions Schema) NamedSchema # | |
| ToSchema a => ToSchema (Vector a) | |
Defined in Data.OpenApi.Internal.Schema Methods declareNamedSchema :: Proxy (Vector a) -> Declare (Definitions Schema) NamedSchema # | |
| ToSchema a => ToSchema (Maybe a) | |
Defined in Data.OpenApi.Internal.Schema Methods declareNamedSchema :: Proxy (Maybe a) -> Declare (Definitions Schema) NamedSchema # | |
| ToSchema a => ToSchema [a] | |
Defined in Data.OpenApi.Internal.Schema Methods declareNamedSchema :: Proxy [a] -> Declare (Definitions Schema) NamedSchema # | |
| (ToSchema a, ToSchema b) => ToSchema (Either a b) | |
Defined in Data.OpenApi.Internal.Schema Methods declareNamedSchema :: Proxy (Either a b) -> Declare (Definitions Schema) NamedSchema # | |
| (Typeable (Fixed a), HasResolution a) => ToSchema (Fixed a) | |
Defined in Data.OpenApi.Internal.Schema Methods declareNamedSchema :: Proxy (Fixed a) -> Declare (Definitions Schema) NamedSchema # | |
| (ToJSONKey k, ToSchema k, ToSchema v) => ToSchema (Map k v) | |
Defined in Data.OpenApi.Internal.Schema Methods declareNamedSchema :: Proxy (Map k v) -> Declare (Definitions Schema) NamedSchema # | |
| (ToJSONKey k, ToSchema k, ToSchema v) => ToSchema (HashMap k v) | |
Defined in Data.OpenApi.Internal.Schema Methods declareNamedSchema :: Proxy (HashMap k v) -> Declare (Definitions Schema) NamedSchema # | |
| (ToSchema a, ToSchema b) => ToSchema (a, b) | |
Defined in Data.OpenApi.Internal.Schema Methods declareNamedSchema :: Proxy (a, b) -> Declare (Definitions Schema) NamedSchema # | |
| (ToSchema a, ToSchema b, ToSchema c) => ToSchema (a, b, c) | |
Defined in Data.OpenApi.Internal.Schema Methods declareNamedSchema :: Proxy (a, b, c) -> Declare (Definitions Schema) NamedSchema # | |
| (ToSchema a, ToSchema b, ToSchema c, ToSchema d) => ToSchema (a, b, c, d) | |
Defined in Data.OpenApi.Internal.Schema Methods declareNamedSchema :: Proxy (a, b, c, d) -> Declare (Definitions Schema) NamedSchema # | |
| (ToSchema a, ToSchema b, ToSchema c, ToSchema d, ToSchema e) => ToSchema (a, b, c, d, e) | |
Defined in Data.OpenApi.Internal.Schema Methods declareNamedSchema :: Proxy (a, b, c, d, e) -> Declare (Definitions Schema) NamedSchema # | |
| (ToSchema a, ToSchema b, ToSchema c, ToSchema d, ToSchema e, ToSchema f) => ToSchema (a, b, c, d, e, f) | |
Defined in Data.OpenApi.Internal.Schema Methods declareNamedSchema :: Proxy (a, b, c, d, e, f) -> Declare (Definitions Schema) NamedSchema # | |
| (ToSchema a, ToSchema b, ToSchema c, ToSchema d, ToSchema e, ToSchema f, ToSchema g) => ToSchema (a, b, c, d, e, f, g) | |
Defined in Data.OpenApi.Internal.Schema Methods declareNamedSchema :: Proxy (a, b, c, d, e, f, g) -> Declare (Definitions Schema) NamedSchema # | |
Swagger
withSwagger :: forall (m :: Type -> Type). MonadIO m => SwaggerConfig m -> Server m -> Server m #
Appends swagger UI to server
swagger :: MonadIO m => SwaggerConfig m -> m OpenApi -> Server m #
Swagger server. It serves static files and injects OpenApi schema
data DefaultInfo #
Default info that is often added to OpenApi schema
Constructors
| DefaultInfo | |
Instances
| Default DefaultInfo | |
Defined in Mig.Swagger Methods def :: DefaultInfo # | |
addDefaultInfo :: DefaultInfo -> OpenApi -> OpenApi #
Adds most common used info to OpenApi schema. Use this function
in the mapSchema field of the SwaggerConfig.