Skip to content

Instantly share code, notes, and snippets.

@EDDYMENS
Created May 9, 2022
Embed
What would you like to do?
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