Skip to content

Instantly share code, notes, and snippets.

@JeffryGonzalez
Last active March 11, 2016 13:39
Show Gist options
  • Select an option

  • Save JeffryGonzalez/524894b6ad80c2c3ff84 to your computer and use it in GitHub Desktop.

Select an option

Save JeffryGonzalez/524894b6ad80c2c3ff84 to your computer and use it in GitHub Desktop.
Books api swagger spec
swagger: '2.0'
info:
description: The Books API
version: 1.0.0
title: Books API
contact: {}
license:
name: MIT
host: 'localhost:3000'
basePath: '/api'
tags:
- name: Default
description: Default section
- name: books
schemes:
- http
paths:
/books:
get:
tags:
- books
summary: Get the full list of books
description: Get the full list of books
operationId: getBooks
consumes: []
produces:
- application/json
parameters: []
responses:
'200':
description: Returns the entire list of books
schema:
type: array
items:
$ref: '#/definitions/Books'
post:
tags:
- books
summary: Used to add a new book
description: Used to add a new book
operationId: postBooks
consumes:
- application/json
produces:
- application/json
parameters:
- in: body
name: body
required: false
schema:
$ref: '#/definitions/BookEdit'
responses:
'201':
description: You successefully added a book
schema:
$ref: '#/definitions/Book'
'400':
description: There were errors validating your book
schema:
$ref: '#/definitions/Error'
'/books/{id}':
get:
tags:
- books
summary: Book Details
description: Book Details
operationId: getBooksId
consumes: []
produces:
- application/json
parameters:
- name: id
in: path
description: The id for the book you wish to retreive. This is a guid.
required: true
type: string
responses:
'200':
description: Single Book
schema:
$ref: '#/definitions/Book'
'404':
description: No book with that id
put:
tags:
- books
summary: Update (replace) a book
description: Update (replace) a book
operationId: putBooksId
consumes:
- application/json
produces:
- application/json
parameters:
- name: id
in: path
description: The id for the book you wish to retreive. This is a guid.
required: true
type: string
- in: body
name: body
required: false
schema:
$ref: '#/definitions/BookEdit'
responses:
'202':
description: Your change has been accepted
'400':
description: There were errors processing your request
schema:
$ref: '#/definitions/Error'
delete:
tags:
- books
summary: Remove a book from the collection
description: Remove a book from the collection
operationId: deleteBooksId
consumes: []
produces: []
parameters:
- name: id
in: path
description: The id for the book you wish to retreive. This is a guid.
required: true
type: string
responses:
'202':
description: Your removal has been accepted
definitions:
Error_Validation:
type: object
properties:
source:
type: string
keys:
type: array
items:
type: string
Book:
type: object
required:
- author
- id
- price
- title
properties:
id:
type: string
author:
type: string
title:
type: string
price:
type: number
format: double
Books:
type: object
required:
- author
- id
- price
- title
properties:
id:
type: string
author:
type: string
title:
type: string
price:
type: number
format: double
BookEdit:
type: object
required:
- author
- price
- title
properties:
author:
type: string
title:
type: string
price:
type: number
format: double
Error:
type: object
required:
- error
- message
- statusCode
- validation
properties:
message:
type: string
statusCode:
type: integer
format: int64
error:
type: string
validation:
$ref: '#/definitions/Error_Validation'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment