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

Safe HaskellNone
LanguageHaskell2010

OpenAPI.Generate.Monad

Description

This module contains the Generator monad and functions which deal with this monad. In addition this module contains the means for logging and resolving references since they are closely linked to the Generator monad.

Synopsis

Documentation

data GeneratorEnvironment Source #

The reader environment of the Generator monad

The currentPath is updated using the nested function to track the current position within the specification. This is used to produce tracable log messages. The references map is a lookup table for references within the OpenAPI specification.

data GeneratorLogEntry Source #

A log entry containing the location within the OpenAPI specification where the message was produced, a severity and the actual message.

type GeneratorLogs = [GeneratorLogEntry] Source #

The type contained in the writer of the Generator used to collect log entries

newtype Generator a Source #

The Generator monad is used to pass a Reader environment to functions in need of resolving references and collects log messages.

runGenerator :: GeneratorEnvironment -> Generator a -> (a, GeneratorLogs) Source #

Runs the generator monad within a provided environment.

createEnvironment :: Flags -> ReferenceMap -> GeneratorEnvironment Source #

Create an environment based on a ReferenceMap and Flags

logMessage :: GeneratorLogSeverity -> Text -> Generator () Source #

Writes a log message to a Generator monad

logError :: Text -> Generator () Source #

Writes an error to a Generator monad

logWarning :: Text -> Generator () Source #

Writes a warning to a Generator monad

logInfo :: Text -> Generator () Source #

Writes an info to a Generator monad

transformGeneratorLogs :: GeneratorLogs -> [Text] Source #

Transforms a log returned from runGenerator to a list of Text values for easier printing.

transformSeverity :: GeneratorLogSeverity -> Text Source #

Transforms the severity to a Text representation

transformPath :: [Text] -> Text Source #

Transforms the path to a Text representation (parts are seperated with a dot)

nested :: Text -> Generator a -> Generator a Source #

This function can be used to tell the Generator monad where in the OpenAPI specification the generator currently is

createReferenceLookupM :: (Text -> ReferenceMap -> Maybe a) -> Text -> Generator (Maybe a) Source #

Helper function to create a lookup function for a specific type

getSchemaReferenceM :: Text -> Generator (Maybe SchemaObject) Source #

Resolve a SchemaObject reference from within the Generator monad

getResponseReferenceM :: Text -> Generator (Maybe ResponseObject) Source #

Resolve a ResponseObject reference from within the Generator monad

getExampleReferenceM :: Text -> Generator (Maybe ExampleObject) Source #

Resolve a ExampleObject reference from within the Generator monad

getHeaderReferenceM :: Text -> Generator (Maybe HeaderObject) Source #

Resolve a HeaderObject reference from within the Generator monad

getFlags :: Generator Flags Source #

Get all flags passed to the program

getFlag :: (Flags -> a) -> Generator a Source #

Get a specific flag selected by f