update the example to show off multiple-responses

This commit is contained in:
Alp Mestanogullari 2015-01-04 16:53:02 +01:00
parent 71142b08d4
commit 07472ccb7a
2 changed files with 32 additions and 12 deletions

View file

@ -39,6 +39,11 @@ instance ToParam (QueryParam "capital" Bool) where
instance ToSample Greet where instance ToSample Greet where
toSample = Just $ Greet "Hello, haskeller!" toSample = Just $ Greet "Hello, haskeller!"
toSamples =
[ ("If you use ?capital=true", Greet "HELLO, HASKELLER")
, ("If you use ?capital=false", Greet "Hello, haskeller")
]
-- API specification -- API specification
type TestApi = type TestApi =
-- GET /hello/:name?capital={true, false} returns a Greet as JSON -- GET /hello/:name?capital={true, false} returns a Greet as JSON

View file

@ -1,8 +1,7 @@
POST /greet POST /greet
----------- -----------
**Request Body**: **Request Body**:
``` javascript ``` javascript
{ {
@ -10,50 +9,66 @@ POST /greet
} }
``` ```
**Response**: **Response**:
- Status code 201 - Status code 201
- Response body as below. - If you use ?capital=true
``` javascript ``` javascript
{ {
"msg": "Hello, haskeller!" "msg": "HELLO, HASKELLER"
}
```
- If you use ?capital=false
``` javascript
{
"msg": "Hello, haskeller"
} }
``` ```
GET /hello/:name GET /hello/:name
---------------- ----------------
**Captures**: **Captures**:
- *name*: name of the person to greet - *name*: name of the person to greet
**GET Parameters**: **GET Parameters**:
- capital - capital
- **Values**: *true, false* - **Values**: *true, false*
- **Description**: Get the greeting message in uppercase (true) or not (false). Default is false. - **Description**: Get the greeting message in uppercase (true) or not (false). Default is false.
**Response**: **Response**:
- Status code 200 - Status code 200
- Response body as below. - If you use ?capital=true
``` javascript ``` javascript
{ {
"msg": "Hello, haskeller!" "msg": "HELLO, HASKELLER"
}
```
- If you use ?capital=false
``` javascript
{
"msg": "Hello, haskeller"
} }
``` ```
DELETE /greet/:greetid DELETE /greet/:greetid
---------------------- ----------------------
**Captures**: **Captures**:
- *greetid*: identifier of the greet msg to remove - *greetid*: identifier of the greet msg to remove
**Response**: **Response**:
- Status code 204 - Status code 204
- No response body - No response body