swagger: "2.0"
info:
  version: "1.0.0"
  title: "To Do List API"
schemes:
  - "http"
x-controller: todo
paths:
  /:
    get:
      summary: Get a list of tasks
      x-operation: getList
      responses:
        200:
          description: Get a list of tasks
          schema:
            $ref: '#/definitions/TaskList'
    post:
      summary: Add a new task
      x-operation: addTask
      parameters:
        - $ref: "#/parameters/TaskItem"
      responses:
        200:
          description: Get the added task
          schema:
            $ref: '#/definitions/Task'
  /{task_id}:
    parameters:
      - in: path
        name: task_id
        required: true
        type: number
        minimum: 0
    get:
      summary: Get a task by ID
      x-operation: getTask
      responses:
        200:
          description: Get the task
          schema:
            $ref: '#/definitions/Task'
        404:
          description: Not found
    put:
      summary: Update a task
      x-operation: updateTask
      parameters:
        - $ref: "#/parameters/TaskItem"
      responses:
        200:
          description: Get the updated task
          schema:
            $ref: '#/definitions/Task'
        404:
          description: Not found
    delete:
      summary: Delete a task
      x-operation: deleteTask
      responses:
        204:
          description: Task deleted
definitions:
  Task:
    type: object
    required:
      - title
      - due
    properties:
      id:
        type: integer
        minimum: 0
      title:
        type: string
        minLength: 1
      due:
        type: string
        format: date-time
      completed:
        type: boolean
        default: false
  TaskList:
    type: array
    items:
      $ref: '#/definitions/Task'
parameters:
  TaskItem:
    in: body
    name: body
    required: true
    schema:
      $ref: "#/definitions/Task"