Skip to content

Instantly share code, notes, and snippets.

@anhnguyen1618
Created December 1, 2019 14:20
Show Gist options
  • Save anhnguyen1618/c13c5489518dccc73148e7f846caefa7 to your computer and use it in GitHub Desktop.
Save anhnguyen1618/c13c5489518dccc73148e7f846caefa7 to your computer and use it in GitHub Desktop.
openapi: "3.0.0"
info:
version: 1.0.0
title: Task management API
paths:
/task:
post:
summary: Create a task
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/Task'
responses:
'201':
description: Created
content:
application/json:
schema:
$ref: '#/components/schemas/Task'
'422':
description: Unprocessable entity
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
default:
description: Unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/tasks:
get:
summary: Get all tasks
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/Tasks'
default:
description: Unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/task/{task_id}:
get:
summary: Get all tasks
parameters:
- name: task_id
in: path
description: task id
required: true
schema:
type: string
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/Task'
default:
description: Unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
put:
summary: Update task with id
parameters:
- name: task_id
in: path
description: task id
required: true
schema:
type: string
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/Task'
responses:
'201':
description: Created
content:
application/json:
schema:
$ref: '#/components/schemas/Task'
default:
description: Unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
delete:
summary: Delete
parameters:
- name: task_id
in: path
description: task id
required: true
schema:
type: string
responses:
'204':
description: No content
default:
description: Unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
components:
schemas:
Task:
type: object
required:
- name
- status
properties:
id:
type: string
readOnly: true
name:
type: string
minLength: 1
maxLength: 100
status:
type: string
minLength: 1
enum: [pending, ongoing, completed]
created:
type: string
readOnly: true
format: date-time
Tasks:
type: array
items:
$ref: "#/components/schemas/Task"
Error:
type: object
required:
- code
- message
properties:
code:
type: integer
format: int32
message:
type: string
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment