openapi3-code-generator-0.1.0.6: OpenAPI3 Haskell Client Code Generator

Safe HaskellNone
LanguageHaskell2010

OpenAPI.Generate.Internal.Operation

Description

Helpers for the generation of the operation functions

Synopsis

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 #

Arguments

:: 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 ByteString to the required response type. Note that the response is nested within a HTTP monad and an Either.

-> 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 :: ParameterObject -> Generator (Q Type) Source #

Get the type of a parameter depending on its schema type and the configuration options (Flags). If the parameter is not required, a Maybe type is produced.

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