-
Notifications
You must be signed in to change notification settings - Fork 2
/
cat-or-dog.openapi.yml
271 lines (262 loc) · 10.4 KB
/
cat-or-dog.openapi.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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
openapi: 3.0.0
info:
title: Cat or Dog Classification API
description: API application showcasing image recognition using deep learning, classifying uploaded images as cats or dogs.
contact:
name: Cat or Dog classification API support
email: [email protected]
license:
name: Eclipse Public License either version 1.0 or (at your option) any later version.
url: https://www.eclipse.org/legal/epl-v10.html
version: 0.9.0
servers:
- url: /cat-or-dog
paths:
/classify/{id}:
get:
summary: Returns the details about a classification job.
description: Finds classification jobs by ID.
parameters:
- name: "id"
in: path
required: true
schema:
$ref: '#/components/schemas/JobId'
description: Id value for the job that was requested. It is a random UUIDv4 string
example: 6ae111c8-3a2d-4515-a57d-23287ee8c41d
responses:
"200":
description: Details about a finished classification job (successfully or not).
content:
"application/json":
schema:
$ref: '#/components/schemas/ClassifyGetResponse200'
examples:
done:
summary: Details for a classification job that has finished successfully
value:
"~id": "6ae111c8-3a2d-4515-a57d-23287ee8c41d"
status: "job.status/DONE"
details:
guess:
class: "dog"
prob: 0.976572453975677
error:
summary: Details for a classification job that has finished unsuccessfully
value:
id: "6ae111c8-3a2d-4515-a57d-23287ee8c41d"
status: "job.status/ERROR"
details:
reason: "invalid-image-file"
"application/transit+json":
schema:
$ref: '#/components/schemas/ClassifyGetResponse200'
examples:
done:
summary: Details for a classification job that has finished successfully
value:
- "^ "
- "~:id"
- "6ae111c8-3a2d-4515-a57d-23287ee8c41d"
- "~:status"
- "~:job.status/DONE"
- "~:details"
- "^ "
error:
summary: Details for a classification job that has finished unsuccessfully
value: ["^ ", "~:id", "6ae111c8-3a2d-4515-a57d-23287ee8c41d", "~:status", "~:job.status/ERROR", "~:details", ["^ ", "~:reason", "invalid-image-file"]]
"201":
description: Details about a non-finished classification job.
content:
"application/json":
schema:
$ref: '#/components/schemas/ClassifyGetResponse201'
examples:
classifying:
summary: Details for a job that is in the classifying stage
value:
id: "6ae111c8-3a2d-4515-a57d-23287ee8c41dzzzzzzzz"
status: "job.status/CLASSIFYING"
details: {}
"application/transit+json":
schema:
$ref: '#/components/schemas/ClassifyGetResponse201'
examples:
classifying:
summary: Details for a job that is in the classifying stage
value: ["^ ", "~:id", "6ae111c8-3a2d-4515-a57d-23287ee8c41d", "~:status", "~:job.status/CLASSIFYING", "~:details", ["^ "]]
"404":
description: Error returned when the requested job doesn't exist.
content:
text/html:
schema:
type: string
/classify:
post:
summary: Submit a new classification job
description: Submits a new classification job for an image that has already been uploaded to the service, using the /files API endpoint.
parameters:
- name: "Content-Type"
in: header
description: The request must include a ContenType header, with the value "application/transit+json"
required: true
schema:
type: string
- name: "Accept"
in: header
description: The request must include an Accept, with the value "application/transit+json"
required: true
schema:
type: string
requestBody:
description: Submit a classification job.
required: true
content:
application/json:
schema:
type: object
required:
- upload-url
properties:
upload-url:
type: string
description: URL of a previously uploaded file, using the tus.io protocol for resumable uploads (https://tus.io/)
example:
upload-url: https://some.server.name/files/5439ad4e477644c5be5e10b0c1b9b1b2
application/transit+json:
schema:
type: object
required:
- upload-url
properties:
upload-url:
type: string
description: URL of a previously uploaded file.
example: ["^ ","~:upload-url","https://some.server.name/files/819ff9bc1f734ccea9d2103cf487eb0f"]
responses:
"201":
description: The new classification job has been accepted and queued for processing.
headers:
Location:
description: The URL where the job details can be queried.
schema:
type: string
example: "https://some.server.name/cat-or-dog/classify/6ae111c8-3a2d-4515-a57d-23287ee8c41d"
"400":
description: The request points to an invalid upload file (the files does't exist, it doesn't have a supported format, etc.)
content:
application/json:
schema:
type: object
required:
- cause
- additional-details
properties:
cause:
type: string
description: A short description of the type of error.
"additional-details":
type: object
description: Additional details on the type of error.
example:
cause: "File does not exist"
additional-details:
upload-url: "https://some.server.name/files/819ff9bc1f734ccea9d2103cf487eb0f"
application/transit+json:
schema:
type: object
required:
- cause
- additional-details
properties:
cause:
type: string
description: A short description of the type of error.
"additional-details":
type: object
description: Additional details on the type of error.
example: ["^ ", "~:cause", "File does not exist", "~:additional-details", ["^ ", "~:upload-url", "https://some.server.name/files/819ff9bc1f734ccea9d2103cf487eb0f"]]
components:
schemas:
JobId:
type: string
description: Id value for the job that was requested. It is a random UUIDv4 string
example: 6ae111c8-3a2d-4515-a57d-23287ee8c41d
JobStatus:
type: string
description: >
A string representation of the current status of the job. As of now, the possible job statuses are:
* ":job.status/SUBMITTED": The job has been created, but processing of the job has not started yet. This is a non-finished status.
* ":job.status/PREPROCESSING": The job has started and is in the preprocessing stage. This is a non-finished status.
* ":job.status/CLASSIFYING": The job has started and is in the classification stage. This is a non-finished status.
* ":job.status/ERROR": The job has finished unsuccessfully. This is a finished status.
* ":job.status/DONE": The job has finished successfully. This is a finished status.
enum:
- ":job.status/SUBMITTED"
- ":job.status/PREPROCESSING"
- ":job.status/CLASSIFYING"
- ":job.status/DONE"
- ":job.status/ERROR"
JobCommon:
type: object
properties:
id:
$ref: '#/components/schemas/JobId'
status:
$ref: '#/components/schemas/JobStatus'
JobInProgress:
allOf:
- $ref: '#/components/schemas/JobCommon'
- type: object
required:
- details
properties:
details:
type: object
description: An empty object
JobError:
allOf:
- $ref: '#/components/schemas/JobCommon'
- type: object
required:
- details
properties:
details:
type: object
required:
- reason
properties:
reason:
type: string
description: "A string with details about the error of the job."
JobDone:
allOf:
- $ref: '#/components/schemas/JobCommon'
- type: object
required:
- details
properties:
details:
type: object
required:
- guess
properties:
guess:
type: object
required:
- class
- prob
properties:
class:
type: string
description: A string with the label assigned by the classification engine to the image. As of now, it's either "cat" or "dog".
prob:
type: number
format: float
description: A floating point number with the probability assigned by the classification engine the assigned label.
ClassifyGetResponse200:
oneOf:
- $ref: '#/components/schemas/JobError'
- $ref: '#/components/schemas/JobDone'
ClassifyGetResponse201:
$ref: '#/components/schemas/JobInProgress'