Skip to content

Instantly share code, notes, and snippets.

@nicolaferraro
Created September 5, 2018 12:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicolaferraro/ac312ced055e8e6c38f9996c4de7a0b6 to your computer and use it in GitHub Desktop.
Save nicolaferraro/ac312ced055e8e6c38f9996c4de7a0b6 to your computer and use it in GitHub Desktop.
Todo Swagger
---
swagger: "2.0"
info:
title: "Todo App API"
description: "Example Todo Application API"
version: "1.0.0"
license:
name: "Apache 2.0"
url: "http://www.apache.org/licenses/LICENSE-2.0.html"
host: "hostname"
basePath: /api
schemes:
- "http"
- "https"
paths:
/:
get:
tags:
- tasks
- fetching
summary: "List all tasks"
description: "Fetches all tasks from the database"
produces:
- "application/json"
responses:
200:
description: All is good
schema:
type: "array"
items:
$ref: "#/definitions/Task"
post:
tags:
- tasks
- creating
summary: "Create new task"
description: "Stores new task in the database"
produces:
- "application/json"
consumes:
- "application/json"
parameters:
- in: body
name: body
description: "Task to create"
required: true
schema:
$ref: "#/definitions/Task"
responses:
201:
description: All is good
schema:
$ref: "#/definitions/Task"
/{id}:
get:
tags:
- tasks
- fetching
summary: "Fetch task"
description: "Fetches task by given identifier"
produces:
- "application/json"
parameters:
- in: path
name: id
type: integer
format: int64
description: "Task identifier"
required: true
responses:
200:
description: All is good
schema:
$ref: "#/definitions/Task"
404:
description: "No task with provided identifier found"
put:
tags:
- tasks
- updating
summary: "Update task"
description: "Updates task by given identifier"
produces:
- "application/json"
consumes:
- "application/json"
parameters:
- in: path
name: id
type: integer
format: int64
description: "Task identifier"
required: true
- in: body
name: body
description: "Task with updates"
required: true
schema:
$ref: "#/definitions/Task"
responses:
200:
description: All is good
schema:
$ref: "#/definitions/Task"
delete:
tags:
- tasks
- destruction
summary: "Delete task"
description: "Deletes task by given identifier"
parameters:
- in: path
name: id
type: integer
format: int64
description: "Task identifier to delete"
required: true
responses:
204:
description: Task deleted
securityDefinitions:
username_password:
type: basic
definitions:
Task:
type: object
properties:
id:
type: integer
format: int64
title: "Task ID"
description: "Unique task identifier"
task:
type: "string"
title: "The task"
description: "Task line"
completed:
type: "integer"
title: "Task completition status"
description: "0 - ongoing, 1 - completed"
minimum: 0
maximum: 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment