Safe Haskell | None |
---|---|
Language | Haskell2010 |
Renders the intermediate structure into common documentation formats
Example scripts
Generating plaintext/JSON documentation from api types
Writing our own rendering format
Example of rendering the intermediate structure
Intermediate structure
ApiDocs ( fromList [( "/hello/world", , Details (fromList ([ ( "RequestBody" , Details (fromList ([ ( "Format" , Detail "': * () ('[] *)" ) , ( "ContentType" , Detail "()" ) ])) ) , ( "RequestType" , Detail "'POST" ) , ( "Response" , Details (fromList ([ ( "Format" , Detail "': * () ('[] *)" ) , ( "ContentType" , Detail "()" ) ])) ) ])) )])
JSON
{ "/hello/world": { "Response": { "Format": "': * () ('[] *)", "ContentType": "()" }, "RequestType": "'POST", "RequestBody": { "Format": "': * () ('[] *)", "ContentType": "()" } } }
Text
/hello/world: RequestBody: Format: ': * () ('[] *) ContentType: () RequestType: 'POST Response: Format: ': * () ('[] *) ContentType: ()
Documentation
Intermediate documentation structure, a hashmap of endpoints
API type:
type API = "users" :> ( "update" :> Response '[()] () :<|> "get" :> Response '[()] () )
Parsed into ApiDocs:
ApiDocs ( fromList [ ( "/users/update", , Details (fromList ([ ( "Response" , Details (fromList ([ ( "Format" , Detail "': * () ('[] *)" ) , ( "ContentType" , Detail "()" ) ])) ) ])) ) , ( "/users/get", , Details (fromList ([ ( "Response" , Details (fromList ([ ( "Format" , Detail "': * () ('[] *)" ) , ( "ContentType" , Detail "()" ) ])) ) ])) ) ])
For more examples reference Test.Servant.Docs.Simple.Samples
Details of the Api Route
Examples
Authentication: true
Can be interpreted as a Parameter (Authentication) and a Detail (true)
Response: Format: ... ContentType: ...
Can be interpreted as a Parameter (Response) and Details (Format (...), ContentType (...))
class Renderable a where Source #
Convert ApiDocs into different documentation formats
Instances
Renderable Markdown Source # | |
Renderable PlainText Source # | Conversion to plaintext |
Renderable Pretty Source # | Conversion to prettyprint |
Renderable Json Source # | Conversion to JSON using Data.Aeson |
Conversion to JSON using Data.Aeson
Conversion to markdown
Conversion to prettyprint
Instances
Renderable Pretty Source # | Conversion to prettyprint |