@elysiajs/openapi 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +7 -0
- package/README.md +101 -0
- package/bun.lock +537 -0
- package/bunfig.toml +2 -0
- package/dist/cjs/gen/index.js +127 -0
- package/dist/cjs/index.d.ts +35 -0
- package/dist/cjs/index.js +639 -0
- package/dist/cjs/openapi.d.ts +25 -0
- package/dist/cjs/openapi.js +285 -0
- package/dist/cjs/scalar/index.js +183 -0
- package/dist/cjs/swagger/index.js +129 -0
- package/dist/cjs/swagger/types.js +18 -0
- package/dist/cjs/types.d.ts +137 -0
- package/dist/cjs/types.js +18 -0
- package/dist/gen/index.d.ts +36 -0
- package/dist/gen/index.mjs +108 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.mjs +612 -0
- package/dist/openapi.d.ts +25 -0
- package/dist/openapi.mjs +257 -0
- package/dist/scalar/index.d.ts +3 -0
- package/dist/scalar/index.mjs +158 -0
- package/dist/swagger/index.d.ts +7 -0
- package/dist/swagger/index.mjs +103 -0
- package/dist/swagger/types.d.ts +274 -0
- package/dist/swagger/types.mjs +0 -0
- package/dist/types.d.ts +137 -0
- package/dist/types.mjs +0 -0
- package/package.json +92 -0
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/openapi.ts
|
|
21
|
+
var openapi_exports = {};
|
|
22
|
+
__export(openapi_exports, {
|
|
23
|
+
capitalize: () => capitalize,
|
|
24
|
+
getPossiblePath: () => getPossiblePath,
|
|
25
|
+
toOpenAPISchema: () => toOpenAPISchema,
|
|
26
|
+
withHeaders: () => withHeaders
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(openapi_exports);
|
|
29
|
+
var import_elysia = require("elysia");
|
|
30
|
+
var capitalize = (word) => word.charAt(0).toUpperCase() + word.slice(1);
|
|
31
|
+
var toRef = (name) => import_elysia.t.Ref(`#/components/schemas/${name}`);
|
|
32
|
+
var toOperationId = (method, paths) => {
|
|
33
|
+
let operationId = method.toLowerCase();
|
|
34
|
+
if (!paths || paths === "/") return operationId + "Index";
|
|
35
|
+
for (const path of paths.split("/"))
|
|
36
|
+
operationId += path.includes(":") ? "By" + capitalize(path.replace(":", "")) : capitalize(path);
|
|
37
|
+
operationId = operationId.replace(/\?/g, "Optional");
|
|
38
|
+
return operationId;
|
|
39
|
+
};
|
|
40
|
+
var optionalParamsRegex = /(\/:\w+\?)/g;
|
|
41
|
+
var getPossiblePath = (path) => {
|
|
42
|
+
const optionalParams = path.match(optionalParamsRegex);
|
|
43
|
+
if (!optionalParams) return [path];
|
|
44
|
+
const originalPath = path.replace(/\?/g, "");
|
|
45
|
+
const paths = [originalPath];
|
|
46
|
+
for (let i = 0; i < optionalParams.length; i++) {
|
|
47
|
+
const newPath = path.replace(optionalParams[i], "");
|
|
48
|
+
paths.push(...getPossiblePath(newPath));
|
|
49
|
+
}
|
|
50
|
+
return paths;
|
|
51
|
+
};
|
|
52
|
+
function toOpenAPISchema(app, exclude, references) {
|
|
53
|
+
const {
|
|
54
|
+
methods: excludeMethods = ["OPTIONS"],
|
|
55
|
+
staticFile: excludeStaticFile = true,
|
|
56
|
+
tags: excludeTags
|
|
57
|
+
} = exclude ?? {};
|
|
58
|
+
const excludePaths = Array.isArray(exclude?.paths) ? exclude.paths : typeof exclude?.paths !== "undefined" ? [exclude.paths] : [];
|
|
59
|
+
const paths = /* @__PURE__ */ Object.create(null);
|
|
60
|
+
const routes = app.getGlobalRoutes();
|
|
61
|
+
if (references) {
|
|
62
|
+
if (!Array.isArray(references)) references = [references];
|
|
63
|
+
for (let i = 0; i < references.length; i++) {
|
|
64
|
+
const reference = references[i];
|
|
65
|
+
if (typeof reference === "function") references[i] = reference();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
for (const route of routes) {
|
|
69
|
+
if (route.hooks?.detail?.hide) continue;
|
|
70
|
+
const method = route.method.toLowerCase();
|
|
71
|
+
if (excludeStaticFile && route.path.includes(".") || excludePaths.includes(route.path) || excludeMethods.includes(method))
|
|
72
|
+
continue;
|
|
73
|
+
const hooks = route.hooks ?? {};
|
|
74
|
+
if (references)
|
|
75
|
+
for (const reference of references) {
|
|
76
|
+
const refer = reference[route.path]?.[method];
|
|
77
|
+
if (!refer) continue;
|
|
78
|
+
if (!hooks.body && refer.body) hooks.body = refer.body;
|
|
79
|
+
if (!hooks.query && refer.query) hooks.query = refer.query;
|
|
80
|
+
if (!hooks.params && refer.params) hooks.params = refer.params;
|
|
81
|
+
if (!hooks.headers && refer.headers)
|
|
82
|
+
hooks.headers = refer.headers;
|
|
83
|
+
if (!hooks.response && refer.response) {
|
|
84
|
+
hooks.response = {};
|
|
85
|
+
for (const [status, schema] of Object.entries(
|
|
86
|
+
refer.response
|
|
87
|
+
))
|
|
88
|
+
if (!hooks.response[status])
|
|
89
|
+
hooks.response[status] = schema;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (excludeTags && hooks.detail.tags?.some((tag) => excludeTags?.includes(tag)))
|
|
93
|
+
continue;
|
|
94
|
+
const operation = {
|
|
95
|
+
...hooks.detail
|
|
96
|
+
};
|
|
97
|
+
const parameters = [];
|
|
98
|
+
if (hooks.params) {
|
|
99
|
+
if (typeof hooks.params === "string")
|
|
100
|
+
hooks.params = toRef(hooks.params);
|
|
101
|
+
if (hooks.params.type === "object" && hooks.params.properties) {
|
|
102
|
+
for (const [paramName, paramSchema] of Object.entries(
|
|
103
|
+
hooks.params.properties
|
|
104
|
+
))
|
|
105
|
+
parameters.push({
|
|
106
|
+
name: paramName,
|
|
107
|
+
in: "path",
|
|
108
|
+
required: true,
|
|
109
|
+
// Path parameters are always required
|
|
110
|
+
schema: paramSchema
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
if (hooks.query) {
|
|
115
|
+
if (typeof hooks.query === "string")
|
|
116
|
+
hooks.query = toRef(hooks.query);
|
|
117
|
+
if (hooks.query.type === "object" && hooks.query.properties) {
|
|
118
|
+
const required = hooks.query.required || [];
|
|
119
|
+
for (const [queryName, querySchema] of Object.entries(
|
|
120
|
+
hooks.query.properties
|
|
121
|
+
))
|
|
122
|
+
parameters.push({
|
|
123
|
+
name: queryName,
|
|
124
|
+
in: "query",
|
|
125
|
+
required: required.includes(queryName),
|
|
126
|
+
schema: querySchema
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
if (hooks.headers) {
|
|
131
|
+
if (typeof hooks.headers === "string")
|
|
132
|
+
hooks.headers = toRef(hooks.headers);
|
|
133
|
+
if (hooks.headers.type === "object" && hooks.headers.properties) {
|
|
134
|
+
const required = hooks.headers.required || [];
|
|
135
|
+
for (const [headerName, headerSchema] of Object.entries(
|
|
136
|
+
hooks.headers.properties
|
|
137
|
+
))
|
|
138
|
+
parameters.push({
|
|
139
|
+
name: headerName,
|
|
140
|
+
in: "header",
|
|
141
|
+
required: required.includes(headerName),
|
|
142
|
+
schema: headerSchema
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
if (hooks.cookie) {
|
|
147
|
+
if (typeof hooks.cookie === "string")
|
|
148
|
+
hooks.cookie = toRef(hooks.cookie);
|
|
149
|
+
if (hooks.cookie.type === "object" && hooks.cookie.properties) {
|
|
150
|
+
const required = hooks.cookie.required || [];
|
|
151
|
+
for (const [cookieName, cookieSchema] of Object.entries(
|
|
152
|
+
hooks.cookie.properties
|
|
153
|
+
))
|
|
154
|
+
parameters.push({
|
|
155
|
+
name: cookieName,
|
|
156
|
+
in: "cookie",
|
|
157
|
+
required: required.includes(cookieName),
|
|
158
|
+
schema: cookieSchema
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
if (parameters.length > 0) operation.parameters = parameters;
|
|
163
|
+
if (hooks.body) {
|
|
164
|
+
if (typeof hooks.body === "string") hooks.body = toRef(hooks.body);
|
|
165
|
+
if (hooks.parse) {
|
|
166
|
+
const content = {};
|
|
167
|
+
const parsers = hooks.parse;
|
|
168
|
+
for (const parser of parsers) {
|
|
169
|
+
if (typeof parser.fn === "function") continue;
|
|
170
|
+
switch (parser.fn) {
|
|
171
|
+
case "text":
|
|
172
|
+
case "text/plain":
|
|
173
|
+
content["text/plain"] = { schema: hooks.body };
|
|
174
|
+
continue;
|
|
175
|
+
case "urlencoded":
|
|
176
|
+
case "application/x-www-form-urlencoded":
|
|
177
|
+
content["application/x-www-form-urlencoded"] = {
|
|
178
|
+
schema: hooks.body
|
|
179
|
+
};
|
|
180
|
+
continue;
|
|
181
|
+
case "json":
|
|
182
|
+
case "application/json":
|
|
183
|
+
content["application/json"] = { schema: hooks.body };
|
|
184
|
+
continue;
|
|
185
|
+
case "formdata":
|
|
186
|
+
case "multipart/form-data":
|
|
187
|
+
content["multipart/form-data"] = {
|
|
188
|
+
schema: hooks.body
|
|
189
|
+
};
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
operation.requestBody = { content, required: true };
|
|
194
|
+
} else {
|
|
195
|
+
operation.requestBody = {
|
|
196
|
+
content: {
|
|
197
|
+
"application/json": {
|
|
198
|
+
schema: hooks.body
|
|
199
|
+
},
|
|
200
|
+
"application/x-www-form-urlencoded": {
|
|
201
|
+
schema: hooks.body
|
|
202
|
+
},
|
|
203
|
+
"multipart/form-data": {
|
|
204
|
+
schema: hooks.body
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
required: true
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
if (hooks.response) {
|
|
212
|
+
operation.responses = {};
|
|
213
|
+
if (typeof hooks.response === "object" && !hooks.response.type && !hooks.response.$ref) {
|
|
214
|
+
for (let [status, schema] of Object.entries(hooks.response)) {
|
|
215
|
+
if (typeof schema === "string") schema = toRef(schema);
|
|
216
|
+
const { type, examples, $ref, ...options } = schema;
|
|
217
|
+
operation.responses[status] = {
|
|
218
|
+
description: `Response for status ${status}`,
|
|
219
|
+
...options,
|
|
220
|
+
content: type === "void" || type === "null" || type === "undefined" ? schema : {
|
|
221
|
+
"application/json": {
|
|
222
|
+
schema
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
} else {
|
|
228
|
+
if (typeof hooks.response === "string")
|
|
229
|
+
hooks.response = toRef(hooks.response);
|
|
230
|
+
operation.responses["200"] = {
|
|
231
|
+
description: "Successful response",
|
|
232
|
+
content: {
|
|
233
|
+
"application/json": {
|
|
234
|
+
schema: hooks.response
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
for (let path of getPossiblePath(route.path)) {
|
|
241
|
+
const operationId = toOperationId(route.method, path);
|
|
242
|
+
path = path.replace(/:([^/]+)/g, "{$1}");
|
|
243
|
+
if (!paths[path]) paths[path] = {};
|
|
244
|
+
const current = paths[path];
|
|
245
|
+
if (method !== "all") {
|
|
246
|
+
current[method] = {
|
|
247
|
+
...operation,
|
|
248
|
+
operationId
|
|
249
|
+
};
|
|
250
|
+
continue;
|
|
251
|
+
}
|
|
252
|
+
for (const method2 of [
|
|
253
|
+
"get",
|
|
254
|
+
"post",
|
|
255
|
+
"put",
|
|
256
|
+
"delete",
|
|
257
|
+
"patch",
|
|
258
|
+
"head",
|
|
259
|
+
"options",
|
|
260
|
+
"trace"
|
|
261
|
+
])
|
|
262
|
+
current[method2] = {
|
|
263
|
+
...operation,
|
|
264
|
+
operationId
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
const schemas = app.getGlobalDefinitions?.().type;
|
|
269
|
+
return {
|
|
270
|
+
components: {
|
|
271
|
+
schemas
|
|
272
|
+
},
|
|
273
|
+
paths
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
var withHeaders = (schema, headers) => Object.assign(schema, {
|
|
277
|
+
headers
|
|
278
|
+
});
|
|
279
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
280
|
+
0 && (module.exports = {
|
|
281
|
+
capitalize,
|
|
282
|
+
getPossiblePath,
|
|
283
|
+
toOpenAPISchema,
|
|
284
|
+
withHeaders
|
|
285
|
+
});
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/scalar/index.ts
|
|
21
|
+
var scalar_exports = {};
|
|
22
|
+
__export(scalar_exports, {
|
|
23
|
+
ScalarRender: () => ScalarRender
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(scalar_exports);
|
|
26
|
+
var elysiaCSS = `.light-mode {
|
|
27
|
+
--scalar-color-1: #2a2f45;
|
|
28
|
+
--scalar-color-2: #757575;
|
|
29
|
+
--scalar-color-3: #8e8e8e;
|
|
30
|
+
--scalar-color-accent: #f06292;
|
|
31
|
+
|
|
32
|
+
--scalar-background-1: #fff;
|
|
33
|
+
--scalar-background-2: #f6f6f6;
|
|
34
|
+
--scalar-background-3: #e7e7e7;
|
|
35
|
+
|
|
36
|
+
--scalar-border-color: rgba(0, 0, 0, 0.1);
|
|
37
|
+
}
|
|
38
|
+
.dark-mode {
|
|
39
|
+
--scalar-color-1: rgba(255, 255, 255, 0.9);
|
|
40
|
+
--scalar-color-2: rgba(156, 163, 175, 1);
|
|
41
|
+
--scalar-color-3: rgba(255, 255, 255, 0.44);
|
|
42
|
+
--scalar-color-accent: #f06292;
|
|
43
|
+
|
|
44
|
+
--scalar-background-1: #111728;
|
|
45
|
+
--scalar-background-2: #1e293b;
|
|
46
|
+
--scalar-background-3: #334155;
|
|
47
|
+
--scalar-background-accent: #f062921f;
|
|
48
|
+
|
|
49
|
+
--scalar-border-color: rgba(255, 255, 255, 0.1);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/* Document Sidebar */
|
|
53
|
+
.light-mode .t-doc__sidebar,
|
|
54
|
+
.dark-mode .t-doc__sidebar {
|
|
55
|
+
--scalar-sidebar-background-1: var(--scalar-background-1);
|
|
56
|
+
--scalar-sidebar-color-1: var(--scalar-color-1);
|
|
57
|
+
--scalar-sidebar-color-2: var(--scalar-color-2);
|
|
58
|
+
--scalar-sidebar-border-color: var(--scalar-border-color);
|
|
59
|
+
|
|
60
|
+
--scalar-sidebar-item-hover-background: var(--scalar-background-2);
|
|
61
|
+
--scalar-sidebar-item-hover-color: currentColor;
|
|
62
|
+
|
|
63
|
+
--scalar-sidebar-item-active-background: #f062921f;
|
|
64
|
+
--scalar-sidebar-color-active: var(--scalar-color-accent);
|
|
65
|
+
|
|
66
|
+
--scalar-sidebar-search-background: transparent;
|
|
67
|
+
--scalar-sidebar-search-color: var(--scalar-color-3);
|
|
68
|
+
--scalar-sidebar-search-border-color: var(--scalar-border-color);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/* advanced */
|
|
72
|
+
.light-mode {
|
|
73
|
+
--scalar-button-1: rgb(49 53 56);
|
|
74
|
+
--scalar-button-1-color: #fff;
|
|
75
|
+
--scalar-button-1-hover: rgb(28 31 33);
|
|
76
|
+
|
|
77
|
+
--scalar-color-green: #069061;
|
|
78
|
+
--scalar-color-red: #ef0006;
|
|
79
|
+
--scalar-color-yellow: #edbe20;
|
|
80
|
+
--scalar-color-blue: #0082d0;
|
|
81
|
+
--scalar-color-orange: #fb892c;
|
|
82
|
+
--scalar-color-purple: #5203d1;
|
|
83
|
+
|
|
84
|
+
--scalar-scrollbar-color: rgba(0, 0, 0, 0.18);
|
|
85
|
+
--scalar-scrollbar-color-active: rgba(0, 0, 0, 0.36);
|
|
86
|
+
}
|
|
87
|
+
.dark-mode {
|
|
88
|
+
--scalar-button-1: #f6f6f6;
|
|
89
|
+
--scalar-button-1-color: #000;
|
|
90
|
+
--scalar-button-1-hover: #e7e7e7;
|
|
91
|
+
|
|
92
|
+
--scalar-color-green: #a3ffa9;
|
|
93
|
+
--scalar-color-red: #ffa3a3;
|
|
94
|
+
--scalar-color-yellow: #fffca3;
|
|
95
|
+
--scalar-color-blue: #a5d6ff;
|
|
96
|
+
--scalar-color-orange: #e2ae83;
|
|
97
|
+
--scalar-color-purple: #d2a8ff;
|
|
98
|
+
|
|
99
|
+
--scalar-scrollbar-color: rgba(255, 255, 255, 0.24);
|
|
100
|
+
--scalar-scrollbar-color-active: rgba(255, 255, 255, 0.48);
|
|
101
|
+
}
|
|
102
|
+
.section-flare {
|
|
103
|
+
width: 100%;
|
|
104
|
+
height: 400px;
|
|
105
|
+
position: absolute;
|
|
106
|
+
}
|
|
107
|
+
.section-flare-item:first-of-type:before {
|
|
108
|
+
content: "";
|
|
109
|
+
position: absolute;
|
|
110
|
+
top: 0;
|
|
111
|
+
right: 0;
|
|
112
|
+
bottom: 0;
|
|
113
|
+
left: 0;
|
|
114
|
+
--stripes: repeating-linear-gradient(100deg, #fff 0%, #fff 0%, transparent 2%, transparent 12%, #fff 17%);
|
|
115
|
+
--stripesDark: repeating-linear-gradient(100deg, #000 0%, #000 0%, transparent 10%, transparent 12%, #000 17%);
|
|
116
|
+
--rainbow: repeating-linear-gradient(100deg, #60a5fa 10%, #e879f9 16%, #5eead4 22%, #60a5fa 30%);
|
|
117
|
+
contain: strict;
|
|
118
|
+
contain-intrinsic-size: 100vw 40vh;
|
|
119
|
+
background-image: var(--stripesDark), var(--rainbow);
|
|
120
|
+
background-size: 300%, 200%;
|
|
121
|
+
background-position: 50% 50%, 50% 50%;
|
|
122
|
+
filter: opacity(20%) saturate(200%);
|
|
123
|
+
-webkit-mask-image: radial-gradient(ellipse at 100% 0%, black 40%, transparent 70%);
|
|
124
|
+
mask-image: radial-gradient(ellipse at 100% 0%, black 40%, transparent 70%);
|
|
125
|
+
pointer-events: none;
|
|
126
|
+
}
|
|
127
|
+
.section-flare-item:first-of-type:after {
|
|
128
|
+
content: "";
|
|
129
|
+
position: absolute;
|
|
130
|
+
top: 0;
|
|
131
|
+
right: 0;
|
|
132
|
+
bottom: 0;
|
|
133
|
+
left: 0;
|
|
134
|
+
background-image: var(--stripes), var(--rainbow);
|
|
135
|
+
background-size: 200%, 100%;
|
|
136
|
+
background-attachment: fixed;
|
|
137
|
+
mix-blend-mode: difference;
|
|
138
|
+
background-image: var(--stripesDark), var(--rainbow);
|
|
139
|
+
pointer-events: none;
|
|
140
|
+
}
|
|
141
|
+
.light-mode .section-flare-item:first-of-type:after,
|
|
142
|
+
.light-mode .section-flare-item:first-of-type:before {
|
|
143
|
+
background-image: var(--stripes), var(--rainbow);
|
|
144
|
+
filter: opacity(4%) saturate(200%);
|
|
145
|
+
}`;
|
|
146
|
+
var ScalarRender = (info, config) => `<!doctype html>
|
|
147
|
+
<html>
|
|
148
|
+
<head>
|
|
149
|
+
<title>${info.title}</title>
|
|
150
|
+
<meta
|
|
151
|
+
name="description"
|
|
152
|
+
content="${info.description}"
|
|
153
|
+
/>
|
|
154
|
+
<meta
|
|
155
|
+
name="og:description"
|
|
156
|
+
content="${info.description}"
|
|
157
|
+
/>
|
|
158
|
+
<meta charset="utf-8" />
|
|
159
|
+
<meta
|
|
160
|
+
name="viewport"
|
|
161
|
+
content="width=device-width, initial-scale=1" />
|
|
162
|
+
<style>
|
|
163
|
+
body {
|
|
164
|
+
margin: 0;
|
|
165
|
+
}
|
|
166
|
+
</style>
|
|
167
|
+
<style>
|
|
168
|
+
${config.customCss ?? elysiaCSS}
|
|
169
|
+
</style>
|
|
170
|
+
</head>
|
|
171
|
+
<body>
|
|
172
|
+
<script
|
|
173
|
+
id="api-reference"
|
|
174
|
+
data-url="${config.url}"
|
|
175
|
+
>
|
|
176
|
+
</script>
|
|
177
|
+
<script src="${config.cdn}" crossorigin></script>
|
|
178
|
+
</body>
|
|
179
|
+
</html>`;
|
|
180
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
181
|
+
0 && (module.exports = {
|
|
182
|
+
ScalarRender
|
|
183
|
+
});
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/swagger/index.ts
|
|
21
|
+
var swagger_exports = {};
|
|
22
|
+
__export(swagger_exports, {
|
|
23
|
+
SwaggerUIRender: () => SwaggerUIRender,
|
|
24
|
+
transformDateProperties: () => transformDateProperties
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(swagger_exports);
|
|
27
|
+
function isSchemaObject(schema) {
|
|
28
|
+
return "type" in schema || "properties" in schema || "items" in schema;
|
|
29
|
+
}
|
|
30
|
+
function isDateTimeProperty(key, schema) {
|
|
31
|
+
return (key === "createdAt" || key === "updatedAt") && "anyOf" in schema && Array.isArray(schema.anyOf);
|
|
32
|
+
}
|
|
33
|
+
function transformDateProperties(schema) {
|
|
34
|
+
if (!isSchemaObject(schema) || typeof schema !== "object" || schema === null)
|
|
35
|
+
return schema;
|
|
36
|
+
const newSchema = { ...schema };
|
|
37
|
+
Object.entries(newSchema).forEach(([key, value]) => {
|
|
38
|
+
if (isSchemaObject(value)) {
|
|
39
|
+
if (isDateTimeProperty(key, value)) {
|
|
40
|
+
const dateTimeFormat = value.anyOf?.find(
|
|
41
|
+
(item) => isSchemaObject(item) && item.format === "date-time"
|
|
42
|
+
);
|
|
43
|
+
if (dateTimeFormat) {
|
|
44
|
+
const dateTimeSchema = {
|
|
45
|
+
type: "string",
|
|
46
|
+
format: "date-time",
|
|
47
|
+
default: dateTimeFormat.default
|
|
48
|
+
};
|
|
49
|
+
newSchema[key] = dateTimeSchema;
|
|
50
|
+
}
|
|
51
|
+
} else {
|
|
52
|
+
;
|
|
53
|
+
newSchema[key] = transformDateProperties(value);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
return newSchema;
|
|
58
|
+
}
|
|
59
|
+
var SwaggerUIRender = (info, config) => {
|
|
60
|
+
const {
|
|
61
|
+
version = "latest",
|
|
62
|
+
theme = `https://unpkg.com/swagger-ui-dist@${version ?? "latest"}/swagger-ui.css`,
|
|
63
|
+
cdn = `https://unpkg.com/swagger-ui-dist@${version}/swagger-ui-bundle.js`,
|
|
64
|
+
autoDarkMode = true,
|
|
65
|
+
...rest
|
|
66
|
+
} = config;
|
|
67
|
+
const stringifiedOptions = JSON.stringify(
|
|
68
|
+
{
|
|
69
|
+
dom_id: "#swagger-ui",
|
|
70
|
+
...rest
|
|
71
|
+
},
|
|
72
|
+
(_, value) => typeof value === "function" ? void 0 : value
|
|
73
|
+
);
|
|
74
|
+
const options = JSON.parse(stringifiedOptions);
|
|
75
|
+
if (options.components && options.components.schemas)
|
|
76
|
+
options.components.schemas = Object.fromEntries(
|
|
77
|
+
Object.entries(options.components.schemas).map(([key, schema]) => [
|
|
78
|
+
key,
|
|
79
|
+
transformDateProperties(schema)
|
|
80
|
+
])
|
|
81
|
+
);
|
|
82
|
+
return `<!DOCTYPE html>
|
|
83
|
+
<html lang="en">
|
|
84
|
+
<head>
|
|
85
|
+
<meta charset="utf-8" />
|
|
86
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
87
|
+
<title>${info.title}</title>
|
|
88
|
+
<meta
|
|
89
|
+
name="description"
|
|
90
|
+
content="${info.description}"
|
|
91
|
+
/>
|
|
92
|
+
<meta
|
|
93
|
+
name="og:description"
|
|
94
|
+
content="${info.description}"
|
|
95
|
+
/>
|
|
96
|
+
${autoDarkMode && typeof theme === "string" ? `<style>
|
|
97
|
+
@media (prefers-color-scheme: dark) {
|
|
98
|
+
body {
|
|
99
|
+
background-color: #222;
|
|
100
|
+
color: #faf9a;
|
|
101
|
+
}
|
|
102
|
+
.swagger-ui {
|
|
103
|
+
filter: invert(92%) hue-rotate(180deg);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.swagger-ui .microlight {
|
|
107
|
+
filter: invert(100%) hue-rotate(180deg);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
</style>` : ""}
|
|
111
|
+
${typeof theme === "string" ? `<link rel="stylesheet" href="${theme}" />` : `<link rel="stylesheet" media="(prefers-color-scheme: light)" href="${theme.light}" />
|
|
112
|
+
<link rel="stylesheet" media="(prefers-color-scheme: dark)" href="${theme.dark}" />`}
|
|
113
|
+
</head>
|
|
114
|
+
<body>
|
|
115
|
+
<div id="swagger-ui"></div>
|
|
116
|
+
<script src="${cdn}" crossorigin></script>
|
|
117
|
+
<script>
|
|
118
|
+
window.onload = () => {
|
|
119
|
+
window.ui = SwaggerUIBundle(${stringifiedOptions});
|
|
120
|
+
};
|
|
121
|
+
</script>
|
|
122
|
+
</body>
|
|
123
|
+
</html>`;
|
|
124
|
+
};
|
|
125
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
126
|
+
0 && (module.exports = {
|
|
127
|
+
SwaggerUIRender,
|
|
128
|
+
transformDateProperties
|
|
129
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// src/swagger/types.ts
|
|
17
|
+
var types_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(types_exports);
|