@kubb/oas 3.0.0-alpha.2 → 3.0.0-alpha.21

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.
@@ -0,0 +1,380 @@
1
+ import { Call, Tuples, Objects, Booleans, Strings, Pipe, Fn } from 'hotscript';
2
+ import { Object as Object$1 } from 'ts-toolbelt';
3
+ import { JSONSchema, FromSchema } from 'json-schema-to-ts';
4
+ import * as OasTypes from 'oas/types';
5
+
6
+ type Checks$5 = {
7
+ AllOFf: {
8
+ allOf: any[];
9
+ };
10
+ Object: {
11
+ type: 'object';
12
+ properties: any;
13
+ };
14
+ Properties: {
15
+ properties: any;
16
+ };
17
+ PropertiesRequired: {
18
+ properties: Record<string, any>;
19
+ required: string[];
20
+ };
21
+ };
22
+ type FixAdditionalPropertiesForAllOf<T> = T extends Checks$5['AllOFf'] ? Omit<T, 'allOf'> & {
23
+ allOf: Call<Tuples.Map<Objects.Omit<'additionalProperties'>>, T['allOf']>;
24
+ } : T;
25
+ type FixMissingAdditionalProperties<T> = T extends Checks$5['Object'] ? Omit<T, 'additionalProperties'> & {
26
+ additionalProperties: false;
27
+ } : T;
28
+ type FixMissingTypeObject<T> = T extends Checks$5['Properties'] ? T & {
29
+ type: 'object';
30
+ } : T;
31
+ type FixExtraRequiredFields<T> = T extends Checks$5['PropertiesRequired'] ? Omit<T, 'required'> & {
32
+ required: Call<Tuples.Filter<Booleans.Extends<keyof T['properties']>>, T['required']>;
33
+ } : T;
34
+ type FixJSONSchema<T> = FixAdditionalPropertiesForAllOf<FixMissingAdditionalProperties<FixMissingTypeObject<FixExtraRequiredFields<T>>>>;
35
+ type Mutable<Type> = FixJSONSchema<{
36
+ -readonly [Key in keyof Type]: Mutable<Type[Key]>;
37
+ }>;
38
+ type RefToPath<T extends string> = T extends `#/${infer Ref}` ? Call<Strings.Split<'/'>, Ref> : never;
39
+ type ResolveRef<TObj, TRef extends string> = {
40
+ $id: TRef;
41
+ } & Object$1.Path<TObj, RefToPath<TRef>>;
42
+ type ResolveRefInObj<T, TBase> = T extends {
43
+ $ref: infer Ref;
44
+ } ? (Ref extends string ? ResolveRef<TBase, Ref> : T) : T;
45
+ type ResolveRefsInObj<T, TBase = T> = {
46
+ [K in keyof T]: ResolveRefsInObj<ResolveRefInObj<T[K], TBase>, TBase>;
47
+ };
48
+ type Infer<TOas> = Mutable<ResolveRefsInObj<TOas>>;
49
+
50
+ type Checks$4<TParamType = never> = {
51
+ Required: {
52
+ required: true;
53
+ };
54
+ Schemas: {
55
+ schema: JSONSchema;
56
+ };
57
+ Enum: {
58
+ type: JSONSchemaTypeName;
59
+ enum?: any[];
60
+ };
61
+ Parameters: {
62
+ in: string;
63
+ required?: boolean;
64
+ }[];
65
+ SingleParameter: [{
66
+ in: TParamType;
67
+ required?: true;
68
+ }];
69
+ Responses: {
70
+ responses: any;
71
+ };
72
+ };
73
+ type PathMap<TOAS extends OasTypes.OASDocument> = TOAS['paths'];
74
+ interface ParamPropMap {
75
+ query: 'query';
76
+ path: 'params';
77
+ header: 'headers';
78
+ }
79
+ type JSONSchemaTypeName = 'string' | 'number' | 'integer' | 'boolean' | 'object' | 'array' | 'null';
80
+ type ParamObj<TParameter extends {
81
+ name: string;
82
+ }> = TParameter extends Checks$4['Required'] ? {
83
+ [TName in TParameter['name']]: TParameter extends Checks$4['Schemas'] ? FromSchema<TParameter['schema']> : TParameter extends Checks$4['Enum'] ? FromSchema<{
84
+ type: TParameter['type'];
85
+ enum: TParameter['enum'];
86
+ }> : unknown;
87
+ } : {
88
+ [TName in TParameter['name']]?: TParameter extends Checks$4['Schemas'] ? FromSchema<TParameter['schema']> : TParameter extends Checks$4['Enum'] ? FromSchema<{
89
+ type: TParameter['type'];
90
+ enum: TParameter['enum'];
91
+ }> : unknown;
92
+ };
93
+ interface ParamToRequestParam<TParameters extends Checks$4['Parameters']> extends Fn {
94
+ return: this['arg0'] extends {
95
+ name: string;
96
+ in: infer TParamType;
97
+ } ? TParameters extends Checks$4<TParamType>['SingleParameter'] ? {
98
+ [TKey in TParamType extends keyof ParamPropMap ? ParamPropMap[TParamType] : never]: ParamObj<this['arg0']>;
99
+ } : {
100
+ [TKey in TParamType extends keyof ParamPropMap ? ParamPropMap[TParamType] : never]?: ParamObj<this['arg0']>;
101
+ } : {};
102
+ }
103
+ type ParamMap<TParameters extends Checks$4['Parameters']> = Pipe<TParameters, [Tuples.Map<ParamToRequestParam<TParameters>>, Tuples.ToIntersection]>;
104
+ type MethodMap<TOAS extends OasTypes.OASDocument, TPath extends keyof PathMap<TOAS>> = PathMap<TOAS>[TPath];
105
+ type StatusMap<TOAS extends OasTypes.OASDocument, TPath extends keyof PathMap<TOAS>, TMethod extends keyof MethodMap<TOAS, TPath>> = MethodMap<TOAS, TPath>[TMethod] extends Checks$4['Responses'] ? MethodMap<TOAS, TPath>[TMethod]['responses'] : never;
106
+
107
+ type Checks$3<TName extends string | number | symbol = never> = {
108
+ ModelWithSchemas: {
109
+ components: {
110
+ schemas: Record<string, JSONSchema>;
111
+ };
112
+ };
113
+ ModelWithSchemasNamed: {
114
+ components: {
115
+ schemas: {
116
+ [TModelName in TName]: JSONSchema;
117
+ };
118
+ };
119
+ };
120
+ ModelWithDefinitions: {
121
+ definitions: Record<string, JSONSchema>;
122
+ };
123
+ ModelWithDefinitionsNamed: {
124
+ definitions: {
125
+ [TModelName in TName]: JSONSchema;
126
+ };
127
+ };
128
+ };
129
+ type Model<TOAS extends OasTypes.OASDocument, TName extends TOAS extends Checks$3['ModelWithSchemas'] ? keyof TOAS['components']['schemas'] : TOAS extends Checks$3['ModelWithDefinitions'] ? keyof TOAS['definitions'] : never> = TOAS extends Checks$3<TName>['ModelWithSchemasNamed'] ? FromSchema<TOAS['components']['schemas'][TName]> : TOAS extends Checks$3<TName>['ModelWithDefinitionsNamed'] ? FromSchema<TOAS['definitions'][TName]> : never;
130
+
131
+ type TupleToUnion<T> = T extends any[] ? T[number] : never;
132
+ type SplitByDelimiter<T extends string, D extends string> = T extends `${infer P}${D}${infer Q}` ? [P, ...SplitByDelimiter<Q, D>] : [T];
133
+
134
+ type Checks$2 = {
135
+ Security: {
136
+ security: {
137
+ [key: string]: any;
138
+ }[];
139
+ };
140
+ AuthParams: {
141
+ Basic: {
142
+ type: 'http';
143
+ scheme: 'basic';
144
+ } | {
145
+ type: 'basic';
146
+ };
147
+ Bearer: {
148
+ type: 'http';
149
+ scheme: 'bearer';
150
+ } | {
151
+ type: 'bearer';
152
+ };
153
+ OAuth2: {
154
+ type: 'oauth2';
155
+ };
156
+ ApiKey: {
157
+ type: 'apiKey';
158
+ in: 'header';
159
+ };
160
+ };
161
+ AuthName: {
162
+ Basic: `basic${string}`;
163
+ Bearer: `bearer${string}`;
164
+ OAuth2: `oauth${string}`;
165
+ };
166
+ };
167
+ type SecuritySchemeName<T extends Checks$2['Security']> = Call<Tuples.Map<Objects.Keys>, T['security']>[number];
168
+ declare namespace AuthParams {
169
+ type Basic<TSecurityScheme> = TSecurityScheme extends Checks$2['AuthParams']['Basic'] ? {
170
+ headers: {
171
+ /**
172
+ * `Authorization` header is required for basic authentication
173
+ * @see https://en.wikipedia.org/wiki/Basic_access_authentication
174
+ *
175
+ * It contains the word `Basic` followed by a space and a base64-encoded string `username:password`
176
+ *
177
+ * @example
178
+ * ```
179
+ * Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
180
+ * ```
181
+ */
182
+ Authorization: `Basic ${string}`;
183
+ };
184
+ } : {};
185
+ type Bearer<TSecurityScheme> = TSecurityScheme extends Checks$2['AuthParams']['Bearer'] ? {
186
+ /**
187
+ * `Authorization` header is required for bearer authentication
188
+ * @see https://swagger.io/docs/specification/authentication/bearer-authentication/
189
+ */
190
+ headers: {
191
+ /**
192
+ * It contains the word `Bearer` followed by a space and the token
193
+ *
194
+ * @example
195
+ * ```
196
+ * Authorization: Bearer {token}
197
+ * ```
198
+ */
199
+ Authorization: `Bearer ${string}`;
200
+ };
201
+ } : {};
202
+ type ApiKey<TSecurityScheme> = TSecurityScheme extends Checks$2['AuthParams']['ApiKey'] & {
203
+ name: infer TApiKeyHeaderName;
204
+ } ? {
205
+ headers: {
206
+ [THeaderName in TApiKeyHeaderName extends string ? TApiKeyHeaderName : never]: string;
207
+ };
208
+ } : TSecurityScheme extends {
209
+ type: 'apiKey';
210
+ in: 'query';
211
+ name: infer TApiKeyQueryName;
212
+ } ? {
213
+ query: {
214
+ [TQueryName in TApiKeyQueryName extends string ? TApiKeyQueryName : never]: string;
215
+ };
216
+ } : {};
217
+ type OAuth2<TSecurityScheme> = TSecurityScheme extends Checks$2['AuthParams']['OAuth2'] ? {
218
+ /**
219
+ * `Authorization` header is required for OAuth2.
220
+ */
221
+ headers: {
222
+ /**
223
+ * The access token string as issued by the authorization server.
224
+ * @example `Authorization: Bearer <access_token>`
225
+ */
226
+ Authorization: `Bearer ${string}`;
227
+ };
228
+ } : {};
229
+ }
230
+ type OASSecurityParams<TSecurityScheme> = AuthParams.Basic<TSecurityScheme> & AuthParams.Bearer<TSecurityScheme> & AuthParams.ApiKey<TSecurityScheme> & AuthParams.OAuth2<TSecurityScheme>;
231
+ type SecurityParamsBySecurityRef<TOAS, TSecurityObj> = TSecurityObj extends Checks$2['Security'] ? TOAS extends {
232
+ components: {
233
+ securitySchemes: {
234
+ [TSecuritySchemeNameKey in SecuritySchemeName<TSecurityObj> extends string ? SecuritySchemeName<TSecurityObj> : never]: infer TSecurityScheme;
235
+ };
236
+ };
237
+ } | {
238
+ securityDefinitions: {
239
+ [TSecuritySchemeNameKey in SecuritySchemeName<TSecurityObj> extends string ? SecuritySchemeName<TSecurityObj> : never]: infer TSecurityScheme;
240
+ };
241
+ } ? OASSecurityParams<TSecurityScheme> : SecuritySchemeName<TSecurityObj> extends Checks$2['AuthName']['Basic'] ? AuthParams.Basic<{
242
+ type: 'http';
243
+ scheme: 'basic';
244
+ }> : SecuritySchemeName<TSecurityObj> extends Checks$2['AuthName']['Bearer'] ? AuthParams.Bearer<{
245
+ type: 'http';
246
+ scheme: 'bearer';
247
+ }> : SecuritySchemeName<TSecurityObj> extends Checks$2['AuthName']['OAuth2'] ? AuthParams.OAuth2<{
248
+ type: 'oauth2';
249
+ }> : {} : {};
250
+
251
+ type Checks$1 = {
252
+ RequestBodyJson: {
253
+ requestBody: {
254
+ content: {
255
+ 'application/json': {
256
+ schema: JSONSchema;
257
+ };
258
+ };
259
+ };
260
+ };
261
+ RequestBodyFormData: {
262
+ requestBody: {
263
+ content: {
264
+ 'multipart/form-data': {
265
+ schema: JSONSchema;
266
+ };
267
+ };
268
+ };
269
+ };
270
+ RequestBodyFormEncoded: {
271
+ requestBody: {
272
+ content: {
273
+ 'application/x-www-form-urlencoded': {
274
+ schema: JSONSchema;
275
+ };
276
+ };
277
+ };
278
+ };
279
+ Parameters: {
280
+ parameters: {
281
+ name: string;
282
+ in: string;
283
+ }[];
284
+ };
285
+ PathBrackets: `${string}{${string}}${string}`;
286
+ PathPattern: `${string}:${string}${string}`;
287
+ Required: {
288
+ required: true;
289
+ };
290
+ };
291
+ type ExtractPathParamsWithPattern<TPath extends string> = Pipe<TPath, [
292
+ Strings.Split<'/'>,
293
+ Tuples.Filter<Strings.StartsWith<':'>>,
294
+ Tuples.Map<Strings.Trim<':'>>,
295
+ Tuples.ToUnion
296
+ ]>;
297
+ type IsPathParameter<T extends string> = T extends `{${infer U}}` ? U : never;
298
+ type ExtractPathParameters<T extends any[]> = {
299
+ [K in keyof T]: IsPathParameter<T[K]>;
300
+ };
301
+ type ExtractSegments<TPath extends string> = SplitByDelimiter<TPath, '/'>;
302
+ type ExtractSubSegments<T extends any[]> = {
303
+ [K in keyof T]: SplitByDelimiter<T[K], ';'>;
304
+ };
305
+ type ExtractPathParamsWithBrackets<TPath extends string> = TupleToUnion<ExtractPathParameters<ExtractSubSegments<ExtractSegments<TPath>>[number]>>;
306
+ type RequestParams<TOAS extends OasTypes.OASDocument, TPath extends keyof PathMap<TOAS>, TMethod extends keyof MethodMap<TOAS, TPath>> = (MethodMap<TOAS, TPath>[TMethod] extends Checks$1['RequestBodyJson'] ? MethodMap<TOAS, TPath>[TMethod]['requestBody'] extends Checks$1['Required'] ? {
307
+ /**
308
+ * The request body in JSON is required for this request.
309
+ *
310
+ * The value of `json` will be stringified and sent as the request body with `Content-Type: application/json`.
311
+ */
312
+ json: FromSchema<MethodMap<TOAS, TPath>[TMethod]['requestBody']['content']['application/json']['schema']>;
313
+ } : {
314
+ /**
315
+ * The request body in JSON is optional for this request.
316
+ *
317
+ * The value of `json` will be stringified and sent as the request body with `Content-Type: application/json`.
318
+ */
319
+ json?: FromSchema<MethodMap<TOAS, TPath>[TMethod]['requestBody']['content']['application/json']['schema']>;
320
+ } : MethodMap<TOAS, TPath>[TMethod] extends Checks$1['RequestBodyFormData'] ? MethodMap<TOAS, TPath>[TMethod]['requestBody'] extends Checks$1['Required'] ? {
321
+ /**
322
+ * The request body in multipart/form-data is required for this request.
323
+ *
324
+ * The value of `formData` will be sent as the request body with `Content-Type: multipart/form-data`.
325
+ */
326
+ formData: FromSchema<MethodMap<TOAS, TPath>[TMethod]['requestBody']['content']['multipart/form-data']['schema']>;
327
+ } : {
328
+ /**
329
+ * The request body in multipart/form-data is optional for this request.
330
+ *
331
+ * The value of `formData` will be sent as the request body with `Content-Type: multipart/form-data`.
332
+ */
333
+ formData?: FromSchema<MethodMap<TOAS, TPath>[TMethod]['requestBody']['content']['multipart/form-data']['schema']>;
334
+ } : MethodMap<TOAS, TPath>[TMethod] extends Checks$1['RequestBodyFormEncoded'] ? MethodMap<TOAS, TPath>[TMethod]['requestBody'] extends Checks$1['Required'] ? {
335
+ /**
336
+ * The request body in application/x-www-form-urlencoded is required for this request.
337
+ *
338
+ * The value of `formUrlEncoded` will be sent as the request body with `Content-Type: application/x-www-form-urlencoded`.
339
+ */
340
+ formUrlEncoded: FromSchema<MethodMap<TOAS, TPath>[TMethod]['requestBody']['content']['application/x-www-form-urlencoded']['schema']>;
341
+ } : {
342
+ /**
343
+ * The request body in application/x-www-form-urlencoded is optional for this request.
344
+ *
345
+ * The value of `formUrlEncoded` will be sent as the request body with `Content-Type: application/x-www-form-urlencoded`.
346
+ */
347
+ formUrlEncoded?: FromSchema<MethodMap<TOAS, TPath>[TMethod]['requestBody']['content']['application/x-www-form-urlencoded']['schema']>;
348
+ } : {}) & (MethodMap<TOAS, TPath>[TMethod] extends Checks$1['Parameters'] ? ParamMap<MethodMap<TOAS, TPath>[TMethod]['parameters']> : {}) & // If there is any parameters defined in path but not in the parameters array, we should add them to the params
349
+ (TPath extends Checks$1['PathBrackets'] ? {
350
+ /**
351
+ * Parameters defined in the path are required for this request.
352
+ *
353
+ * The value of `params` will be used to replace the path parameters.
354
+ *
355
+ * For example if path is `/todos/{id}` and `params` is `{ id: '1' }`, the path will be `/todos/1`
356
+ */
357
+ params: Record<ExtractPathParamsWithBrackets<TPath>, string | number | bigint | boolean>;
358
+ } : {}) & (TPath extends Checks$1['PathPattern'] ? {
359
+ /**
360
+ * Parameters defined in the path are required for this request.
361
+ *
362
+ * The value of `params` will be used to replace the path parameters.
363
+ *
364
+ * For example if path is `/todos/:id` and `params` is `{ id: '1' }`, the path will be `/todos/1`.
365
+ */
366
+ params: Record<ExtractPathParamsWithPattern<TPath>, string | number | bigint | boolean>;
367
+ } : {}) & // Respect security definitions in path object
368
+ SecurityParamsBySecurityRef<TOAS, MethodMap<TOAS, TPath>[TMethod]> & // Respect global security definitions
369
+ SecurityParamsBySecurityRef<TOAS, TOAS>;
370
+
371
+ type Checks = {
372
+ Content: {
373
+ content: any;
374
+ };
375
+ };
376
+ type ResponseSchemas<TOAS extends OasTypes.OASDocument, TPath extends keyof PathMap<TOAS>, TMethod extends keyof MethodMap<TOAS, TPath>, TStatus extends keyof StatusMap<TOAS, TPath, TMethod>> = StatusMap<TOAS, TPath, TMethod>[TStatus]['content'];
377
+ type JSONResponseSchema<TOAS extends OasTypes.OASDocument, TPath extends keyof PathMap<TOAS>, TMethod extends keyof MethodMap<TOAS, TPath>, TStatus extends keyof StatusMap<TOAS, TPath, TMethod>> = StatusMap<TOAS, TPath, TMethod>[TStatus] extends Checks['Content'] ? ResponseSchemas<TOAS, TPath, TMethod, TStatus>[keyof ResponseSchemas<TOAS, TPath, TMethod, TStatus>]['schema'] : StatusMap<TOAS, TPath, TMethod>[TStatus]['schema'];
378
+ type Response<TOAS extends OasTypes.OASDocument, TPath extends keyof PathMap<TOAS>, TMethod extends keyof MethodMap<TOAS, TPath>, TStatusCode extends keyof StatusMap<TOAS, TPath, TMethod> = 200> = FromSchema<JSONResponseSchema<TOAS, TPath, TMethod, TStatusCode>>;
379
+
380
+ export type { Infer, MethodMap, Model, PathMap, RequestParams, Response, StatusMap };
package/dist/infer.js ADDED
@@ -0,0 +1,3 @@
1
+
2
+ //# sourceMappingURL=infer.js.map
3
+ //# sourceMappingURL=infer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"infer.js"}
package/dist/parser.cjs CHANGED
@@ -1,35 +1,37 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1
+ 'use strict';
2
2
 
3
+ var chunk2ZT6EJGT_cjs = require('./chunk-2ZT6EJGT.cjs');
4
+ var openapiCore = require('@redocly/openapi-core');
5
+ var OASNormalize = require('oas-normalize');
6
+ var swagger2openapi = require('swagger2openapi');
3
7
 
8
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
4
9
 
5
- var _chunkUIWP4KHBcjs = require('./chunk-UIWP4KHB.cjs');
10
+ var OASNormalize__default = /*#__PURE__*/_interopDefault(OASNormalize);
11
+ var swagger2openapi__default = /*#__PURE__*/_interopDefault(swagger2openapi);
6
12
 
7
- // src/parser/index.ts
8
- var _oasnormalize = require('oas-normalize'); var _oasnormalize2 = _interopRequireDefault(_oasnormalize);
9
- var _swagger2openapi = require('swagger2openapi'); var _swagger2openapi2 = _interopRequireDefault(_swagger2openapi);
10
- var _openapicore = require('@redocly/openapi-core');
11
- async function parse(pathOrApi, options = {}, oasClass = _chunkUIWP4KHBcjs.Oas) {
13
+ async function parse(pathOrApi, options = {}, oasClass = chunk2ZT6EJGT_cjs.Oas) {
12
14
  if (typeof pathOrApi === "string") {
13
- const config = await _openapicore.loadConfig.call(void 0, );
14
- const bundleResults = await _openapicore.bundle.call(void 0, { ref: pathOrApi, config, base: pathOrApi });
15
+ const config = await openapiCore.loadConfig();
16
+ const bundleResults = await openapiCore.bundle({ ref: pathOrApi, config, base: pathOrApi });
15
17
  return parse(bundleResults.bundle.parsed, options);
16
18
  }
17
- const oasNormalize = new (0, _oasnormalize2.default)(pathOrApi, {
19
+ const oasNormalize = new OASNormalize__default.default(pathOrApi, {
18
20
  enablePaths: true,
19
21
  colorizeErrors: true
20
22
  });
21
23
  const document = await oasNormalize.load();
22
- if (_chunkUIWP4KHBcjs.isOpenApiV2Document.call(void 0, document)) {
23
- const { openapi } = await _swagger2openapi2.default.convertObj(document, {
24
+ if (chunk2ZT6EJGT_cjs.isOpenApiV2Document(document)) {
25
+ const { openapi } = await swagger2openapi__default.default.convertObj(document, {
24
26
  anchors: true
25
27
  });
26
- const oas2 = await _chunkUIWP4KHBcjs.filterAndSort.call(void 0, openapi, options);
28
+ const oas2 = await chunk2ZT6EJGT_cjs.filterAndSort(openapi, options);
27
29
  return new oasClass({ oas: oas2 });
28
30
  }
29
- const oas = await _chunkUIWP4KHBcjs.filterAndSort.call(void 0, document, options);
31
+ const oas = await chunk2ZT6EJGT_cjs.filterAndSort(document, options);
30
32
  return new oasClass({ oas });
31
33
  }
32
34
 
33
-
34
35
  exports.parse = parse;
36
+ //# sourceMappingURL=parser.cjs.map
35
37
  //# sourceMappingURL=parser.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/kubb/kubb/packages/oas/dist/parser.cjs","../src/parser/index.ts"],"names":["oas"],"mappings":"AAAA;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACNA,yGAAyB;AACzB,oHAA4B;AAC5B,oDAAmC;AAkDnC,MAAA,SAAsB,KAAA,CAAM,SAAA,EAAiC,QAAA,EAAyB,CAAC,CAAA,EAAG,SAAA,EAAuB,qBAAA,EAAmB;AAClI,EAAA,GAAA,CAAI,OAAO,UAAA,IAAc,QAAA,EAAU;AAEjC,IAAA,MAAM,OAAA,EAAS,MAAM,qCAAA,CAAW;AAChC,IAAA,MAAM,cAAA,EAAgB,MAAM,iCAAA,EAAS,GAAA,EAAK,SAAA,EAAW,MAAA,EAAQ,IAAA,EAAM,UAAU,CAAC,CAAA;AAE9E,IAAA,OAAO,KAAA,CAAM,aAAA,CAAc,MAAA,CAAO,MAAA,EAAQ,OAAO,CAAA;AAAA,EACnD;AAEA,EAAA,MAAM,aAAA,EAAe,IAAI,2BAAA,CAAa,SAAA,EAAW;AAAA,IAC/C,WAAA,EAAa,IAAA;AAAA,IACb,cAAA,EAAgB;AAAA,EAClB,CAAC,CAAA;AACD,EAAA,MAAM,SAAA,EAAY,MAAM,YAAA,CAAa,IAAA,CAAK,CAAA;AAE1C,EAAA,GAAA,CAAI,mDAAA,QAA4B,CAAA,EAAG;AACjC,IAAA,MAAM,EAAE,QAAQ,EAAA,EAAI,MAAM,yBAAA,CAAgB,UAAA,CAAW,QAAA,EAAU;AAAA,MAC7D,OAAA,EAAS;AAAA,IACX,CAAC,CAAA;AAED,IAAA,MAAMA,KAAAA,EAAM,MAAM,6CAAA,OAAc,EAAwB,OAAO,CAAA;AAE/D,IAAA,OAAO,IAAI,QAAA,CAAS,EAAE,GAAA,EAAKA,KAAmB,CAAC,CAAA;AAAA,EACjD;AAEA,EAAA,MAAM,IAAA,EAAM,MAAM,6CAAA,QAAc,EAAyB,OAAO,CAAA;AAEhE,EAAA,OAAO,IAAI,QAAA,CAAS,EAAE,IAAI,CAAC,CAAA;AAC7B;ADjDA;AACE;AACF,sBAAC","file":"/home/runner/work/kubb/kubb/packages/oas/dist/parser.cjs","sourcesContent":[null,"import OASNormalize from 'oas-normalize'\nimport swagger2openapi from 'swagger2openapi'\nimport { bundle, loadConfig } from '@redocly/openapi-core'\n\nimport { Oas } from '../Oas.ts'\nimport { filterAndSort, isOpenApiV2Document } from '../utils.ts'\n\nimport type { OASDocument } from 'oas/types'\nimport type { OpenAPI } from 'openapi-types'\n\nexport type FormatOptions = {\n verbose?: boolean\n 'no-sort'?: boolean\n sort?: boolean\n output?: string\n sortSet?: {\n root?: Array<'openapi' | 'info' | 'servers' | 'paths' | 'components' | 'tags' | 'x-tagGroups' | 'externalDocs'>\n get?: Array<'operationId' | 'summary' | 'description' | 'parameters' | 'requestBody' | 'responses'>\n post?: Array<'operationId' | 'summary' | 'description' | 'parameters' | 'requestBody' | 'responses'>\n put?: Array<'operationId' | 'summary' | 'description' | 'parameters' | 'requestBody' | 'responses'>\n patch?: Array<'operationId' | 'summary' | 'description' | 'parameters' | 'requestBody' | 'responses'>\n delete?: Array<'operationId' | 'summary' | 'description' | 'parameters' | 'requestBody' | 'responses'>\n parameters?: Array<'name' | 'in' | 'description' | 'required' | 'schema'>\n requestBody?: Array<'description' | 'required' | 'content'>\n responses?: Array<'description' | 'headers' | 'content' | 'links'>\n content?: Array<string>\n components?: Array<'parameters' | 'schemas'>\n schema?: Array<'description' | 'type' | 'items' | 'properties' | 'format' | 'example' | 'default'>\n schemas?: Array<'description' | 'type' | 'items' | 'properties' | 'format' | 'example' | 'default'>\n properties?: Array<'description' | 'type' | 'items' | 'format' | 'example' | 'default' | 'enum'>\n }\n filterSet?: {\n methods?: Array<'get' | 'post' | 'put' | 'patch' | 'delete' | 'options' | 'trace' | 'head' | 'parameters'>\n inverseMethods?: Array<'get' | 'post' | 'put' | 'patch' | 'delete' | 'options' | 'trace' | 'head' | 'parameters'>\n tags?: Array<string>\n inverseTags?: Array<string>\n operationIds?: Array<string>\n inverseOperationIds?: Array<string>\n operations?: Array<string>\n flags?: Array<string>\n inverseFlags?: Array<string>\n flagValues?: Array<string>\n inverseFlagValues?: Array<string>\n stripFlags?: Array<string>\n responseContent?: Array<string>\n inverseResponseContent?: Array<string>\n unusedComponents?: Array<'requestBodies' | 'schemas' | 'parameters' | 'responses'>\n }\n sortComponentsSet?: {}\n casingSet?: {}\n}\n\nexport async function parse(pathOrApi: string | OASDocument, options: FormatOptions = {}, oasClass: typeof Oas = Oas): Promise<Oas> {\n if (typeof pathOrApi === 'string') {\n // resolve external refs\n const config = await loadConfig()\n const bundleResults = await bundle({ ref: pathOrApi, config, base: pathOrApi })\n\n return parse(bundleResults.bundle.parsed, options)\n }\n\n const oasNormalize = new OASNormalize(pathOrApi, {\n enablePaths: true,\n colorizeErrors: true,\n })\n const document = (await oasNormalize.load()) as OpenAPI.Document\n\n if (isOpenApiV2Document(document)) {\n const { openapi } = await swagger2openapi.convertObj(document, {\n anchors: true,\n })\n\n const oas = await filterAndSort(openapi as OASDocument, options)\n\n return new oasClass({ oas: oas as OASDocument })\n }\n\n const oas = await filterAndSort(document as OASDocument, options)\n\n return new oasClass({ oas })\n}\n"]}
1
+ {"version":3,"sources":["../src/parser/index.ts"],"names":["Oas","loadConfig","bundle","OASNormalize","isOpenApiV2Document","swagger2openapi","oas","filterAndSort"],"mappings":";;;;;;;;;;;;AAoDA,eAAsB,MAAM,SAAiC,EAAA,OAAA,GAAyB,EAAC,EAAG,WAAuBA,qBAAmB,EAAA;AAClI,EAAI,IAAA,OAAO,cAAc,QAAU,EAAA;AAEjC,IAAM,MAAA,MAAA,GAAS,MAAMC,sBAAW,EAAA,CAAA;AAChC,IAAM,MAAA,aAAA,GAAgB,MAAMC,kBAAO,CAAA,EAAE,KAAK,SAAW,EAAA,MAAA,EAAQ,IAAM,EAAA,SAAA,EAAW,CAAA,CAAA;AAE9E,IAAA,OAAO,KAAM,CAAA,aAAA,CAAc,MAAO,CAAA,MAAA,EAAQ,OAAO,CAAA,CAAA;AAAA,GACnD;AAEA,EAAM,MAAA,YAAA,GAAe,IAAIC,6BAAA,CAAa,SAAW,EAAA;AAAA,IAC/C,WAAa,EAAA,IAAA;AAAA,IACb,cAAgB,EAAA,IAAA;AAAA,GACjB,CAAA,CAAA;AACD,EAAM,MAAA,QAAA,GAAY,MAAM,YAAA,CAAa,IAAK,EAAA,CAAA;AAE1C,EAAI,IAAAC,qCAAA,CAAoB,QAAQ,CAAG,EAAA;AACjC,IAAA,MAAM,EAAE,OAAQ,EAAA,GAAI,MAAMC,gCAAA,CAAgB,WAAW,QAAU,EAAA;AAAA,MAC7D,OAAS,EAAA,IAAA;AAAA,KACV,CAAA,CAAA;AAED,IAAA,MAAMC,IAAM,GAAA,MAAMC,+BAAc,CAAA,OAAA,EAAwB,OAAO,CAAA,CAAA;AAE/D,IAAA,OAAO,IAAI,QAAA,CAAS,EAAE,GAAA,EAAKD,MAAoB,CAAA,CAAA;AAAA,GACjD;AAEA,EAAA,MAAM,GAAM,GAAA,MAAMC,+BAAc,CAAA,QAAA,EAAyB,OAAO,CAAA,CAAA;AAEhE,EAAA,OAAO,IAAI,QAAA,CAAS,EAAE,GAAA,EAAK,CAAA,CAAA;AAC7B","file":"parser.cjs","sourcesContent":["import { bundle, loadConfig } from '@redocly/openapi-core'\nimport OASNormalize from 'oas-normalize'\nimport swagger2openapi from 'swagger2openapi'\n\nimport { Oas } from '../Oas.ts'\nimport { filterAndSort, isOpenApiV2Document } from '../utils.ts'\n\nimport type { OASDocument } from 'oas/types'\nimport type { OpenAPI } from 'openapi-types'\n\nexport type FormatOptions = {\n verbose?: boolean\n 'no-sort'?: boolean\n sort?: boolean\n output?: string\n sortSet?: {\n root?: Array<'openapi' | 'info' | 'servers' | 'paths' | 'components' | 'tags' | 'x-tagGroups' | 'externalDocs'>\n get?: Array<'operationId' | 'summary' | 'description' | 'parameters' | 'requestBody' | 'responses'>\n post?: Array<'operationId' | 'summary' | 'description' | 'parameters' | 'requestBody' | 'responses'>\n put?: Array<'operationId' | 'summary' | 'description' | 'parameters' | 'requestBody' | 'responses'>\n patch?: Array<'operationId' | 'summary' | 'description' | 'parameters' | 'requestBody' | 'responses'>\n delete?: Array<'operationId' | 'summary' | 'description' | 'parameters' | 'requestBody' | 'responses'>\n parameters?: Array<'name' | 'in' | 'description' | 'required' | 'schema'>\n requestBody?: Array<'description' | 'required' | 'content'>\n responses?: Array<'description' | 'headers' | 'content' | 'links'>\n content?: Array<string>\n components?: Array<'parameters' | 'schemas'>\n schema?: Array<'description' | 'type' | 'items' | 'properties' | 'format' | 'example' | 'default'>\n schemas?: Array<'description' | 'type' | 'items' | 'properties' | 'format' | 'example' | 'default'>\n properties?: Array<'description' | 'type' | 'items' | 'format' | 'example' | 'default' | 'enum'>\n }\n filterSet?: {\n methods?: Array<'get' | 'post' | 'put' | 'patch' | 'delete' | 'options' | 'trace' | 'head' | 'parameters'>\n inverseMethods?: Array<'get' | 'post' | 'put' | 'patch' | 'delete' | 'options' | 'trace' | 'head' | 'parameters'>\n tags?: Array<string>\n inverseTags?: Array<string>\n operationIds?: Array<string>\n inverseOperationIds?: Array<string>\n operations?: Array<string>\n flags?: Array<string>\n inverseFlags?: Array<string>\n flagValues?: Array<string>\n inverseFlagValues?: Array<string>\n stripFlags?: Array<string>\n responseContent?: Array<string>\n inverseResponseContent?: Array<string>\n unusedComponents?: Array<'requestBodies' | 'schemas' | 'parameters' | 'responses'>\n }\n sortComponentsSet?: {}\n casingSet?: {}\n}\n\nexport async function parse(pathOrApi: string | OASDocument, options: FormatOptions = {}, oasClass: typeof Oas = Oas): Promise<Oas> {\n if (typeof pathOrApi === 'string') {\n // resolve external refs\n const config = await loadConfig()\n const bundleResults = await bundle({ ref: pathOrApi, config, base: pathOrApi })\n\n return parse(bundleResults.bundle.parsed, options)\n }\n\n const oasNormalize = new OASNormalize(pathOrApi, {\n enablePaths: true,\n colorizeErrors: true,\n })\n const document = (await oasNormalize.load()) as OpenAPI.Document\n\n if (isOpenApiV2Document(document)) {\n const { openapi } = await swagger2openapi.convertObj(document, {\n anchors: true,\n })\n\n const oas = await filterAndSort(openapi as OASDocument, options)\n\n return new oasClass({ oas: oas as OASDocument })\n }\n\n const oas = await filterAndSort(document as OASDocument, options)\n\n return new oasClass({ oas })\n}\n"]}
package/dist/parser.js CHANGED
@@ -1,13 +1,8 @@
1
- import {
2
- Oas,
3
- filterAndSort,
4
- isOpenApiV2Document
5
- } from "./chunk-7D7ASOLY.js";
1
+ import { isOpenApiV2Document, filterAndSort, Oas } from './chunk-TVOJ46T6.js';
2
+ import { loadConfig, bundle } from '@redocly/openapi-core';
3
+ import OASNormalize from 'oas-normalize';
4
+ import swagger2openapi from 'swagger2openapi';
6
5
 
7
- // src/parser/index.ts
8
- import OASNormalize from "oas-normalize";
9
- import swagger2openapi from "swagger2openapi";
10
- import { bundle, loadConfig } from "@redocly/openapi-core";
11
6
  async function parse(pathOrApi, options = {}, oasClass = Oas) {
12
7
  if (typeof pathOrApi === "string") {
13
8
  const config = await loadConfig();
@@ -29,7 +24,7 @@ async function parse(pathOrApi, options = {}, oasClass = Oas) {
29
24
  const oas = await filterAndSort(document, options);
30
25
  return new oasClass({ oas });
31
26
  }
32
- export {
33
- parse
34
- };
27
+
28
+ export { parse };
29
+ //# sourceMappingURL=parser.js.map
35
30
  //# sourceMappingURL=parser.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/parser/index.ts"],"sourcesContent":["import OASNormalize from 'oas-normalize'\nimport swagger2openapi from 'swagger2openapi'\nimport { bundle, loadConfig } from '@redocly/openapi-core'\n\nimport { Oas } from '../Oas.ts'\nimport { filterAndSort, isOpenApiV2Document } from '../utils.ts'\n\nimport type { OASDocument } from 'oas/types'\nimport type { OpenAPI } from 'openapi-types'\n\nexport type FormatOptions = {\n verbose?: boolean\n 'no-sort'?: boolean\n sort?: boolean\n output?: string\n sortSet?: {\n root?: Array<'openapi' | 'info' | 'servers' | 'paths' | 'components' | 'tags' | 'x-tagGroups' | 'externalDocs'>\n get?: Array<'operationId' | 'summary' | 'description' | 'parameters' | 'requestBody' | 'responses'>\n post?: Array<'operationId' | 'summary' | 'description' | 'parameters' | 'requestBody' | 'responses'>\n put?: Array<'operationId' | 'summary' | 'description' | 'parameters' | 'requestBody' | 'responses'>\n patch?: Array<'operationId' | 'summary' | 'description' | 'parameters' | 'requestBody' | 'responses'>\n delete?: Array<'operationId' | 'summary' | 'description' | 'parameters' | 'requestBody' | 'responses'>\n parameters?: Array<'name' | 'in' | 'description' | 'required' | 'schema'>\n requestBody?: Array<'description' | 'required' | 'content'>\n responses?: Array<'description' | 'headers' | 'content' | 'links'>\n content?: Array<string>\n components?: Array<'parameters' | 'schemas'>\n schema?: Array<'description' | 'type' | 'items' | 'properties' | 'format' | 'example' | 'default'>\n schemas?: Array<'description' | 'type' | 'items' | 'properties' | 'format' | 'example' | 'default'>\n properties?: Array<'description' | 'type' | 'items' | 'format' | 'example' | 'default' | 'enum'>\n }\n filterSet?: {\n methods?: Array<'get' | 'post' | 'put' | 'patch' | 'delete' | 'options' | 'trace' | 'head' | 'parameters'>\n inverseMethods?: Array<'get' | 'post' | 'put' | 'patch' | 'delete' | 'options' | 'trace' | 'head' | 'parameters'>\n tags?: Array<string>\n inverseTags?: Array<string>\n operationIds?: Array<string>\n inverseOperationIds?: Array<string>\n operations?: Array<string>\n flags?: Array<string>\n inverseFlags?: Array<string>\n flagValues?: Array<string>\n inverseFlagValues?: Array<string>\n stripFlags?: Array<string>\n responseContent?: Array<string>\n inverseResponseContent?: Array<string>\n unusedComponents?: Array<'requestBodies' | 'schemas' | 'parameters' | 'responses'>\n }\n sortComponentsSet?: {}\n casingSet?: {}\n}\n\nexport async function parse(pathOrApi: string | OASDocument, options: FormatOptions = {}, oasClass: typeof Oas = Oas): Promise<Oas> {\n if (typeof pathOrApi === 'string') {\n // resolve external refs\n const config = await loadConfig()\n const bundleResults = await bundle({ ref: pathOrApi, config, base: pathOrApi })\n\n return parse(bundleResults.bundle.parsed, options)\n }\n\n const oasNormalize = new OASNormalize(pathOrApi, {\n enablePaths: true,\n colorizeErrors: true,\n })\n const document = (await oasNormalize.load()) as OpenAPI.Document\n\n if (isOpenApiV2Document(document)) {\n const { openapi } = await swagger2openapi.convertObj(document, {\n anchors: true,\n })\n\n const oas = await filterAndSort(openapi as OASDocument, options)\n\n return new oasClass({ oas: oas as OASDocument })\n }\n\n const oas = await filterAndSort(document as OASDocument, options)\n\n return new oasClass({ oas })\n}\n"],"mappings":";;;;;;;AAAA,OAAO,kBAAkB;AACzB,OAAO,qBAAqB;AAC5B,SAAS,QAAQ,kBAAkB;AAkDnC,eAAsB,MAAM,WAAiC,UAAyB,CAAC,GAAG,WAAuB,KAAmB;AAClI,MAAI,OAAO,cAAc,UAAU;AAEjC,UAAM,SAAS,MAAM,WAAW;AAChC,UAAM,gBAAgB,MAAM,OAAO,EAAE,KAAK,WAAW,QAAQ,MAAM,UAAU,CAAC;AAE9E,WAAO,MAAM,cAAc,OAAO,QAAQ,OAAO;AAAA,EACnD;AAEA,QAAM,eAAe,IAAI,aAAa,WAAW;AAAA,IAC/C,aAAa;AAAA,IACb,gBAAgB;AAAA,EAClB,CAAC;AACD,QAAM,WAAY,MAAM,aAAa,KAAK;AAE1C,MAAI,oBAAoB,QAAQ,GAAG;AACjC,UAAM,EAAE,QAAQ,IAAI,MAAM,gBAAgB,WAAW,UAAU;AAAA,MAC7D,SAAS;AAAA,IACX,CAAC;AAED,UAAMA,OAAM,MAAM,cAAc,SAAwB,OAAO;AAE/D,WAAO,IAAI,SAAS,EAAE,KAAKA,KAAmB,CAAC;AAAA,EACjD;AAEA,QAAM,MAAM,MAAM,cAAc,UAAyB,OAAO;AAEhE,SAAO,IAAI,SAAS,EAAE,IAAI,CAAC;AAC7B;","names":["oas"]}
1
+ {"version":3,"sources":["../src/parser/index.ts"],"names":["oas"],"mappings":";;;;;AAoDA,eAAsB,MAAM,SAAiC,EAAA,OAAA,GAAyB,EAAC,EAAG,WAAuB,GAAmB,EAAA;AAClI,EAAI,IAAA,OAAO,cAAc,QAAU,EAAA;AAEjC,IAAM,MAAA,MAAA,GAAS,MAAM,UAAW,EAAA,CAAA;AAChC,IAAM,MAAA,aAAA,GAAgB,MAAM,MAAO,CAAA,EAAE,KAAK,SAAW,EAAA,MAAA,EAAQ,IAAM,EAAA,SAAA,EAAW,CAAA,CAAA;AAE9E,IAAA,OAAO,KAAM,CAAA,aAAA,CAAc,MAAO,CAAA,MAAA,EAAQ,OAAO,CAAA,CAAA;AAAA,GACnD;AAEA,EAAM,MAAA,YAAA,GAAe,IAAI,YAAA,CAAa,SAAW,EAAA;AAAA,IAC/C,WAAa,EAAA,IAAA;AAAA,IACb,cAAgB,EAAA,IAAA;AAAA,GACjB,CAAA,CAAA;AACD,EAAM,MAAA,QAAA,GAAY,MAAM,YAAA,CAAa,IAAK,EAAA,CAAA;AAE1C,EAAI,IAAA,mBAAA,CAAoB,QAAQ,CAAG,EAAA;AACjC,IAAA,MAAM,EAAE,OAAQ,EAAA,GAAI,MAAM,eAAA,CAAgB,WAAW,QAAU,EAAA;AAAA,MAC7D,OAAS,EAAA,IAAA;AAAA,KACV,CAAA,CAAA;AAED,IAAA,MAAMA,IAAM,GAAA,MAAM,aAAc,CAAA,OAAA,EAAwB,OAAO,CAAA,CAAA;AAE/D,IAAA,OAAO,IAAI,QAAA,CAAS,EAAE,GAAA,EAAKA,MAAoB,CAAA,CAAA;AAAA,GACjD;AAEA,EAAA,MAAM,GAAM,GAAA,MAAM,aAAc,CAAA,QAAA,EAAyB,OAAO,CAAA,CAAA;AAEhE,EAAA,OAAO,IAAI,QAAA,CAAS,EAAE,GAAA,EAAK,CAAA,CAAA;AAC7B","file":"parser.js","sourcesContent":["import { bundle, loadConfig } from '@redocly/openapi-core'\nimport OASNormalize from 'oas-normalize'\nimport swagger2openapi from 'swagger2openapi'\n\nimport { Oas } from '../Oas.ts'\nimport { filterAndSort, isOpenApiV2Document } from '../utils.ts'\n\nimport type { OASDocument } from 'oas/types'\nimport type { OpenAPI } from 'openapi-types'\n\nexport type FormatOptions = {\n verbose?: boolean\n 'no-sort'?: boolean\n sort?: boolean\n output?: string\n sortSet?: {\n root?: Array<'openapi' | 'info' | 'servers' | 'paths' | 'components' | 'tags' | 'x-tagGroups' | 'externalDocs'>\n get?: Array<'operationId' | 'summary' | 'description' | 'parameters' | 'requestBody' | 'responses'>\n post?: Array<'operationId' | 'summary' | 'description' | 'parameters' | 'requestBody' | 'responses'>\n put?: Array<'operationId' | 'summary' | 'description' | 'parameters' | 'requestBody' | 'responses'>\n patch?: Array<'operationId' | 'summary' | 'description' | 'parameters' | 'requestBody' | 'responses'>\n delete?: Array<'operationId' | 'summary' | 'description' | 'parameters' | 'requestBody' | 'responses'>\n parameters?: Array<'name' | 'in' | 'description' | 'required' | 'schema'>\n requestBody?: Array<'description' | 'required' | 'content'>\n responses?: Array<'description' | 'headers' | 'content' | 'links'>\n content?: Array<string>\n components?: Array<'parameters' | 'schemas'>\n schema?: Array<'description' | 'type' | 'items' | 'properties' | 'format' | 'example' | 'default'>\n schemas?: Array<'description' | 'type' | 'items' | 'properties' | 'format' | 'example' | 'default'>\n properties?: Array<'description' | 'type' | 'items' | 'format' | 'example' | 'default' | 'enum'>\n }\n filterSet?: {\n methods?: Array<'get' | 'post' | 'put' | 'patch' | 'delete' | 'options' | 'trace' | 'head' | 'parameters'>\n inverseMethods?: Array<'get' | 'post' | 'put' | 'patch' | 'delete' | 'options' | 'trace' | 'head' | 'parameters'>\n tags?: Array<string>\n inverseTags?: Array<string>\n operationIds?: Array<string>\n inverseOperationIds?: Array<string>\n operations?: Array<string>\n flags?: Array<string>\n inverseFlags?: Array<string>\n flagValues?: Array<string>\n inverseFlagValues?: Array<string>\n stripFlags?: Array<string>\n responseContent?: Array<string>\n inverseResponseContent?: Array<string>\n unusedComponents?: Array<'requestBodies' | 'schemas' | 'parameters' | 'responses'>\n }\n sortComponentsSet?: {}\n casingSet?: {}\n}\n\nexport async function parse(pathOrApi: string | OASDocument, options: FormatOptions = {}, oasClass: typeof Oas = Oas): Promise<Oas> {\n if (typeof pathOrApi === 'string') {\n // resolve external refs\n const config = await loadConfig()\n const bundleResults = await bundle({ ref: pathOrApi, config, base: pathOrApi })\n\n return parse(bundleResults.bundle.parsed, options)\n }\n\n const oasNormalize = new OASNormalize(pathOrApi, {\n enablePaths: true,\n colorizeErrors: true,\n })\n const document = (await oasNormalize.load()) as OpenAPI.Document\n\n if (isOpenApiV2Document(document)) {\n const { openapi } = await swagger2openapi.convertObj(document, {\n anchors: true,\n })\n\n const oas = await filterAndSort(openapi as OASDocument, options)\n\n return new oasClass({ oas: oas as OASDocument })\n }\n\n const oas = await filterAndSort(document as OASDocument, options)\n\n return new oasClass({ oas })\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/oas",
3
- "version": "3.0.0-alpha.2",
3
+ "version": "3.0.0-alpha.21",
4
4
  "description": "Oas helpers",
5
5
  "keywords": [
6
6
  "typescript",
@@ -28,6 +28,11 @@
28
28
  "require": "./dist/parser.cjs",
29
29
  "default": "./dist/parser.cjs"
30
30
  },
31
+ "./infer": {
32
+ "import": "./dist/infer.js",
33
+ "require": "./dist/infer.cjs",
34
+ "default": "./dist/infer.cjs"
35
+ },
31
36
  "./package.json": "./package.json",
32
37
  "./*": "./*"
33
38
  },
@@ -38,6 +43,9 @@
38
43
  "*": {
39
44
  "parser": [
40
45
  "./dist/parser.d.ts"
46
+ ],
47
+ "infer": [
48
+ "./dist/infer.d.ts"
41
49
  ]
42
50
  }
43
51
  },
@@ -48,14 +56,14 @@
48
56
  "!/**/__tests__/**"
49
57
  ],
50
58
  "dependencies": {
51
- "@redocly/openapi-core": "^1.21.0",
59
+ "@redocly/openapi-core": "^1.25.3",
52
60
  "hotscript": "^1.0.13",
53
- "json-schema-to-ts": "^3.1.0",
54
- "oas": "^24.6.0",
55
- "oas-normalize": "^11.1.1",
56
- "openapi-format": "^1.22.3",
61
+ "json-schema-to-ts": "^3.1.1",
62
+ "oas": "^24.9.0",
63
+ "oas-normalize": "^11.1.2",
64
+ "openapi-format": "^1.23.2",
57
65
  "openapi-types": "^12.1.3",
58
- "remeda": "^2.11.0",
66
+ "remeda": "^2.14.0",
59
67
  "swagger2openapi": "^7.0.8",
60
68
  "ts-toolbelt": "^9.6.0"
61
69
  },
@@ -63,11 +71,10 @@
63
71
  "@stoplight/yaml": "^4.3.0",
64
72
  "@types/swagger2openapi": "^7.0.4",
65
73
  "expect-type": "^0.19.0",
66
- "tsup": "^8.2.4",
67
- "typescript": "^5.5.4",
68
- "@kubb/config-biome": "3.0.0-alpha.2",
69
- "@kubb/config-ts": "3.0.0-alpha.2",
70
- "@kubb/config-tsup": "3.0.0-alpha.2"
74
+ "tsup": "^8.3.0",
75
+ "typescript": "^5.6.2",
76
+ "@kubb/config-ts": "3.0.0-alpha.21",
77
+ "@kubb/config-tsup": "3.0.0-alpha.21"
71
78
  },
72
79
  "engines": {
73
80
  "node": ">=20"
package/src/Oas.ts CHANGED
@@ -194,11 +194,10 @@ export class Oas<const TOAS = unknown> extends BaseOas {
194
194
  })
195
195
 
196
196
  await oasNormalize.validate({
197
+ convertToLatest: true,
197
198
  parser: {
198
199
  validate: {
199
200
  colorizeErrors: true,
200
- schema: false,
201
- spec: false,
202
201
  },
203
202
  },
204
203
  })
@@ -1,6 +1,6 @@
1
+ import { bundle, loadConfig } from '@redocly/openapi-core'
1
2
  import OASNormalize from 'oas-normalize'
2
3
  import swagger2openapi from 'swagger2openapi'
3
- import { bundle, loadConfig } from '@redocly/openapi-core'
4
4
 
5
5
  import { Oas } from '../Oas.ts'
6
6
  import { filterAndSort, isOpenApiV2Document } from '../utils.ts'