-
Notifications
You must be signed in to change notification settings - Fork 0
API: answers
luqiuyuan edited this page Dec 29, 2020
·
2 revisions
VERB | PATH | DESC |
---|---|---|
GET | /questions/:id/answers | get answers of a question |
GET | /answers/:id | show an answer |
POST | /questions/:id/answers | create an answer of a question |
PATCH/PUT | answers/:id | update an answer |
DELETE | answers/:id | destroy an answer |
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) | 未找到 |
{
"answer": {
"content": "Dream it possible"
}
}
validations
- answer (required)
- content (required, max length 65535)
see view SHOW
STATUS | ERROR TYPE | DESC | EXAMPLE |
---|---|---|---|
created (201) | 创建成功 | ||
bad request (400) | missing_field | 缺少参数 | { "code": "missing_field", "field": "answer:content" } |
invalid_field | 参数错误 | { "code": "invalid_field", "field": "answer:content" } |
{
"answer": {
"content": "You are the apple of my eyes",
}
}
validations
- answer (required)
- content (required, max length 65535)
see view SHOW
STATUS | ERROR TYPE | DESC | EXAMPLE |
---|---|---|---|
ok (200) | 成功 | ||
bad request (400) | missing_field | 缺少参数 | { "code": "missing_field", "field": "answer" } |
invalid_field | 参数错误 | { "code": "invalid_field", "field": "answer:content" } |
|
not found (404) | 未找到 |
see view INDEX
STATUS | ERROR TYPE | DESC | EXAMPLE |
---|---|---|---|
ok (200) | 成功 | ||
not found (404) | 未找到 |
{
"answer": {
"id": 13579,
"content": "Dream it possible",
"question_id": 123,
"user_id": 2345,
"created_at": "2016-05-01T23:00:00.000Z",
"updated_at": "2016-05-01T23:00:00.000Z",
"number_of_likes": 15,
"liked": true
}
}
{
"answers": [
{
"id": 13579,
"content": "Dream it possible",
"question_id": 953,
"user_id": 2345,
"created_at": "2016-05-01T23:00:00.000Z",
"updated_at": "2016-05-01T23:00:00.000Z",
"number_of_likes": 0,
"liked": false
}
]
}