-
Notifications
You must be signed in to change notification settings - Fork 0
API: questions
luqiuyuan edited this page Jun 7, 2019
·
1 revision
VERB | PATH | DESC |
---|---|---|
GET | /questions | show all questions |
GET | /questions/:id | show a question |
POST | /questions | create a question |
PATCH/PUT | questions/:id | update a question |
DELETE | questions/:id | destroy a question |
see view INDEX
STATUS | ERROR TYPE | DESC | EXAMPLE |
---|---|---|---|
ok (200) | 创建成功 | ||
not found (404) | 未找到 |
see view INDEX
STATUS | ERROR TYPE | DESC | EXAMPLE |
---|---|---|---|
ok (200) | 创建成功 | ||
not found (404) | 未找到 |
{
"question": {
"title": "You are the apple of my eyes",
"content": "Really?"
}
}
validations
- question (required)
- title (required, max length 255)
- content (max length 65535)
see view SHOW
STATUS | ERROR TYPE | DESC | EXAMPLE |
---|---|---|---|
created (201) | 创建成功 | ||
bad request (400) | missing_field | 缺少参数 | { "code": "missing_field", "field": "question:title" } |
invalid_field | 参数错误 | { "code": "invalid_field", "field": "question:title" } |
{
"question": {
"title": "You are the apple of my eyes",
"content": "Really?"
}
}
validations
- question (required)
- title (required, max length 255)
- content (max length 65535)
see view SHOW
STATUS | ERROR TYPE | DESC | EXAMPLE |
---|---|---|---|
ok (200) | 成功 | ||
bad request (400) | missing_field | 缺少参数 | { "code": "missing_field", "field": "question" } |
invalid_field | 参数错误 | { "code": "invalid_field", "field": "question:title" } |
|
not found (404) | 未找到 |
see view INDEX
STATUS | ERROR TYPE | DESC | EXAMPLE |
---|---|---|---|
ok (200) | 成功 | ||
not found (404) | 未找到 |
{
"question": {
"id": 1,
"title": "Why human is born alone?",
"user_id": 5,
"created_at": "2016-05-01T23:00:00.000Z",
"updated_at": "2016-05-01T23:00:00.000Z",
"number_of_likes": 15,
"liked": true
}
}
{
"questions": [
{
"id": 1,
"title": "Why human is born alone?",
"user_id": 5,
"created_at": "2016-05-01T23:00:00.000Z",
"updated_at": "2016-05-01T23:00:00.000Z",
"number_of_likes": 0,
"liked": false
}
]
}