on master help sign in
update the example to show off multiple-responses
commit07472ccb7aec9e33e0927c8d9506b9d1f7a568b6 authorAlp Mestanogullari <alpmestan@gmail.com> dateSun 4 Jan 2015, 16:53 (12 years ago) parent71142b0
2 files changed+32−12
example/greet.hs+5 example/greet.md+27−12
example/greet.hs+5
@@ -39,6 +39,11 @@ instance ToParam (QueryParam "capital" Bool) where
3939instance ToSample Greet where
4040 toSample = Just $ Greet "Hello, haskeller!"
4141
42+ toSamples =
43+ [ ("If you use ?capital=true", Greet "HELLO, HASKELLER")
44+ , ("If you use ?capital=false", Greet "Hello, haskeller")
45+ ]
46+
4247-- API specification
4348type TestApi =
4449 -- GET /hello/:name?capital={true, false} returns a Greet as JSON
example/greet.md+27−12
@@ -1,8 +1,7 @@
1−
21POST /greet
32-----------
43
5−**Request Body**:
4+**Request Body**:
65
76``` javascript
87{
@@ -10,50 +9,66 @@ POST /greet
109}
1110```
1211
13−**Response**:
12+**Response**:
1413
1514 - Status code 201
16− - Response body as below.
15+ - If you use ?capital=true
1716
1817``` javascript
1918{
20− "msg": "Hello, haskeller!"
19+ "msg": "HELLO, HASKELLER"
20+}
21+```
22+
23+ - If you use ?capital=false
24+
25+``` javascript
26+{
27+ "msg": "Hello, haskeller"
2128}
2229```
2330
2431GET /hello/:name
2532----------------
2633
27−**Captures**:
34+**Captures**:
2835
2936- *name*: name of the person to greet
3037
31−**GET Parameters**:
38+**GET Parameters**:
3239
3340 - capital
3441 - **Values**: *true, false*
3542 - **Description**: Get the greeting message in uppercase (true) or not (false). Default is false.
3643
3744
38−**Response**:
45+**Response**:
3946
4047 - Status code 200
41− - Response body as below.
48+ - If you use ?capital=true
4249
4350``` javascript
4451{
45− "msg": "Hello, haskeller!"
52+ "msg": "HELLO, HASKELLER"
53+}
54+```
55+
56+ - If you use ?capital=false
57+
58+``` javascript
59+{
60+ "msg": "Hello, haskeller"
4661}
4762```
4863
4964DELETE /greet/:greetid
5065----------------------
5166
52−**Captures**:
67+**Captures**:
5368
5469- *greetid*: identifier of the greet msg to remove
5570
56−**Response**:
71+**Response**:
5772
5873 - Status code 204
5974 - No response body