@kubb/adapter-oas 5.0.0-alpha.42 → 5.0.0-alpha.44
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/dist/index.cjs +161 -64
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +332 -13
- package/dist/index.js +159 -60
- package/dist/index.js.map +1 -1
- package/package.json +6 -7
- package/src/constants.ts +12 -0
- package/src/factory.ts +8 -12
- package/src/guards.ts +1 -1
- package/src/index.ts +2 -2
- package/src/parser.ts +68 -54
- package/src/refs.ts +4 -2
- package/src/resolvers.ts +48 -25
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,329 @@
|
|
|
1
1
|
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
2
|
import * as _$_kubb_core0 from "@kubb/core";
|
|
3
3
|
import { AdapterFactoryOptions, AdapterSource, ast } from "@kubb/core";
|
|
4
|
-
import { DiscriminatorObject as DiscriminatorObject$
|
|
4
|
+
import { DiscriminatorObject as DiscriminatorObject$2, MediaTypeObject as MediaTypeObject$2, OASDocument, ResponseObject as ResponseObject$2, SchemaObject as SchemaObject$2 } from "oas/types";
|
|
5
5
|
import { Operation as Operation$1 } from "oas/operation";
|
|
6
|
-
import { OpenAPIV3 } from "openapi-types";
|
|
7
6
|
|
|
7
|
+
//#region ../../node_modules/.pnpm/openapi-types@12.1.3/node_modules/openapi-types/dist/index.d.ts
|
|
8
|
+
declare namespace OpenAPIV3 {
|
|
9
|
+
interface Document<T extends {} = {}> {
|
|
10
|
+
openapi: string;
|
|
11
|
+
info: InfoObject;
|
|
12
|
+
servers?: ServerObject[];
|
|
13
|
+
paths: PathsObject<T>;
|
|
14
|
+
components?: ComponentsObject;
|
|
15
|
+
security?: SecurityRequirementObject[];
|
|
16
|
+
tags?: TagObject[];
|
|
17
|
+
externalDocs?: ExternalDocumentationObject;
|
|
18
|
+
'x-express-openapi-additional-middleware'?: (((request: any, response: any, next: any) => Promise<void>) | ((request: any, response: any, next: any) => void))[];
|
|
19
|
+
'x-express-openapi-validation-strict'?: boolean;
|
|
20
|
+
}
|
|
21
|
+
interface InfoObject {
|
|
22
|
+
title: string;
|
|
23
|
+
description?: string;
|
|
24
|
+
termsOfService?: string;
|
|
25
|
+
contact?: ContactObject;
|
|
26
|
+
license?: LicenseObject;
|
|
27
|
+
version: string;
|
|
28
|
+
}
|
|
29
|
+
interface ContactObject {
|
|
30
|
+
name?: string;
|
|
31
|
+
url?: string;
|
|
32
|
+
email?: string;
|
|
33
|
+
}
|
|
34
|
+
interface LicenseObject {
|
|
35
|
+
name: string;
|
|
36
|
+
url?: string;
|
|
37
|
+
}
|
|
38
|
+
interface ServerObject {
|
|
39
|
+
url: string;
|
|
40
|
+
description?: string;
|
|
41
|
+
variables?: {
|
|
42
|
+
[variable: string]: ServerVariableObject;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
interface ServerVariableObject {
|
|
46
|
+
enum?: string[];
|
|
47
|
+
default: string;
|
|
48
|
+
description?: string;
|
|
49
|
+
}
|
|
50
|
+
interface PathsObject<T extends {} = {}, P extends {} = {}> {
|
|
51
|
+
[pattern: string]: (PathItemObject<T> & P) | undefined;
|
|
52
|
+
}
|
|
53
|
+
enum HttpMethods {
|
|
54
|
+
GET = "get",
|
|
55
|
+
PUT = "put",
|
|
56
|
+
POST = "post",
|
|
57
|
+
DELETE = "delete",
|
|
58
|
+
OPTIONS = "options",
|
|
59
|
+
HEAD = "head",
|
|
60
|
+
PATCH = "patch",
|
|
61
|
+
TRACE = "trace"
|
|
62
|
+
}
|
|
63
|
+
type PathItemObject<T extends {} = {}> = {
|
|
64
|
+
$ref?: string;
|
|
65
|
+
summary?: string;
|
|
66
|
+
description?: string;
|
|
67
|
+
servers?: ServerObject[];
|
|
68
|
+
parameters?: (ReferenceObject | ParameterObject)[];
|
|
69
|
+
} & { [method in HttpMethods]?: OperationObject<T> };
|
|
70
|
+
type OperationObject<T extends {} = {}> = {
|
|
71
|
+
tags?: string[];
|
|
72
|
+
summary?: string;
|
|
73
|
+
description?: string;
|
|
74
|
+
externalDocs?: ExternalDocumentationObject;
|
|
75
|
+
operationId?: string;
|
|
76
|
+
parameters?: (ReferenceObject | ParameterObject)[];
|
|
77
|
+
requestBody?: ReferenceObject | RequestBodyObject;
|
|
78
|
+
responses: ResponsesObject;
|
|
79
|
+
callbacks?: {
|
|
80
|
+
[callback: string]: ReferenceObject | CallbackObject;
|
|
81
|
+
};
|
|
82
|
+
deprecated?: boolean;
|
|
83
|
+
security?: SecurityRequirementObject[];
|
|
84
|
+
servers?: ServerObject[];
|
|
85
|
+
} & T;
|
|
86
|
+
interface ExternalDocumentationObject {
|
|
87
|
+
description?: string;
|
|
88
|
+
url: string;
|
|
89
|
+
}
|
|
90
|
+
interface ParameterObject extends ParameterBaseObject {
|
|
91
|
+
name: string;
|
|
92
|
+
in: string;
|
|
93
|
+
}
|
|
94
|
+
interface HeaderObject extends ParameterBaseObject {}
|
|
95
|
+
interface ParameterBaseObject {
|
|
96
|
+
description?: string;
|
|
97
|
+
required?: boolean;
|
|
98
|
+
deprecated?: boolean;
|
|
99
|
+
allowEmptyValue?: boolean;
|
|
100
|
+
style?: string;
|
|
101
|
+
explode?: boolean;
|
|
102
|
+
allowReserved?: boolean;
|
|
103
|
+
schema?: ReferenceObject | SchemaObject;
|
|
104
|
+
example?: any;
|
|
105
|
+
examples?: {
|
|
106
|
+
[media: string]: ReferenceObject | ExampleObject;
|
|
107
|
+
};
|
|
108
|
+
content?: {
|
|
109
|
+
[media: string]: MediaTypeObject;
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
type NonArraySchemaObjectType = 'boolean' | 'object' | 'number' | 'string' | 'integer';
|
|
113
|
+
type ArraySchemaObjectType = 'array';
|
|
114
|
+
type SchemaObject = ArraySchemaObject | NonArraySchemaObject;
|
|
115
|
+
interface ArraySchemaObject extends BaseSchemaObject {
|
|
116
|
+
type: ArraySchemaObjectType;
|
|
117
|
+
items: ReferenceObject | SchemaObject;
|
|
118
|
+
}
|
|
119
|
+
interface NonArraySchemaObject extends BaseSchemaObject {
|
|
120
|
+
type?: NonArraySchemaObjectType;
|
|
121
|
+
}
|
|
122
|
+
interface BaseSchemaObject {
|
|
123
|
+
title?: string;
|
|
124
|
+
description?: string;
|
|
125
|
+
format?: string;
|
|
126
|
+
default?: any;
|
|
127
|
+
multipleOf?: number;
|
|
128
|
+
maximum?: number;
|
|
129
|
+
exclusiveMaximum?: boolean;
|
|
130
|
+
minimum?: number;
|
|
131
|
+
exclusiveMinimum?: boolean;
|
|
132
|
+
maxLength?: number;
|
|
133
|
+
minLength?: number;
|
|
134
|
+
pattern?: string;
|
|
135
|
+
additionalProperties?: boolean | ReferenceObject | SchemaObject;
|
|
136
|
+
maxItems?: number;
|
|
137
|
+
minItems?: number;
|
|
138
|
+
uniqueItems?: boolean;
|
|
139
|
+
maxProperties?: number;
|
|
140
|
+
minProperties?: number;
|
|
141
|
+
required?: string[];
|
|
142
|
+
enum?: any[];
|
|
143
|
+
properties?: {
|
|
144
|
+
[name: string]: ReferenceObject | SchemaObject;
|
|
145
|
+
};
|
|
146
|
+
allOf?: (ReferenceObject | SchemaObject)[];
|
|
147
|
+
oneOf?: (ReferenceObject | SchemaObject)[];
|
|
148
|
+
anyOf?: (ReferenceObject | SchemaObject)[];
|
|
149
|
+
not?: ReferenceObject | SchemaObject;
|
|
150
|
+
nullable?: boolean;
|
|
151
|
+
discriminator?: DiscriminatorObject;
|
|
152
|
+
readOnly?: boolean;
|
|
153
|
+
writeOnly?: boolean;
|
|
154
|
+
xml?: XMLObject;
|
|
155
|
+
externalDocs?: ExternalDocumentationObject;
|
|
156
|
+
example?: any;
|
|
157
|
+
deprecated?: boolean;
|
|
158
|
+
}
|
|
159
|
+
interface DiscriminatorObject {
|
|
160
|
+
propertyName: string;
|
|
161
|
+
mapping?: {
|
|
162
|
+
[value: string]: string;
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
interface XMLObject {
|
|
166
|
+
name?: string;
|
|
167
|
+
namespace?: string;
|
|
168
|
+
prefix?: string;
|
|
169
|
+
attribute?: boolean;
|
|
170
|
+
wrapped?: boolean;
|
|
171
|
+
}
|
|
172
|
+
interface ReferenceObject {
|
|
173
|
+
$ref: string;
|
|
174
|
+
}
|
|
175
|
+
interface ExampleObject {
|
|
176
|
+
summary?: string;
|
|
177
|
+
description?: string;
|
|
178
|
+
value?: any;
|
|
179
|
+
externalValue?: string;
|
|
180
|
+
}
|
|
181
|
+
interface MediaTypeObject {
|
|
182
|
+
schema?: ReferenceObject | SchemaObject;
|
|
183
|
+
example?: any;
|
|
184
|
+
examples?: {
|
|
185
|
+
[media: string]: ReferenceObject | ExampleObject;
|
|
186
|
+
};
|
|
187
|
+
encoding?: {
|
|
188
|
+
[media: string]: EncodingObject;
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
interface EncodingObject {
|
|
192
|
+
contentType?: string;
|
|
193
|
+
headers?: {
|
|
194
|
+
[header: string]: ReferenceObject | HeaderObject;
|
|
195
|
+
};
|
|
196
|
+
style?: string;
|
|
197
|
+
explode?: boolean;
|
|
198
|
+
allowReserved?: boolean;
|
|
199
|
+
}
|
|
200
|
+
interface RequestBodyObject {
|
|
201
|
+
description?: string;
|
|
202
|
+
content: {
|
|
203
|
+
[media: string]: MediaTypeObject;
|
|
204
|
+
};
|
|
205
|
+
required?: boolean;
|
|
206
|
+
}
|
|
207
|
+
interface ResponsesObject {
|
|
208
|
+
[code: string]: ReferenceObject | ResponseObject;
|
|
209
|
+
}
|
|
210
|
+
interface ResponseObject {
|
|
211
|
+
description: string;
|
|
212
|
+
headers?: {
|
|
213
|
+
[header: string]: ReferenceObject | HeaderObject;
|
|
214
|
+
};
|
|
215
|
+
content?: {
|
|
216
|
+
[media: string]: MediaTypeObject;
|
|
217
|
+
};
|
|
218
|
+
links?: {
|
|
219
|
+
[link: string]: ReferenceObject | LinkObject;
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
interface LinkObject {
|
|
223
|
+
operationRef?: string;
|
|
224
|
+
operationId?: string;
|
|
225
|
+
parameters?: {
|
|
226
|
+
[parameter: string]: any;
|
|
227
|
+
};
|
|
228
|
+
requestBody?: any;
|
|
229
|
+
description?: string;
|
|
230
|
+
server?: ServerObject;
|
|
231
|
+
}
|
|
232
|
+
interface CallbackObject {
|
|
233
|
+
[url: string]: PathItemObject;
|
|
234
|
+
}
|
|
235
|
+
interface SecurityRequirementObject {
|
|
236
|
+
[name: string]: string[];
|
|
237
|
+
}
|
|
238
|
+
interface ComponentsObject {
|
|
239
|
+
schemas?: {
|
|
240
|
+
[key: string]: ReferenceObject | SchemaObject;
|
|
241
|
+
};
|
|
242
|
+
responses?: {
|
|
243
|
+
[key: string]: ReferenceObject | ResponseObject;
|
|
244
|
+
};
|
|
245
|
+
parameters?: {
|
|
246
|
+
[key: string]: ReferenceObject | ParameterObject;
|
|
247
|
+
};
|
|
248
|
+
examples?: {
|
|
249
|
+
[key: string]: ReferenceObject | ExampleObject;
|
|
250
|
+
};
|
|
251
|
+
requestBodies?: {
|
|
252
|
+
[key: string]: ReferenceObject | RequestBodyObject;
|
|
253
|
+
};
|
|
254
|
+
headers?: {
|
|
255
|
+
[key: string]: ReferenceObject | HeaderObject;
|
|
256
|
+
};
|
|
257
|
+
securitySchemes?: {
|
|
258
|
+
[key: string]: ReferenceObject | SecuritySchemeObject;
|
|
259
|
+
};
|
|
260
|
+
links?: {
|
|
261
|
+
[key: string]: ReferenceObject | LinkObject;
|
|
262
|
+
};
|
|
263
|
+
callbacks?: {
|
|
264
|
+
[key: string]: ReferenceObject | CallbackObject;
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
type SecuritySchemeObject = HttpSecurityScheme | ApiKeySecurityScheme | OAuth2SecurityScheme | OpenIdSecurityScheme;
|
|
268
|
+
interface HttpSecurityScheme {
|
|
269
|
+
type: 'http';
|
|
270
|
+
description?: string;
|
|
271
|
+
scheme: string;
|
|
272
|
+
bearerFormat?: string;
|
|
273
|
+
}
|
|
274
|
+
interface ApiKeySecurityScheme {
|
|
275
|
+
type: 'apiKey';
|
|
276
|
+
description?: string;
|
|
277
|
+
name: string;
|
|
278
|
+
in: string;
|
|
279
|
+
}
|
|
280
|
+
interface OAuth2SecurityScheme {
|
|
281
|
+
type: 'oauth2';
|
|
282
|
+
description?: string;
|
|
283
|
+
flows: {
|
|
284
|
+
implicit?: {
|
|
285
|
+
authorizationUrl: string;
|
|
286
|
+
refreshUrl?: string;
|
|
287
|
+
scopes: {
|
|
288
|
+
[scope: string]: string;
|
|
289
|
+
};
|
|
290
|
+
};
|
|
291
|
+
password?: {
|
|
292
|
+
tokenUrl: string;
|
|
293
|
+
refreshUrl?: string;
|
|
294
|
+
scopes: {
|
|
295
|
+
[scope: string]: string;
|
|
296
|
+
};
|
|
297
|
+
};
|
|
298
|
+
clientCredentials?: {
|
|
299
|
+
tokenUrl: string;
|
|
300
|
+
refreshUrl?: string;
|
|
301
|
+
scopes: {
|
|
302
|
+
[scope: string]: string;
|
|
303
|
+
};
|
|
304
|
+
};
|
|
305
|
+
authorizationCode?: {
|
|
306
|
+
authorizationUrl: string;
|
|
307
|
+
tokenUrl: string;
|
|
308
|
+
refreshUrl?: string;
|
|
309
|
+
scopes: {
|
|
310
|
+
[scope: string]: string;
|
|
311
|
+
};
|
|
312
|
+
};
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
interface OpenIdSecurityScheme {
|
|
316
|
+
type: 'openIdConnect';
|
|
317
|
+
description?: string;
|
|
318
|
+
openIdConnectUrl: string;
|
|
319
|
+
}
|
|
320
|
+
interface TagObject {
|
|
321
|
+
name: string;
|
|
322
|
+
description?: string;
|
|
323
|
+
externalDocs?: ExternalDocumentationObject;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
//#endregion
|
|
8
327
|
//#region src/types.d.ts
|
|
9
328
|
/**
|
|
10
329
|
* Content-type string used when selecting request/response schemas from a spec.
|
|
@@ -29,7 +348,7 @@ type ContentType = 'application/json' | (string & {});
|
|
|
29
348
|
* }
|
|
30
349
|
* ```
|
|
31
350
|
*/
|
|
32
|
-
type SchemaObject = SchemaObject$
|
|
351
|
+
type SchemaObject$1 = SchemaObject$2 & {
|
|
33
352
|
/**
|
|
34
353
|
* OAS 3.0 vendor extension: marks a schema as nullable without using `type: ['null', ...]`.
|
|
35
354
|
*/
|
|
@@ -46,15 +365,15 @@ type SchemaObject = SchemaObject$1 & {
|
|
|
46
365
|
/**
|
|
47
366
|
* OAS 3.1: positional tuple items, replacing the multi-item `items` array from OAS 3.0.
|
|
48
367
|
*/
|
|
49
|
-
prefixItems?: Array<SchemaObject | ReferenceObject>;
|
|
368
|
+
prefixItems?: Array<SchemaObject$1 | ReferenceObject$1>;
|
|
50
369
|
/**
|
|
51
370
|
* JSON Schema: maps regex patterns to sub-schemas for validating additional properties.
|
|
52
371
|
*/
|
|
53
|
-
patternProperties?: Record<string, SchemaObject | boolean>;
|
|
372
|
+
patternProperties?: Record<string, SchemaObject$1 | boolean>;
|
|
54
373
|
/**
|
|
55
374
|
* Single-schema form of `items`. Narrowed from the base type to take precedence over the tuple overload.
|
|
56
375
|
*/
|
|
57
|
-
items?: SchemaObject | ReferenceObject;
|
|
376
|
+
items?: SchemaObject$1 | ReferenceObject$1;
|
|
58
377
|
/**
|
|
59
378
|
* Enum values for this schema (narrowed from `unknown[]`).
|
|
60
379
|
*/
|
|
@@ -69,7 +388,7 @@ type SchemaObject = SchemaObject$1 & {
|
|
|
69
388
|
* HttpMethods['POST'] // 'post'
|
|
70
389
|
* ```
|
|
71
390
|
*/
|
|
72
|
-
declare const HttpMethods: Record<Uppercase<ast.HttpMethod>, Lowercase<ast.HttpMethod>>;
|
|
391
|
+
declare const HttpMethods$1: Record<Uppercase<ast.HttpMethod>, Lowercase<ast.HttpMethod>>;
|
|
73
392
|
/**
|
|
74
393
|
* Lowercase HTTP method string as used by the `oas` package (`'get' | 'post' | ...`).
|
|
75
394
|
*/
|
|
@@ -85,19 +404,19 @@ type Operation = Operation$1;
|
|
|
85
404
|
/**
|
|
86
405
|
* OpenAPI `discriminator` object attached to a `oneOf`/`anyOf` schema.
|
|
87
406
|
*/
|
|
88
|
-
type DiscriminatorObject = DiscriminatorObject$
|
|
407
|
+
type DiscriminatorObject$1 = DiscriminatorObject$2;
|
|
89
408
|
/**
|
|
90
409
|
* OpenAPI `$ref` pointer object (`{ $ref: string }`).
|
|
91
410
|
*/
|
|
92
|
-
type ReferenceObject = OpenAPIV3.ReferenceObject;
|
|
411
|
+
type ReferenceObject$1 = OpenAPIV3.ReferenceObject;
|
|
93
412
|
/**
|
|
94
413
|
* OpenAPI response object type (may contain `content`, `description`, `headers`).
|
|
95
414
|
*/
|
|
96
|
-
type ResponseObject = ResponseObject$
|
|
415
|
+
type ResponseObject$1 = ResponseObject$2;
|
|
97
416
|
/**
|
|
98
417
|
* OpenAPI media type object that maps a content-type to a schema.
|
|
99
418
|
*/
|
|
100
|
-
type MediaTypeObject = MediaTypeObject$
|
|
419
|
+
type MediaTypeObject$1 = MediaTypeObject$2;
|
|
101
420
|
/**
|
|
102
421
|
* User-facing options for `adapterOas(...)`.
|
|
103
422
|
*
|
|
@@ -235,7 +554,7 @@ declare function parseDocument(pathOrApi: string | Document, {
|
|
|
235
554
|
/**
|
|
236
555
|
* Deep-merges multiple OpenAPI documents into a single `Document`.
|
|
237
556
|
*
|
|
238
|
-
* Each document is parsed independently then recursively merged
|
|
557
|
+
* Each document is parsed independently then recursively merged via `mergeDeep` from `@internals/utils`.
|
|
239
558
|
* Throws when the input array is empty.
|
|
240
559
|
*
|
|
241
560
|
* @example
|
|
@@ -271,5 +590,5 @@ declare function validateDocument(document: Document, {
|
|
|
271
590
|
throwOnError
|
|
272
591
|
}?: ValidateDocumentOptions): Promise<void>;
|
|
273
592
|
//#endregion
|
|
274
|
-
export { type AdapterOas, type AdapterOasOptions, type AdapterOasResolvedOptions, type ContentType, type DiscriminatorObject, type Document, type HttpMethod, HttpMethods, type MediaTypeObject, type Operation, type ParseOptions, type ReferenceObject, type ResponseObject, type SchemaObject, type ValidateDocumentOptions, adapterOas, adapterOasName, mergeDocuments, parseDocument, parseFromConfig, validateDocument };
|
|
593
|
+
export { type AdapterOas, type AdapterOasOptions, type AdapterOasResolvedOptions, type ContentType, type DiscriminatorObject$1 as DiscriminatorObject, type Document, type HttpMethod, HttpMethods$1 as HttpMethods, type MediaTypeObject$1 as MediaTypeObject, type Operation, type ParseOptions, type ReferenceObject$1 as ReferenceObject, type ResponseObject$1 as ResponseObject, type SchemaObject$1 as SchemaObject, type ValidateDocumentOptions, adapterOas, adapterOasName, mergeDocuments, parseDocument, parseFromConfig, validateDocument };
|
|
275
594
|
//# sourceMappingURL=index.d.ts.map
|