Skip to content

Commit 5fb8983

Browse files
author
KLF
committed
Added openapi schema for Valentines API so collection can be generated in Postman
1 parent 9cf40bc commit 5fb8983

File tree

2 files changed

+137
-0
lines changed

2 files changed

+137
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.vscode

valentines-book-list-openapi.yaml

+136
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
openapi: 3.0.3
2+
info:
3+
title: Valentine's Book List API
4+
description: |
5+
This API allows you to view the books that Valentine has read or plans to read.
6+
7+
The API is available at `https://valentines-book-list.glitch.me`
8+
version: "acc411151ad8c42b47a9a37b91f1415aecd2a49e"
9+
servers:
10+
- url: https://valentines-book-list.glitch.me
11+
paths:
12+
/status:
13+
get:
14+
tags: ["status"]
15+
summary: Returns the status of the API. Example response
16+
description: |
17+
Status `UP` indicates that the API is running as expected.
18+
19+
No response or any other response indicates that the API is not functioning correctly.
20+
responses:
21+
"200":
22+
description: Response when service is available
23+
content:
24+
application/json:
25+
schema:
26+
type: object
27+
properties:
28+
status: { type: "string" }
29+
example: {
30+
"status": "UP"
31+
}
32+
/books/lists:
33+
get:
34+
tags: ["books"]
35+
summary: Get a book list
36+
description: |
37+
Returns a list of books. Requires authentication.
38+
39+
This endpoint uses pagination to handle the returned results.\
40+
Paginating the results ensures responses are easier to handle.\
41+
Each response will indicate the total number of results, the \
42+
current page, and the total number of pages.
43+
parameters:
44+
- name: api-key
45+
description: API Key that is required for this endpoint
46+
in: query
47+
schema: { type: "string" }
48+
required: true
49+
example: "8fhg93xkjd38fhg834jdfgjd"
50+
- name: list
51+
description: "Specifies the list you want to retrieve. Must be one of: favourite-books, non-fiction, wishlist, fiction."
52+
in: query
53+
schema: { type: "string" }
54+
required: true
55+
example: "non-fiction"
56+
- name: page
57+
description: Specifies the page you wish to retrive from the entire result set.
58+
in: query
59+
schema: { type: "integer" }
60+
required: false
61+
example: 1
62+
responses:
63+
"200":
64+
description: Indicates a successful response.
65+
content:
66+
application/json:
67+
schema:
68+
type: object
69+
properties:
70+
status: { type: "string" }
71+
num_results: { type: "integer" }
72+
page: { type: "integer" }
73+
total_pages: { type: "integer" }
74+
results:
75+
type: array
76+
items:
77+
type: object
78+
properties:
79+
title: { type: "string" }
80+
category: { type: "array", items: { type: "string" } }
81+
type: { type: "string" }
82+
author: { type: "string" }
83+
release_year: { type: "integer" }
84+
rating: { oneOf: [{ "type": "string" } , { "type": "number"}] }
85+
example: {
86+
"status": "OK",
87+
"num_results": 17,
88+
"page": 1,
89+
"total_pages": 4,
90+
"results": [
91+
{
92+
"title": "Crush It!: Why NOW Is the Time to Cash In on Your Passion",
93+
"category": [
94+
"non-fiction"
95+
],
96+
"type": "audio",
97+
"author": "Gary Vaynerchuk",
98+
"release_year": 2010,
99+
"rating": "7"
100+
}
101+
]
102+
}
103+
"400":
104+
description: Indicates that the parameters provided are invalid.
105+
content:
106+
application/json:
107+
schema:
108+
type: object
109+
properties:
110+
error: { type: "string" }
111+
"401":
112+
description: Indicates user is unauthorized
113+
content:
114+
application/json:
115+
schema:
116+
type: object
117+
properties:
118+
error:
119+
type: object
120+
properties:
121+
error-string: { type: "string" }
122+
detail:
123+
type: object
124+
properties:
125+
errorcode: { type: "string" }
126+
"404":
127+
description: Indicates books not found
128+
content:
129+
application/json:
130+
schema:
131+
type: object
132+
properties:
133+
error: { type: "string" }
134+
tags:
135+
- name: status
136+
- name: books

0 commit comments

Comments
 (0)