Skip to content

Instantly share code, notes, and snippets.

@LetMyPeopleCode
Last active May 25, 2023 20:49
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save LetMyPeopleCode/99abd6eea4894d149971e98113e29076 to your computer and use it in GitHub Desktop.
OpenAPI 3.0 definition for Postman ToDo API Quickstart
openapi: 3.0.0
info:
title: My ToDo API
description: Create, read, edit, and complete tasks.
version: 0.1.0
servers:
- url: http://localhost:8080
description: Development server
variables:
port:
default: '8080'
components:
schemas:
id_code:
description: A, UUID identifying an individual task.
type: string
minLength: 1
maxLength: 36
task:
description: Text between 2 to 255 characters.
type: string
minLength: 2
maxLength: 255
completed:
description: True means the task is completed, false means it is not.
type: boolean
complete:
description: Use true to show all tasks, false to show only incomplete tasks.
type: boolean
to_do:
description: An object containing a task's information
type: object
properties:
idcode:
$ref: '#/components/schemas/id_code'
task:
$ref: '#/components/schemas/task'
completed:
$ref: '#/components/schemas/completed'
to_do_list:
description: An array of toDo objects.
type: array
items:
$ref: '#/components/schemas/to_do'
error_msg:
type: object
properties:
message:
type: string
paths:
/todo:
get:
description: Gets a list of all items or all incomplete items.
parameters:
- name: complete
in: query
required: false
schema:
$ref: '#/components/schemas/complete'
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/to_do_list'
post:
description: Create a to-do item.
requestBody:
content:
application/x-www-form-urlencoded:
schema:
type: object
properties:
task:
$ref: '#/components/schemas/task'
completed:
$ref: '#/components/schemas/completed'
required:
- task
responses:
'200':
description: Returns a copy of the new ToDo object.
content:
'application/json':
schema:
$ref: '#/components/schemas/to_do'
'400':
description: Creation failed. Returns an error.
content:
'application/json':
schema:
$ref: '#/components/schemas/error_msg'
put:
description: Update a to-do item.
requestBody:
content:
application/x-www-form-urlencoded:
schema:
type: object
properties:
id_code:
$ref: '#/components/schemas/id_code'
task:
$ref: '#/components/schemas/task'
completed:
$ref: '#/components/schemas/completed'
required:
- id_code
responses:
'200':
description: Item updated. Returns the item's updated ToDo object.
content:
'application/json':
schema:
$ref: '#/components/schemas/to_do'
'400':
description: Update failed. Returns an error message.
content:
'application/json':
schema:
$ref: '#/components/schemas/error_msg'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment