@redocly/openapi-core 1.17.1 → 1.18.1
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/CHANGELOG.md +20 -0
- package/lib/bundle.d.ts +1 -1
- package/lib/bundle.js +16 -2
- package/lib/config/all.js +6 -0
- package/lib/config/builtIn.js +10 -2
- package/lib/config/config-resolvers.js +15 -4
- package/lib/config/config.d.ts +2 -2
- package/lib/config/config.js +15 -0
- package/lib/config/load.d.ts +1 -2
- package/lib/config/minimal.js +8 -0
- package/lib/config/recommended-strict.js +8 -0
- package/lib/config/recommended.js +8 -0
- package/lib/config/types.d.ts +10 -4
- package/lib/config/utils.js +13 -1
- package/lib/decorators/arazzo/index.d.ts +1 -0
- package/lib/decorators/arazzo/index.js +4 -0
- package/lib/decorators/async2/index.d.ts +1 -0
- package/lib/decorators/async2/index.js +4 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +4 -2
- package/lib/oas-types.d.ts +13 -8
- package/lib/oas-types.js +10 -0
- package/lib/rules/arazzo/index.d.ts +3 -0
- package/lib/rules/arazzo/index.js +10 -0
- package/lib/rules/common/path-segment-plural.js +2 -1
- package/lib/rules/common/spec.d.ts +2 -2
- package/lib/types/arazzo.d.ts +2276 -0
- package/lib/types/arazzo.js +386 -0
- package/lib/types/asyncapi.js +17 -43
- package/lib/types/oas3.js +0 -8
- package/lib/types/oas3_1.js +2 -2
- package/lib/types/redocly-yaml.d.ts +4 -4
- package/lib/types/redocly-yaml.js +15 -5
- package/lib/typings/arazzo.d.ts +30 -0
- package/lib/typings/arazzo.js +2 -0
- package/lib/utils.d.ts +8 -4
- package/lib/utils.js +38 -7
- package/lib/visitors.d.ts +11 -0
- package/package.json +3 -2
- package/src/__tests__/lint.test.ts +0 -50
- package/src/bundle.ts +15 -3
- package/src/config/__tests__/__snapshots__/config-resolvers.test.ts.snap +20 -0
- package/src/config/__tests__/__snapshots__/config.test.ts.snap +3 -0
- package/src/config/__tests__/config.test.ts +6 -0
- package/src/config/all.ts +6 -0
- package/src/config/builtIn.ts +10 -2
- package/src/config/config-resolvers.ts +17 -3
- package/src/config/config.ts +17 -0
- package/src/config/load.ts +1 -2
- package/src/config/minimal.ts +8 -0
- package/src/config/recommended-strict.ts +8 -0
- package/src/config/recommended.ts +8 -0
- package/src/config/types.ts +15 -2
- package/src/config/utils.ts +15 -0
- package/src/decorators/arazzo/index.ts +1 -0
- package/src/decorators/async2/index.ts +1 -0
- package/src/index.ts +1 -0
- package/src/oas-types.ts +25 -4
- package/src/rules/arazzo/index.ts +11 -0
- package/src/rules/common/__tests__/spec.test.ts +47 -0
- package/src/rules/common/no-invalid-schema-examples.ts +3 -2
- package/src/rules/common/path-segment-plural.ts +3 -2
- package/src/rules/common/spec.ts +2 -2
- package/src/types/arazzo.ts +391 -0
- package/src/types/asyncapi.ts +22 -43
- package/src/types/oas3.ts +0 -7
- package/src/types/oas3_1.ts +2 -2
- package/src/types/redocly-yaml.ts +18 -8
- package/src/typings/arazzo.ts +44 -0
- package/src/utils.ts +41 -8
- package/src/visitors.ts +18 -0
- package/tsconfig.tsbuildinfo +1 -1
package/src/utils.ts
CHANGED
|
@@ -2,14 +2,14 @@ import * as fs from 'fs';
|
|
|
2
2
|
import { extname } from 'path';
|
|
3
3
|
import * as minimatch from 'minimatch';
|
|
4
4
|
import fetch from 'node-fetch';
|
|
5
|
-
import * as pluralize from 'pluralize';
|
|
6
5
|
import { parseYaml } from './js-yaml';
|
|
7
|
-
import { UserContext } from './walk';
|
|
8
6
|
import { env } from './env';
|
|
9
7
|
import { logger, colorize } from './logger';
|
|
10
|
-
import { HttpResolveConfig } from './config';
|
|
11
8
|
import { HttpsProxyAgent } from 'https-proxy-agent';
|
|
12
9
|
|
|
10
|
+
import type { HttpResolveConfig } from './config';
|
|
11
|
+
import type { UserContext } from './walk';
|
|
12
|
+
|
|
13
13
|
export { parseYaml, stringifyYaml } from './js-yaml';
|
|
14
14
|
|
|
15
15
|
export type StackFrame<T> = {
|
|
@@ -146,10 +146,6 @@ export function validateMimeTypeOAS3(
|
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
-
export function isSingular(path: string) {
|
|
150
|
-
return pluralize.isSingular(path);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
149
|
export function readFileAsStringSync(filePath: string) {
|
|
154
150
|
return fs.readFileSync(filePath, 'utf-8');
|
|
155
151
|
}
|
|
@@ -267,7 +263,7 @@ export function pickDefined<T extends Record<string, unknown>>(
|
|
|
267
263
|
}
|
|
268
264
|
|
|
269
265
|
export function nextTick() {
|
|
270
|
-
new Promise((resolve) => {
|
|
266
|
+
return new Promise((resolve) => {
|
|
271
267
|
setTimeout(resolve);
|
|
272
268
|
});
|
|
273
269
|
}
|
|
@@ -284,3 +280,40 @@ export function getProxyAgent() {
|
|
|
284
280
|
const proxy = process.env.HTTPS_PROXY || process.env.HTTP_PROXY;
|
|
285
281
|
return proxy ? new HttpsProxyAgent(proxy) : undefined;
|
|
286
282
|
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Checks if two objects are deeply equal.
|
|
286
|
+
* Borrowed the source code from https://github.com/lukeed/dequal.
|
|
287
|
+
*/
|
|
288
|
+
export function dequal(foo: any, bar: any): boolean {
|
|
289
|
+
let ctor, len;
|
|
290
|
+
if (foo === bar) return true;
|
|
291
|
+
|
|
292
|
+
if (foo && bar && (ctor = foo.constructor) === bar.constructor) {
|
|
293
|
+
if (ctor === Date) return foo.getTime() === bar.getTime();
|
|
294
|
+
if (ctor === RegExp) return foo.toString() === bar.toString();
|
|
295
|
+
|
|
296
|
+
if (ctor === Array) {
|
|
297
|
+
if ((len = foo.length) === bar.length) {
|
|
298
|
+
while (len-- && dequal(foo[len], bar[len]));
|
|
299
|
+
}
|
|
300
|
+
return len === -1;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
if (!ctor || typeof foo === 'object') {
|
|
304
|
+
len = 0;
|
|
305
|
+
for (ctor in foo) {
|
|
306
|
+
if (
|
|
307
|
+
Object.prototype.hasOwnProperty.call(foo, ctor) &&
|
|
308
|
+
++len &&
|
|
309
|
+
!Object.prototype.hasOwnProperty.call(bar, ctor)
|
|
310
|
+
)
|
|
311
|
+
return false;
|
|
312
|
+
if (!(ctor in bar) || !dequal(foo[ctor], bar[ctor])) return false;
|
|
313
|
+
}
|
|
314
|
+
return Object.keys(bar).length === len;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
return foo !== foo && bar !== bar;
|
|
319
|
+
}
|
package/src/visitors.ts
CHANGED
|
@@ -50,6 +50,7 @@ import type {
|
|
|
50
50
|
Oas2SecurityScheme,
|
|
51
51
|
} from './typings/swagger';
|
|
52
52
|
import type { Async2Definition } from './typings/asyncapi';
|
|
53
|
+
import type { ArazzoDefinition } from './typings/arazzo';
|
|
53
54
|
|
|
54
55
|
export type SkipFunctionContext = Pick<
|
|
55
56
|
UserContext,
|
|
@@ -212,6 +213,10 @@ type Async2FlatVisitor = {
|
|
|
212
213
|
Root?: VisitFunctionOrObject<Async2Definition>;
|
|
213
214
|
};
|
|
214
215
|
|
|
216
|
+
type ArazzoFlatVisitor = {
|
|
217
|
+
Root?: VisitFunctionOrObject<ArazzoDefinition>;
|
|
218
|
+
};
|
|
219
|
+
|
|
215
220
|
const legacyTypesMap = {
|
|
216
221
|
Root: 'DefinitionRoot',
|
|
217
222
|
ServerVariablesMap: 'ServerVariableMap',
|
|
@@ -244,6 +249,12 @@ type Async2NestedVisitor = {
|
|
|
244
249
|
: Async2FlatVisitor[T] & NestedVisitor<Async2NestedVisitor>;
|
|
245
250
|
};
|
|
246
251
|
|
|
252
|
+
type ArazzoNestedVisitor = {
|
|
253
|
+
[T in keyof ArazzoFlatVisitor]: ArazzoFlatVisitor[T] extends Function
|
|
254
|
+
? ArazzoFlatVisitor[T]
|
|
255
|
+
: ArazzoFlatVisitor[T] & NestedVisitor<ArazzoNestedVisitor>;
|
|
256
|
+
};
|
|
257
|
+
|
|
247
258
|
export type Oas3Visitor = BaseVisitor &
|
|
248
259
|
Oas3NestedVisitor &
|
|
249
260
|
Record<string, VisitFunction<any> | NestedVisitObject<any, Oas3NestedVisitor>>;
|
|
@@ -256,6 +267,10 @@ export type Async2Visitor = BaseVisitor &
|
|
|
256
267
|
Async2NestedVisitor &
|
|
257
268
|
Record<string, VisitFunction<any> | NestedVisitObject<any, Async2NestedVisitor>>;
|
|
258
269
|
|
|
270
|
+
export type ArazzoVisitor = BaseVisitor &
|
|
271
|
+
ArazzoNestedVisitor &
|
|
272
|
+
Record<string, VisitFunction<any> | NestedVisitObject<any, ArazzoNestedVisitor>>;
|
|
273
|
+
|
|
259
274
|
export type NestedVisitor<T> = Exclude<T, 'any' | 'ref' | 'Root'>;
|
|
260
275
|
|
|
261
276
|
export type NormalizedOasVisitors<T extends BaseVisitor> = {
|
|
@@ -278,12 +293,15 @@ export type NormalizedOasVisitors<T extends BaseVisitor> = {
|
|
|
278
293
|
export type Oas3Rule = (options: Record<string, any>) => Oas3Visitor | Oas3Visitor[];
|
|
279
294
|
export type Oas2Rule = (options: Record<string, any>) => Oas2Visitor | Oas2Visitor[];
|
|
280
295
|
export type Async2Rule = (options: Record<string, any>) => Async2Visitor | Async2Visitor[];
|
|
296
|
+
export type ArazzoRule = (options: Record<string, any>) => ArazzoVisitor | ArazzoVisitor[];
|
|
281
297
|
export type Oas3Preprocessor = (options: Record<string, any>) => Oas3Visitor;
|
|
282
298
|
export type Oas2Preprocessor = (options: Record<string, any>) => Oas2Visitor;
|
|
283
299
|
export type Async2Preprocessor = (options: Record<string, any>) => Async2Visitor;
|
|
300
|
+
export type ArazzoPreprocessor = (options: Record<string, any>) => ArazzoVisitor;
|
|
284
301
|
export type Oas3Decorator = (options: Record<string, any>) => Oas3Visitor;
|
|
285
302
|
export type Oas2Decorator = (options: Record<string, any>) => Oas2Visitor;
|
|
286
303
|
export type Async2Decorator = (options: Record<string, any>) => Async2Visitor;
|
|
304
|
+
export type ArazzoDecorator = (options: Record<string, any>) => ArazzoVisitor;
|
|
287
305
|
|
|
288
306
|
// alias for the latest version supported
|
|
289
307
|
// every time we update it - consider semver
|