From 07472ccb7aec9e33e0927c8d9506b9d1f7a568b6 Mon Sep 17 00:00:00 2001 From: Alp Mestanogullari Date: Sun, 4 Jan 2015 16:53:02 +0100 Subject: [PATCH] update the example to show off multiple-responses --- example/greet.hs | 5 +++++ example/greet.md | 39 +++++++++++++++++++++++++++------------ 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/example/greet.hs b/example/greet.hs index 868a55ac..38a29292 100644 --- a/example/greet.hs +++ b/example/greet.hs @@ -39,6 +39,11 @@ instance ToParam (QueryParam "capital" Bool) where instance ToSample Greet where toSample = Just $ Greet "Hello, haskeller!" + toSamples = + [ ("If you use ?capital=true", Greet "HELLO, HASKELLER") + , ("If you use ?capital=false", Greet "Hello, haskeller") + ] + -- API specification type TestApi = -- GET /hello/:name?capital={true, false} returns a Greet as JSON diff --git a/example/greet.md b/example/greet.md index 2191063c..284c7eeb 100644 --- a/example/greet.md +++ b/example/greet.md @@ -1,8 +1,7 @@ - POST /greet ----------- -**Request Body**: +**Request Body**: ``` javascript { @@ -10,50 +9,66 @@ POST /greet } ``` -**Response**: +**Response**: - Status code 201 - - Response body as below. + - If you use ?capital=true ``` javascript { - "msg": "Hello, haskeller!" + "msg": "HELLO, HASKELLER" +} +``` + + - If you use ?capital=false + +``` javascript +{ + "msg": "Hello, haskeller" } ``` GET /hello/:name ---------------- -**Captures**: +**Captures**: - *name*: name of the person to greet -**GET Parameters**: +**GET Parameters**: - capital - **Values**: *true, false* - **Description**: Get the greeting message in uppercase (true) or not (false). Default is false. -**Response**: +**Response**: - Status code 200 - - Response body as below. + - If you use ?capital=true ``` javascript { - "msg": "Hello, haskeller!" + "msg": "HELLO, HASKELLER" +} +``` + + - If you use ?capital=false + +``` javascript +{ + "msg": "Hello, haskeller" } ``` DELETE /greet/:greetid ---------------------- -**Captures**: +**Captures**: - *greetid*: identifier of the greet msg to remove -**Response**: +**Response**: - Status code 204 - No response body