api-tools-0.8.0.1: DSL for generating API boilerplate and docs

Safe HaskellNone
LanguageHaskell2010

Data.API.Types

Contents

Synopsis

Documentation

type API = [Thing] Source #

an API spec is made up of a list of type/element specs, each specifying a Haskell type and JSON wrappers

data APINode Source #

Specifies an individual element/type of the API

Constructors

APINode 

Fields

newtype FieldName Source #

FieldName identifies recod fields and union alternatives must contain a valid identifier valid in Haskell and any API client wrappers (e.g., if Ruby wrappers are to be generated the names should easily map into Ruby)

Constructors

FieldName 

Fields

type MDComment = String Source #

Markdown comments are represented by strings

type Prefix = CI String Source #

a distinct case-insensitive short prefix used to form unique record field names and data constructors:

  • must be a valid Haskell identifier
  • must be unique within the API

data Spec Source #

type/element specs are either simple type isomorphisms of basic JSON types, records, unions or enumerated types

data FieldType Source #

In addition to the type and comment, record fields may carry a flag indicating that they are read-only, and may have a default value, which must be of a compatible type.

type Conversion = Maybe (FieldName, FieldName) Source #

Conversion possibly converts to an internal representation. If specified, a conversion is a pair of an injection function name and a projection function name.

data APIType Source #

Type is either a list, Maybe, a named element of the API or a basic type

Constructors

TyList APIType

list elements are types

TyMaybe APIType

Maybe elements are types

TyName TypeName

the referenced type must be defined by the API

TyBasic BasicType

a JSON string, int, bool etc.

TyJSON

a generic JSON value

Instances

data BasicType Source #

the basic JSON types (N.B., no floating point numbers, yet)

Constructors

BTstring

a JSON UTF-8 string

BTbinary

a base-64-encoded byte string

BTbool

a JSON bool

BTint

a JSON integral number

BTutc

a JSON UTC string

newtype Binary Source #

Binary data is represented in JSON format as a base64-encoded string

Constructors

Binary 

Fields

Instances

Eq Binary Source # 

Methods

(==) :: Binary -> Binary -> Bool #

(/=) :: Binary -> Binary -> Bool #

Ord Binary Source # 
Show Binary Source # 
Arbitrary Binary Source # 
ToJSON Binary Source # 
FromJSON Binary Source # 
NFData Binary Source # 

Methods

rnf :: Binary -> () #

SafeCopy Binary Source # 
Serialise Binary Source # 
Example Binary Source # 
FromJSONWithErrs Binary Source # 

defaultValueAsJsValue :: DefaultValue -> Value Source #

Convert a default value to an Aeson Value. This differs from toJSON as it will not round-trip with fromJSON: UTC default values are turned into strings.

Orphan instances

Arbitrary Text Source # 

Methods

arbitrary :: Gen Text #

shrink :: Text -> [Text] #

ToJSON s0 => ToJSON (CI s0) Source # 

Methods

toJSON :: CI s0 -> Value #

toEncoding :: CI s0 -> Encoding #

toJSONList :: [CI s0] -> Value #

toEncodingList :: [CI s0] -> Encoding #

FromJSON s0 => FromJSON (CI s0) Source # 

Methods

parseJSON :: Value -> Parser (CI s0) #

parseJSONList :: Value -> Parser [CI s0] #