記事API - kuranari/mblog GitHub Wiki

ユーザの投稿記事投稿を表します。

  • title
    • 記事のタイトル
    • type: string
  • body
    • 記事の本文
    • type: string
  • user
    • 投稿したユーザー
  • favorite_users
    • お気に入りをしたユーザー一覧

GET /articles

記事一覧を返します。

GET /articles 

response

HTTP/1.1 200 OK
[
  {
    "id": 1,
    "title": "Alice in wonderland",
    "body": "hogehoge",
    "user": {
      "id": 1,
      "email": "[email protected]",
      "created_at": "2017-12-17T05:03:49.000Z",
      "updated_at": "2017-12-17T09:21:02.000Z"
    },
    "favorite_users": []
  }
]

GET /articles/:id

記事を返します。

GET /articles/:id

response

HTTP/1.1 200 OK
{
  "id": 1,
  "title": "Alice in wonderland",
  "body": "hogehoge",
  "user": {
    "id": 1,
    "email": "[email protected]",
    "created_at": "2017-12-17T05:03:49.000Z",
    "updated_at": "2017-12-17T09:21:02.000Z"
  },
  "favorite_users": []
}

POST /articles

記事を投稿します

POST /articles

input

{
    "title": "Alice in wonderland",
    "body": "hogehoge",
}

response

HTTP/1.1 200 OK
{
  "id": 1,
  "title": "Alice in wonderland",
  "body": "hogehoge",
  "user": {
    "id": 1,
    "email": "[email protected]",
    "created_at": "2017-12-17T05:03:49.000Z",
    "updated_at": "2017-12-17T09:21:02.000Z"
  },
  "favorite_users": []
}

PUT /articles/:id

記事を更新します

PUT /articles/:id

input

{
    "title": "Bible",
}

response

HTTP/1.1 200 OK
{
  "id": 1,
  "title": "Bible",
  "body": "hogehoge",
  "user": {
    "id": 1,
    "email": "[email protected]",
    "created_at": "2017-12-17T05:03:49.000Z",
    "updated_at": "2017-12-17T09:21:02.000Z"
  },
  "favorite_users": []
}

DELETE /articles/:id

記事を削除します

DELETE /articles/:id

response

HTTP/1.1 204 No Content