-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathcolor-names-v1-OpenAPI.yml
437 lines (420 loc) · 12.8 KB
/
color-names-v1-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
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
openapi: 3.0.3
info:
title: Color Name API
description: An API that provides names for colors based on their hex value
version: 1.1.0
license:
name: MIT
url: https://github.com/meodai/color-name-api/blob/main/LICENSE
contact:
name: meodai
url: https://elastiq.ch/
email: [email protected]
servers:
- url: https://api.color.pizza/v1/
components:
schemas:
listDescription:
type: object
properties:
title:
type: string
description: The title of the color name list
description:
type: string
description: A description of the color name list
url:
type: string
description: API endpoint to get the colors of the list
source:
type: string
description: URL to the source of the color name list
key:
type: string
description: Reference key of the color name list in the API
license:
type: string
description: License of the given color name list
colorCount:
type: integer
description: Amount of colors in the list
colorBasic:
type: object
required:
- name
- hex
- rgb
- hsl
- lab
- luminance
- luminanceWCAG
- swatchImg
properties:
name:
type: string
description: Name of the closest color relative to the hex value provided
minLength: 1
hex:
type: string
description: Hex value of the color (can differ from the requested hex value)
pattern: '^#?([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$'
rgb:
type: object
description: RGB values
required: [r, g, b]
properties:
r:
type: integer
minimum: 0
maximum: 255
g:
type: integer
minimum: 0
maximum: 255
b:
type: integer
minimum: 0
maximum: 255
hsl:
type: object
description: HSL values. All percentages are represented as integers (e.g., 50% as `50`).
required: [h, s, l]
properties:
h:
type: number
minimum: 0
maximum: 360
s:
type: number
minimum: 0
maximum: 100
l:
type: number
minimum: 0
maximum: 100
lab:
type: object
description: LAB values
required: [l, a, b]
properties:
l:
type: number
minimum: 0
maximum: 100
a:
type: number
minimum: -128
maximum: 127
b:
type: number
minimum: -128
maximum: 127
luminance:
type: number
description: Luminance value
minimum: 0
luminanceWCAG:
type: number
description: Luminance value according to WCAG
minimum: 0
swatchImg:
type: object
description: SVG representation of the color
required: [svgNamed, svg]
properties:
svgNamed:
type: string
description: SVG representation of the color with the name
format: svg
svg:
type: string
description: SVG representation of the color without the name
format: svg
color:
allOf:
- $ref: '#/components/schemas/colorBasic'
- type: object
- required:
- distance
- requestedHex
properties:
requestedHex:
type: string
description: The hex value that was requested by the user
distance:
type: number
description: The distance between the requested hex value and the closest color (0 = exact match)
possibleLists:
type: string
description: Predefined color lists. Names are case-sensitive.
enum:
- default
- bestOf
- short
- wikipedia
- french
- spanish
- german
- ridgway
- risograph
- basic
- chineseTraditional
- html
- japaneseTraditional
- leCorbusier
- nbsIscc
- ntc
- osxcrayons
- ral
- sanzoWadaI
- thesaurus
- werner
- windows
- x11
- xkcd
socketColorResponse:
type: object
properties:
paletteTitle:
type: string
list:
$ref: '#/components/schemas/possibleLists'
colors:
type: array
items:
$ref: '#/components/schemas/colorBasic'
error:
type: object
properties:
status:
type: number
message:
type: string
example:
status: 404
message: 'Not Found'
paths:
/:
get:
summary: Get all colors of the default color name list
description: |
Returns an array of colors from the specified list, with distance calculations
to show how close each match is to the requested colors. When providing multiple
values, the endpoint will find the closest match for each color.
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
properties:
colors:
type: array
items:
$ref: '#/components/schemas/color'
paletteTitle:
type: string
example:
paletteTitle: 'Default color list'
colors:
- name: 'red'
hex: 'FF0000'
rgb: {r: 255, g: 0, b: 0}
hsl: {h: 0, s: 100, l: 50}
lab: {l: 53.24, a: 80.09, b: 67.2}
luminance: 0.2126
luminanceWCAG: 0.2126
distance: 0
requestedHex: 'FF0000'
swatchImg:
svgNamed: >
<svg xmlns="http://www.w3.org/2000/svg" width="100" height="...
svg: >
<svg xmlns="http://www.w3.org/2000/svg" width="100" height="...
'404':
description: NOT FOUND
content:
application/json:
schema:
$ref: '#/components/schemas/error'
parameters:
- name: list
in: query
description: The name of the color name list to use (case-insensitive)
schema:
$ref: '#/components/schemas/possibleLists'
style: form
explode: false
- name: values
in: query
description: A comma-separated list of hex values (e.g., `FF0000,00FF00` do not include the `#`)
schema:
type: string
- name: noduplicates
in: query
description: Allow duplicate names or not
schema:
type: boolean
/names/:
get:
summary: Get all colors of the default color name list
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
properties:
colors:
type: array
items:
$ref: '#/components/schemas/colorBasic'
'404':
description: NOT FOUND
content:
application/json:
schema:
$ref: '#/components/schemas/error'
parameters:
- name: name
in: query
description: The name of the color to retrieve (min 3 characters)
schema:
type: string
style: form
explode: false
required: true
- name: list
in: query
description: The name of the color name list to use
schema:
$ref: '#/components/schemas/possibleLists'
style: form
explode: false
/lists/:
get:
summary: Get all colors of the default color name list
description: |
Returns a list of available color name lists with descriptions and URLs to
the color list endpoints.
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
properties:
availableColorNameLists:
type: array
items:
type: string
listDescriptions:
type: object
properties:
default:
$ref: '#/components/schemas/listDescription'
bestOf:
$ref: '#/components/schemas/listDescription'
wikipedia:
$ref: '#/components/schemas/listDescription'
french:
$ref: '#/components/schemas/listDescription'
spanish:
$ref: '#/components/schemas/listDescription'
german:
$ref: '#/components/schemas/listDescription'
ridgway:
$ref: '#/components/schemas/listDescription'
risograph:
$ref: '#/components/schemas/listDescription'
basic:
$ref: '#/components/schemas/listDescription'
chineseTraditional:
$ref: '#/components/schemas/listDescription'
html:
$ref: '#/components/schemas/listDescription'
japaneseTraditional:
$ref: '#/components/schemas/listDescription'
leCorbusier:
$ref: '#/components/schemas/listDescription'
nbsIscc:
$ref: '#/components/schemas/listDescription'
ntc:
$ref: '#/components/schemas/listDescription'
osxcrayons:
$ref: '#/components/schemas/listDescription'
ral:
$ref: '#/components/schemas/listDescription'
sanzoWadaI:
$ref: '#/components/schemas/listDescription'
thesaurus:
$ref: '#/components/schemas/listDescription'
werner:
$ref: '#/components/schemas/listDescription'
windows:
$ref: '#/components/schemas/listDescription'
x11:
$ref: '#/components/schemas/listDescription'
xkcd:
$ref: '#/components/schemas/listDescription'
'404':
description: NOT FOUND
content:
application/json:
schema:
$ref: '#/components/schemas/error'
/swatch/:
get:
summary: Generate a color swatch for any color
description: |
Generates an SVG swatch representation of a color. The swatch can include
the color name if provided. The SVG is designed to be visually appealing
and readable across different backgrounds.
parameters:
- name: color
in: query
description: The hex value of the color to retrieve without '#'
schema:
type: string
style: form
explode: false
required: true
- name: name
in: query
description: The name of the color
schema:
type: string
style: form
explode: false
required: false
responses:
'200':
description: OK
content:
image/svg+xml:
schema:
type: string
'404':
description: NOT FOUND
content:
application/json:
schema:
$ref: '#/components/schemas/error'
x-socket-io:
version: "4.x"
events:
- name: colors
description: Emitted when new colors are requested
payload:
$ref: '#/components/schemas/socketColorResponse'
direction: server-to-client
authentication:
required: false
cors:
enabled: true
origins:
description: Controlled via ALLOWED_SOCKET_ORIGINS environment variable
default: ["http://localhost:8080"]