-
Notifications
You must be signed in to change notification settings - Fork 13
/
swagger.yaml
240 lines (234 loc) · 7.17 KB
/
swagger.yaml
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
openapi: 3.0.0
info:
title: Image CDN API for Web
description: |
The main purpose of the API is to help Web Developers to serve
images in the best possible way to the users meaning balance between
quality and speed.
The API could be easily integrated with <img> or <picture> tags.
Use API key "MjUyMTM3OTQyNw__" to try out API with any images from unsplash.com.
version: 2.4.0
servers:
- url: https://pixboost.com/api/2
components:
securitySchemes:
ApiKey:
type: apiKey
in: query
name: auth
parameters:
imgUrl:
description: |
Url of the original image including schema.
Note that query parameters need to be properly encoded
in: path
name: imgUrl
required: true
schema:
type: string
examples:
simple:
value: https://images.unsplash.com/photo-1703860274966-40a784387389
with-query-param:
value: https://images.unsplash.com/photo-1703860274966-40a784387389%3Fv%3D123
description: will fetch https://images.unsplash.com/photo-1703860274966-40a784387389?v=123
save-data:
description: >
Sets an optional behaviour when Save-Data header is "on".
When passing "off" value the result image won't use extra
compression when data saver mode is on.
When passing "hide" value the result image will be an empty 1x1 image.
When absent the API will use reduced quality for result images.
required: false
in: query
name: save-data
schema:
type: string
enum: [ "off", hide ]
dppx:
description: >
Number of dots per pixel defines the ratio between device and CSS pixels.
The query parameter is a hint that enables extra optimisations for high
density screens. The format is a float number that's the same format as window.devicePixelRatio.
required: false
in: query
name: dppx
schema:
type: number
format: float
default: 1
examples:
desktop:
value: 1
summary: Most desktop monitors
iphonese:
value: 2
summary: IPhone SE
galaxy51:
value: 2.625
summary: Samsung Galaxy A51
galaxy8:
value: 4
summary: Samsung Galaxy S8
trim-border:
description: >
Removes the edges of the image that have exactly the same color.
required: false
in: query
name: trim-border
schema:
type: boolean
allowEmptyValue: true
security:
- ApiKey: []
paths:
/img/{imgUrl}/optimise:
get:
summary: Optimises a source image
description: |
Optimises an image and returns it in the next-gen format supported
by the browser. The API knows about supported formats through the "Accept"
header.
operationId: optimiseImage
tags:
- images
parameters:
- $ref: "#/components/parameters/imgUrl"
- $ref: "#/components/parameters/dppx"
- $ref: "#/components/parameters/save-data"
- $ref: "#/components/parameters/trim-border"
responses:
200:
description: An optimised image
content:
"image/*":
schema:
type: string
format: binary
"image/jxl":
schema:
type: string
format: binary
"image/avif":
schema:
type: string
format: binary
"image/webp":
schema:
type: string
format: binary
/img/{imgUrl}/resize:
get:
summary: Resizes a source image
description: |
Resizes a source image to the specific size, but will always respect
aspect ratio. Will apply similar to /optimise optimisations.
Use /fit to resize to the exact given size with ignoring aspect ratio.
operationId: resizeImage
tags:
- images
parameters:
- $ref: "#/components/parameters/imgUrl"
- $ref: "#/components/parameters/dppx"
- $ref: "#/components/parameters/save-data"
- $ref: "#/components/parameters/trim-border"
- name: size
required: true
in: query
description: |
Size of the result image. Should be in the format 'width'x'height', e.g. 200x300
Only width or height could be passed, e.g 200, x300.
schema:
type: string
examples:
width-and-height:
value: 200x300
only-width:
value: 200
only-height:
value: x300
responses:
200:
description: A resized image
content:
"image/*":
schema:
type: string
format: binary
"image/jxl":
schema:
type: string
format: binary
"image/avif":
schema:
type: string
format: binary
"image/webp":
schema:
type: string
format: binary
/img/{imgUrl}/fit:
get:
summary: Resizes a source image
description: |
Resizes a source image to the exact specific size and ignoring aspect ratio.
aspect ratio. Will apply similar to /optimise optimisations.
Use /resize to resize and preserve aspect ratio.
operationId: fitImage
tags:
- images
parameters:
- $ref: "#/components/parameters/imgUrl"
- $ref: "#/components/parameters/dppx"
- $ref: "#/components/parameters/save-data"
- $ref: "#/components/parameters/trim-border"
- name: size
required: true
in: query
description: |
size of the image in the response. Should be in the format 'width'x'height', e.g. 200x300
schema:
type: string
pattern: \d{1,4}x\d{1,4}
examples:
size:
value: 200x300
responses:
200:
description: A resized image
content:
"image/*":
schema:
type: string
format: binary
"image/jxl":
schema:
type: string
format: binary
"image/avif":
schema:
type: string
format: binary
"image/webp":
schema:
type: string
format: binary
/img/{imgUrl}/asis:
get:
summary: Respond with original image without any modifications
description: |
This could be useful when your Image API is behind CDN, so any /asis requests
will be cached there. The Content-Type preserved from the original.
operationId: asisImage
tags:
- images
parameters:
- $ref: "#/components/parameters/imgUrl"
responses:
200:
description: The source image loaded from imgUrl
content:
"*/*":
schema:
type: string
format: binary