Back to top

Sample API

サンプルの仕様書

Example

Example

Example GET API
GET/example

処理概要

  • [端的にどんなAPIかを書く]

  • [注意点、特記事項など]

Example URI

GET http://localhost:3000/example
Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "value": "GET API Response Example"
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "value": {
      "type": "string",
      "description": "値"
    }
  }
}

Example POST API
POST/example

処理概要

  • [端的にどんなAPIかを書く]

  • [注意点、特記事項など]

Example URI

POST http://localhost:3000/example
Request
HideShow
Headers
Content-Type: application/json
Body
{
  "value": "POST API Request Example"
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "value": {
      "type": "string",
      "description": "値"
    }
  },
  "required": [
    "value"
  ]
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "value": "POST API Response Example"
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "value": {
      "type": "string",
      "description": "値"
    }
  }
}

All User

Todo一覧取得

Todo一覧取得
GET/todos

処理概要

  • Todo一覧を取得

Example URI

GET http://localhost:3000/todos
Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "description": "OK",
  "todos": [
    {
      "id": 1,
      "name": "やること"
    }
  ]
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "description": {
      "type": "string",
      "description": "説明"
    },
    "todos": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "number",
            "description": "ID"
          },
          "name": {
            "type": "string",
            "description": "名前"
          }
        }
      },
      "description": "Todo一覧"
    }
  }
}

指定したTodo取得

指定したTodo取得
GET/todos/{todo_id}

処理概要

  • 指定したTodoを取得

Example URI

GET http://localhost:3000/todos/1
URI Parameters
HideShow
todo_id
number (required) Example: 1

TodoのID

Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "description": "OK",
  "todo": {
    "id": 1,
    "name": "やること"
  }
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "description": {
      "type": "string",
      "description": "説明"
    },
    "todo": {
      "type": "object",
      "properties": {
        "id": {
          "type": "number",
          "description": "ID"
        },
        "name": {
          "type": "string",
          "description": "名前"
        }
      },
      "description": "Todo詳細"
    }
  }
}

Todoの新規追加

Todoの新規追加
POST/todos/new

処理概要

  • Todoの新規追加

Example URI

POST http://localhost:3000/todos/new
Request
HideShow
Headers
Content-Type: application/json
Body
{
  "name": "やること"
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "description": "名前"
    }
  },
  "required": [
    "name"
  ]
}
Response  201
HideShow
Headers
Content-Type: application/json
Body
{
  "description": "Created",
  "message": "Todoを新規作成しました",
  "todo": {
    "id": 1,
    "name": "やること"
  }
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "description": {
      "type": "string",
      "description": "Description"
    },
    "message": {
      "type": "string",
      "description": "メッセージ"
    },
    "todo": {
      "type": "object",
      "properties": {
        "id": {
          "type": "number",
          "description": "ID"
        },
        "name": {
          "type": "string",
          "description": "名前"
        }
      },
      "description": "追加したTodo詳細"
    }
  }
}

Generated by aglio on 28 Nov 2020