@redocly/openapi-core 0.0.0-snapshot.1750229202 → 0.0.0-snapshot.1750261968
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/README.md +1 -9
- package/lib/benchmark/benches/lint-with-many-rules.bench.d.ts +5 -0
- package/lib/benchmark/benches/lint-with-many-rules.bench.d.ts.map +1 -0
- package/lib/benchmark/benches/lint-with-many-rules.bench.js +36 -0
- package/lib/benchmark/benches/lint-with-many-rules.bench.js.map +1 -0
- package/lib/benchmark/benches/lint-with-nested-rule.bench.d.ts +5 -0
- package/lib/benchmark/benches/lint-with-nested-rule.bench.d.ts.map +1 -0
- package/lib/benchmark/benches/lint-with-nested-rule.bench.js +40 -0
- package/lib/benchmark/benches/lint-with-nested-rule.bench.js.map +1 -0
- package/lib/benchmark/benches/lint-with-no-rules.bench.d.ts +5 -0
- package/lib/benchmark/benches/lint-with-no-rules.bench.d.ts.map +1 -0
- package/lib/benchmark/benches/lint-with-no-rules.bench.js +21 -0
- package/lib/benchmark/benches/lint-with-no-rules.bench.js.map +1 -0
- package/lib/benchmark/benches/lint-with-top-level-rule-report.bench.d.ts +5 -0
- package/lib/benchmark/benches/lint-with-top-level-rule-report.bench.d.ts.map +1 -0
- package/lib/benchmark/benches/lint-with-top-level-rule-report.bench.js +33 -0
- package/lib/benchmark/benches/lint-with-top-level-rule-report.bench.js.map +1 -0
- package/lib/benchmark/benches/lint-with-top-level-rule.bench.d.ts +5 -0
- package/lib/benchmark/benches/lint-with-top-level-rule.bench.d.ts.map +1 -0
- package/lib/benchmark/benches/lint-with-top-level-rule.bench.js +32 -0
- package/lib/benchmark/benches/lint-with-top-level-rule.bench.js.map +1 -0
- package/lib/benchmark/benches/recommended-oas3.bench.d.ts +4 -0
- package/lib/benchmark/benches/recommended-oas3.bench.d.ts.map +1 -0
- package/lib/benchmark/benches/recommended-oas3.bench.js +18 -0
- package/lib/benchmark/benches/recommended-oas3.bench.js.map +1 -0
- package/lib/benchmark/benches/resolve-with-no-external.bench.d.ts +4 -0
- package/lib/benchmark/benches/resolve-with-no-external.bench.d.ts.map +1 -0
- package/lib/benchmark/benches/resolve-with-no-external.bench.js +19 -0
- package/lib/benchmark/benches/resolve-with-no-external.bench.js.map +1 -0
- package/lib/benchmark/utils.d.ts +7 -0
- package/lib/benchmark/utils.d.ts.map +1 -0
- package/lib/benchmark/utils.js +31 -0
- package/lib/benchmark/utils.js.map +1 -0
- package/lib/bundle.d.ts +5 -7
- package/lib/bundle.d.ts.map +1 -1
- package/lib/bundle.js +84 -20
- package/lib/bundle.js.map +1 -1
- package/lib/config/all.d.ts +2 -2
- package/lib/config/all.d.ts.map +1 -1
- package/lib/config/all.js.map +1 -1
- package/lib/config/builtIn.d.ts +2 -2
- package/lib/config/builtIn.d.ts.map +1 -1
- package/lib/config/builtIn.js.map +1 -1
- package/lib/config/config-resolvers.d.ts +12 -15
- package/lib/config/config-resolvers.d.ts.map +1 -1
- package/lib/config/config-resolvers.js +236 -185
- package/lib/config/config-resolvers.js.map +1 -1
- package/lib/config/config.d.ts +14 -16
- package/lib/config/config.d.ts.map +1 -1
- package/lib/config/config.js +45 -68
- package/lib/config/config.js.map +1 -1
- package/lib/config/load.d.ts +9 -6
- package/lib/config/load.d.ts.map +1 -1
- package/lib/config/load.js +38 -20
- package/lib/config/load.js.map +1 -1
- package/lib/config/minimal.d.ts +2 -2
- package/lib/config/minimal.d.ts.map +1 -1
- package/lib/config/minimal.js.map +1 -1
- package/lib/config/recommended-strict.d.ts +2 -2
- package/lib/config/recommended-strict.d.ts.map +1 -1
- package/lib/config/recommended-strict.js.map +1 -1
- package/lib/config/recommended.d.ts +2 -2
- package/lib/config/recommended.d.ts.map +1 -1
- package/lib/config/recommended.js.map +1 -1
- package/lib/config/rules.d.ts +2 -2
- package/lib/config/rules.d.ts.map +1 -1
- package/lib/config/rules.js.map +1 -1
- package/lib/config/spec.d.ts +2 -2
- package/lib/config/spec.d.ts.map +1 -1
- package/lib/config/spec.js +1 -1
- package/lib/config/spec.js.map +1 -1
- package/lib/config/types.d.ts +33 -14
- package/lib/config/types.d.ts.map +1 -1
- package/lib/config/utils.d.ts +6 -4
- package/lib/config/utils.d.ts.map +1 -1
- package/lib/config/utils.js +95 -2
- package/lib/config/utils.js.map +1 -1
- package/lib/index.d.ts +2 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/lint.d.ts +2 -5
- package/lib/lint.d.ts.map +1 -1
- package/lib/lint.js +10 -10
- package/lib/lint.js.map +1 -1
- package/lib/oas-types.d.ts.map +1 -1
- package/lib/oas-types.js +0 -1
- package/lib/oas-types.js.map +1 -1
- package/lib/resolve.d.ts.map +1 -1
- package/lib/resolve.js +4 -2
- package/lib/resolve.js.map +1 -1
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/index.js.map +1 -1
- package/lib/types/redocly-yaml.d.ts +1 -0
- package/lib/types/redocly-yaml.d.ts.map +1 -1
- package/lib/types/redocly-yaml.js +58 -33
- package/lib/types/redocly-yaml.js.map +1 -1
- package/lib/utils.d.ts +2 -1
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +11 -1
- package/lib/utils.js.map +1 -1
- package/lib/walk.d.ts.map +1 -1
- package/lib/walk.js +7 -2
- package/lib/walk.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -164,7 +164,7 @@ it tries to find `redocly.yaml` in the current working directory.
|
|
|
164
164
|
async function loadConfig(options?: {
|
|
165
165
|
// optional path to the config file for resolving $refs and proper error locations
|
|
166
166
|
configPath?: string;
|
|
167
|
-
// allows to add custom `extends`
|
|
167
|
+
// allows to add custom `extends` additionally to one from the config file
|
|
168
168
|
customExtends?: string[];
|
|
169
169
|
}): Promise<Config>;
|
|
170
170
|
```
|
|
@@ -179,8 +179,6 @@ async function lint(options: {
|
|
|
179
179
|
ref: string;
|
|
180
180
|
// config object
|
|
181
181
|
config: Config;
|
|
182
|
-
// optional alias for an API
|
|
183
|
-
alias?: string;
|
|
184
182
|
}): Promise<NormalizedProblem[]>;
|
|
185
183
|
```
|
|
186
184
|
|
|
@@ -196,8 +194,6 @@ async function lintFromString(options: {
|
|
|
196
194
|
absoluteRef?: string;
|
|
197
195
|
// config object
|
|
198
196
|
config: Config;
|
|
199
|
-
// optional alias for an API
|
|
200
|
-
alias?: string;
|
|
201
197
|
}): Promise<NormalizedProblem[]>;
|
|
202
198
|
```
|
|
203
199
|
|
|
@@ -211,8 +207,6 @@ async function bundle(options: {
|
|
|
211
207
|
ref: string;
|
|
212
208
|
// config object
|
|
213
209
|
config: Config;
|
|
214
|
-
// optional alias for an API
|
|
215
|
-
alias?: string;
|
|
216
210
|
// whether to fully dereference $refs, resulting document won't have any $ref
|
|
217
211
|
// warning: this can produce circular objects
|
|
218
212
|
dereference?: boolean;
|
|
@@ -245,8 +239,6 @@ async function bundleFromString(options: {
|
|
|
245
239
|
absoluteRef?: string;
|
|
246
240
|
// config object
|
|
247
241
|
config: Config;
|
|
248
|
-
// optional alias for an API
|
|
249
|
-
alias?: string;
|
|
250
242
|
// whether to fully dereference $refs, resulting document won't have any $ref
|
|
251
243
|
// warning: this can produce circular objects
|
|
252
244
|
dereference?: boolean;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const name = "Validate with 50 top-level rules";
|
|
2
|
+
export declare const count = 10;
|
|
3
|
+
export declare function setupAsync(): Promise<void>;
|
|
4
|
+
export declare function measureAsync(): Promise<import("../../walk.js").NormalizedProblem[]>;
|
|
5
|
+
//# sourceMappingURL=lint-with-many-rules.bench.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lint-with-many-rules.bench.d.ts","sourceRoot":"","sources":["../../../src/benchmark/benches/lint-with-many-rules.bench.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,IAAI,qCAAqC,CAAC;AACvD,eAAO,MAAM,KAAK,KAAK,CAAC;AAqBxB,wBAAsB,UAAU,kBAE/B;AAED,wBAAgB,YAAY,yDAM3B"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
import { lintDocument } from '../../lint.js';
|
|
4
|
+
import { BaseResolver } from '../../resolve.js';
|
|
5
|
+
import { parseYamlToDocument, makeConfigForRuleset } from '../utils.js';
|
|
6
|
+
import url from 'node:url';
|
|
7
|
+
const __internalDirname = path.dirname(url.fileURLToPath(import.meta.url ?? __dirname));
|
|
8
|
+
export const name = 'Validate with 50 top-level rules';
|
|
9
|
+
export const count = 10;
|
|
10
|
+
const rebillyDefinitionRef = path.resolve(path.join(__internalDirname, 'rebilly.yaml'));
|
|
11
|
+
const rebillyDocument = parseYamlToDocument(fs.readFileSync(rebillyDefinitionRef, 'utf-8'), rebillyDefinitionRef);
|
|
12
|
+
const ruleset = {};
|
|
13
|
+
for (let i = 0; i < 50; i++) {
|
|
14
|
+
ruleset['rule-' + i] = () => {
|
|
15
|
+
let count = 0;
|
|
16
|
+
return {
|
|
17
|
+
Schema() {
|
|
18
|
+
count++;
|
|
19
|
+
if (count === -1)
|
|
20
|
+
throw new Error('Disable optimization');
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
let config;
|
|
26
|
+
export async function setupAsync() {
|
|
27
|
+
config = await makeConfigForRuleset(ruleset);
|
|
28
|
+
}
|
|
29
|
+
export function measureAsync() {
|
|
30
|
+
return lintDocument({
|
|
31
|
+
externalRefResolver: new BaseResolver(),
|
|
32
|
+
document: rebillyDocument,
|
|
33
|
+
config,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=lint-with-many-rules.bench.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lint-with-many-rules.bench.js","sourceRoot":"","sources":["../../../src/benchmark/benches/lint-with-many-rules.bench.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,GAAG,MAAM,UAAU,CAAC;AAI3B,MAAM,iBAAiB,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,SAAS,CAAC,CAAC,CAAC;AAExF,MAAM,CAAC,MAAM,IAAI,GAAG,kCAAkC,CAAC;AACvD,MAAM,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;AACxB,MAAM,oBAAoB,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,cAAc,CAAC,CAAC,CAAC;AACxF,MAAM,eAAe,GAAG,mBAAmB,CACzC,EAAE,CAAC,YAAY,CAAC,oBAAoB,EAAE,OAAO,CAAC,EAC9C,oBAAoB,CACrB,CAAC;AAEF,MAAM,OAAO,GAAQ,EAAE,CAAC;AACxB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;IAC5B,OAAO,CAAC,OAAO,GAAG,CAAC,CAAC,GAAG,GAAG,EAAE;QAC1B,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,OAAO;YACL,MAAM;gBACJ,KAAK,EAAE,CAAC;gBACR,IAAI,KAAK,KAAK,CAAC,CAAC;oBAAE,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;YAC5D,CAAC;SACF,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAED,IAAI,MAAwB,CAAC;AAC7B,MAAM,CAAC,KAAK,UAAU,UAAU;IAC9B,MAAM,GAAG,MAAM,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAC/C,CAAC;AAED,MAAM,UAAU,YAAY;IAC1B,OAAO,YAAY,CAAC;QAClB,mBAAmB,EAAE,IAAI,YAAY,EAAE;QACvC,QAAQ,EAAE,eAAe;QACzB,MAAM;KACP,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const name = "Validate with single nested rule";
|
|
2
|
+
export declare const count = 10;
|
|
3
|
+
export declare function setupAsync(): Promise<void>;
|
|
4
|
+
export declare function measureAsync(): Promise<import("../../walk.js").NormalizedProblem[]>;
|
|
5
|
+
//# sourceMappingURL=lint-with-nested-rule.bench.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lint-with-nested-rule.bench.d.ts","sourceRoot":"","sources":["../../../src/benchmark/benches/lint-with-nested-rule.bench.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,IAAI,qCAAqC,CAAC;AACvD,eAAO,MAAM,KAAK,KAAK,CAAC;AAyBxB,wBAAsB,UAAU,kBAE/B;AAED,wBAAgB,YAAY,yDAM3B"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { readFileSync } from 'fs';
|
|
2
|
+
import { join as pathJoin, resolve as pathResolve } from 'path';
|
|
3
|
+
import { lintDocument } from '../../lint.js';
|
|
4
|
+
import { BaseResolver } from '../../resolve.js';
|
|
5
|
+
import { parseYamlToDocument, makeConfigForRuleset } from '../utils.js';
|
|
6
|
+
export const name = 'Validate with single nested rule';
|
|
7
|
+
export const count = 10;
|
|
8
|
+
const rebillyDefinitionRef = pathResolve(pathJoin(__dirname, 'rebilly.yaml'));
|
|
9
|
+
const rebillyDocument = parseYamlToDocument(readFileSync(rebillyDefinitionRef, 'utf-8'), rebillyDefinitionRef);
|
|
10
|
+
const visitor = {
|
|
11
|
+
test: () => {
|
|
12
|
+
let count = 0;
|
|
13
|
+
return {
|
|
14
|
+
PathItem: {
|
|
15
|
+
Parameter() {
|
|
16
|
+
count++;
|
|
17
|
+
},
|
|
18
|
+
Operation: {
|
|
19
|
+
Parameter() {
|
|
20
|
+
count++;
|
|
21
|
+
if (count === -1)
|
|
22
|
+
throw new Error('Disable optimization');
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
let config;
|
|
30
|
+
export async function setupAsync() {
|
|
31
|
+
config = await makeConfigForRuleset(visitor);
|
|
32
|
+
}
|
|
33
|
+
export function measureAsync() {
|
|
34
|
+
return lintDocument({
|
|
35
|
+
externalRefResolver: new BaseResolver(),
|
|
36
|
+
document: rebillyDocument,
|
|
37
|
+
config,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=lint-with-nested-rule.bench.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lint-with-nested-rule.bench.js","sourceRoot":"","sources":["../../../src/benchmark/benches/lint-with-nested-rule.bench.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,MAAM,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAIxE,MAAM,CAAC,MAAM,IAAI,GAAG,kCAAkC,CAAC;AACvD,MAAM,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;AACxB,MAAM,oBAAoB,GAAG,WAAW,CAAC,QAAQ,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC,CAAC;AAC9E,MAAM,eAAe,GAAG,mBAAmB,CACzC,YAAY,CAAC,oBAAoB,EAAE,OAAO,CAAC,EAC3C,oBAAoB,CACrB,CAAC;AACF,MAAM,OAAO,GAAG;IACd,IAAI,EAAE,GAAG,EAAE;QACT,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,OAAO;YACL,QAAQ,EAAE;gBACR,SAAS;oBACP,KAAK,EAAE,CAAC;gBACV,CAAC;gBACD,SAAS,EAAE;oBACT,SAAS;wBACP,KAAK,EAAE,CAAC;wBACR,IAAI,KAAK,KAAK,CAAC,CAAC;4BAAE,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;oBAC5D,CAAC;iBACF;aACF;SACF,CAAC;IACJ,CAAC;CACF,CAAC;AACF,IAAI,MAAwB,CAAC;AAC7B,MAAM,CAAC,KAAK,UAAU,UAAU;IAC9B,MAAM,GAAG,MAAM,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAC/C,CAAC;AAED,MAAM,UAAU,YAAY;IAC1B,OAAO,YAAY,CAAC;QAClB,mBAAmB,EAAE,IAAI,YAAY,EAAE;QACvC,QAAQ,EAAE,eAAe;QACzB,MAAM;KACP,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const name = "Validate with no rules";
|
|
2
|
+
export declare const count = 10;
|
|
3
|
+
export declare function setupAsync(): Promise<void>;
|
|
4
|
+
export declare function measureAsync(): Promise<import("../../walk.js").NormalizedProblem[]>;
|
|
5
|
+
//# sourceMappingURL=lint-with-no-rules.bench.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lint-with-no-rules.bench.d.ts","sourceRoot":"","sources":["../../../src/benchmark/benches/lint-with-no-rules.bench.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,IAAI,2BAA2B,CAAC;AAC7C,eAAO,MAAM,KAAK,KAAK,CAAC;AAQxB,wBAAsB,UAAU,kBAE/B;AACD,wBAAgB,YAAY,yDAM3B"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { readFileSync } from 'fs';
|
|
2
|
+
import { join as pathJoin, resolve as pathResolve } from 'path';
|
|
3
|
+
import { lintDocument } from '../../lint.js';
|
|
4
|
+
import { BaseResolver } from '../../resolve.js';
|
|
5
|
+
import { parseYamlToDocument, makeConfigForRuleset } from '../utils.js';
|
|
6
|
+
export const name = 'Validate with no rules';
|
|
7
|
+
export const count = 10;
|
|
8
|
+
const rebillyDefinitionRef = pathResolve(pathJoin(__dirname, 'rebilly.yaml'));
|
|
9
|
+
const rebillyDocument = parseYamlToDocument(readFileSync(rebillyDefinitionRef, 'utf-8'), rebillyDefinitionRef);
|
|
10
|
+
let config;
|
|
11
|
+
export async function setupAsync() {
|
|
12
|
+
config = await makeConfigForRuleset({});
|
|
13
|
+
}
|
|
14
|
+
export function measureAsync() {
|
|
15
|
+
return lintDocument({
|
|
16
|
+
externalRefResolver: new BaseResolver(),
|
|
17
|
+
document: rebillyDocument,
|
|
18
|
+
config,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=lint-with-no-rules.bench.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lint-with-no-rules.bench.js","sourceRoot":"","sources":["../../../src/benchmark/benches/lint-with-no-rules.bench.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,MAAM,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAIxE,MAAM,CAAC,MAAM,IAAI,GAAG,wBAAwB,CAAC;AAC7C,MAAM,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;AACxB,MAAM,oBAAoB,GAAG,WAAW,CAAC,QAAQ,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC,CAAC;AAC9E,MAAM,eAAe,GAAG,mBAAmB,CACzC,YAAY,CAAC,oBAAoB,EAAE,OAAO,CAAC,EAC3C,oBAAoB,CACrB,CAAC;AAEF,IAAI,MAAwB,CAAC;AAC7B,MAAM,CAAC,KAAK,UAAU,UAAU;IAC9B,MAAM,GAAG,MAAM,oBAAoB,CAAC,EAAE,CAAC,CAAC;AAC1C,CAAC;AACD,MAAM,UAAU,YAAY;IAC1B,OAAO,YAAY,CAAC;QAClB,mBAAmB,EAAE,IAAI,YAAY,EAAE;QACvC,QAAQ,EAAE,eAAe;QACzB,MAAM;KACP,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const name = "Validate with single top-level rule and report";
|
|
2
|
+
export declare const count = 10;
|
|
3
|
+
export declare function setupAsync(): Promise<void>;
|
|
4
|
+
export declare function measureAsync(): Promise<import("../../walk.js").NormalizedProblem[]>;
|
|
5
|
+
//# sourceMappingURL=lint-with-top-level-rule-report.bench.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lint-with-top-level-rule-report.bench.d.ts","sourceRoot":"","sources":["../../../src/benchmark/benches/lint-with-top-level-rule-report.bench.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,IAAI,mDAAmD,CAAC;AACrE,eAAO,MAAM,KAAK,KAAK,CAAC;AAQxB,wBAAsB,UAAU,kBAc/B;AAED,wBAAgB,YAAY,yDAM3B"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { readFileSync } from 'fs';
|
|
2
|
+
import { join as pathJoin, resolve as pathResolve } from 'path';
|
|
3
|
+
import { lintDocument } from '../../lint.js';
|
|
4
|
+
import { BaseResolver } from '../../resolve.js';
|
|
5
|
+
import { parseYamlToDocument, makeConfigForRuleset } from '../utils.js';
|
|
6
|
+
export const name = 'Validate with single top-level rule and report';
|
|
7
|
+
export const count = 10;
|
|
8
|
+
const rebillyDefinitionRef = pathResolve(pathJoin(__dirname, 'rebilly.yaml'));
|
|
9
|
+
const rebillyDocument = parseYamlToDocument(readFileSync(rebillyDefinitionRef, 'utf-8'), rebillyDefinitionRef);
|
|
10
|
+
let config;
|
|
11
|
+
export async function setupAsync() {
|
|
12
|
+
config = await makeConfigForRuleset({
|
|
13
|
+
test: () => {
|
|
14
|
+
return {
|
|
15
|
+
Schema(schema, ctx) {
|
|
16
|
+
if (schema.type === 'number') {
|
|
17
|
+
ctx.report({
|
|
18
|
+
message: 'type number is not allowed',
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
export function measureAsync() {
|
|
27
|
+
return lintDocument({
|
|
28
|
+
externalRefResolver: new BaseResolver(),
|
|
29
|
+
document: rebillyDocument,
|
|
30
|
+
config,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=lint-with-top-level-rule-report.bench.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lint-with-top-level-rule-report.bench.js","sourceRoot":"","sources":["../../../src/benchmark/benches/lint-with-top-level-rule-report.bench.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,MAAM,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAIxE,MAAM,CAAC,MAAM,IAAI,GAAG,gDAAgD,CAAC;AACrE,MAAM,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;AACxB,MAAM,oBAAoB,GAAG,WAAW,CAAC,QAAQ,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC,CAAC;AAC9E,MAAM,eAAe,GAAG,mBAAmB,CACzC,YAAY,CAAC,oBAAoB,EAAE,OAAO,CAAC,EAC3C,oBAAoB,CACrB,CAAC;AAEF,IAAI,MAAwB,CAAC;AAC7B,MAAM,CAAC,KAAK,UAAU,UAAU;IAC9B,MAAM,GAAG,MAAM,oBAAoB,CAAC;QAClC,IAAI,EAAE,GAAG,EAAE;YACT,OAAO;gBACL,MAAM,CAAC,MAAM,EAAE,GAAG;oBAChB,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;wBAC7B,GAAG,CAAC,MAAM,CAAC;4BACT,OAAO,EAAE,4BAA4B;yBACtC,CAAC,CAAC;oBACL,CAAC;gBACH,CAAC;aACF,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,YAAY;IAC1B,OAAO,YAAY,CAAC;QAClB,mBAAmB,EAAE,IAAI,YAAY,EAAE;QACvC,QAAQ,EAAE,eAAe;QACzB,MAAM;KACP,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const name = "Validate with single top-level rule";
|
|
2
|
+
export declare const count = 10;
|
|
3
|
+
export declare function setupAsync(): Promise<void>;
|
|
4
|
+
export declare function measureAsync(): Promise<import("../../walk.js").NormalizedProblem[]>;
|
|
5
|
+
//# sourceMappingURL=lint-with-top-level-rule.bench.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lint-with-top-level-rule.bench.d.ts","sourceRoot":"","sources":["../../../src/benchmark/benches/lint-with-top-level-rule.bench.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,IAAI,wCAAwC,CAAC;AAC1D,eAAO,MAAM,KAAK,KAAK,CAAC;AAQxB,wBAAsB,UAAU,kBAY/B;AAED,wBAAgB,YAAY,yDAM3B"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { readFileSync } from 'fs';
|
|
2
|
+
import { join as pathJoin, resolve as pathResolve } from 'path';
|
|
3
|
+
import { lintDocument } from '../../lint.js';
|
|
4
|
+
import { BaseResolver } from '../../resolve.js';
|
|
5
|
+
import { parseYamlToDocument, makeConfigForRuleset } from '../utils.js';
|
|
6
|
+
export const name = 'Validate with single top-level rule';
|
|
7
|
+
export const count = 10;
|
|
8
|
+
const rebillyDefinitionRef = pathResolve(pathJoin(__dirname, 'rebilly.yaml'));
|
|
9
|
+
const rebillyDocument = parseYamlToDocument(readFileSync(rebillyDefinitionRef, 'utf-8'), rebillyDefinitionRef);
|
|
10
|
+
let config;
|
|
11
|
+
export async function setupAsync() {
|
|
12
|
+
config = await makeConfigForRuleset({
|
|
13
|
+
test: () => {
|
|
14
|
+
let count = 0;
|
|
15
|
+
return {
|
|
16
|
+
Schema() {
|
|
17
|
+
count++;
|
|
18
|
+
if (count === -1)
|
|
19
|
+
throw new Error('Disable optimization');
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
export function measureAsync() {
|
|
26
|
+
return lintDocument({
|
|
27
|
+
externalRefResolver: new BaseResolver(),
|
|
28
|
+
document: rebillyDocument,
|
|
29
|
+
config,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=lint-with-top-level-rule.bench.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lint-with-top-level-rule.bench.js","sourceRoot":"","sources":["../../../src/benchmark/benches/lint-with-top-level-rule.bench.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,MAAM,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAIxE,MAAM,CAAC,MAAM,IAAI,GAAG,qCAAqC,CAAC;AAC1D,MAAM,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;AACxB,MAAM,oBAAoB,GAAG,WAAW,CAAC,QAAQ,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC,CAAC;AAC9E,MAAM,eAAe,GAAG,mBAAmB,CACzC,YAAY,CAAC,oBAAoB,EAAE,OAAO,CAAC,EAC3C,oBAAoB,CACrB,CAAC;AAEF,IAAI,MAAwB,CAAC;AAC7B,MAAM,CAAC,KAAK,UAAU,UAAU;IAC9B,MAAM,GAAG,MAAM,oBAAoB,CAAC;QAClC,IAAI,EAAE,GAAG,EAAE;YACT,IAAI,KAAK,GAAG,CAAC,CAAC;YACd,OAAO;gBACL,MAAM;oBACJ,KAAK,EAAE,CAAC;oBACR,IAAI,KAAK,KAAK,CAAC,CAAC;wBAAE,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;gBAC5D,CAAC;aACF,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,YAAY;IAC1B,OAAO,YAAY,CAAC;QAClB,mBAAmB,EAAE,IAAI,YAAY,EAAE;QACvC,QAAQ,EAAE,eAAe;QACzB,MAAM;KACP,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recommended-oas3.bench.d.ts","sourceRoot":"","sources":["../../../src/benchmark/benches/recommended-oas3.bench.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,IAAI,oCAAoC,CAAC;AACtD,eAAO,MAAM,KAAK,KAAK,CAAC;AAOxB,wBAAgB,YAAY,yDAM3B"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { readFileSync } from 'fs';
|
|
2
|
+
import { join as pathJoin, resolve as pathResolve } from 'path';
|
|
3
|
+
import { lintDocument } from '../../lint.js';
|
|
4
|
+
import { StyleguideConfig, defaultPlugin, resolvePreset } from '../../config/index.js';
|
|
5
|
+
import { BaseResolver } from '../../resolve.js';
|
|
6
|
+
import { parseYamlToDocument } from '../utils.js';
|
|
7
|
+
export const name = 'Validate with recommended rules';
|
|
8
|
+
export const count = 10;
|
|
9
|
+
const rebillyDefinitionRef = pathResolve(pathJoin(__dirname, 'rebilly.yaml'));
|
|
10
|
+
const rebillyDocument = parseYamlToDocument(readFileSync(rebillyDefinitionRef, 'utf-8'), rebillyDefinitionRef);
|
|
11
|
+
export function measureAsync() {
|
|
12
|
+
return lintDocument({
|
|
13
|
+
externalRefResolver: new BaseResolver(),
|
|
14
|
+
document: rebillyDocument,
|
|
15
|
+
config: new StyleguideConfig(resolvePreset('recommended', [defaultPlugin])),
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=recommended-oas3.bench.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recommended-oas3.bench.js","sourceRoot":"","sources":["../../../src/benchmark/benches/recommended-oas3.bench.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,MAAM,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACvF,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAElD,MAAM,CAAC,MAAM,IAAI,GAAG,iCAAiC,CAAC;AACtD,MAAM,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;AACxB,MAAM,oBAAoB,GAAG,WAAW,CAAC,QAAQ,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC,CAAC;AAC9E,MAAM,eAAe,GAAG,mBAAmB,CACzC,YAAY,CAAC,oBAAoB,EAAE,OAAO,CAAC,EAC3C,oBAAoB,CACrB,CAAC;AAEF,MAAM,UAAU,YAAY;IAC1B,OAAO,YAAY,CAAC;QAClB,mBAAmB,EAAE,IAAI,YAAY,EAAE;QACvC,QAAQ,EAAE,eAAe;QACzB,MAAM,EAAE,IAAI,gBAAgB,CAAC,aAAa,CAAC,aAAa,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC;KAC5E,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-with-no-external.bench.d.ts","sourceRoot":"","sources":["../../../src/benchmark/benches/resolve-with-no-external.bench.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,IAAI,kCAAkC,CAAC;AACpD,eAAO,MAAM,KAAK,KAAK,CAAC;AAQxB,wBAAgB,YAAY,uDAM3B"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as path from 'path';
|
|
2
|
+
import { readFileSync } from 'fs';
|
|
3
|
+
import { resolveDocument, BaseResolver } from '../../resolve.js';
|
|
4
|
+
import { parseYamlToDocument } from '../utils.js';
|
|
5
|
+
import { Oas3Types } from '../../types/oas3.js';
|
|
6
|
+
import { normalizeTypes } from '../../types/index.js';
|
|
7
|
+
export const name = 'Resolve with no external refs';
|
|
8
|
+
export const count = 10;
|
|
9
|
+
const rebillyDefinitionRef = path.resolve(path.join(__dirname, 'rebilly.yaml'));
|
|
10
|
+
const rebillyDocument = parseYamlToDocument(readFileSync(rebillyDefinitionRef, 'utf-8'), rebillyDefinitionRef);
|
|
11
|
+
const externalRefResolver = new BaseResolver();
|
|
12
|
+
export function measureAsync() {
|
|
13
|
+
return resolveDocument({
|
|
14
|
+
rootDocument: rebillyDocument,
|
|
15
|
+
externalRefResolver,
|
|
16
|
+
rootType: normalizeTypes(Oas3Types).Root,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=resolve-with-no-external.bench.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-with-no-external.bench.js","sourceRoot":"","sources":["../../../src/benchmark/benches/resolve-with-no-external.bench.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,MAAM,CAAC,MAAM,IAAI,GAAG,+BAA+B,CAAC;AACpD,MAAM,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;AACxB,MAAM,oBAAoB,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC,CAAC;AAChF,MAAM,eAAe,GAAG,mBAAmB,CACzC,YAAY,CAAC,oBAAoB,EAAE,OAAO,CAAC,EAC3C,oBAAoB,CACrB,CAAC;AACF,MAAM,mBAAmB,GAAG,IAAI,YAAY,EAAE,CAAC;AAE/C,MAAM,UAAU,YAAY;IAC1B,OAAO,eAAe,CAAC;QACrB,YAAY,EAAE,eAAe;QAC7B,mBAAmB;QACnB,QAAQ,EAAE,cAAc,CAAC,SAAS,CAAC,CAAC,IAAI;KACzC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { StyleguideConfig } from '../config/index.js';
|
|
2
|
+
import type { Document } from '../resolve.js';
|
|
3
|
+
import type { Oas3RuleSet } from '../oas-types.js';
|
|
4
|
+
import type { Plugin } from '../config/types.js';
|
|
5
|
+
export declare function parseYamlToDocument(body: string, absoluteRef?: string): Document;
|
|
6
|
+
export declare function makeConfigForRuleset(rules: Oas3RuleSet, plugin?: Partial<Plugin>): Promise<StyleguideConfig>;
|
|
7
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/benchmark/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAgC,MAAM,oBAAoB,CAAC;AAEpF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,KAAK,EAAc,MAAM,EAA4B,MAAM,oBAAoB,CAAC;AAEvF,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,GAAE,MAAW,GAAG,QAAQ,CAKpF;AAED,wBAAsB,oBAAoB,CAAC,KAAK,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,6BAqBtF"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { parseYaml } from '../js-yaml/index.js';
|
|
2
|
+
import { Source } from '../resolve.js';
|
|
3
|
+
import { StyleguideConfig, mergeExtends, resolvePlugins } from '../config/index.js';
|
|
4
|
+
export function parseYamlToDocument(body, absoluteRef = '') {
|
|
5
|
+
return {
|
|
6
|
+
source: new Source(absoluteRef, body),
|
|
7
|
+
parsed: parseYaml(body, { filename: absoluteRef }),
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export async function makeConfigForRuleset(rules, plugin) {
|
|
11
|
+
const rulesConf = {};
|
|
12
|
+
const ruleId = 'test';
|
|
13
|
+
Object.keys(rules).forEach((name) => {
|
|
14
|
+
rulesConf[`${ruleId}/${name}`] = 'error';
|
|
15
|
+
});
|
|
16
|
+
const extendConfigs = [
|
|
17
|
+
(await resolvePlugins([
|
|
18
|
+
{
|
|
19
|
+
...plugin,
|
|
20
|
+
id: ruleId,
|
|
21
|
+
rules: { oas3: rules },
|
|
22
|
+
},
|
|
23
|
+
])),
|
|
24
|
+
];
|
|
25
|
+
if (rules) {
|
|
26
|
+
extendConfigs.push({ rules });
|
|
27
|
+
}
|
|
28
|
+
const styleguide = mergeExtends(extendConfigs);
|
|
29
|
+
return new StyleguideConfig(styleguide);
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/benchmark/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAMpF,MAAM,UAAU,mBAAmB,CAAC,IAAY,EAAE,cAAsB,EAAE;IACxE,OAAO;QACL,MAAM,EAAE,IAAI,MAAM,CAAC,WAAW,EAAE,IAAI,CAAC;QACrC,MAAM,EAAE,SAAS,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC;KACnD,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,KAAkB,EAAE,MAAwB;IACrF,MAAM,SAAS,GAA+B,EAAE,CAAC;IACjD,MAAM,MAAM,GAAG,MAAM,CAAC;IACtB,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QAClC,SAAS,CAAC,GAAG,MAAM,IAAI,IAAI,EAAE,CAAC,GAAG,OAAO,CAAC;IAC3C,CAAC,CAAC,CAAC;IACH,MAAM,aAAa,GAAG;QACpB,CAAC,MAAM,cAAc,CAAC;YACpB;gBACE,GAAG,MAAM;gBACT,EAAE,EAAE,MAAM;gBACV,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE;aACvB;SACF,CAAC,CAA6B;KAChC,CAAC;IACF,IAAI,KAAK,EAAE,CAAC;QACV,aAAa,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IAChC,CAAC;IACD,MAAM,UAAU,GAAG,YAAY,CAAC,aAAa,CAAC,CAAC;IAE/C,OAAO,IAAI,gBAAgB,CAAC,UAAU,CAAC,CAAC;AAC1C,CAAC"}
|
package/lib/bundle.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BaseResolver } from './resolve.js';
|
|
2
2
|
import { SpecMajorVersion } from './oas-types.js';
|
|
3
|
-
import { type Config } from './config/index.js';
|
|
3
|
+
import { type Config, type StyleguideConfig } from './config/index.js';
|
|
4
4
|
import type { NormalizedNodeType, NodeType } from './types/index.js';
|
|
5
5
|
import type { NormalizedProblem } from './walk.js';
|
|
6
6
|
import type { Document, ResolvedRefMap } from './resolve.js';
|
|
@@ -10,10 +10,9 @@ export declare enum OasVersion {
|
|
|
10
10
|
Version3_0 = "oas3_0",
|
|
11
11
|
Version3_1 = "oas3_1"
|
|
12
12
|
}
|
|
13
|
-
export type
|
|
13
|
+
export type BundleOptions = {
|
|
14
14
|
externalRefResolver?: BaseResolver;
|
|
15
15
|
config: Config;
|
|
16
|
-
alias?: string;
|
|
17
16
|
dereference?: boolean;
|
|
18
17
|
base?: string | null;
|
|
19
18
|
removeUnusedComponents?: boolean;
|
|
@@ -24,11 +23,11 @@ export declare function bundle(opts: {
|
|
|
24
23
|
ref?: string;
|
|
25
24
|
doc?: Document;
|
|
26
25
|
collectSpecData?: CollectFn;
|
|
27
|
-
} &
|
|
26
|
+
} & BundleOptions): Promise<BundleResult>;
|
|
28
27
|
export declare function bundleFromString(opts: {
|
|
29
28
|
source: string;
|
|
30
29
|
absoluteRef?: string;
|
|
31
|
-
} &
|
|
30
|
+
} & BundleOptions): Promise<BundleResult>;
|
|
32
31
|
export type BundleResult = {
|
|
33
32
|
bundle: Document;
|
|
34
33
|
problems: NormalizedProblem[];
|
|
@@ -39,8 +38,7 @@ export type BundleResult = {
|
|
|
39
38
|
};
|
|
40
39
|
export declare function bundleDocument(opts: {
|
|
41
40
|
document: Document;
|
|
42
|
-
config:
|
|
43
|
-
alias?: string;
|
|
41
|
+
config: StyleguideConfig;
|
|
44
42
|
customTypes?: Record<string, NodeType>;
|
|
45
43
|
externalRefResolver: BaseResolver;
|
|
46
44
|
dereference?: boolean;
|
package/lib/bundle.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../src/bundle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAsD,MAAM,cAAc,CAAC;AAIhG,OAAO,EAIL,gBAAgB,EAEjB,MAAM,gBAAgB,CAAC;AAQxB,OAAO,
|
|
1
|
+
{"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../src/bundle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAsD,MAAM,cAAc,CAAC;AAIhG,OAAO,EAIL,gBAAgB,EAEjB,MAAM,gBAAgB,CAAC;AAQxB,OAAO,EAGL,KAAK,MAAM,EACX,KAAK,gBAAgB,EAGtB,MAAM,mBAAmB,CAAC;AAM3B,OAAO,KAAK,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,KAAK,EAA2C,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE5F,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,oBAAY,UAAU;IACpB,QAAQ,SAAS;IACjB,UAAU,WAAW;IACrB,UAAU,WAAW;CACtB;AACD,MAAM,MAAM,aAAa,GAAG;IAC1B,mBAAmB,CAAC,EAAE,YAAY,CAAC;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AA2FF,wBAAsB,YAAY,CAAC,QAAQ,EAAE,QAAQ,EAAE,cAAc,EAAE,cAAc,gBAiBpF;AAED,wBAAsB,MAAM,CAC1B,IAAI,EAAE;IACJ,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,QAAQ,CAAC;IACf,eAAe,CAAC,EAAE,SAAS,CAAC;CAC7B,GAAG,aAAa,yBA0BlB;AAED,wBAAsB,gBAAgB,CACpC,IAAI,EAAE;IACJ,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,GAAG,aAAa,yBAWlB;AAID,MAAM,MAAM,YAAY,GAAG;IACzB,MAAM,EAAE,QAAQ,CAAC;IACjB,QAAQ,EAAE,iBAAiB,EAAE,CAAC;IAC9B,gBAAgB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC9B,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,QAAQ,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IAC3C,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACvD,CAAC;AAEF,wBAAsB,cAAc,CAAC,IAAI,EAAE;IACzC,QAAQ,EAAE,QAAQ,CAAC;IACnB,MAAM,EAAE,gBAAgB,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACvC,mBAAmB,EAAE,YAAY,CAAC;IAClC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,GAAG,OAAO,CAAC,YAAY,CAAC,CA+FxB;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,wJAoE7E"}
|
package/lib/bundle.js
CHANGED
|
@@ -6,30 +6,93 @@ import { detectSpec, getTypes, getMajorSpecVersion, SpecMajorVersion, SpecVersio
|
|
|
6
6
|
import { isAbsoluteUrl, isExternalValue, isRef, refBaseName } from './ref-utils.js';
|
|
7
7
|
import { initRules } from './config/rules.js';
|
|
8
8
|
import { reportUnresolvedRef } from './rules/no-unresolved-refs.js';
|
|
9
|
-
import { dequal, isPlainObject, isTruthy } from './utils.js';
|
|
9
|
+
import { dequal, isEmptyObject, isPlainObject, isTruthy } from './utils.js';
|
|
10
10
|
import { RemoveUnusedComponents as RemoveUnusedComponentsOas2 } from './decorators/oas2/remove-unused-components.js';
|
|
11
11
|
import { RemoveUnusedComponents as RemoveUnusedComponentsOas3 } from './decorators/oas3/remove-unused-components.js';
|
|
12
12
|
import { NormalizedConfigTypes } from './types/redocly-yaml.js';
|
|
13
|
-
import {
|
|
13
|
+
import { mergeExtends, resolvePreset, } from './config/index.js';
|
|
14
|
+
import path from 'path';
|
|
15
|
+
import { defaultPlugin } from './config/builtIn.js';
|
|
14
16
|
export var OasVersion;
|
|
15
17
|
(function (OasVersion) {
|
|
16
18
|
OasVersion["Version2"] = "oas2";
|
|
17
19
|
OasVersion["Version3_0"] = "oas3_0";
|
|
18
20
|
OasVersion["Version3_1"] = "oas3_1";
|
|
19
21
|
})(OasVersion || (OasVersion = {}));
|
|
20
|
-
|
|
21
|
-
{
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
function bundleExtends(node, ctx) {
|
|
23
|
+
if (!node.extends) {
|
|
24
|
+
return node;
|
|
25
|
+
}
|
|
26
|
+
const resolvedExtends = node.extends
|
|
27
|
+
.map((presetItem) => {
|
|
28
|
+
if (!isAbsoluteUrl(presetItem) && !path.extname(presetItem)) {
|
|
29
|
+
return resolvePreset(presetItem, [defaultPlugin]); // TODO: implement plugins
|
|
30
|
+
}
|
|
31
|
+
const resolvedRef = ctx.resolve({ $ref: presetItem });
|
|
32
|
+
if (resolvedRef.location && resolvedRef.node) {
|
|
33
|
+
return resolvedRef.node;
|
|
34
|
+
}
|
|
35
|
+
return null;
|
|
36
|
+
})
|
|
37
|
+
.filter(isTruthy);
|
|
38
|
+
return removeEmptyRules(mergeExtends([
|
|
39
|
+
...resolvedExtends.map((nested) => bundleExtends(nested, ctx)),
|
|
40
|
+
{ ...node, extends: undefined },
|
|
41
|
+
]));
|
|
42
|
+
}
|
|
43
|
+
const bundleVisitor = () => {
|
|
44
|
+
const scorecardPlugins = [];
|
|
45
|
+
return normalizeVisitors([
|
|
46
|
+
{
|
|
47
|
+
severity: 'error',
|
|
48
|
+
ruleId: 'configBundler',
|
|
49
|
+
visitor: {
|
|
50
|
+
ref: {
|
|
51
|
+
leave(node, ctx, resolved) {
|
|
52
|
+
replaceRef(node, resolved, ctx);
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
ConfigStyleguide: {
|
|
56
|
+
leave(node, ctx) {
|
|
57
|
+
if (node.extends) {
|
|
58
|
+
const bundled = bundleExtends(node, ctx);
|
|
59
|
+
Object.assign(node, bundled);
|
|
60
|
+
delete node.extends;
|
|
61
|
+
scorecardPlugins.push(...bundled.plugins);
|
|
62
|
+
delete bundled.plugins;
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
'rootRedoclyConfigSchema.scorecard.levels_items': {
|
|
67
|
+
leave(node, ctx) {
|
|
68
|
+
if (node.extends) {
|
|
69
|
+
const bundled = bundleExtends(node, ctx);
|
|
70
|
+
Object.assign(node, bundled);
|
|
71
|
+
delete node.extends;
|
|
72
|
+
scorecardPlugins.push(...bundled.plugins);
|
|
73
|
+
delete bundled.plugins;
|
|
74
|
+
delete node.plugins;
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
ConfigRoot: {
|
|
79
|
+
leave(node, ctx) {
|
|
80
|
+
if (node.extends) {
|
|
81
|
+
const bundled = bundleExtends(node, ctx);
|
|
82
|
+
Object.assign(node, bundled);
|
|
83
|
+
node.plugins = Array.from(new Set([...(node.plugins || []), ...scorecardPlugins]));
|
|
84
|
+
delete node.extends;
|
|
85
|
+
}
|
|
86
|
+
},
|
|
28
87
|
},
|
|
29
88
|
},
|
|
30
89
|
},
|
|
31
|
-
|
|
32
|
-
|
|
90
|
+
], NormalizedConfigTypes);
|
|
91
|
+
};
|
|
92
|
+
function removeEmptyRules(config) {
|
|
93
|
+
// TODO: convert strings to constants
|
|
94
|
+
return Object.fromEntries(Object.entries(config).filter(([key, value]) => !isEmptyObject(value) && key !== 'pluginPaths' && key !== 'extendPaths'));
|
|
95
|
+
}
|
|
33
96
|
export async function bundleConfig(document, resolvedRefMap) {
|
|
34
97
|
const ctx = {
|
|
35
98
|
problems: [],
|
|
@@ -40,7 +103,7 @@ export async function bundleConfig(document, resolvedRefMap) {
|
|
|
40
103
|
walkDocument({
|
|
41
104
|
document,
|
|
42
105
|
rootType: NormalizedConfigTypes.ConfigRoot,
|
|
43
|
-
normalizedVisitors: bundleVisitor,
|
|
106
|
+
normalizedVisitors: bundleVisitor(),
|
|
44
107
|
resolvedRefMap,
|
|
45
108
|
ctx,
|
|
46
109
|
});
|
|
@@ -59,6 +122,7 @@ export async function bundle(opts) {
|
|
|
59
122
|
return bundleDocument({
|
|
60
123
|
document,
|
|
61
124
|
...opts,
|
|
125
|
+
config: opts.config.styleguide,
|
|
62
126
|
externalRefResolver,
|
|
63
127
|
});
|
|
64
128
|
}
|
|
@@ -69,17 +133,17 @@ export async function bundleFromString(opts) {
|
|
|
69
133
|
document,
|
|
70
134
|
...opts,
|
|
71
135
|
externalRefResolver,
|
|
136
|
+
config: opts.config.styleguide,
|
|
72
137
|
});
|
|
73
138
|
}
|
|
74
139
|
export async function bundleDocument(opts) {
|
|
75
|
-
const { document, config,
|
|
140
|
+
const { document, config, customTypes, externalRefResolver, dereference = false, removeUnusedComponents = false, keepUrlRefs = false, } = opts;
|
|
76
141
|
const specVersion = detectSpec(document.parsed);
|
|
77
142
|
const specMajorVersion = getMajorSpecVersion(specVersion);
|
|
78
|
-
const
|
|
79
|
-
const
|
|
80
|
-
const
|
|
81
|
-
const
|
|
82
|
-
const decorators = initRules(rules, governanceConfig, 'decorators', specVersion);
|
|
143
|
+
const rules = config.getRulesForSpecVersion(specMajorVersion);
|
|
144
|
+
const types = normalizeTypes(config.extendTypes(customTypes ?? getTypes(specVersion), specVersion), config);
|
|
145
|
+
const preprocessors = initRules(rules, config, 'preprocessors', specVersion);
|
|
146
|
+
const decorators = initRules(rules, config, 'decorators', specVersion);
|
|
83
147
|
const ctx = {
|
|
84
148
|
problems: [],
|
|
85
149
|
oasVersion: specVersion,
|
|
@@ -132,7 +196,7 @@ export async function bundleDocument(opts) {
|
|
|
132
196
|
});
|
|
133
197
|
return {
|
|
134
198
|
bundle: document,
|
|
135
|
-
problems: ctx.problems.map((problem) =>
|
|
199
|
+
problems: ctx.problems.map((problem) => config.addProblemToIgnore(problem)),
|
|
136
200
|
fileDependencies: externalRefResolver.getFiles(),
|
|
137
201
|
rootType: types.Root,
|
|
138
202
|
refTypes: ctx.refTypes,
|