Safe Haskell | None |
---|---|
Language | Haskell2010 |
Helpers for the generation of the operation functions
Synopsis
- getResponseObject :: Referencable ResponseObject -> Generator (Maybe ResponseObject)
- getResponseSchema :: ResponseObject -> Generator (Maybe Schema)
- defineOperationFunction :: Bool -> Name -> [ParameterObject] -> Text -> Text -> Maybe RequestBodyDefinition -> Q Exp -> Generator (Q Doc)
- getParameterDescription :: ParameterObject -> Generator Text
- getParameterType :: Flags -> ParameterObject -> Q Type
- getParametersTypeForSignature :: [Q Type] -> Name -> Name -> Name -> Q Type
- getParametersTypeForSignatureWithMonadTransformer :: [Q Type] -> Name -> Name -> Name -> Q Type
- getOperationName :: Text -> Text -> OperationObject -> Generator Name
- getOperationDescription :: OperationObject -> Text
- getParametersFromOperationConcrete :: OperationObject -> Generator [ParameterObject]
- getBodySchemaFromOperation :: OperationObject -> Generator (Maybe RequestBodyDefinition)
- generateParameterizedRequestPath :: [(Name, ParameterObject)] -> Text -> Q Exp
- generateQueryParams :: [(Name, ParameterObject)] -> Q Exp
- data RequestBodyDefinition = RequestBodyDefinition {}
Documentation
getResponseObject :: Referencable ResponseObject -> Generator (Maybe ResponseObject) Source #
Resolve a possibly referenced response to a concrete value.
A warning is logged if the reference is not found.
getResponseSchema :: ResponseObject -> Generator (Maybe Schema) Source #
Extracts the response Schema
from a ResponseObject
.
A warning is logged if the response does not contain one of the supported media types.
defineOperationFunction Source #
:: Bool | Should the configuration be passed explicitly as parameter? |
-> Name | How the function should be called |
-> [ParameterObject] | The parameters |
-> Text | The request path. It may contain placeholders in the form my{var}path |
-> Text | HTTP Method (POST,GET,etc.) |
-> Maybe RequestBodyDefinition | Schema of body |
-> Q Exp | An expression used to transform the response from |
-> Generator (Q Doc) | Function body definition in TH |
Defines the body of an Operation function The Operation function calls an generall HTTP function all Parameters are arguments to the function
getParameterDescription :: ParameterObject -> Generator Text Source #
Get a description of a parameter object (the name and if available the description from the specification)
getParameterType :: Flags -> ParameterObject -> Q Type Source #
getParametersTypeForSignature :: [Q Type] -> Name -> Name -> Name -> Q Type Source #
Gets the Type definition dependent on the number of parameters/types A monadic name for which its forall structure is defined outside this function can be given
[t|OC.Configuration -> Int -> $(varT monadName) ($(responseType) $(responseInnerType))|] = getParametersTypeForSignature conT ''Int
getParametersTypeForSignatureWithMonadTransformer :: [Q Type] -> Name -> Name -> Name -> Q Type Source #
Same as getParametersTypeForSignature
but with the configuration in ReaderT
instead of a parameter
getOperationName :: Text -> Text -> OperationObject -> Generator Name Source #
Constructs the name of an operation.
If an $sel:operationId:OperationObject
is available, this is the primary choice.
If it is not available, the id is constructed based on the request path and method.
getOperationDescription :: OperationObject -> Text Source #
Extracts a description from an OperationObject
.
If available, the description is used, the summary otherwise.
If neither is available, an empty description is used.
getParametersFromOperationConcrete :: OperationObject -> Generator [ParameterObject] Source #
Extracts all parameters of an operation
Concrete objects are always added. References try to get resolved to a concrete object. If this fails, the parameter is skipped and a warning gets produced.
getBodySchemaFromOperation :: OperationObject -> Generator (Maybe RequestBodyDefinition) Source #
Extracts the request body schema from an operation and the encoding which should be used on the body data.
generateParameterizedRequestPath :: [(Name, ParameterObject)] -> Text -> Q Exp Source #
Resolves placeholders in paths with dynamic expressions
"my{var}path" -> "my" ++ myVar ++ "/path"
If the placeholder is at the end or at the beginning an empty string gets appended
generateQueryParams :: [(Name, ParameterObject)] -> Q Exp Source #
Generates query params in the form of [(Text,ByteString)]
data RequestBodyDefinition Source #
Extracted request body information which can be used for code generation