@redocly/openapi-core 1.0.0-beta.102 → 1.0.0-beta.105
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/__tests__/utils.ts +3 -1
- package/lib/config/config.d.ts +4 -3
- package/lib/config/config.js +23 -16
- package/lib/config/load.d.ts +1 -1
- package/lib/config/load.js +15 -3
- package/lib/config/rules.d.ts +1 -1
- package/lib/config/types.d.ts +4 -2
- package/lib/decorators/common/filters/filter-helper.d.ts +3 -0
- package/lib/decorators/common/filters/filter-helper.js +67 -0
- package/lib/decorators/common/filters/filter-in.d.ts +2 -0
- package/lib/decorators/common/filters/filter-in.js +17 -0
- package/lib/decorators/common/filters/filter-out.d.ts +2 -0
- package/lib/decorators/common/filters/filter-out.js +17 -0
- package/lib/decorators/oas2/index.d.ts +2 -0
- package/lib/decorators/oas2/index.js +5 -1
- package/lib/decorators/oas3/index.d.ts +2 -0
- package/lib/decorators/oas3/index.js +5 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.js +2 -1
- package/lib/lint.d.ts +2 -0
- package/lib/lint.js +2 -2
- package/lib/redocly/registry-api-types.d.ts +2 -0
- package/lib/redocly/registry-api.d.ts +1 -1
- package/lib/redocly/registry-api.js +3 -1
- package/lib/rules/ajv.d.ts +1 -1
- package/lib/rules/ajv.js +1 -1
- package/lib/rules/common/assertions/asserts.d.ts +6 -1
- package/lib/rules/common/assertions/asserts.js +81 -51
- package/lib/rules/common/assertions/utils.d.ts +2 -1
- package/lib/rules/common/assertions/utils.js +27 -8
- package/lib/types/redocly-yaml.js +317 -27
- package/lib/utils.d.ts +5 -3
- package/lib/utils.js +15 -2
- package/lib/walk.d.ts +4 -14
- package/lib/walk.js +35 -26
- package/package.json +3 -2
- package/src/__tests__/fixtures/.redocly.lint-ignore.yaml +5 -0
- package/src/__tests__/lint.test.ts +70 -10
- package/src/__tests__/utils.test.ts +42 -1
- package/src/config/__tests__/load.test.ts +8 -2
- package/src/config/config.ts +31 -27
- package/src/config/load.ts +29 -9
- package/src/config/types.ts +6 -5
- package/src/decorators/__tests__/filter-in.test.ts +310 -0
- package/src/decorators/__tests__/filter-out.test.ts +331 -0
- package/src/decorators/common/filters/filter-helper.ts +72 -0
- package/src/decorators/common/filters/filter-in.ts +18 -0
- package/src/decorators/common/filters/filter-out.ts +18 -0
- package/src/decorators/oas2/index.ts +5 -1
- package/src/decorators/oas3/index.ts +5 -1
- package/src/index.ts +2 -1
- package/src/lint.ts +4 -3
- package/src/redocly/registry-api-types.ts +2 -0
- package/src/redocly/registry-api.ts +4 -0
- package/src/rules/ajv.ts +4 -4
- package/src/rules/common/assertions/__tests__/asserts.test.ts +149 -146
- package/src/rules/common/assertions/asserts.ts +97 -52
- package/src/rules/common/assertions/utils.ts +41 -16
- package/src/types/redocly-yaml.ts +322 -34
- package/src/utils.ts +28 -15
- package/src/walk.ts +59 -47
- package/tsconfig.tsbuildinfo +1 -1
package/__tests__/utils.ts
CHANGED
|
@@ -48,7 +48,7 @@ export const yamlSerializer = {
|
|
|
48
48
|
export function makeConfigForRuleset(
|
|
49
49
|
rules: Oas3RuleSet,
|
|
50
50
|
plugin?: Partial<Plugin>,
|
|
51
|
-
version: string = 'oas3'
|
|
51
|
+
version: string = 'oas3'
|
|
52
52
|
) {
|
|
53
53
|
const rulesConf: Record<string, RuleConfig> = {};
|
|
54
54
|
const ruleId = 'test';
|
|
@@ -72,6 +72,7 @@ export function makeConfigForRuleset(
|
|
|
72
72
|
export async function makeConfig(
|
|
73
73
|
rules: Record<string, RuleConfig>,
|
|
74
74
|
decorators?: Record<string, DecoratorConfig>,
|
|
75
|
+
configPath?: string
|
|
75
76
|
) {
|
|
76
77
|
return new LintConfig(
|
|
77
78
|
await resolveLint({
|
|
@@ -82,5 +83,6 @@ export async function makeConfig(
|
|
|
82
83
|
decorators,
|
|
83
84
|
},
|
|
84
85
|
}),
|
|
86
|
+
configPath
|
|
85
87
|
);
|
|
86
88
|
}
|
package/lib/config/config.d.ts
CHANGED
|
@@ -26,18 +26,19 @@ export declare class LintConfig {
|
|
|
26
26
|
extendPaths: string[];
|
|
27
27
|
pluginPaths: string[];
|
|
28
28
|
constructor(rawConfig: ResolvedLintConfig, configFile?: string | undefined);
|
|
29
|
+
resolveIgnore(ignoreFile?: string): void;
|
|
29
30
|
saveIgnore(): void;
|
|
30
31
|
addIgnore(problem: NormalizedProblem): void;
|
|
31
32
|
addProblemToIgnore(problem: NormalizedProblem): NormalizedProblem;
|
|
32
33
|
extendTypes(types: Record<string, NodeType>, version: OasVersion): Record<string, NodeType>;
|
|
33
34
|
getRuleSettings(ruleId: string, oasVersion: OasVersion): {
|
|
34
|
-
severity: import("
|
|
35
|
+
severity: import("./types").RuleSeverity;
|
|
35
36
|
};
|
|
36
37
|
getPreprocessorSettings(ruleId: string, oasVersion: OasVersion): {
|
|
37
|
-
severity: import("
|
|
38
|
+
severity: import("./types").RuleSeverity;
|
|
38
39
|
};
|
|
39
40
|
getDecoratorSettings(ruleId: string, oasVersion: OasVersion): {
|
|
40
|
-
severity: import("
|
|
41
|
+
severity: import("./types").RuleSeverity;
|
|
41
42
|
};
|
|
42
43
|
getUnusedRules(): {
|
|
43
44
|
rules: string[];
|
package/lib/config/config.js
CHANGED
|
@@ -28,6 +28,16 @@ function getDomains() {
|
|
|
28
28
|
}
|
|
29
29
|
return domains;
|
|
30
30
|
}
|
|
31
|
+
function getIgnoreFilePath(configFile) {
|
|
32
|
+
if (configFile) {
|
|
33
|
+
return utils_1.doesYamlFileExist(configFile)
|
|
34
|
+
? path.join(path.dirname(configFile), exports.IGNORE_FILE)
|
|
35
|
+
: path.join(configFile, exports.IGNORE_FILE);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
return typeof process === 'undefined' ? undefined : path.join(process.cwd(), exports.IGNORE_FILE);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
31
41
|
exports.DOMAINS = getDomains();
|
|
32
42
|
exports.AVAILABLE_REGIONS = Object.keys(exports.DOMAINS);
|
|
33
43
|
class LintConfig {
|
|
@@ -57,23 +67,20 @@ class LintConfig {
|
|
|
57
67
|
};
|
|
58
68
|
this.extendPaths = rawConfig.extendPaths || [];
|
|
59
69
|
this.pluginPaths = rawConfig.pluginPaths || [];
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
for (const
|
|
71
|
-
this.ignore[
|
|
72
|
-
for (const ruleId of Object.keys(this.ignore[fileName])) {
|
|
73
|
-
this.ignore[fileName][ruleId] = new Set(this.ignore[fileName][ruleId]);
|
|
74
|
-
}
|
|
75
|
-
delete this.ignore[fileName];
|
|
70
|
+
this.resolveIgnore(getIgnoreFilePath(configFile));
|
|
71
|
+
}
|
|
72
|
+
resolveIgnore(ignoreFile) {
|
|
73
|
+
if (!ignoreFile || !utils_1.doesYamlFileExist(ignoreFile))
|
|
74
|
+
return;
|
|
75
|
+
this.ignore =
|
|
76
|
+
js_yaml_1.parseYaml(fs.readFileSync(ignoreFile, 'utf-8')) || {};
|
|
77
|
+
// resolve ignore paths
|
|
78
|
+
for (const fileName of Object.keys(this.ignore)) {
|
|
79
|
+
this.ignore[path.resolve(path.dirname(ignoreFile), fileName)] = this.ignore[fileName];
|
|
80
|
+
for (const ruleId of Object.keys(this.ignore[fileName])) {
|
|
81
|
+
this.ignore[fileName][ruleId] = new Set(this.ignore[fileName][ruleId]);
|
|
76
82
|
}
|
|
83
|
+
delete this.ignore[fileName];
|
|
77
84
|
}
|
|
78
85
|
}
|
|
79
86
|
saveIgnore() {
|
package/lib/config/load.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Config } from './config';
|
|
2
2
|
import type { RawConfig } from './types';
|
|
3
|
-
export declare function loadConfig(configPath?: string | undefined, customExtends?: string[]): Promise<Config>;
|
|
3
|
+
export declare function loadConfig(configPath?: string | undefined, customExtends?: string[], processRawConfig?: (rawConfig: RawConfig) => void | Promise<void>): Promise<Config>;
|
|
4
4
|
export declare const CONFIG_FILE_NAMES: string[];
|
|
5
5
|
export declare function findConfig(dir?: string): string | undefined;
|
|
6
6
|
export declare function getConfig(configPath?: string | undefined): Promise<RawConfig>;
|
package/lib/config/load.js
CHANGED
|
@@ -17,10 +17,9 @@ const utils_1 = require("../utils");
|
|
|
17
17
|
const config_1 = require("./config");
|
|
18
18
|
const utils_2 = require("./utils");
|
|
19
19
|
const config_resolvers_1 = require("./config-resolvers");
|
|
20
|
-
function
|
|
20
|
+
function addConfigMetadata({ rawConfig, customExtends, configPath, }) {
|
|
21
21
|
var _a;
|
|
22
22
|
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
-
const rawConfig = yield getConfig(configPath);
|
|
24
23
|
if (customExtends !== undefined) {
|
|
25
24
|
rawConfig.lint = rawConfig.lint || {};
|
|
26
25
|
rawConfig.lint.extends = customExtends;
|
|
@@ -61,6 +60,19 @@ function loadConfig(configPath = findConfig(), customExtends) {
|
|
|
61
60
|
return config_resolvers_1.resolveConfig(rawConfig, configPath);
|
|
62
61
|
});
|
|
63
62
|
}
|
|
63
|
+
function loadConfig(configPath = findConfig(), customExtends, processRawConfig) {
|
|
64
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
65
|
+
const rawConfig = yield getConfig(configPath);
|
|
66
|
+
if (typeof processRawConfig === 'function') {
|
|
67
|
+
yield processRawConfig(rawConfig);
|
|
68
|
+
}
|
|
69
|
+
return yield addConfigMetadata({
|
|
70
|
+
rawConfig,
|
|
71
|
+
customExtends,
|
|
72
|
+
configPath,
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
}
|
|
64
76
|
exports.loadConfig = loadConfig;
|
|
65
77
|
exports.CONFIG_FILE_NAMES = ['redocly.yaml', 'redocly.yml', '.redocly.yaml', '.redocly.yml'];
|
|
66
78
|
function findConfig(dir) {
|
|
@@ -79,7 +91,7 @@ function findConfig(dir) {
|
|
|
79
91
|
exports.findConfig = findConfig;
|
|
80
92
|
function getConfig(configPath = findConfig()) {
|
|
81
93
|
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
-
if (!configPath)
|
|
94
|
+
if (!configPath || !utils_1.doesYamlFileExist(configPath))
|
|
83
95
|
return {};
|
|
84
96
|
try {
|
|
85
97
|
const rawConfig = ((yield utils_1.loadYaml(configPath)) || {});
|
package/lib/config/rules.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RuleSet, OasVersion } from '../oas-types';
|
|
2
2
|
import { LintConfig } from './config';
|
|
3
3
|
export declare function initRules<T extends Function, P extends RuleSet<T>>(rules: P[], config: LintConfig, type: 'rules' | 'preprocessors' | 'decorators', oasVersion: OasVersion): {
|
|
4
|
-
severity: import("
|
|
4
|
+
severity: import("./types").RuleSeverity;
|
|
5
5
|
ruleId: string;
|
|
6
6
|
visitor: any;
|
|
7
7
|
}[];
|
package/lib/config/types.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { ProblemSeverity } from '../walk';
|
|
2
2
|
import type { Oas3PreprocessorsSet, OasMajorVersion, Oas3DecoratorsSet, Oas2RuleSet, Oas2PreprocessorsSet, Oas2DecoratorsSet, Oas3RuleSet, OasVersion } from '../oas-types';
|
|
3
3
|
import type { NodeType } from '../types';
|
|
4
|
-
export declare type
|
|
4
|
+
export declare type RuleSeverity = ProblemSeverity | 'off';
|
|
5
|
+
export declare type PreprocessorSeverity = RuleSeverity | 'on';
|
|
6
|
+
export declare type RuleConfig = RuleSeverity | ({
|
|
5
7
|
severity?: ProblemSeverity;
|
|
6
8
|
} & Record<string, any>);
|
|
7
|
-
export declare type PreprocessorConfig =
|
|
9
|
+
export declare type PreprocessorConfig = PreprocessorSeverity | ({
|
|
8
10
|
severity?: ProblemSeverity;
|
|
9
11
|
} & Record<string, any>);
|
|
10
12
|
export declare type DecoratorConfig = PreprocessorConfig;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkIfMatchByStrategy = exports.filter = void 0;
|
|
4
|
+
const ref_utils_1 = require("../../../ref-utils");
|
|
5
|
+
const utils_1 = require("../../../utils");
|
|
6
|
+
function filter(node, ctx, criteria) {
|
|
7
|
+
const { parent, key } = ctx;
|
|
8
|
+
let didDelete = false;
|
|
9
|
+
if (Array.isArray(node)) {
|
|
10
|
+
for (let i = 0; i < node.length; i++) {
|
|
11
|
+
if (ref_utils_1.isRef(node[i])) {
|
|
12
|
+
const resolved = ctx.resolve(node[i]);
|
|
13
|
+
if (criteria(resolved.node)) {
|
|
14
|
+
node.splice(i, 1);
|
|
15
|
+
didDelete = true;
|
|
16
|
+
i--;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
if (criteria(node[i])) {
|
|
20
|
+
node.splice(i, 1);
|
|
21
|
+
didDelete = true;
|
|
22
|
+
i--;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
else if (utils_1.isPlainObject(node)) {
|
|
27
|
+
for (const key of Object.keys(node)) {
|
|
28
|
+
node = node;
|
|
29
|
+
if (ref_utils_1.isRef(node[key])) {
|
|
30
|
+
const resolved = ctx.resolve(node[key]);
|
|
31
|
+
if (criteria(resolved.node)) {
|
|
32
|
+
delete node[key];
|
|
33
|
+
didDelete = true;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (criteria(node[key])) {
|
|
37
|
+
delete node[key];
|
|
38
|
+
didDelete = true;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (didDelete && (utils_1.isEmptyObject(node) || utils_1.isEmptyArray(node))) {
|
|
43
|
+
delete parent[key];
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.filter = filter;
|
|
47
|
+
function checkIfMatchByStrategy(nodeValue, decoratorValue, strategy) {
|
|
48
|
+
if (nodeValue === undefined || decoratorValue === undefined) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
if (!Array.isArray(decoratorValue) && !Array.isArray(nodeValue)) {
|
|
52
|
+
return nodeValue === decoratorValue;
|
|
53
|
+
}
|
|
54
|
+
decoratorValue = toArrayIfNeeded(decoratorValue);
|
|
55
|
+
nodeValue = toArrayIfNeeded(nodeValue);
|
|
56
|
+
if (strategy === 'any') {
|
|
57
|
+
return decoratorValue.some((item) => nodeValue.includes(item));
|
|
58
|
+
}
|
|
59
|
+
if (strategy === 'all') {
|
|
60
|
+
return decoratorValue.every((item) => nodeValue.includes(item));
|
|
61
|
+
}
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
exports.checkIfMatchByStrategy = checkIfMatchByStrategy;
|
|
65
|
+
function toArrayIfNeeded(value) {
|
|
66
|
+
return Array.isArray(value) ? value : [value];
|
|
67
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FilterIn = void 0;
|
|
4
|
+
const filter_helper_1 = require("./filter-helper");
|
|
5
|
+
const DEFAULT_STRATEGY = 'any';
|
|
6
|
+
const FilterIn = ({ property, value, matchStrategy }) => {
|
|
7
|
+
const strategy = matchStrategy || DEFAULT_STRATEGY;
|
|
8
|
+
const filterInCriteria = (item) => (item === null || item === void 0 ? void 0 : item[property]) && !filter_helper_1.checkIfMatchByStrategy(item === null || item === void 0 ? void 0 : item[property], value, strategy);
|
|
9
|
+
return {
|
|
10
|
+
any: {
|
|
11
|
+
enter: (node, ctx) => {
|
|
12
|
+
filter_helper_1.filter(node, ctx, filterInCriteria);
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
exports.FilterIn = FilterIn;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FilterOut = void 0;
|
|
4
|
+
const filter_helper_1 = require("./filter-helper");
|
|
5
|
+
const DEFAULT_STRATEGY = 'any';
|
|
6
|
+
const FilterOut = ({ property, value, matchStrategy }) => {
|
|
7
|
+
const strategy = matchStrategy || DEFAULT_STRATEGY;
|
|
8
|
+
const filterOutCriteria = (item) => filter_helper_1.checkIfMatchByStrategy(item === null || item === void 0 ? void 0 : item[property], value, strategy);
|
|
9
|
+
return {
|
|
10
|
+
any: {
|
|
11
|
+
enter: (node, ctx) => {
|
|
12
|
+
filter_helper_1.filter(node, ctx, filterOutCriteria);
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
exports.FilterOut = FilterOut;
|
|
@@ -6,10 +6,14 @@ const operation_description_override_1 = require("../common/operation-descriptio
|
|
|
6
6
|
const tag_description_override_1 = require("../common/tag-description-override");
|
|
7
7
|
const info_description_override_1 = require("../common/info-description-override");
|
|
8
8
|
const remove_x_internal_1 = require("../common/remove-x-internal");
|
|
9
|
+
const filter_in_1 = require("../common/filters/filter-in");
|
|
10
|
+
const filter_out_1 = require("../common/filters/filter-out");
|
|
9
11
|
exports.decorators = {
|
|
10
12
|
'registry-dependencies': registry_dependencies_1.RegistryDependencies,
|
|
11
13
|
'operation-description-override': operation_description_override_1.OperationDescriptionOverride,
|
|
12
14
|
'tag-description-override': tag_description_override_1.TagDescriptionOverride,
|
|
13
15
|
'info-description-override': info_description_override_1.InfoDescriptionOverride,
|
|
14
|
-
'remove-x-internal': remove_x_internal_1.RemoveXInternal
|
|
16
|
+
'remove-x-internal': remove_x_internal_1.RemoveXInternal,
|
|
17
|
+
'filter-in': filter_in_1.FilterIn,
|
|
18
|
+
'filter-out': filter_out_1.FilterOut,
|
|
15
19
|
};
|
|
@@ -6,10 +6,14 @@ const operation_description_override_1 = require("../common/operation-descriptio
|
|
|
6
6
|
const tag_description_override_1 = require("../common/tag-description-override");
|
|
7
7
|
const info_description_override_1 = require("../common/info-description-override");
|
|
8
8
|
const remove_x_internal_1 = require("../common/remove-x-internal");
|
|
9
|
+
const filter_in_1 = require("../common/filters/filter-in");
|
|
10
|
+
const filter_out_1 = require("../common/filters/filter-out");
|
|
9
11
|
exports.decorators = {
|
|
10
12
|
'registry-dependencies': registry_dependencies_1.RegistryDependencies,
|
|
11
13
|
'operation-description-override': operation_description_override_1.OperationDescriptionOverride,
|
|
12
14
|
'tag-description-override': tag_description_override_1.TagDescriptionOverride,
|
|
13
15
|
'info-description-override': info_description_override_1.InfoDescriptionOverride,
|
|
14
|
-
'remove-x-internal': remove_x_internal_1.RemoveXInternal
|
|
16
|
+
'remove-x-internal': remove_x_internal_1.RemoveXInternal,
|
|
17
|
+
'filter-in': filter_in_1.FilterIn,
|
|
18
|
+
'filter-out': filter_out_1.FilterOut,
|
|
15
19
|
};
|
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { BundleOutputFormat, readFileFromUrl, slash } from './utils';
|
|
1
|
+
export { BundleOutputFormat, readFileFromUrl, slash, doesYamlFileExist } from './utils';
|
|
2
2
|
export { Oas3_1Types } from './types/oas3_1';
|
|
3
3
|
export { Oas3Types } from './types/oas3';
|
|
4
4
|
export { Oas2Types } from './types/oas2';
|
|
@@ -8,7 +8,7 @@ export { Oas2Definition } from './typings/swagger';
|
|
|
8
8
|
export { StatsAccumulator, StatsName } from './typings/common';
|
|
9
9
|
export { normalizeTypes } from './types';
|
|
10
10
|
export { Stats } from './rules/other/stats';
|
|
11
|
-
export { Config, LintConfig, RawConfig, IGNORE_FILE, Region, getMergedConfig, transformConfig, loadConfig, getConfig, findConfig, CONFIG_FILE_NAMES, } from './config';
|
|
11
|
+
export { Config, LintConfig, RawConfig, IGNORE_FILE, Region, getMergedConfig, transformConfig, loadConfig, getConfig, findConfig, CONFIG_FILE_NAMES, RuleSeverity } from './config';
|
|
12
12
|
export { RedoclyClient, isRedoclyRegistryURL } from './redocly';
|
|
13
13
|
export { Source, BaseResolver, Document, resolveDocument, ResolveError, YamlParseError, makeDocumentFromString, } from './resolve';
|
|
14
14
|
export { parseYaml, stringifyYaml } from './js-yaml';
|
package/lib/index.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mapTypeToComponent = exports.bundleDocument = exports.bundle = exports.lintConfig = exports.lintFromString = exports.lintDocument = exports.validate = exports.lint = exports.getTotals = exports.formatProblems = exports.getLineColLocation = exports.getAstNodeByPointer = exports.walkDocument = exports.normalizeVisitors = exports.OasVersion = exports.openAPIMajor = exports.OasMajorVersion = exports.detectOpenAPI = exports.isRef = exports.unescapePointer = exports.stringifyYaml = exports.parseYaml = exports.makeDocumentFromString = exports.YamlParseError = exports.ResolveError = exports.resolveDocument = exports.BaseResolver = exports.Source = exports.isRedoclyRegistryURL = exports.RedoclyClient = exports.CONFIG_FILE_NAMES = exports.findConfig = exports.getConfig = exports.loadConfig = exports.transformConfig = exports.getMergedConfig = exports.IGNORE_FILE = exports.LintConfig = exports.Config = exports.Stats = exports.normalizeTypes = exports.ConfigTypes = exports.Oas2Types = exports.Oas3Types = exports.Oas3_1Types = exports.slash = exports.readFileFromUrl = void 0;
|
|
3
|
+
exports.mapTypeToComponent = exports.bundleDocument = exports.bundle = exports.lintConfig = exports.lintFromString = exports.lintDocument = exports.validate = exports.lint = exports.getTotals = exports.formatProblems = exports.getLineColLocation = exports.getAstNodeByPointer = exports.walkDocument = exports.normalizeVisitors = exports.OasVersion = exports.openAPIMajor = exports.OasMajorVersion = exports.detectOpenAPI = exports.isRef = exports.unescapePointer = exports.stringifyYaml = exports.parseYaml = exports.makeDocumentFromString = exports.YamlParseError = exports.ResolveError = exports.resolveDocument = exports.BaseResolver = exports.Source = exports.isRedoclyRegistryURL = exports.RedoclyClient = exports.CONFIG_FILE_NAMES = exports.findConfig = exports.getConfig = exports.loadConfig = exports.transformConfig = exports.getMergedConfig = exports.IGNORE_FILE = exports.LintConfig = exports.Config = exports.Stats = exports.normalizeTypes = exports.ConfigTypes = exports.Oas2Types = exports.Oas3Types = exports.Oas3_1Types = exports.doesYamlFileExist = exports.slash = exports.readFileFromUrl = void 0;
|
|
4
4
|
var utils_1 = require("./utils");
|
|
5
5
|
Object.defineProperty(exports, "readFileFromUrl", { enumerable: true, get: function () { return utils_1.readFileFromUrl; } });
|
|
6
6
|
Object.defineProperty(exports, "slash", { enumerable: true, get: function () { return utils_1.slash; } });
|
|
7
|
+
Object.defineProperty(exports, "doesYamlFileExist", { enumerable: true, get: function () { return utils_1.doesYamlFileExist; } });
|
|
7
8
|
var oas3_1_1 = require("./types/oas3_1");
|
|
8
9
|
Object.defineProperty(exports, "Oas3_1Types", { enumerable: true, get: function () { return oas3_1_1.Oas3_1Types; } });
|
|
9
10
|
var oas3_1 = require("./types/oas3");
|
package/lib/lint.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BaseResolver, Document } from './resolve';
|
|
2
2
|
import { NodeType } from './types';
|
|
3
|
+
import { ProblemSeverity } from './walk';
|
|
3
4
|
import { LintConfig, Config } from './config';
|
|
4
5
|
export declare function lint(opts: {
|
|
5
6
|
ref: string;
|
|
@@ -20,4 +21,5 @@ export declare function lintDocument(opts: {
|
|
|
20
21
|
}): Promise<import("./walk").NormalizedProblem[]>;
|
|
21
22
|
export declare function lintConfig(opts: {
|
|
22
23
|
document: Document;
|
|
24
|
+
severity?: ProblemSeverity;
|
|
23
25
|
}): Promise<import("./walk").NormalizedProblem[]>;
|
package/lib/lint.js
CHANGED
|
@@ -72,7 +72,7 @@ function lintDocument(opts) {
|
|
|
72
72
|
exports.lintDocument = lintDocument;
|
|
73
73
|
function lintConfig(opts) {
|
|
74
74
|
return __awaiter(this, void 0, void 0, function* () {
|
|
75
|
-
const { document } = opts;
|
|
75
|
+
const { document, severity } = opts;
|
|
76
76
|
const ctx = {
|
|
77
77
|
problems: [],
|
|
78
78
|
oasVersion: oas_types_1.OasVersion.Version3_0,
|
|
@@ -84,7 +84,7 @@ function lintConfig(opts) {
|
|
|
84
84
|
rules: { spec: 'error' },
|
|
85
85
|
});
|
|
86
86
|
const types = types_1.normalizeTypes(redocly_yaml_1.ConfigTypes, config);
|
|
87
|
-
const rules = [{ severity: 'error', ruleId: 'spec', visitor: spec_1.OasSpec({ severity: 'error' }) }];
|
|
87
|
+
const rules = [{ severity: severity || 'error', ruleId: 'configuration spec', visitor: spec_1.OasSpec({ severity: 'error' }) }];
|
|
88
88
|
const normalizedVisitors = visitors_1.normalizeVisitors(rules, types);
|
|
89
89
|
walk_1.walkDocument({
|
|
90
90
|
document,
|
|
@@ -13,5 +13,5 @@ export declare class RegistryApi {
|
|
|
13
13
|
organizations: string[];
|
|
14
14
|
}>;
|
|
15
15
|
prepareFileUpload({ organizationId, name, version, filesHash, filename, isUpsert, }: RegistryApiTypes.PrepareFileuploadParams): Promise<RegistryApiTypes.PrepareFileuploadOKResponse>;
|
|
16
|
-
pushApi({ organizationId, name, version, rootFilePath, filePaths, branch, isUpsert, isPublic, }: RegistryApiTypes.PushApiParams): Promise<void>;
|
|
16
|
+
pushApi({ organizationId, name, version, rootFilePath, filePaths, branch, isUpsert, isPublic, batchId, batchSize }: RegistryApiTypes.PushApiParams): Promise<void>;
|
|
17
17
|
}
|
|
@@ -80,7 +80,7 @@ class RegistryApi {
|
|
|
80
80
|
throw new Error('Could not prepare file upload');
|
|
81
81
|
});
|
|
82
82
|
}
|
|
83
|
-
pushApi({ organizationId, name, version, rootFilePath, filePaths, branch, isUpsert, isPublic, }) {
|
|
83
|
+
pushApi({ organizationId, name, version, rootFilePath, filePaths, branch, isUpsert, isPublic, batchId, batchSize }) {
|
|
84
84
|
return __awaiter(this, void 0, void 0, function* () {
|
|
85
85
|
const response = yield this.request(`/${organizationId}/${name}/${version}`, {
|
|
86
86
|
method: 'PUT',
|
|
@@ -94,6 +94,8 @@ class RegistryApi {
|
|
|
94
94
|
branch,
|
|
95
95
|
isUpsert,
|
|
96
96
|
isPublic,
|
|
97
|
+
batchId,
|
|
98
|
+
batchSize
|
|
97
99
|
}),
|
|
98
100
|
}, this.region);
|
|
99
101
|
if (response.ok) {
|
package/lib/rules/ajv.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { ErrorObject } from '@redocly/ajv';
|
|
|
2
2
|
import { Location } from '../ref-utils';
|
|
3
3
|
import { ResolveFn } from '../walk';
|
|
4
4
|
export declare function releaseAjvInstance(): void;
|
|
5
|
-
export declare function validateJsonSchema(data: any, schema: any, schemaLoc: Location, instancePath: string, resolve: ResolveFn
|
|
5
|
+
export declare function validateJsonSchema(data: any, schema: any, schemaLoc: Location, instancePath: string, resolve: ResolveFn, disallowAdditionalProperties: boolean): {
|
|
6
6
|
valid: boolean;
|
|
7
7
|
errors: (ErrorObject & {
|
|
8
8
|
suggest?: string[];
|
package/lib/rules/ajv.js
CHANGED
|
@@ -24,7 +24,7 @@ function getAjv(resolve, disallowAdditionalProperties) {
|
|
|
24
24
|
loadSchemaSync(base, $ref) {
|
|
25
25
|
const resolvedRef = resolve({ $ref }, base.split('#')[0]);
|
|
26
26
|
if (!resolvedRef || !resolvedRef.location)
|
|
27
|
-
return
|
|
27
|
+
return false;
|
|
28
28
|
return Object.assign({ $id: resolvedRef.location.absolutePointer }, resolvedRef.node);
|
|
29
29
|
},
|
|
30
30
|
logger: false,
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import { Location } from '../../../ref-utils';
|
|
2
|
+
declare type AssertResult = {
|
|
3
|
+
isValid: boolean;
|
|
4
|
+
location?: Location;
|
|
5
|
+
};
|
|
6
|
+
declare type Asserts = Record<string, (value: any, condition: any, baseLocation: Location, rawValue?: any) => AssertResult>;
|
|
2
7
|
export declare const runOnKeysSet: Set<string>;
|
|
3
8
|
export declare const runOnValuesSet: Set<string>;
|
|
4
9
|
export declare const asserts: Asserts;
|