@clov-std/elysia-openapi 0.0.0-stage → 1.0.0
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.md +21 -0
- package/README.md +79 -2
- package/dist/document.d.ts +11 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +550 -0
- package/dist/openapi-types-3.2.d.ts +510 -0
- package/dist/openapi.d.ts +12 -0
- package/dist/scalar-types.d.ts +83 -0
- package/dist/schema.d.ts +50 -0
- package/package.json +48 -5
|
@@ -0,0 +1,510 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Specification Extensions, allowed on every object that "MAY be extended".
|
|
3
|
+
*
|
|
4
|
+
* @see https://spec.openapis.org/oas/v3.2.1.html#specification-extensions
|
|
5
|
+
*/
|
|
6
|
+
export type SpecificationExtensions = Record<`x-${string}`, unknown>;
|
|
7
|
+
/**
|
|
8
|
+
* Root object of an OpenAPI Description.
|
|
9
|
+
*
|
|
10
|
+
* At least one of `components`, `paths` or `webhooks` MUST be present.
|
|
11
|
+
*
|
|
12
|
+
* @see https://spec.openapis.org/oas/v3.2.1.html#openapi-object
|
|
13
|
+
*/
|
|
14
|
+
export interface OpenAPIObject extends SpecificationExtensions {
|
|
15
|
+
openapi: `3.2.${number}`;
|
|
16
|
+
$self?: string;
|
|
17
|
+
info: InfoObject;
|
|
18
|
+
jsonSchemaDialect?: string;
|
|
19
|
+
servers?: ServerObject[];
|
|
20
|
+
paths?: PathsObject;
|
|
21
|
+
webhooks?: Record<string, PathItemObject>;
|
|
22
|
+
components?: ComponentsObject;
|
|
23
|
+
security?: SecurityRequirementObject[];
|
|
24
|
+
tags?: TagObject[];
|
|
25
|
+
externalDocs?: ExternalDocumentationObject;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* @see https://spec.openapis.org/oas/v3.2.1.html#info-object
|
|
29
|
+
*/
|
|
30
|
+
export interface InfoObject extends SpecificationExtensions {
|
|
31
|
+
title: string;
|
|
32
|
+
summary?: string;
|
|
33
|
+
description?: string;
|
|
34
|
+
termsOfService?: string;
|
|
35
|
+
contact?: ContactObject;
|
|
36
|
+
license?: LicenseObject;
|
|
37
|
+
version: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* @see https://spec.openapis.org/oas/v3.2.1.html#contact-object
|
|
41
|
+
*/
|
|
42
|
+
export interface ContactObject extends SpecificationExtensions {
|
|
43
|
+
name?: string;
|
|
44
|
+
url?: string;
|
|
45
|
+
email?: string;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* `identifier` and `url` are mutually exclusive.
|
|
49
|
+
*
|
|
50
|
+
* @see https://spec.openapis.org/oas/v3.2.1.html#license-object
|
|
51
|
+
*/
|
|
52
|
+
export interface LicenseObject extends SpecificationExtensions {
|
|
53
|
+
name: string;
|
|
54
|
+
identifier?: string;
|
|
55
|
+
url?: string;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* @see https://spec.openapis.org/oas/v3.2.1.html#server-object
|
|
59
|
+
*/
|
|
60
|
+
export interface ServerObject extends SpecificationExtensions {
|
|
61
|
+
url: string;
|
|
62
|
+
description?: string;
|
|
63
|
+
name?: string;
|
|
64
|
+
variables?: Record<string, ServerVariableObject>;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* @see https://spec.openapis.org/oas/v3.2.1.html#server-variable-object
|
|
68
|
+
*/
|
|
69
|
+
export interface ServerVariableObject extends SpecificationExtensions {
|
|
70
|
+
enum?: [string, ...string[]];
|
|
71
|
+
default: string;
|
|
72
|
+
description?: string;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* @see https://spec.openapis.org/oas/v3.2.1.html#components-object
|
|
76
|
+
*/
|
|
77
|
+
export interface ComponentsObject extends SpecificationExtensions {
|
|
78
|
+
schemas?: Record<string, SchemaObject>;
|
|
79
|
+
responses?: Record<string, ResponseObject | ReferenceObject>;
|
|
80
|
+
parameters?: Record<string, ParameterObject | ReferenceObject>;
|
|
81
|
+
examples?: Record<string, ExampleObject | ReferenceObject>;
|
|
82
|
+
requestBodies?: Record<string, RequestBodyObject | ReferenceObject>;
|
|
83
|
+
headers?: Record<string, HeaderObject | ReferenceObject>;
|
|
84
|
+
securitySchemes?: Record<string, SecuritySchemeObject | ReferenceObject>;
|
|
85
|
+
links?: Record<string, LinkObject | ReferenceObject>;
|
|
86
|
+
callbacks?: Record<string, CallbackObject | ReferenceObject>;
|
|
87
|
+
pathItems?: Record<string, PathItemObject>;
|
|
88
|
+
mediaTypes?: Record<string, MediaTypeObject | ReferenceObject>;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* @see https://spec.openapis.org/oas/v3.2.1.html#paths-object
|
|
92
|
+
*/
|
|
93
|
+
export type PathsObject = SpecificationExtensions & Record<`/${string}`, PathItemObject>;
|
|
94
|
+
/**
|
|
95
|
+
* @see https://spec.openapis.org/oas/v3.2.1.html#path-item-object
|
|
96
|
+
*/
|
|
97
|
+
export interface PathItemObject extends SpecificationExtensions {
|
|
98
|
+
$ref?: string;
|
|
99
|
+
summary?: string;
|
|
100
|
+
description?: string;
|
|
101
|
+
get?: OperationObject;
|
|
102
|
+
put?: OperationObject;
|
|
103
|
+
post?: OperationObject;
|
|
104
|
+
delete?: OperationObject;
|
|
105
|
+
options?: OperationObject;
|
|
106
|
+
head?: OperationObject;
|
|
107
|
+
patch?: OperationObject;
|
|
108
|
+
trace?: OperationObject;
|
|
109
|
+
query?: OperationObject;
|
|
110
|
+
/**
|
|
111
|
+
* Keys are HTTP methods with the exact capitalization to send, and MUST NOT
|
|
112
|
+
* contain any method that has a fixed field (e.g. `POST`).
|
|
113
|
+
*/
|
|
114
|
+
additionalOperations?: Record<string, OperationObject>;
|
|
115
|
+
servers?: ServerObject[];
|
|
116
|
+
parameters?: (ParameterObject | ReferenceObject)[];
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* @see https://spec.openapis.org/oas/v3.2.1.html#operation-object
|
|
120
|
+
*/
|
|
121
|
+
export interface OperationObject extends SpecificationExtensions {
|
|
122
|
+
tags?: string[];
|
|
123
|
+
summary?: string;
|
|
124
|
+
description?: string;
|
|
125
|
+
externalDocs?: ExternalDocumentationObject;
|
|
126
|
+
operationId?: string;
|
|
127
|
+
parameters?: (ParameterObject | ReferenceObject)[];
|
|
128
|
+
requestBody?: RequestBodyObject | ReferenceObject;
|
|
129
|
+
responses?: ResponsesObject;
|
|
130
|
+
callbacks?: Record<string, CallbackObject | ReferenceObject>;
|
|
131
|
+
deprecated?: boolean;
|
|
132
|
+
security?: SecurityRequirementObject[];
|
|
133
|
+
servers?: ServerObject[];
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* @see https://spec.openapis.org/oas/v3.2.1.html#external-documentation-object
|
|
137
|
+
*/
|
|
138
|
+
export interface ExternalDocumentationObject extends SpecificationExtensions {
|
|
139
|
+
description?: string;
|
|
140
|
+
url: string;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* @see https://spec.openapis.org/oas/v3.2.1.html#parameter-locations
|
|
144
|
+
*/
|
|
145
|
+
export type ParameterLocation = 'query' | 'querystring' | 'header' | 'path' | 'cookie';
|
|
146
|
+
/**
|
|
147
|
+
* @see https://spec.openapis.org/oas/v3.2.1.html#style-values
|
|
148
|
+
*/
|
|
149
|
+
export type ParameterStyle = 'matrix' | 'label' | 'simple' | 'form' | 'spaceDelimited' | 'pipeDelimited' | 'deepObject' | 'cookie';
|
|
150
|
+
/**
|
|
151
|
+
* @see https://spec.openapis.org/oas/v3.2.1.html#common-fixed-fields
|
|
152
|
+
*/
|
|
153
|
+
export interface ParameterObjectBase extends SpecificationExtensions {
|
|
154
|
+
name: string;
|
|
155
|
+
in: ParameterLocation;
|
|
156
|
+
description?: string;
|
|
157
|
+
/** REQUIRED and MUST be `true` when `in` is `"path"`. */
|
|
158
|
+
required?: boolean;
|
|
159
|
+
deprecated?: boolean;
|
|
160
|
+
allowEmptyValue?: boolean;
|
|
161
|
+
example?: unknown;
|
|
162
|
+
examples?: Record<string, ExampleObject | ReferenceObject>;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* @see https://spec.openapis.org/oas/v3.2.1.html#fixed-fields-for-use-with-schema
|
|
166
|
+
*/
|
|
167
|
+
export interface ParameterObjectWithSchema extends ParameterObjectBase {
|
|
168
|
+
style?: ParameterStyle;
|
|
169
|
+
explode?: boolean;
|
|
170
|
+
allowReserved?: boolean;
|
|
171
|
+
schema: SchemaObject;
|
|
172
|
+
content?: never;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* @see https://spec.openapis.org/oas/v3.2.1.html#fixed-fields-for-use-with-content
|
|
176
|
+
*/
|
|
177
|
+
export interface ParameterObjectWithContent extends ParameterObjectBase {
|
|
178
|
+
/** MUST only contain one entry. */
|
|
179
|
+
content: Record<string, MediaTypeObject | ReferenceObject>;
|
|
180
|
+
style?: never;
|
|
181
|
+
explode?: never;
|
|
182
|
+
allowReserved?: never;
|
|
183
|
+
schema?: never;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* A parameter MUST contain either `schema` or `content`, but not both.
|
|
187
|
+
*
|
|
188
|
+
* @see https://spec.openapis.org/oas/v3.2.1.html#parameter-object
|
|
189
|
+
*/
|
|
190
|
+
export type ParameterObject = ParameterObjectWithSchema | ParameterObjectWithContent;
|
|
191
|
+
/**
|
|
192
|
+
* @see https://spec.openapis.org/oas/v3.2.1.html#request-body-object
|
|
193
|
+
*/
|
|
194
|
+
export interface RequestBodyObject extends SpecificationExtensions {
|
|
195
|
+
description?: string;
|
|
196
|
+
content: Record<string, MediaTypeObject | ReferenceObject>;
|
|
197
|
+
required?: boolean;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* @see https://spec.openapis.org/oas/v3.2.1.html#media-type-object
|
|
201
|
+
*/
|
|
202
|
+
export interface MediaTypeObject extends SpecificationExtensions {
|
|
203
|
+
schema?: SchemaObject;
|
|
204
|
+
itemSchema?: SchemaObject;
|
|
205
|
+
example?: unknown;
|
|
206
|
+
examples?: Record<string, ExampleObject | ReferenceObject>;
|
|
207
|
+
encoding?: Record<string, EncodingObject>;
|
|
208
|
+
prefixEncoding?: EncodingObject[];
|
|
209
|
+
itemEncoding?: EncodingObject;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* @see https://spec.openapis.org/oas/v3.2.1.html#encoding-object
|
|
213
|
+
*/
|
|
214
|
+
export interface EncodingObject extends SpecificationExtensions {
|
|
215
|
+
contentType?: string;
|
|
216
|
+
headers?: Record<string, HeaderObject | ReferenceObject>;
|
|
217
|
+
encoding?: Record<string, EncodingObject>;
|
|
218
|
+
prefixEncoding?: EncodingObject[];
|
|
219
|
+
itemEncoding?: EncodingObject;
|
|
220
|
+
style?: ParameterStyle;
|
|
221
|
+
explode?: boolean;
|
|
222
|
+
allowReserved?: boolean;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Keys are HTTP status codes (`"200"`) or ranges (`"2XX"`).
|
|
226
|
+
*
|
|
227
|
+
* @see https://spec.openapis.org/oas/v3.2.1.html#responses-object
|
|
228
|
+
*/
|
|
229
|
+
export interface ResponsesObject extends SpecificationExtensions {
|
|
230
|
+
default?: ResponseObject | ReferenceObject;
|
|
231
|
+
[statusCode: `${1 | 2 | 3 | 4 | 5}${string}`]: ResponseObject | ReferenceObject;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* @see https://spec.openapis.org/oas/v3.2.1.html#response-object
|
|
235
|
+
*/
|
|
236
|
+
export interface ResponseObject extends SpecificationExtensions {
|
|
237
|
+
summary?: string;
|
|
238
|
+
description?: string;
|
|
239
|
+
headers?: Record<string, HeaderObject | ReferenceObject>;
|
|
240
|
+
content?: Record<string, MediaTypeObject | ReferenceObject>;
|
|
241
|
+
links?: Record<string, LinkObject | ReferenceObject>;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Keys are runtime expressions.
|
|
245
|
+
*
|
|
246
|
+
* shortcut: `x-` extensions are not typed, TS cannot exclude them from a `string` index signature
|
|
247
|
+
*
|
|
248
|
+
* @see https://spec.openapis.org/oas/v3.2.1.html#callback-object
|
|
249
|
+
*/
|
|
250
|
+
export type CallbackObject = Record<string, PathItemObject>;
|
|
251
|
+
/**
|
|
252
|
+
* `dataValue` and `value` are mutually exclusive, as are `serializedValue`, `externalValue` and `value`.
|
|
253
|
+
*
|
|
254
|
+
* @see https://spec.openapis.org/oas/v3.2.1.html#example-object
|
|
255
|
+
*/
|
|
256
|
+
export interface ExampleObject extends SpecificationExtensions {
|
|
257
|
+
summary?: string;
|
|
258
|
+
description?: string;
|
|
259
|
+
dataValue?: unknown;
|
|
260
|
+
serializedValue?: string;
|
|
261
|
+
externalValue?: string;
|
|
262
|
+
/** Deprecated for non-JSON serialization targets, use `dataValue` or `serializedValue` instead. */
|
|
263
|
+
value?: unknown;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* `operationRef` and `operationId` are mutually exclusive.
|
|
267
|
+
*
|
|
268
|
+
* @see https://spec.openapis.org/oas/v3.2.1.html#link-object
|
|
269
|
+
*/
|
|
270
|
+
export interface LinkObject extends SpecificationExtensions {
|
|
271
|
+
operationRef?: string;
|
|
272
|
+
operationId?: string;
|
|
273
|
+
parameters?: Record<string, unknown>;
|
|
274
|
+
requestBody?: unknown;
|
|
275
|
+
description?: string;
|
|
276
|
+
server?: ServerObject;
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* @see https://spec.openapis.org/oas/v3.2.1.html#common-fixed-fields-1
|
|
280
|
+
*/
|
|
281
|
+
export interface HeaderObjectBase extends SpecificationExtensions {
|
|
282
|
+
description?: string;
|
|
283
|
+
required?: boolean;
|
|
284
|
+
deprecated?: boolean;
|
|
285
|
+
example?: unknown;
|
|
286
|
+
examples?: Record<string, ExampleObject | ReferenceObject>;
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* @see https://spec.openapis.org/oas/v3.2.1.html#fixed-fields-for-use-with-schema-0
|
|
290
|
+
*/
|
|
291
|
+
export interface HeaderObjectWithSchema extends HeaderObjectBase {
|
|
292
|
+
style?: 'simple';
|
|
293
|
+
explode?: boolean;
|
|
294
|
+
schema: SchemaObject;
|
|
295
|
+
content?: never;
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* @see https://spec.openapis.org/oas/v3.2.1.html#fixed-fields-for-use-with-content-0
|
|
299
|
+
*/
|
|
300
|
+
export interface HeaderObjectWithContent extends HeaderObjectBase {
|
|
301
|
+
/** MUST only contain one entry. */
|
|
302
|
+
content: Record<string, MediaTypeObject | ReferenceObject>;
|
|
303
|
+
style?: never;
|
|
304
|
+
explode?: never;
|
|
305
|
+
schema?: never;
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* A header MUST contain either `schema` or `content`, but not both.
|
|
309
|
+
*
|
|
310
|
+
* @see https://spec.openapis.org/oas/v3.2.1.html#header-object
|
|
311
|
+
*/
|
|
312
|
+
export type HeaderObject = HeaderObjectWithSchema | HeaderObjectWithContent;
|
|
313
|
+
/**
|
|
314
|
+
* @see https://spec.openapis.org/oas/v3.2.1.html#tag-object
|
|
315
|
+
*/
|
|
316
|
+
export interface TagObject extends SpecificationExtensions {
|
|
317
|
+
name: string;
|
|
318
|
+
summary?: string;
|
|
319
|
+
description?: string;
|
|
320
|
+
externalDocs?: ExternalDocumentationObject;
|
|
321
|
+
parent?: string;
|
|
322
|
+
kind?: string;
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* This object cannot be extended with additional properties.
|
|
326
|
+
*
|
|
327
|
+
* @see https://spec.openapis.org/oas/v3.2.1.html#reference-object
|
|
328
|
+
*/
|
|
329
|
+
export interface ReferenceObject {
|
|
330
|
+
$ref: string;
|
|
331
|
+
summary?: string;
|
|
332
|
+
description?: string;
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* @see https://json-schema.org/draft/2020-12/json-schema-validation#section-6.1.1
|
|
336
|
+
*/
|
|
337
|
+
export type JsonSchemaType = 'null' | 'boolean' | 'object' | 'array' | 'number' | 'string' | 'integer';
|
|
338
|
+
/**
|
|
339
|
+
* JSON Schema Draft 2020-12 keywords plus the OpenAPI fixed fields.
|
|
340
|
+
*
|
|
341
|
+
* @see https://spec.openapis.org/oas/v3.2.1.html#schema-object
|
|
342
|
+
* @see https://json-schema.org/draft/2020-12/json-schema-core
|
|
343
|
+
* @see https://json-schema.org/draft/2020-12/json-schema-validation
|
|
344
|
+
*/
|
|
345
|
+
export interface SchemaObjectDefinition extends SpecificationExtensions {
|
|
346
|
+
$schema?: string;
|
|
347
|
+
$id?: string;
|
|
348
|
+
$ref?: string;
|
|
349
|
+
$anchor?: string;
|
|
350
|
+
$dynamicRef?: string;
|
|
351
|
+
$dynamicAnchor?: string;
|
|
352
|
+
$vocabulary?: Record<string, boolean>;
|
|
353
|
+
$comment?: string;
|
|
354
|
+
$defs?: Record<string, SchemaObject>;
|
|
355
|
+
allOf?: SchemaObject[];
|
|
356
|
+
anyOf?: SchemaObject[];
|
|
357
|
+
oneOf?: SchemaObject[];
|
|
358
|
+
not?: SchemaObject;
|
|
359
|
+
if?: SchemaObject;
|
|
360
|
+
then?: SchemaObject;
|
|
361
|
+
else?: SchemaObject;
|
|
362
|
+
dependentSchemas?: Record<string, SchemaObject>;
|
|
363
|
+
prefixItems?: SchemaObject[];
|
|
364
|
+
items?: SchemaObject;
|
|
365
|
+
contains?: SchemaObject;
|
|
366
|
+
properties?: Record<string, SchemaObject>;
|
|
367
|
+
patternProperties?: Record<string, SchemaObject>;
|
|
368
|
+
additionalProperties?: SchemaObject;
|
|
369
|
+
propertyNames?: SchemaObject;
|
|
370
|
+
unevaluatedItems?: SchemaObject;
|
|
371
|
+
unevaluatedProperties?: SchemaObject;
|
|
372
|
+
type?: JsonSchemaType | JsonSchemaType[];
|
|
373
|
+
enum?: unknown[];
|
|
374
|
+
const?: unknown;
|
|
375
|
+
multipleOf?: number;
|
|
376
|
+
maximum?: number;
|
|
377
|
+
exclusiveMaximum?: number;
|
|
378
|
+
minimum?: number;
|
|
379
|
+
exclusiveMinimum?: number;
|
|
380
|
+
maxLength?: number;
|
|
381
|
+
minLength?: number;
|
|
382
|
+
pattern?: string;
|
|
383
|
+
maxItems?: number;
|
|
384
|
+
minItems?: number;
|
|
385
|
+
uniqueItems?: boolean;
|
|
386
|
+
maxContains?: number;
|
|
387
|
+
minContains?: number;
|
|
388
|
+
maxProperties?: number;
|
|
389
|
+
minProperties?: number;
|
|
390
|
+
required?: string[];
|
|
391
|
+
dependentRequired?: Record<string, string[]>;
|
|
392
|
+
title?: string;
|
|
393
|
+
description?: string;
|
|
394
|
+
default?: unknown;
|
|
395
|
+
deprecated?: boolean;
|
|
396
|
+
readOnly?: boolean;
|
|
397
|
+
writeOnly?: boolean;
|
|
398
|
+
examples?: unknown[];
|
|
399
|
+
format?: string;
|
|
400
|
+
contentEncoding?: string;
|
|
401
|
+
contentMediaType?: string;
|
|
402
|
+
contentSchema?: SchemaObject;
|
|
403
|
+
discriminator?: DiscriminatorObject;
|
|
404
|
+
xml?: XMLObject;
|
|
405
|
+
externalDocs?: ExternalDocumentationObject;
|
|
406
|
+
/** @deprecated Use the JSON Schema `examples` keyword instead. */
|
|
407
|
+
example?: unknown;
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* A JSON Schema 2020-12 schema, which may also be a boolean.
|
|
411
|
+
*
|
|
412
|
+
* @see https://spec.openapis.org/oas/v3.2.1.html#schema-object
|
|
413
|
+
*/
|
|
414
|
+
export type SchemaObject = SchemaObjectDefinition | boolean;
|
|
415
|
+
/**
|
|
416
|
+
* @see https://spec.openapis.org/oas/v3.2.1.html#discriminator-object
|
|
417
|
+
*/
|
|
418
|
+
export interface DiscriminatorObject extends SpecificationExtensions {
|
|
419
|
+
propertyName: string;
|
|
420
|
+
mapping?: Record<string, string>;
|
|
421
|
+
defaultMapping?: string;
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* @see https://spec.openapis.org/oas/v3.2.1.html#xml-node-types
|
|
425
|
+
*/
|
|
426
|
+
export type XMLNodeType = 'element' | 'attribute' | 'text' | 'cdata' | 'none';
|
|
427
|
+
/**
|
|
428
|
+
* @see https://spec.openapis.org/oas/v3.2.1.html#xml-object
|
|
429
|
+
*/
|
|
430
|
+
export interface XMLObject extends SpecificationExtensions {
|
|
431
|
+
nodeType?: XMLNodeType;
|
|
432
|
+
name?: string;
|
|
433
|
+
namespace?: string;
|
|
434
|
+
prefix?: string;
|
|
435
|
+
/** @deprecated Use `nodeType: "attribute"` instead. */
|
|
436
|
+
attribute?: boolean;
|
|
437
|
+
/** @deprecated Use `nodeType: "element"` instead. */
|
|
438
|
+
wrapped?: boolean;
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* @see https://spec.openapis.org/oas/v3.2.1.html#security-scheme-object
|
|
442
|
+
*/
|
|
443
|
+
export interface SecuritySchemeObjectBase extends SpecificationExtensions {
|
|
444
|
+
description?: string;
|
|
445
|
+
deprecated?: boolean;
|
|
446
|
+
}
|
|
447
|
+
export interface ApiKeySecuritySchemeObject extends SecuritySchemeObjectBase {
|
|
448
|
+
type: 'apiKey';
|
|
449
|
+
name: string;
|
|
450
|
+
in: 'query' | 'header' | 'cookie';
|
|
451
|
+
}
|
|
452
|
+
export interface HttpSecuritySchemeObject extends SecuritySchemeObjectBase {
|
|
453
|
+
type: 'http';
|
|
454
|
+
scheme: string;
|
|
455
|
+
/** Only applies when `scheme` is `"bearer"`. */
|
|
456
|
+
bearerFormat?: string;
|
|
457
|
+
}
|
|
458
|
+
export interface MutualTLSSecuritySchemeObject extends SecuritySchemeObjectBase {
|
|
459
|
+
type: 'mutualTLS';
|
|
460
|
+
}
|
|
461
|
+
export interface OAuth2SecuritySchemeObject extends SecuritySchemeObjectBase {
|
|
462
|
+
type: 'oauth2';
|
|
463
|
+
flows: OAuthFlowsObject;
|
|
464
|
+
oauth2MetadataUrl?: string;
|
|
465
|
+
}
|
|
466
|
+
export interface OpenIdConnectSecuritySchemeObject extends SecuritySchemeObjectBase {
|
|
467
|
+
type: 'openIdConnect';
|
|
468
|
+
openIdConnectUrl: string;
|
|
469
|
+
}
|
|
470
|
+
export type SecuritySchemeObject = ApiKeySecuritySchemeObject | HttpSecuritySchemeObject | MutualTLSSecuritySchemeObject | OAuth2SecuritySchemeObject | OpenIdConnectSecuritySchemeObject;
|
|
471
|
+
/**
|
|
472
|
+
* Each flow requires its own subset of URL fields, see {@link OAuthFlowObject}.
|
|
473
|
+
*
|
|
474
|
+
* @see https://spec.openapis.org/oas/v3.2.1.html#oauth-flows-object
|
|
475
|
+
*/
|
|
476
|
+
export interface OAuthFlowsObject extends SpecificationExtensions {
|
|
477
|
+
implicit?: OAuthFlowObject & {
|
|
478
|
+
authorizationUrl: string;
|
|
479
|
+
};
|
|
480
|
+
password?: OAuthFlowObject & {
|
|
481
|
+
tokenUrl: string;
|
|
482
|
+
};
|
|
483
|
+
clientCredentials?: OAuthFlowObject & {
|
|
484
|
+
tokenUrl: string;
|
|
485
|
+
};
|
|
486
|
+
authorizationCode?: OAuthFlowObject & {
|
|
487
|
+
authorizationUrl: string;
|
|
488
|
+
tokenUrl: string;
|
|
489
|
+
};
|
|
490
|
+
deviceAuthorization?: OAuthFlowObject & {
|
|
491
|
+
deviceAuthorizationUrl: string;
|
|
492
|
+
tokenUrl: string;
|
|
493
|
+
};
|
|
494
|
+
}
|
|
495
|
+
/**
|
|
496
|
+
* @see https://spec.openapis.org/oas/v3.2.1.html#oauth-flow-object
|
|
497
|
+
*/
|
|
498
|
+
export interface OAuthFlowObject extends SpecificationExtensions {
|
|
499
|
+
authorizationUrl?: string;
|
|
500
|
+
deviceAuthorizationUrl?: string;
|
|
501
|
+
tokenUrl?: string;
|
|
502
|
+
refreshUrl?: string;
|
|
503
|
+
scopes: Record<string, string>;
|
|
504
|
+
}
|
|
505
|
+
/**
|
|
506
|
+
* Keys are security scheme names (or URIs), values are required scopes or roles.
|
|
507
|
+
*
|
|
508
|
+
* @see https://spec.openapis.org/oas/v3.2.1.html#security-requirement-object
|
|
509
|
+
*/
|
|
510
|
+
export type SecurityRequirementObject = Record<string, string[]>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type AnyElysia } from 'elysia';
|
|
2
|
+
import type { OpenAPIObject } from './openapi-types-3.2';
|
|
3
|
+
import type { ScalarConfiguration } from './scalar-types';
|
|
4
|
+
export interface OpenAPIOptions {
|
|
5
|
+
/** @default '/openapi' */
|
|
6
|
+
readonly path?: string;
|
|
7
|
+
/** @default `${path}/json` */
|
|
8
|
+
readonly specPath?: string;
|
|
9
|
+
readonly scalar?: ScalarConfiguration;
|
|
10
|
+
readonly document?: Partial<OpenAPIObject>;
|
|
11
|
+
}
|
|
12
|
+
export declare const openapiPlugin: ({ path, specPath, scalar, document: base }?: OpenAPIOptions) => (<const App extends AnyElysia>(host: App) => App);
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { ServerObject } from './openapi-types-3.2';
|
|
2
|
+
/**
|
|
3
|
+
* The Scalar API reference configuration options.
|
|
4
|
+
*
|
|
5
|
+
* Only the JSON-serializable ones: the configuration is inlined in the page with `JSON.stringify`, so
|
|
6
|
+
* functions (events, `customFetch`, `plugins`, slug generators, custom sorters) would be dropped. `url` is
|
|
7
|
+
* set by the plugin.
|
|
8
|
+
*/
|
|
9
|
+
export interface ScalarConfiguration {
|
|
10
|
+
readonly authentication?: {
|
|
11
|
+
readonly preferredSecurityScheme?: string | readonly (string | readonly string[])[];
|
|
12
|
+
readonly securitySchemes?: Readonly<Record<string, Readonly<Record<string, unknown>>>>;
|
|
13
|
+
readonly createAnySecurityScheme?: boolean;
|
|
14
|
+
};
|
|
15
|
+
readonly agent?: {
|
|
16
|
+
readonly key?: string;
|
|
17
|
+
readonly disabled?: boolean;
|
|
18
|
+
};
|
|
19
|
+
readonly baseServerURL?: string;
|
|
20
|
+
readonly customCss?: string;
|
|
21
|
+
readonly darkMode?: boolean;
|
|
22
|
+
readonly defaultHttpClient?: {
|
|
23
|
+
readonly targetKey: string;
|
|
24
|
+
readonly clientKey: string;
|
|
25
|
+
};
|
|
26
|
+
readonly defaultOpenAllTags?: boolean;
|
|
27
|
+
readonly defaultOpenFirstTag?: boolean;
|
|
28
|
+
readonly defaultRequestBodyView?: 'form' | 'raw';
|
|
29
|
+
readonly documentDownloadType?: 'json' | 'yaml' | 'both' | 'direct' | 'none';
|
|
30
|
+
readonly expandAllModelSections?: boolean;
|
|
31
|
+
readonly expandAllParameters?: boolean;
|
|
32
|
+
readonly expandAllResponses?: boolean;
|
|
33
|
+
readonly expandAllSchemaProperties?: boolean;
|
|
34
|
+
readonly favicon?: string;
|
|
35
|
+
/** `target/client` ids, like `shell/curl` */
|
|
36
|
+
readonly featuredClients?: readonly string[];
|
|
37
|
+
readonly forceDarkModeState?: 'dark' | 'light';
|
|
38
|
+
readonly hiddenClients?: true | readonly string[] | Readonly<Record<string, boolean | readonly string[]>>;
|
|
39
|
+
readonly hideClientButton?: boolean;
|
|
40
|
+
readonly hideDarkModeToggle?: boolean;
|
|
41
|
+
readonly hideModelNames?: boolean;
|
|
42
|
+
readonly hideModels?: boolean;
|
|
43
|
+
readonly hideSearch?: boolean;
|
|
44
|
+
readonly hideTestRequestButton?: boolean;
|
|
45
|
+
readonly isEditable?: boolean;
|
|
46
|
+
readonly layout?: 'modern' | 'classic';
|
|
47
|
+
readonly localization?: {
|
|
48
|
+
readonly locale?: string;
|
|
49
|
+
readonly direction?: 'ltr' | 'rtl' | 'auto';
|
|
50
|
+
readonly translations?: Readonly<Record<string, unknown>>;
|
|
51
|
+
};
|
|
52
|
+
readonly maxVisibleRequestBodyProperties?: number;
|
|
53
|
+
readonly mcp?: {
|
|
54
|
+
readonly name?: string;
|
|
55
|
+
readonly url?: string;
|
|
56
|
+
readonly disabled?: boolean;
|
|
57
|
+
};
|
|
58
|
+
readonly metaData?: Readonly<Record<string, string>>;
|
|
59
|
+
readonly modelsSectionLabel?: string;
|
|
60
|
+
readonly oauth2RedirectUri?: string;
|
|
61
|
+
readonly operationsSorter?: 'alpha' | 'method';
|
|
62
|
+
readonly operationTitleSource?: 'summary' | 'path';
|
|
63
|
+
readonly orderRequiredPropertiesFirst?: boolean;
|
|
64
|
+
readonly orderSchemaPropertiesBy?: 'alpha' | 'preserve';
|
|
65
|
+
readonly pathRouting?: {
|
|
66
|
+
readonly basePath: string;
|
|
67
|
+
};
|
|
68
|
+
readonly persistAuth?: boolean;
|
|
69
|
+
/** ESM modules default-exporting a plugin */
|
|
70
|
+
readonly pluginUrls?: readonly string[];
|
|
71
|
+
readonly proxyUrl?: string;
|
|
72
|
+
readonly schemaKeyboardNav?: boolean;
|
|
73
|
+
readonly searchHotKey?: string;
|
|
74
|
+
readonly servers?: readonly ServerObject[];
|
|
75
|
+
readonly showDeveloperTools?: 'always' | 'localhost' | 'never';
|
|
76
|
+
readonly showExtensions?: readonly `x-${string}`[];
|
|
77
|
+
readonly showOperationId?: boolean;
|
|
78
|
+
readonly showSidebar?: boolean;
|
|
79
|
+
readonly tagsSorter?: 'alpha';
|
|
80
|
+
readonly telemetry?: boolean;
|
|
81
|
+
readonly theme?: 'alternate' | 'bluePlanet' | 'deepSpace' | 'default' | 'elysiajs' | 'fastify' | 'kepler' | 'laserwave' | 'mars' | 'moon' | 'none' | 'purple' | 'saturn' | 'solarized';
|
|
82
|
+
readonly withDefaultFonts?: boolean;
|
|
83
|
+
}
|
package/dist/schema.d.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { AnySchema } from 'elysia';
|
|
2
|
+
import type { SchemaObject } from './openapi-types-3.2';
|
|
3
|
+
export type Models = Record<string, AnySchema>;
|
|
4
|
+
/** A hook schema, or the name of a model (`body: 'User'`). */
|
|
5
|
+
export type HookSchema = AnySchema | string;
|
|
6
|
+
/** Named properties a schema accepts, see {@link objectShapeOf}. */
|
|
7
|
+
export interface ObjectShape {
|
|
8
|
+
readonly properties: Readonly<Record<string, unknown>>;
|
|
9
|
+
readonly required: ReadonlySet<string>;
|
|
10
|
+
}
|
|
11
|
+
export declare const uniqueSchemas: <T>(schemas: readonly T[]) => T[];
|
|
12
|
+
/**
|
|
13
|
+
* Converts a TypeBox schema to a plain JSON Schema 2020-12, without mutating it.
|
|
14
|
+
*
|
|
15
|
+
* TypeBox schemas already are JSON Schema, only Elysia's custom kinds and model references need rewriting.
|
|
16
|
+
*/
|
|
17
|
+
export declare const toSchema: (node: unknown) => unknown;
|
|
18
|
+
/**
|
|
19
|
+
* Attaches response headers to a response schema, documented as the response's `headers`.
|
|
20
|
+
*
|
|
21
|
+
* Elysia does not validate response headers, this is documentation only.
|
|
22
|
+
*
|
|
23
|
+
* @param schema - The response body schema
|
|
24
|
+
* @param headers - An object schema of the headers
|
|
25
|
+
*
|
|
26
|
+
* @returns A copy of `schema` carrying `headers`
|
|
27
|
+
*/
|
|
28
|
+
export declare const withHeaders: <const Schema extends AnySchema>(schema: Schema, headers: AnySchema) => Schema;
|
|
29
|
+
export declare const toRootSchema: (node: unknown) => SchemaObject;
|
|
30
|
+
/** The schema behind a model name (`'User'`) or a `t.Ref('User')`. */
|
|
31
|
+
export declare const resolveModel: (node: unknown, models: Models) => AnySchema | undefined;
|
|
32
|
+
/** The JSON Schema `type` keyword, whatever the TypeBox kind (`t.Literal('a')` is a `string`). */
|
|
33
|
+
export declare const jsonTypeOf: (node: AnySchema | undefined) => unknown;
|
|
34
|
+
export declare const descriptionOf: (node: AnySchema | undefined) => string | undefined;
|
|
35
|
+
export declare const hasDefault: (node: AnySchema | undefined) => boolean;
|
|
36
|
+
/** Whether Elysia sends every value of the schema as text (strings, numbers, booleans). */
|
|
37
|
+
export declare const isText: (node: unknown, models: Models) => boolean;
|
|
38
|
+
/** Whether every value of the schema is a JSON primitive or `null`. */
|
|
39
|
+
export declare const isPrimitive: (node: unknown, models: Models) => boolean;
|
|
40
|
+
/** `t.ArrayBuffer()` and `t.Uint8Array()`, read by Elysia from an `application/octet-stream` body. */
|
|
41
|
+
export declare const isRawBinary: (node: unknown) => boolean;
|
|
42
|
+
export declare const isFile: (node: unknown) => boolean;
|
|
43
|
+
export declare const containsFile: (node: unknown, models: Models, seen?: Set<unknown>) => boolean;
|
|
44
|
+
/**
|
|
45
|
+
* The named properties a schema accepts: an object, a model (`'Page'`, `t.Ref('Page')`), or a union or intersection
|
|
46
|
+
* of them.
|
|
47
|
+
*
|
|
48
|
+
* A union's property is required when every branch requires it, an intersection's when any does.
|
|
49
|
+
*/
|
|
50
|
+
export declare const objectShapeOf: (node: unknown, models: Models) => ObjectShape | undefined;
|