-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.yml
197 lines (196 loc) · 5.33 KB
/
api.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
openapi: 3.0.2
info:
title: conexample
version: "1"
description:
Simple API example for collecting and managing rated entries about programming languages,
libraries, databases and other IT related entities.
contact:
name: Maintainer
email: michal.getka@gmail.com
servers:
- url: /v1
paths:
/entry:
get:
summary: Get all entries
description: Return all entries stored in the database.
tags:
- entries
operationId: conexample.api.entry.get
responses:
200:
description: Return all entries.
content:
application/json:
schema:
type: array
description: List of stored entries.
items:
$ref: "#/components/schemas/Entry"
examples:
"Some results":
description: Example with some returned values
value:
- name: python
rating: 5
- name: cassandra
rating: 1
"No results":
description: Example with no returned values
value: []
500:
description: Something went wrong :(
post:
summary: Add or update an entry
description:
Adds new entry to the database. If an entry with the given name already exists, it will be
updated.
tags:
- entries
operationId: conexample.api.entry.post
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/Entry"
examples:
python:
value:
name: python
rating: 5
cassandra:
value:
name: cassandra
rating: 1
responses:
201:
description: Entry created
headers:
Location:
schema:
type: string
description: URL to the created entry
200:
description: Entry updated
headers:
Location:
schema:
type: string
description: URL to the updated entry
400:
description: Provided entry is invalid
500:
description: Something went wrong :(
/entry/{name}:
parameters:
- schema:
type: string
minLength: 1
name: name
in: path
required: true
examples:
python:
value: python
cassandra:
value: cassandra
get:
summary: Get entry
description: Returns entry with the provided name. If such entry does not exists returns 404.
tags:
- entries
operationId: conexample.api.entry.element.get
responses:
200:
description: Entry found
content:
application/json:
schema:
$ref: "#/components/schemas/Entry"
examples:
python:
value:
name: python
rating: 5
cassandra:
value:
name: cassandra
rating: 1
404:
description: Entry not found
500:
description: Something went wrong :(
post:
summary: Add or update entry
description: Updates rating for the entry. If the entry does not exist yet it will be created.
tags:
- entries
operationId: conexample.api.entry.element.post
requestBody:
content:
application/json:
schema:
type: object
description: Entry attributes object
properties:
rating:
type: integer
description: Entry rating
minimum: 0
required:
- rating
example:
rating: 5
responses:
201:
description: Entry created
headers:
Location:
schema:
type: string
description: Redirection to self
200:
description: Entry updated
headers:
Location:
schema:
type: string
description: Redirection to self
400:
description: Provided entry is invalid
500:
description: Something went wrong :(
delete:
summary: Delete entry
description: Deletes entry. If the entry does not exist returns 404.
tags:
- entries
operationId: conexample.api.entry.element.delete
responses:
200:
description: Entry deleted
404:
description: Entry not found
500:
description: Something went wrong :(
tags:
- name: entries
description: Operations related to the management of the collected entries.
components:
schemas:
Entry:
type: object
description: Database entry representation
properties:
name:
type: string
description: Entry name
minLength: 1
rating:
type: integer
description: Entry rating
minimum: 0
required:
- name
- rating