dhall-openapi-1.0.2: Convert an OpenAPI specification to a Dhall package
Safe HaskellNone
LanguageHaskell2010

Dhall.Kubernetes.Convert

Synopsis

Documentation

toTypes :: Map Prefix Import -> ([ModelName] -> Definition -> Maybe ModelName) -> Map ModelName Definition -> Map ModelName Expr Source #

Converts all the Swagger definitions to Dhall Types

Note: we cannot do 1-to-1 conversion and we need the whole Map because many types reference other types so we need to access them to decide things like "should this key be optional"

toDefault Source #

Arguments

:: Map Prefix Import

Mapping of prefixes to import roots

-> Map ModelName Definition

All the Swagger definitions

-> ModelName

The name of the object we're converting

-> Expr

The Dhall type of the object

-> Maybe Expr 

Convert a Dhall Type to its default value

getImportsMap Source #

Arguments

:: Map Prefix Import

Mapping of prefixes to import roots

-> DuplicateHandler

Duplicate name handler

-> [ModelName]

A list of all the object names

-> Text

The folder we should get imports from

-> [ModelName]

List of the object names we want to include in the Map

-> Map Text Expr 

Get a Dhall.Map filled with imports, for creating giant Records or Unions of types or defaults

mkImport :: Map Prefix Import -> [Text] -> Text -> Import Source #

Build an import from path components (note: they need to be in reverse order) and a filename

toDefinition :: V1CustomResourceDefinition -> Either Text (ModelName, Definition) Source #

pathSplitter :: Map ModelHierarchy (Maybe ModelName) -> ModelHierarchy -> Definition -> Maybe ModelName Source #

Given the pathsAndModels Map provides a function to be used with toTypes to split types at mostly arbitrary points

The pathsAndModels argument takes the form of a path to an optional ModelName. Paths are of the format noted by modelsToPath. If a ModelName is provided as a value for the given path, it will be returned (to be then used as the ModelName for the nested definition. If no ModelName is provided, guessModelNameForSplit will try to guess. If that fails, Nothing will be returned such that no split will be done by toTypes

Currently not all split points in for nested definitions are supported (in fact only types with a properties attribute are currently supported).