Skip to content

Instantly share code, notes, and snippets.

@EDDYMENS
Created May 9, 2022 12:52
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 EDDYMENS/0aef489ac5c0b6ef099d9f220504758d to your computer and use it in GitHub Desktop.
Save EDDYMENS/0aef489ac5c0b6ef099d9f220504758d to your computer and use it in GitHub Desktop.
openapi: 3.0.0
info:
description: The books endpoint keeps a record of books and their page numbers
version: 1.0.0
title: Book API
servers:
- url: https://lit-taiga-02928.herokuapp.com
- url: http://lit-taiga-02928.herokuapp.com
paths:
/:
get:
summary: Get the list of all books
description: This endpoint will return the list of all books
responses:
"200":
description: successful operation
content:
application/json:
schema:
type: object
properties:
message:
type: string
example: List of books
payload:
type: array
items:
$ref: "#/components/schemas/Book"
post:
summary: Add a new book
description: Add a new book to the book archives
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/Book"
description: JSON payload of the book that needs to be added
required: true
responses:
"200":
description: successful operation
content:
application/json:
schema:
type: object
properties:
message:
type: string
example: Book added successfully
payload:
type: array
items:
$ref: "#/components/schemas/Book"
"405":
description: Invalid input
"/{id}":
put:
summary: Update an existing book
description: Update an existing book in the books archives
parameters:
- name: id
in: path
description: ID of the book you will like to update
required: true
schema:
type: integer
format: int64
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/Book"
description: JSON payload of the book that needs to be updated
required: true
responses:
"200":
description: successfully updated a book
content:
application/json:
schema:
type: object
properties:
message:
type: string
example: Book updated successfully
payload:
type: array
items:
$ref: "#/components/schemas/Book"
"404":
description: A book with the provided ID does not exist
content:
application/json:
schema:
type: object
properties:
message:
type: string
example: Book does not exist
payload:
default: []
"405":
description: Invalid input
content:
application/json:
schema:
type: object
properties:
message:
type: string
example: Invalid input
payload:
default: []
delete:
summary: Deletes a book
description: Delete a book from the list
parameters:
- name: id
in: path
description: ID of the book you will like to delete
required: true
schema:
type: integer
format: int64
responses:
"200":
description: Book deleted successfully
content:
application/json:
schema:
type: object
properties:
message:
type: string
example: Book deleted successfully
payload:
default: []
"404":
description: A book with the provided ID does not exist
content:
application/json:
schema:
type: object
properties:
message:
type: string
example: Book does not exist
payload:
default: []
components:
schemas:
Book:
type: object
required:
- title
- pages
properties:
title:
type: string
example: Harry Potter
pages:
type: integer
example: 123
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment