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

Safe HaskellNone
LanguageHaskell2010

Data.API.Tools.Example

Description

Tool for generating documentation-friendly examples

Synopsis

Documentation

class Example a where Source

The Example class is used to generate a documentation-friendly example for each type in the model

Minimal complete definition

Nothing

Methods

example :: Gen a Source

Generator for example values; defaults to arbitrary if not specified

exampleTool :: APITool Source

Tool to generate Example instances for types generated by datatypesTool. This depends on quickCheckTool.

samplesTool :: Name -> APITool Source

Generate a list of (type name, sample generator) pairs corresponding to each type in the API, with samples encoded as JSON. This depends on the Example instances generated by exampleTool. It generates something like this:

samples :: [(String, Gen Value)]
samples = [("Foo", fmap toJSON (example :: Gen Foo)), ... ]