openapi3-code-generator-0.2.0.0: OpenAPI3 Haskell Client Code Generator
Safe HaskellSafe-Inferred
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 generatorEnvironmentCurrentPath is updated using the nested function to track the current position within the specification. This is used to produce tracable log messages. The generatorEnvironmentReferences map is a lookup table for references within the OpenAPI specification.

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.

Instances

Instances details
Applicative Generator Source # 
Instance details

Defined in OpenAPI.Generate.Monad

Methods

pure :: a -> Generator a #

(<*>) :: Generator (a -> b) -> Generator a -> Generator b #

liftA2 :: (a -> b -> c) -> Generator a -> Generator b -> Generator c #

(*>) :: Generator a -> Generator b -> Generator b #

(<*) :: Generator a -> Generator b -> Generator a #

Functor Generator Source # 
Instance details

Defined in OpenAPI.Generate.Monad

Methods

fmap :: (a -> b) -> Generator a -> Generator b #

(<$) :: a -> Generator b -> Generator a #

Monad Generator Source # 
Instance details

Defined in OpenAPI.Generate.Monad

Methods

(>>=) :: Generator a -> (a -> Generator b) -> Generator b #

(>>) :: Generator a -> Generator b -> Generator b #

return :: a -> Generator a #

MonadReader GeneratorEnvironment Generator Source # 
Instance details

Defined in OpenAPI.Generate.Monad

MonadWriter LogEntries Generator Source # 
Instance details

Defined in OpenAPI.Generate.Monad

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

Runs the generator monad within a provided environment.

logMessage :: LogSeverity -> 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

logTrace :: Text -> Generator () Source #

Writes a trace to a Generator monad

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

resetPath :: [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 (ignoring any previous path changes)

adjustSettings :: (Settings -> Settings) -> Generator a -> Generator a Source #

Allows to adjust the settings for certain parts of the generation.

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

getSettings :: Generator Settings Source #

Get all settings passed to the program

getSetting :: (Settings -> a) -> Generator a Source #

Get a specific setting selected by f