forked from h2non/imaginary
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopenapi.html
More file actions
282 lines (281 loc) · 7.09 KB
/
Copy pathopenapi.html
File metadata and controls
282 lines (281 loc) · 7.09 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Swagger UI</title>
<link rel="stylesheet" type="text/css" href="https://unpkg.com/swagger-ui-dist@3/swagger-ui.css">
<style>
html {
box-sizing: border-box;
overflow: -moz-scrollbars-vertical;
overflow-y: scroll;
}
*,
*:before,
*:after {
box-sizing: inherit;
}
body {
margin: 0;
background: #fafafa;
}
</style>
</head>
<body>
<div id="swagger-ui"></div>
<script src="https://unpkg.com/swagger-ui-dist@3/swagger-ui-bundle.js"></script>
<script src="https://unpkg.com/swagger-ui-dist@3/swagger-ui-standalone-preset.js"></script>
<script src="https://unpkg.com/js-yaml@3.13.1/dist/js-yaml.min.js"></script>
<script>
window.onload = function() {
// Embed the YAML content here
var spec = jsyaml.load(`openapi: 3.0.0
info:
title: Imaginary API
description: Fast HTTP microservice for high-level image processing.
version: "1.0.0"
servers:
- url: http://localhost:8088
- url: https://imaginary-lcpia55i5q-as.a.run.app/
paths:
/:
get:
summary: Get service version
responses:
'200':
description: Service versions
content:
application/json:
schema:
type: object
properties:
imaginary:
type: string
bimg:
type: string
libvips:
type: string
/health:
get:
summary: Get service health and stats
responses:
'200':
description: Service health
content:
application/json:
schema:
type: object
properties:
uptime:
type: number
allocatedMemory:
type: number
totalAllocatedMemory:
type: number
goroutines:
type: number
cpus:
type: number
/form:
get:
summary: Get HTML form for testing
responses:
'200':
description: HTML form
content:
text/html:
schema:
type: string
/info:
get:
summary: Get image metadata
parameters:
- $ref: '#/components/parameters/url'
- $ref: '#/components/parameters/file'
responses:
'200':
description: Image metadata
content:
application/json:
schema:
$ref: '#/components/schemas/ImageInfo'
post:
summary: Get image metadata from uploaded image
requestBody:
$ref: '#/components/requestBodies/Image'
responses:
'200':
description: Image metadata
content:
application/json:
schema:
$ref: '#/components/schemas/ImageInfo'
/crop:
get:
summary: Crop an image
parameters:
- $ref: '#/components/parameters/width'
- $ref: '#/components/parameters/height'
- $ref: '#/components/parameters/quality'
- $ref: '#/components/parameters/compression'
- $ref: '#/components/parameters/type'
- $ref: '#/components/parameters/url'
- $ref: '#/components/parameters/file'
- $ref: '#/components/parameters/force'
- $ref: '#/components/parameters/gravity'
responses:
'200':
$ref: '#/components/responses/ImageResponse'
/resize:
get:
summary: Resize an image
parameters:
- $ref: '#/components/parameters/width'
- $ref: '#/components/parameters/height'
- $ref: '#/components/parameters/quality'
- $ref: '#/components/parameters/compression'
- $ref: '#/components/parameters/type'
- $ref: '#/components/parameters/url'
- $ref: '#/components/parameters/file'
- $ref: '#/components/parameters/force'
- $ref: '#/components/parameters/nocrop'
responses:
'200':
$ref: '#/components/responses/ImageResponse'
components:
schemas:
ImageInfo:
type: object
properties:
width:
type: integer
height:
type: integer
type:
type: string
space:
type: string
hasAlpha:
type: boolean
hasProfile:
type: boolean
channels:
type: integer
orientation:
type: integer
parameters:
width:
name: width
in: query
schema:
type: integer
description: Image width
height:
name: height
in: query
schema:
type: integer
description: Image height
quality:
name: quality
in: query
schema:
type: integer
description: JPEG quality
compression:
name: compression
in: query
schema:
type: integer
description: PNG compression
type:
name: type
in: query
schema:
type: string
enum: [jpeg, png, webp, auto]
description: Image output type
url:
name: url
in: query
schema:
type: string
description: Remote image URL
file:
name: file
in: query
schema:
type: string
description: Local image file path
force:
name: force
in: query
schema:
type: boolean
description: Force transformation
gravity:
name: gravity
in: query
schema:
type: string
enum: [north, south, centre, west, east, smart]
description: Crop gravity
nocrop:
name: nocrop
in: query
schema:
type: boolean
description: Disable crop
requestBodies:
Image:
content:
image/*:
schema:
type: string
format: binary
multipart/form-data:
schema:
type: object
properties:
file:
type: string
format: binary
responses:
ImageResponse:
description: Successful image transformation
content:
image/jpeg: {}
image/png: {}
image/webp: {}
headers:
Error:
schema:
type: string
description: Error message in case of failure with placeholder
securitySchemes:
ApiKey:
type: apiKey
in: header
name: API-Key
security:
- ApiKey: []
`);
// Build a system
const ui = SwaggerUIBundle({
spec: spec,
dom_id: '#swagger-ui',
deepLinking: true,
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
layout: "StandaloneLayout"
})
window.ui = ui
}
</script>
</body>
</html>