on master help sign in
update the example to show off multiple-responses
07472ccAlp Mestanogullari
example/greet.hs+5
@@ -39,6 +39,11 @@ instance ToParam (QueryParam "capital" Bool) where
39instance ToSample Greet where
39instance ToSample Greet where
40 toSample = Just $ Greet "Hello, haskeller!"
40 toSample = Just $ Greet "Hello, haskeller!"
41
41
42+ toSamples =
43+ [ ("If you use ?capital=true", Greet "HELLO, HASKELLER")
44+ , ("If you use ?capital=false", Greet "Hello, haskeller")
45+ ]
46+
42-- API specification
47-- API specification
43type TestApi =
48type TestApi =
44 -- GET /hello/:name?capital={true, false} returns a Greet as JSON
49 -- GET /hello/:name?capital={true, false} returns a Greet as JSON
example/greet.md+27−12
@@ -1,8 +1,7 @@
1−
2POST /greet
1POST /greet
3-----------
2-----------
4
3
5−**Request Body**:
4+**Request Body**:
6
5
7``` javascript
6``` javascript
8{
7{
@@ -10,50 +9,66 @@ POST /greet
10}
9}
11```
10```
12
11
13−**Response**:
12+**Response**:
14
13
15 - Status code 201
14 - Status code 201
16− - Response body as below.
15+ - If you use ?capital=true
17
16
18``` javascript
17``` javascript
19{
18{
19+ "msg": "HELLO, HASKELLER"
20+}
21+```
22+
23+ - If you use ?capital=false
24+
25+``` javascript
26+{
20− "msg": "Hello, haskeller!"
27+ "msg": "Hello, haskeller"
21}
28}
22```
29```
23
30
24GET /hello/:name
31GET /hello/:name
25----------------
32----------------
26
33
27−**Captures**:
34+**Captures**:
28
35
29- *name*: name of the person to greet
36- *name*: name of the person to greet
30
37
31−**GET Parameters**:
38+**GET Parameters**:
32
39
33 - capital
40 - capital
34 - **Values**: *true, false*
41 - **Values**: *true, false*
35 - **Description**: Get the greeting message in uppercase (true) or not (false). Default is false.
42 - **Description**: Get the greeting message in uppercase (true) or not (false). Default is false.
36
43
37
44
38−**Response**:
45+**Response**:
39
46
40 - Status code 200
47 - Status code 200
41− - Response body as below.
48+ - If you use ?capital=true
42
49
43``` javascript
50``` javascript
44{
51{
52+ "msg": "HELLO, HASKELLER"
53+}
54+```
55+
56+ - If you use ?capital=false
57+
58+``` javascript
59+{
45− "msg": "Hello, haskeller!"
60+ "msg": "Hello, haskeller"
46}
61}
47```
62```
48
63
49DELETE /greet/:greetid
64DELETE /greet/:greetid
50----------------------
65----------------------
51
66
52−**Captures**:
67+**Captures**:
53
68
54- *greetid*: identifier of the greet msg to remove
69- *greetid*: identifier of the greet msg to remove
55
70
56−**Response**:
71+**Response**:
57
72
58 - Status code 204
73 - Status code 204
59 - No response body
74 - No response body