@redocly/openapi-core 1.3.0 → 1.4.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 +18 -0
- package/lib/benchmark/benches/lint-with-many-rules.bench.js +4 -4
- package/lib/benchmark/benches/lint-with-nested-rule.bench.js +4 -4
- package/lib/benchmark/benches/lint-with-no-rules.bench.js +4 -4
- package/lib/benchmark/benches/lint-with-top-level-rule-report.bench.js +4 -4
- package/lib/benchmark/benches/lint-with-top-level-rule.bench.js +4 -4
- package/lib/benchmark/benches/recommended-oas3.bench.js +4 -4
- package/lib/benchmark/benches/resolve-with-no-external.bench.js +3 -3
- package/lib/benchmark/utils.js +3 -3
- package/lib/bundle.d.ts +4 -4
- package/lib/bundle.js +25 -25
- package/lib/config/all.d.ts +2 -2
- package/lib/config/all.js +44 -8
- package/lib/config/builtIn.js +2 -0
- package/lib/config/config-resolvers.js +25 -25
- package/lib/config/config.js +9 -9
- package/lib/config/index.js +5 -1
- package/lib/config/load.d.ts +1 -1
- package/lib/config/load.js +6 -6
- package/lib/config/minimal.d.ts +2 -2
- package/lib/config/minimal.js +34 -3
- package/lib/config/recommended-strict.d.ts +3 -0
- package/lib/config/recommended-strict.js +92 -0
- package/lib/config/recommended.d.ts +2 -2
- package/lib/config/recommended.js +34 -3
- package/lib/config/rules.d.ts +1 -1
- package/lib/config/types.d.ts +47 -46
- package/lib/config/types.js +2 -2
- package/lib/config/utils.js +26 -14
- package/lib/decorators/common/filters/filter-helper.js +4 -4
- package/lib/decorators/common/filters/filter-in.js +2 -2
- package/lib/decorators/common/filters/filter-out.js +2 -2
- package/lib/decorators/common/info-description-override.js +1 -1
- package/lib/decorators/common/media-type-examples-override.js +3 -3
- package/lib/decorators/common/operation-description-override.js +1 -1
- package/lib/decorators/common/registry-dependencies.js +1 -1
- package/lib/decorators/common/remove-x-internal.js +4 -4
- package/lib/decorators/common/tag-description-override.js +1 -1
- package/lib/decorators/oas2/remove-unused-components.d.ts +2 -0
- package/lib/{rules → decorators}/oas2/remove-unused-components.js +1 -1
- package/lib/decorators/oas3/remove-unused-components.d.ts +2 -0
- package/lib/{rules → decorators}/oas3/remove-unused-components.js +2 -2
- package/lib/env.js +1 -1
- package/lib/format/codeframes.d.ts +6 -6
- package/lib/format/format.d.ts +2 -2
- package/lib/format/format.js +12 -12
- package/lib/js-yaml/index.d.ts +2 -2
- package/lib/js-yaml/index.js +2 -2
- package/lib/lint.js +18 -18
- package/lib/oas-types.d.ts +12 -10
- package/lib/oas-types.js +2 -2
- package/lib/redocly/index.js +10 -10
- package/lib/redocly/registry-api.js +2 -2
- package/lib/resolve.d.ts +4 -4
- package/lib/resolve.js +18 -18
- package/lib/rules/ajv.js +1 -1
- package/lib/rules/async2/index.d.ts +2 -11
- package/lib/rules/common/assertions/asserts.d.ts +3 -3
- package/lib/rules/common/assertions/asserts.js +21 -21
- package/lib/rules/common/assertions/index.d.ts +4 -4
- package/lib/rules/common/assertions/index.js +3 -3
- package/lib/rules/common/assertions/utils.d.ts +4 -4
- package/lib/rules/common/assertions/utils.js +3 -3
- package/lib/rules/common/info-contact.js +1 -1
- package/lib/rules/common/info-license-url.js +1 -1
- package/lib/rules/common/info-license.js +1 -1
- package/lib/rules/common/no-enum-type-mismatch.js +3 -3
- package/lib/rules/common/no-http-verbs-in-paths.js +2 -2
- package/lib/rules/common/no-invalid-parameter-examples.js +3 -3
- package/lib/rules/common/no-invalid-schema-examples.js +3 -3
- package/lib/rules/common/operation-2xx-response.js +2 -2
- package/lib/rules/common/operation-4xx-response.js +2 -2
- package/lib/rules/common/operation-description.js +1 -1
- package/lib/rules/common/operation-operationId.js +1 -1
- package/lib/rules/common/operation-summary.js +1 -1
- package/lib/rules/common/path-segment-plural.js +1 -1
- package/lib/rules/common/response-contains-header.js +2 -2
- package/lib/rules/common/spec-strict-refs.js +1 -1
- package/lib/rules/common/spec.js +11 -11
- package/lib/rules/common/tag-description.js +1 -1
- package/lib/rules/oas2/boolean-parameter-prefixes.d.ts +1 -1
- package/lib/rules/oas2/index.d.ts +2 -46
- package/lib/rules/oas2/request-mime-type.js +2 -2
- package/lib/rules/oas2/response-contains-property.js +2 -2
- package/lib/rules/oas2/response-mime-type.js +2 -2
- package/lib/rules/oas3/boolean-parameter-prefixes.d.ts +1 -1
- package/lib/rules/oas3/index.d.ts +1 -1
- package/lib/rules/oas3/index.js +1 -1
- package/lib/rules/oas3/no-invalid-media-type-examples.js +3 -3
- package/lib/rules/oas3/operation-4xx-problem-details-rfc7807.js +3 -3
- package/lib/rules/oas3/request-mime-type.js +3 -3
- package/lib/rules/oas3/response-contains-property.js +2 -2
- package/lib/rules/oas3/response-mime-type.js +3 -3
- package/lib/rules/utils.js +3 -3
- package/lib/types/asyncapi.js +21 -21
- package/lib/types/index.d.ts +8 -8
- package/lib/types/oas2.js +14 -14
- package/lib/types/oas3.js +27 -27
- package/lib/types/oas3_1.js +18 -6
- package/lib/types/redocly-yaml.d.ts +11 -0
- package/lib/types/redocly-yaml.js +71 -53
- package/lib/types/theme-config.js +1 -1
- package/lib/typings/common.d.ts +2 -2
- package/lib/typings/openapi.d.ts +6 -6
- package/lib/typings/swagger.d.ts +3 -3
- package/lib/utils.d.ts +5 -5
- package/lib/utils.js +3 -3
- package/lib/visitors.d.ts +38 -40
- package/lib/walk.d.ts +14 -15
- package/lib/walk.js +11 -11
- package/package.json +2 -2
- package/src/__tests__/lint.test.ts +40 -40
- package/src/__tests__/normalizeVisitors.test.ts +23 -5
- package/src/__tests__/ref-utils.test.ts +7 -7
- package/src/__tests__/resolve-http.test.ts +10 -10
- package/src/__tests__/resolve.test.ts +39 -39
- package/src/__tests__/walk.test.ts +48 -48
- package/src/bundle.ts +4 -4
- package/src/config/__tests__/__snapshots__/config-resolvers.test.ts.snap +95 -32
- package/src/config/__tests__/__snapshots__/config.test.ts.snap +81 -81
- package/src/config/__tests__/config-resolvers.test.ts +30 -1
- package/src/config/__tests__/config.test.ts +88 -88
- package/src/config/__tests__/load.test.ts +12 -8
- package/src/config/__tests__/utils.test.ts +18 -18
- package/src/config/all.ts +46 -9
- package/src/config/builtIn.ts +2 -0
- package/src/config/minimal.ts +36 -4
- package/src/config/recommended-strict.ts +93 -0
- package/src/config/recommended.ts +36 -4
- package/src/config/types.ts +22 -8
- package/src/config/utils.ts +15 -0
- package/src/decorators/common/media-type-examples-override.ts +2 -2
- package/src/{rules → decorators}/oas2/remove-unused-components.ts +3 -3
- package/src/{rules → decorators}/oas3/remove-unused-components.ts +3 -3
- package/src/env.ts +1 -1
- package/src/lint.ts +3 -3
- package/src/oas-types.ts +26 -3
- package/src/rules/__tests__/no-unresolved-refs.test.ts +26 -26
- package/src/rules/async2/__tests__/channels-kebab-case.test.ts +12 -12
- package/src/rules/async2/__tests__/no-channel-trailing-slash.test.ts +7 -7
- package/src/rules/async2/index.ts +2 -1
- package/src/rules/common/__tests__/info-license.test.ts +6 -6
- package/src/rules/common/__tests__/license-url.test.ts +6 -6
- package/src/rules/common/__tests__/no-ambiguous-paths.test.ts +13 -13
- package/src/rules/common/__tests__/no-enum-type-mismatch.test.ts +18 -18
- package/src/rules/common/__tests__/no-identical-paths.test.ts +5 -5
- package/src/rules/common/__tests__/no-path-trailing-slash.test.ts +12 -12
- package/src/rules/common/__tests__/operation-2xx-response.test.ts +18 -18
- package/src/rules/common/__tests__/operation-4xx-response.test.ts +23 -23
- package/src/rules/common/__tests__/operation-operationId-unique.test.ts +6 -6
- package/src/rules/common/__tests__/operation-operationId-url-safe.test.ts +5 -5
- package/src/rules/common/__tests__/operation-parameters-unique.test.ts +16 -16
- package/src/rules/common/__tests__/operation-singular-tag.test.ts +6 -6
- package/src/rules/common/__tests__/path-http-verbs-order.test.ts +10 -10
- package/src/rules/common/__tests__/path-not-include-query.test.ts +6 -6
- package/src/rules/common/__tests__/path-params-defined.test.ts +21 -21
- package/src/rules/common/__tests__/paths-kebab-case.test.ts +11 -11
- package/src/rules/common/__tests__/scalar-property-missing-example.test.ts +18 -18
- package/src/rules/common/__tests__/security-defined.test.ts +21 -21
- package/src/rules/common/__tests__/spec-strict-refs.test.ts +9 -9
- package/src/rules/common/__tests__/spec.test.ts +102 -102
- package/src/rules/common/__tests__/tag-description.test.ts +6 -6
- package/src/rules/common/__tests__/tags-alphabetical.test.ts +12 -12
- package/src/rules/common/assertions/__tests__/index.test.ts +15 -15
- package/src/rules/common/assertions/__tests__/utils.test.ts +9 -9
- package/src/rules/oas2/__tests__/boolean-parameter-prefixes.test.ts +7 -7
- package/src/rules/oas2/__tests__/response-contains-header.test.ts +13 -13
- package/src/rules/oas2/__tests__/response-contains-property.test.ts +8 -8
- package/src/rules/oas2/__tests__/spec/info.test.ts +21 -21
- package/src/rules/oas2/__tests__/spec/operation.test.ts +4 -4
- package/src/rules/oas2/__tests__/spec/paths.test.ts +12 -12
- package/src/rules/oas2/__tests__/spec/referenceableScalars.test.ts +1 -1
- package/src/rules/oas2/index.ts +3 -1
- package/src/rules/oas3/__tests__/boolean-parameter-prefixes.test.ts +7 -7
- package/src/rules/oas3/__tests__/component-name-unique.test.ts +186 -186
- package/src/rules/oas3/__tests__/no-empty-enum-servers.com.test.ts +18 -18
- package/src/rules/oas3/__tests__/no-example-value-and-externalValue.test.ts +6 -6
- package/src/rules/oas3/__tests__/no-invalid-media-type-examples.test.ts +36 -36
- package/src/rules/oas3/__tests__/no-server-example.com.test.ts +11 -11
- package/src/rules/oas3/__tests__/no-server-trailing-slash.test.ts +7 -7
- package/src/rules/oas3/__tests__/no-unused-components.test.ts +31 -31
- package/src/rules/oas3/__tests__/operation-4xx-problem-details-rfc7807.test.ts +15 -15
- package/src/rules/oas3/__tests__/response-contains-header.test.ts +26 -26
- package/src/rules/oas3/__tests__/response-contains-property.test.ts +27 -27
- package/src/rules/oas3/__tests__/spec/callbacks.test.ts +1 -1
- package/src/rules/oas3/__tests__/spec/info.test.ts +21 -21
- package/src/rules/oas3/__tests__/spec/operation.test.ts +10 -10
- package/src/rules/oas3/__tests__/spec/paths.test.ts +13 -13
- package/src/rules/oas3/__tests__/spec/referenceableScalars.test.ts +2 -2
- package/src/rules/oas3/__tests__/spec/servers.test.ts +25 -25
- package/src/rules/oas3/__tests__/spec/spec.test.ts +56 -56
- package/src/rules/oas3/__tests__/spec-components-invalid-map-name.test.ts +28 -28
- package/src/rules/oas3/index.ts +3 -3
- package/src/types/oas3_1.ts +12 -0
- package/src/types/redocly-yaml.ts +75 -40
- package/src/visitors.ts +10 -21
- package/src/walk.ts +23 -10
- package/tsconfig.tsbuildinfo +1 -1
- package/lib/rules/oas2/remove-unused-components.d.ts +0 -2
- package/lib/rules/oas3/remove-unused-components.d.ts +0 -2
- /package/src/{rules → decorators}/oas2/__tests__/remove-unused-components.test.ts +0 -0
- /package/src/{rules → decorators}/oas3/__tests__/remove-unused-components.test.ts +0 -0
package/lib/format/format.js
CHANGED
|
@@ -76,7 +76,7 @@ function formatProblems(problems, opts) {
|
|
|
76
76
|
case 'stylish': {
|
|
77
77
|
const groupedByFile = groupByFiles(problems);
|
|
78
78
|
for (const [file, { ruleIdPad, locationPad: positionPad, fileProblems }] of Object.entries(groupedByFile)) {
|
|
79
|
-
logger_1.logger.info(`${logger_1.colorize.blue(ref_utils_1.isAbsoluteUrl(file) ? file : path.relative(cwd, file))}:\n`);
|
|
79
|
+
logger_1.logger.info(`${logger_1.colorize.blue((0, ref_utils_1.isAbsoluteUrl)(file) ? file : path.relative(cwd, file))}:\n`);
|
|
80
80
|
for (let i = 0; i < fileProblems.length; i++) {
|
|
81
81
|
const problem = fileProblems[i];
|
|
82
82
|
logger_1.logger.info(`${formatStylish(problem, positionPad, ruleIdPad)}\n`);
|
|
@@ -90,7 +90,7 @@ function formatProblems(problems, opts) {
|
|
|
90
90
|
output_1.output.write('<?xml version="1.0" encoding="UTF-8"?>\n');
|
|
91
91
|
output_1.output.write('<checkstyle version="4.3">\n');
|
|
92
92
|
for (const [file, { fileProblems }] of Object.entries(groupedByFile)) {
|
|
93
|
-
output_1.output.write(`<file name="${xmlEscape(ref_utils_1.isAbsoluteUrl(file) ? file : path.relative(cwd, file))}">\n`);
|
|
93
|
+
output_1.output.write(`<file name="${xmlEscape((0, ref_utils_1.isAbsoluteUrl)(file) ? file : path.relative(cwd, file))}">\n`);
|
|
94
94
|
fileProblems.forEach(formatCheckstyle);
|
|
95
95
|
output_1.output.write(`</file>\n`);
|
|
96
96
|
}
|
|
@@ -110,11 +110,11 @@ function formatProblems(problems, opts) {
|
|
|
110
110
|
function outputForCodeClimate() {
|
|
111
111
|
const issues = problems.map((p) => {
|
|
112
112
|
const location = p.location[0]; // TODO: support multiple location
|
|
113
|
-
const lineCol = codeframes_1.getLineColLocation(location);
|
|
113
|
+
const lineCol = (0, codeframes_1.getLineColLocation)(location);
|
|
114
114
|
return {
|
|
115
115
|
description: p.message,
|
|
116
116
|
location: {
|
|
117
|
-
path: ref_utils_1.isAbsoluteUrl(location.source.absoluteRef)
|
|
117
|
+
path: (0, ref_utils_1.isAbsoluteUrl)(location.source.absoluteRef)
|
|
118
118
|
? location.source.absoluteRef
|
|
119
119
|
: path.relative(cwd, location.source.absoluteRef),
|
|
120
120
|
lines: {
|
|
@@ -134,19 +134,19 @@ function formatProblems(problems, opts) {
|
|
|
134
134
|
problems: problems.map((p) => {
|
|
135
135
|
var _a, _b, _c;
|
|
136
136
|
const problem = Object.assign(Object.assign({}, p), { location: p.location.map((location) => (Object.assign(Object.assign({}, location), { source: {
|
|
137
|
-
ref: ref_utils_1.isAbsoluteUrl(location.source.absoluteRef)
|
|
137
|
+
ref: (0, ref_utils_1.isAbsoluteUrl)(location.source.absoluteRef)
|
|
138
138
|
? location.source.absoluteRef
|
|
139
139
|
: path.relative(cwd, location.source.absoluteRef),
|
|
140
140
|
} }))), from: p.from
|
|
141
141
|
? Object.assign(Object.assign({}, p.from), { source: {
|
|
142
|
-
ref: ref_utils_1.isAbsoluteUrl((_a = p.from) === null || _a === void 0 ? void 0 : _a.source.absoluteRef)
|
|
142
|
+
ref: (0, ref_utils_1.isAbsoluteUrl)((_a = p.from) === null || _a === void 0 ? void 0 : _a.source.absoluteRef)
|
|
143
143
|
? (_b = p.from) === null || _b === void 0 ? void 0 : _b.source.absoluteRef
|
|
144
144
|
: path.relative(cwd, ((_c = p.from) === null || _c === void 0 ? void 0 : _c.source.absoluteRef) || cwd),
|
|
145
145
|
} }) : undefined });
|
|
146
146
|
if (env_1.env.FORMAT_JSON_WITH_CODEFRAMES) {
|
|
147
147
|
const location = p.location[0]; // TODO: support multiple locations
|
|
148
|
-
const loc = codeframes_1.getLineColLocation(location);
|
|
149
|
-
problem.codeframe = codeframes_1.getCodeframe(loc, color);
|
|
148
|
+
const loc = (0, codeframes_1.getLineColLocation)(location);
|
|
149
|
+
problem.codeframe = (0, codeframes_1.getCodeframe)(loc, color);
|
|
150
150
|
}
|
|
151
151
|
return problem;
|
|
152
152
|
}),
|
|
@@ -163,16 +163,16 @@ function formatProblems(problems, opts) {
|
|
|
163
163
|
function formatCodeframe(problem, idx) {
|
|
164
164
|
const bgColor = getBgColor(problem);
|
|
165
165
|
const location = problem.location[0]; // TODO: support multiple locations
|
|
166
|
-
const relativePath = ref_utils_1.isAbsoluteUrl(location.source.absoluteRef)
|
|
166
|
+
const relativePath = (0, ref_utils_1.isAbsoluteUrl)(location.source.absoluteRef)
|
|
167
167
|
? location.source.absoluteRef
|
|
168
168
|
: path.relative(cwd, location.source.absoluteRef);
|
|
169
|
-
const loc = codeframes_1.getLineColLocation(location);
|
|
169
|
+
const loc = (0, codeframes_1.getLineColLocation)(location);
|
|
170
170
|
const atPointer = location.pointer ? logger_1.colorize.gray(`at ${location.pointer}`) : '';
|
|
171
171
|
const fileWithLoc = `${relativePath}:${loc.start.line}:${loc.start.col}`;
|
|
172
172
|
return (`[${idx + 1}] ${bgColor(fileWithLoc)} ${atPointer}\n\n` +
|
|
173
173
|
`${problem.message}\n\n` +
|
|
174
174
|
formatDidYouMean(problem) +
|
|
175
|
-
codeframes_1.getCodeframe(loc, color) +
|
|
175
|
+
(0, codeframes_1.getCodeframe)(loc, color) +
|
|
176
176
|
'\n\n' +
|
|
177
177
|
formatFrom(cwd, problem.from) +
|
|
178
178
|
`${SEVERITY_NAMES[problem.severity]} was generated by the ${logger_1.colorize.blue(problem.ruleId)} rule.\n\n`);
|
|
@@ -216,7 +216,7 @@ function formatFrom(cwd, location) {
|
|
|
216
216
|
if (!location)
|
|
217
217
|
return '';
|
|
218
218
|
const relativePath = path.relative(cwd, location.source.absoluteRef);
|
|
219
|
-
const loc = codeframes_1.getLineColLocation(location);
|
|
219
|
+
const loc = (0, codeframes_1.getLineColLocation)(location);
|
|
220
220
|
const fileWithLoc = `${relativePath}:${loc.start.line}:${loc.start.col}`;
|
|
221
221
|
const atPointer = location.pointer ? logger_1.colorize.gray(`at ${location.pointer}`) : '';
|
|
222
222
|
return `referenced from ${logger_1.colorize.blue(fileWithLoc)} ${atPointer} \n\n`;
|
package/lib/js-yaml/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { LoadOptions, DumpOptions } from 'js-yaml';
|
|
2
|
-
export declare const parseYaml: (str: string, opts?: LoadOptions
|
|
3
|
-
export declare const stringifyYaml: (obj: any, opts?: DumpOptions
|
|
2
|
+
export declare const parseYaml: (str: string, opts?: LoadOptions) => unknown;
|
|
3
|
+
export declare const stringifyYaml: (obj: any, opts?: DumpOptions) => string;
|
package/lib/js-yaml/index.js
CHANGED
|
@@ -9,7 +9,7 @@ const DEFAULT_SCHEMA_WITHOUT_TIMESTAMP = js_yaml_1.JSON_SCHEMA.extend({
|
|
|
9
9
|
implicit: [js_yaml_1.types.merge],
|
|
10
10
|
explicit: [js_yaml_1.types.binary, js_yaml_1.types.omap, js_yaml_1.types.pairs, js_yaml_1.types.set],
|
|
11
11
|
});
|
|
12
|
-
const parseYaml = (str, opts) => js_yaml_1.load(str, Object.assign({ schema: DEFAULT_SCHEMA_WITHOUT_TIMESTAMP }, opts));
|
|
12
|
+
const parseYaml = (str, opts) => (0, js_yaml_1.load)(str, Object.assign({ schema: DEFAULT_SCHEMA_WITHOUT_TIMESTAMP }, opts));
|
|
13
13
|
exports.parseYaml = parseYaml;
|
|
14
|
-
const stringifyYaml = (obj, opts) => js_yaml_1.dump(obj, opts);
|
|
14
|
+
const stringifyYaml = (obj, opts) => (0, js_yaml_1.dump)(obj, opts);
|
|
15
15
|
exports.stringifyYaml = stringifyYaml;
|
package/lib/lint.js
CHANGED
|
@@ -30,48 +30,48 @@ exports.lint = lint;
|
|
|
30
30
|
function lintFromString(opts) {
|
|
31
31
|
return __awaiter(this, void 0, void 0, function* () {
|
|
32
32
|
const { source, absoluteRef, externalRefResolver = new resolve_1.BaseResolver(opts.config.resolve) } = opts;
|
|
33
|
-
const document = resolve_1.makeDocumentFromString(source, absoluteRef || '/');
|
|
33
|
+
const document = (0, resolve_1.makeDocumentFromString)(source, absoluteRef || '/');
|
|
34
34
|
return lintDocument(Object.assign(Object.assign({ document }, opts), { externalRefResolver, config: opts.config.styleguide }));
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
37
|
exports.lintFromString = lintFromString;
|
|
38
38
|
function lintDocument(opts) {
|
|
39
39
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
-
ajv_1.releaseAjvInstance(); // FIXME: preprocessors can modify nodes which are then cached to ajv-instance by absolute path
|
|
40
|
+
(0, ajv_1.releaseAjvInstance)(); // FIXME: preprocessors can modify nodes which are then cached to ajv-instance by absolute path
|
|
41
41
|
const { document, customTypes, externalRefResolver, config } = opts;
|
|
42
|
-
const specVersion = oas_types_1.detectSpec(document.parsed);
|
|
43
|
-
const specMajorVersion = oas_types_1.getMajorSpecVersion(specVersion);
|
|
42
|
+
const specVersion = (0, oas_types_1.detectSpec)(document.parsed);
|
|
43
|
+
const specMajorVersion = (0, oas_types_1.getMajorSpecVersion)(specVersion);
|
|
44
44
|
const rules = config.getRulesForOasVersion(specMajorVersion);
|
|
45
|
-
const types = types_1.normalizeTypes(config.extendTypes(customTypes !== null && customTypes !== void 0 ? customTypes : oas_types_1.getTypes(specVersion), specVersion), config);
|
|
45
|
+
const types = (0, types_1.normalizeTypes)(config.extendTypes(customTypes !== null && customTypes !== void 0 ? customTypes : (0, oas_types_1.getTypes)(specVersion), specVersion), config);
|
|
46
46
|
const ctx = {
|
|
47
47
|
problems: [],
|
|
48
48
|
oasVersion: specVersion,
|
|
49
49
|
visitorsData: {},
|
|
50
50
|
};
|
|
51
|
-
const preprocessors = config_1.initRules(rules, config, 'preprocessors', specVersion);
|
|
52
|
-
const regularRules = config_1.initRules(rules, config, 'rules', specVersion);
|
|
53
|
-
let resolvedRefMap = yield resolve_1.resolveDocument({
|
|
51
|
+
const preprocessors = (0, config_1.initRules)(rules, config, 'preprocessors', specVersion);
|
|
52
|
+
const regularRules = (0, config_1.initRules)(rules, config, 'rules', specVersion);
|
|
53
|
+
let resolvedRefMap = yield (0, resolve_1.resolveDocument)({
|
|
54
54
|
rootDocument: document,
|
|
55
55
|
rootType: types.Root,
|
|
56
56
|
externalRefResolver,
|
|
57
57
|
});
|
|
58
58
|
if (preprocessors.length > 0) {
|
|
59
59
|
// Make additional pass to resolve refs defined in preprocessors.
|
|
60
|
-
walk_1.walkDocument({
|
|
60
|
+
(0, walk_1.walkDocument)({
|
|
61
61
|
document,
|
|
62
62
|
rootType: types.Root,
|
|
63
|
-
normalizedVisitors: visitors_1.normalizeVisitors(preprocessors, types),
|
|
63
|
+
normalizedVisitors: (0, visitors_1.normalizeVisitors)(preprocessors, types),
|
|
64
64
|
resolvedRefMap,
|
|
65
65
|
ctx,
|
|
66
66
|
});
|
|
67
|
-
resolvedRefMap = yield resolve_1.resolveDocument({
|
|
67
|
+
resolvedRefMap = yield (0, resolve_1.resolveDocument)({
|
|
68
68
|
rootDocument: document,
|
|
69
69
|
rootType: types.Root,
|
|
70
70
|
externalRefResolver,
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
|
-
const normalizedVisitors = visitors_1.normalizeVisitors(regularRules, types);
|
|
74
|
-
walk_1.walkDocument({
|
|
73
|
+
const normalizedVisitors = (0, visitors_1.normalizeVisitors)(regularRules, types);
|
|
74
|
+
(0, walk_1.walkDocument)({
|
|
75
75
|
document,
|
|
76
76
|
rootType: types.Root,
|
|
77
77
|
normalizedVisitors,
|
|
@@ -90,22 +90,22 @@ function lintConfig(opts) {
|
|
|
90
90
|
oasVersion: oas_types_1.SpecVersion.OAS3_0,
|
|
91
91
|
visitorsData: {},
|
|
92
92
|
};
|
|
93
|
-
const plugins = config_1.resolvePlugins([config_1.defaultPlugin]);
|
|
93
|
+
const plugins = (0, config_1.resolvePlugins)([config_1.defaultPlugin]);
|
|
94
94
|
const config = new config_1.StyleguideConfig({
|
|
95
95
|
plugins,
|
|
96
96
|
rules: { spec: 'error' },
|
|
97
97
|
});
|
|
98
|
-
const types = types_1.normalizeTypes(redocly_yaml_1.ConfigTypes, config);
|
|
98
|
+
const types = (0, types_1.normalizeTypes)(redocly_yaml_1.ConfigTypes, config);
|
|
99
99
|
const rules = [
|
|
100
100
|
{
|
|
101
101
|
severity: severity || 'error',
|
|
102
102
|
ruleId: 'configuration spec',
|
|
103
|
-
visitor: spec_1.Spec({ severity: 'error' }),
|
|
103
|
+
visitor: (0, spec_1.Spec)({ severity: 'error' }),
|
|
104
104
|
},
|
|
105
105
|
];
|
|
106
106
|
// TODO: check why any is needed
|
|
107
|
-
const normalizedVisitors = visitors_1.normalizeVisitors(rules, types);
|
|
108
|
-
walk_1.walkDocument({
|
|
107
|
+
const normalizedVisitors = (0, visitors_1.normalizeVisitors)(rules, types);
|
|
108
|
+
(0, walk_1.walkDocument)({
|
|
109
109
|
document,
|
|
110
110
|
rootType: types.ConfigRoot,
|
|
111
111
|
normalizedVisitors,
|
package/lib/oas-types.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Oas3Rule, Oas3Preprocessor, Oas2Rule, Oas2Preprocessor, Async2Preprocessor, Async2Rule } from './visitors';
|
|
2
|
-
|
|
2
|
+
import { BuiltInAsync2RuleId, BuiltInCommonOASRuleId, BuiltInCommonRuleId, BuiltInOAS2RuleId, BuiltInOAS3RuleId } from './types/redocly-yaml';
|
|
3
|
+
export type RuleSet<T> = Record<string, T>;
|
|
3
4
|
export declare enum SpecVersion {
|
|
4
5
|
OAS2 = "oas2",
|
|
5
6
|
OAS3_0 = "oas3_0",
|
|
@@ -11,15 +12,16 @@ export declare enum SpecMajorVersion {
|
|
|
11
12
|
OAS3 = "oas3",
|
|
12
13
|
Async2 = "async2"
|
|
13
14
|
}
|
|
14
|
-
export
|
|
15
|
-
export
|
|
16
|
-
export
|
|
17
|
-
export
|
|
18
|
-
export
|
|
19
|
-
export
|
|
20
|
-
export
|
|
21
|
-
export
|
|
22
|
-
export
|
|
15
|
+
export type RuleMap<Key extends string, RuleConfig, T> = Record<T extends 'built-in' ? Key : string, RuleConfig>;
|
|
16
|
+
export type Oas3RuleSet<T = undefined> = RuleMap<BuiltInCommonRuleId | BuiltInCommonOASRuleId | BuiltInOAS3RuleId | 'assertions', Oas3Rule, T>;
|
|
17
|
+
export type Oas2RuleSet<T = undefined> = RuleMap<BuiltInCommonRuleId | BuiltInCommonOASRuleId | BuiltInOAS2RuleId | 'assertions', Oas2Rule, T>;
|
|
18
|
+
export type Async2RuleSet<T = undefined> = RuleMap<BuiltInCommonRuleId | BuiltInAsync2RuleId | 'assertions', Async2Rule, T>;
|
|
19
|
+
export type Oas3PreprocessorsSet = Record<string, Oas3Preprocessor>;
|
|
20
|
+
export type Oas2PreprocessorsSet = Record<string, Oas2Preprocessor>;
|
|
21
|
+
export type Async2PreprocessorsSet = Record<string, Async2Preprocessor>;
|
|
22
|
+
export type Oas3DecoratorsSet = Record<string, Oas3Preprocessor>;
|
|
23
|
+
export type Oas2DecoratorsSet = Record<string, Oas2Preprocessor>;
|
|
24
|
+
export type Async2DecoratorsSet = Record<string, Async2Preprocessor>;
|
|
23
25
|
export declare function detectSpec(root: any): SpecVersion;
|
|
24
26
|
export declare function getMajorSpecVersion(version: SpecVersion): SpecMajorVersion;
|
|
25
27
|
export declare function getTypes(spec: SpecVersion): Record<string, import("./types").NodeType>;
|
package/lib/oas-types.js
CHANGED
|
@@ -11,13 +11,13 @@ var SpecVersion;
|
|
|
11
11
|
SpecVersion["OAS3_0"] = "oas3_0";
|
|
12
12
|
SpecVersion["OAS3_1"] = "oas3_1";
|
|
13
13
|
SpecVersion["Async2"] = "async2";
|
|
14
|
-
})(SpecVersion
|
|
14
|
+
})(SpecVersion || (exports.SpecVersion = SpecVersion = {}));
|
|
15
15
|
var SpecMajorVersion;
|
|
16
16
|
(function (SpecMajorVersion) {
|
|
17
17
|
SpecMajorVersion["OAS2"] = "oas2";
|
|
18
18
|
SpecMajorVersion["OAS3"] = "oas3";
|
|
19
19
|
SpecMajorVersion["Async2"] = "async2";
|
|
20
|
-
})(SpecMajorVersion
|
|
20
|
+
})(SpecMajorVersion || (exports.SpecMajorVersion = SpecMajorVersion = {}));
|
|
21
21
|
const typesMap = {
|
|
22
22
|
[SpecVersion.OAS2]: oas2_1.Oas2Types,
|
|
23
23
|
[SpecVersion.OAS3_0]: oas3_1.Oas3Types,
|
package/lib/redocly/index.js
CHANGED
|
@@ -41,7 +41,7 @@ class RedoclyClient {
|
|
|
41
41
|
return this.region;
|
|
42
42
|
}
|
|
43
43
|
hasTokens() {
|
|
44
|
-
return utils_1.isNotEmptyObject(this.accessTokens);
|
|
44
|
+
return (0, utils_1.isNotEmptyObject)(this.accessTokens);
|
|
45
45
|
}
|
|
46
46
|
// <backward compatibility: old versions of portal>
|
|
47
47
|
hasToken() {
|
|
@@ -57,9 +57,9 @@ class RedoclyClient {
|
|
|
57
57
|
this.accessTokens = accessTokens;
|
|
58
58
|
}
|
|
59
59
|
loadTokens() {
|
|
60
|
-
const credentialsPath = path_1.resolve(os_1.homedir(), TOKEN_FILENAME);
|
|
60
|
+
const credentialsPath = (0, path_1.resolve)((0, os_1.homedir)(), TOKEN_FILENAME);
|
|
61
61
|
const credentials = this.readCredentialsFile(credentialsPath);
|
|
62
|
-
if (utils_1.isNotEmptyObject(credentials)) {
|
|
62
|
+
if ((0, utils_1.isNotEmptyObject)(credentials)) {
|
|
63
63
|
this.setAccessTokens(Object.assign(Object.assign({}, credentials), (credentials.token &&
|
|
64
64
|
!credentials[this.region] && {
|
|
65
65
|
[this.region]: credentials.token,
|
|
@@ -108,11 +108,11 @@ class RedoclyClient {
|
|
|
108
108
|
}
|
|
109
109
|
isAuthorizedWithRedocly() {
|
|
110
110
|
return __awaiter(this, void 0, void 0, function* () {
|
|
111
|
-
return this.hasTokens() && utils_1.isNotEmptyObject(yield this.getValidTokens());
|
|
111
|
+
return this.hasTokens() && (0, utils_1.isNotEmptyObject)(yield this.getValidTokens());
|
|
112
112
|
});
|
|
113
113
|
}
|
|
114
114
|
readCredentialsFile(credentialsPath) {
|
|
115
|
-
return fs_1.existsSync(credentialsPath) ? JSON.parse(fs_1.readFileSync(credentialsPath, 'utf-8')) : {};
|
|
115
|
+
return (0, fs_1.existsSync)(credentialsPath) ? JSON.parse((0, fs_1.readFileSync)(credentialsPath, 'utf-8')) : {};
|
|
116
116
|
}
|
|
117
117
|
verifyToken(accessToken, region, verbose = false) {
|
|
118
118
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -121,7 +121,7 @@ class RedoclyClient {
|
|
|
121
121
|
}
|
|
122
122
|
login(accessToken, verbose = false) {
|
|
123
123
|
return __awaiter(this, void 0, void 0, function* () {
|
|
124
|
-
const credentialsPath = path_1.resolve(os_1.homedir(), TOKEN_FILENAME);
|
|
124
|
+
const credentialsPath = (0, path_1.resolve)((0, os_1.homedir)(), TOKEN_FILENAME);
|
|
125
125
|
try {
|
|
126
126
|
yield this.verifyToken(accessToken, this.region, verbose);
|
|
127
127
|
}
|
|
@@ -131,13 +131,13 @@ class RedoclyClient {
|
|
|
131
131
|
const credentials = Object.assign(Object.assign({}, this.readCredentialsFile(credentialsPath)), { [this.region]: accessToken, token: accessToken });
|
|
132
132
|
this.accessTokens = credentials;
|
|
133
133
|
this.registryApi.setAccessTokens(credentials);
|
|
134
|
-
fs_1.writeFileSync(credentialsPath, JSON.stringify(credentials, null, 2));
|
|
134
|
+
(0, fs_1.writeFileSync)(credentialsPath, JSON.stringify(credentials, null, 2));
|
|
135
135
|
});
|
|
136
136
|
}
|
|
137
137
|
logout() {
|
|
138
|
-
const credentialsPath = path_1.resolve(os_1.homedir(), TOKEN_FILENAME);
|
|
139
|
-
if (fs_1.existsSync(credentialsPath)) {
|
|
140
|
-
fs_1.unlinkSync(credentialsPath);
|
|
138
|
+
const credentialsPath = (0, path_1.resolve)((0, os_1.homedir)(), TOKEN_FILENAME);
|
|
139
|
+
if ((0, fs_1.existsSync)(credentialsPath)) {
|
|
140
|
+
(0, fs_1.unlinkSync)(credentialsPath);
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
}
|
|
@@ -20,7 +20,7 @@ class RegistryApi {
|
|
|
20
20
|
this.region = region;
|
|
21
21
|
}
|
|
22
22
|
get accessToken() {
|
|
23
|
-
return utils_1.isNotEmptyObject(this.accessTokens) && this.accessTokens[this.region];
|
|
23
|
+
return (0, utils_1.isNotEmptyObject)(this.accessTokens) && this.accessTokens[this.region];
|
|
24
24
|
}
|
|
25
25
|
getBaseUrl(region = config_1.DEFAULT_REGION) {
|
|
26
26
|
return `https://api.${config_1.DOMAINS[region]}/registry`;
|
|
@@ -41,7 +41,7 @@ class RegistryApi {
|
|
|
41
41
|
if (!headers.hasOwnProperty('authorization')) {
|
|
42
42
|
throw new Error('Unauthorized');
|
|
43
43
|
}
|
|
44
|
-
const response = yield node_fetch_1.default(`${this.getBaseUrl(region)}${path}`, Object.assign({}, options, { headers }));
|
|
44
|
+
const response = yield (0, node_fetch_1.default)(`${this.getBaseUrl(region)}${path}`, Object.assign({}, options, { headers }));
|
|
45
45
|
if (response.status === 401) {
|
|
46
46
|
throw new Error('Unauthorized');
|
|
47
47
|
}
|
package/lib/resolve.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { YAMLNode, LoadOptions } from 'yaml-ast-parser';
|
|
2
2
|
import { NormalizedNodeType } from './types';
|
|
3
3
|
import { ResolveConfig } from './config/types';
|
|
4
|
-
export
|
|
4
|
+
export type CollectedRefs = Map<string, Document>;
|
|
5
5
|
export declare class Source {
|
|
6
6
|
absoluteRef: string;
|
|
7
7
|
body: string;
|
|
@@ -23,7 +23,7 @@ export declare class YamlParseError extends Error {
|
|
|
23
23
|
line: number;
|
|
24
24
|
constructor(originalError: Error, source: Source);
|
|
25
25
|
}
|
|
26
|
-
export
|
|
26
|
+
export type Document = {
|
|
27
27
|
source: Source;
|
|
28
28
|
parsed: any;
|
|
29
29
|
};
|
|
@@ -42,7 +42,7 @@ export declare class BaseResolver {
|
|
|
42
42
|
parseDocument(source: Source, isRoot?: boolean): Document;
|
|
43
43
|
resolveDocument(base: string | null, ref: string, isRoot?: boolean): Promise<Document | ResolveError | YamlParseError>;
|
|
44
44
|
}
|
|
45
|
-
export
|
|
45
|
+
export type ResolvedRef = {
|
|
46
46
|
resolved: false;
|
|
47
47
|
isRemote: boolean;
|
|
48
48
|
nodePointer?: string;
|
|
@@ -58,7 +58,7 @@ export declare type ResolvedRef = {
|
|
|
58
58
|
isRemote: boolean;
|
|
59
59
|
error?: undefined;
|
|
60
60
|
};
|
|
61
|
-
export
|
|
61
|
+
export type ResolvedRefMap = Map<string, ResolvedRef>;
|
|
62
62
|
export declare function resolveDocument(opts: {
|
|
63
63
|
rootDocument: Document;
|
|
64
64
|
externalRefResolver: BaseResolver;
|
package/lib/resolve.js
CHANGED
|
@@ -77,7 +77,7 @@ function makeDocumentFromString(sourceString, absoluteRef) {
|
|
|
77
77
|
try {
|
|
78
78
|
return {
|
|
79
79
|
source,
|
|
80
|
-
parsed: utils_1.parseYaml(sourceString, { filename: absoluteRef }),
|
|
80
|
+
parsed: (0, utils_1.parseYaml)(sourceString, { filename: absoluteRef }),
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
83
|
catch (e) {
|
|
@@ -94,10 +94,10 @@ class BaseResolver {
|
|
|
94
94
|
return new Set(Array.from(this.cache.keys()));
|
|
95
95
|
}
|
|
96
96
|
resolveExternalRef(base, ref) {
|
|
97
|
-
if (ref_utils_1.isAbsoluteUrl(ref)) {
|
|
97
|
+
if ((0, ref_utils_1.isAbsoluteUrl)(ref)) {
|
|
98
98
|
return ref;
|
|
99
99
|
}
|
|
100
|
-
if (base && ref_utils_1.isAbsoluteUrl(base)) {
|
|
100
|
+
if (base && (0, ref_utils_1.isAbsoluteUrl)(base)) {
|
|
101
101
|
return new URL(ref, base).href;
|
|
102
102
|
}
|
|
103
103
|
return path.resolve(base ? path.dirname(base) : process.cwd(), ref);
|
|
@@ -105,8 +105,8 @@ class BaseResolver {
|
|
|
105
105
|
loadExternalRef(absoluteRef) {
|
|
106
106
|
return __awaiter(this, void 0, void 0, function* () {
|
|
107
107
|
try {
|
|
108
|
-
if (ref_utils_1.isAbsoluteUrl(absoluteRef)) {
|
|
109
|
-
const { body, mimeType } = yield utils_1.readFileFromUrl(absoluteRef, this.config.http);
|
|
108
|
+
if ((0, ref_utils_1.isAbsoluteUrl)(absoluteRef)) {
|
|
109
|
+
const { body, mimeType } = yield (0, utils_1.readFileFromUrl)(absoluteRef, this.config.http);
|
|
110
110
|
return new Source(absoluteRef, body, mimeType);
|
|
111
111
|
}
|
|
112
112
|
else {
|
|
@@ -136,7 +136,7 @@ class BaseResolver {
|
|
|
136
136
|
try {
|
|
137
137
|
return {
|
|
138
138
|
source,
|
|
139
|
-
parsed: utils_1.parseYaml(source.body, { filename: source.absoluteRef }),
|
|
139
|
+
parsed: (0, utils_1.parseYaml)(source.body, { filename: source.absoluteRef }),
|
|
140
140
|
};
|
|
141
141
|
}
|
|
142
142
|
catch (e) {
|
|
@@ -212,7 +212,7 @@ function resolveDocument(opts) {
|
|
|
212
212
|
return;
|
|
213
213
|
}
|
|
214
214
|
for (let i = 0; i < node.length; i++) {
|
|
215
|
-
walk(node[i], itemsType || unknownType, ref_utils_1.joinPointer(nodeAbsoluteRef, i));
|
|
215
|
+
walk(node[i], itemsType || unknownType, (0, ref_utils_1.joinPointer)(nodeAbsoluteRef, i));
|
|
216
216
|
}
|
|
217
217
|
return;
|
|
218
218
|
}
|
|
@@ -230,19 +230,19 @@ function resolveDocument(opts) {
|
|
|
230
230
|
propType === unknownType) {
|
|
231
231
|
propType = types_1.SpecExtension;
|
|
232
232
|
}
|
|
233
|
-
if (!types_1.isNamedType(propType) && (propType === null || propType === void 0 ? void 0 : propType.directResolveAs)) {
|
|
233
|
+
if (!(0, types_1.isNamedType)(propType) && (propType === null || propType === void 0 ? void 0 : propType.directResolveAs)) {
|
|
234
234
|
propType = propType.directResolveAs;
|
|
235
235
|
propValue = { $ref: propValue };
|
|
236
236
|
}
|
|
237
237
|
if (propType && propType.name === undefined && propType.resolvable !== false) {
|
|
238
238
|
propType = resolvableScalarType;
|
|
239
239
|
}
|
|
240
|
-
if (!types_1.isNamedType(propType) || typeof propValue !== 'object') {
|
|
240
|
+
if (!(0, types_1.isNamedType)(propType) || typeof propValue !== 'object') {
|
|
241
241
|
continue;
|
|
242
242
|
}
|
|
243
|
-
walk(propValue, propType, ref_utils_1.joinPointer(nodeAbsoluteRef, ref_utils_1.escapePointer(propName)));
|
|
243
|
+
walk(propValue, propType, (0, ref_utils_1.joinPointer)(nodeAbsoluteRef, (0, ref_utils_1.escapePointer)(propName)));
|
|
244
244
|
}
|
|
245
|
-
if (ref_utils_1.isRef(node)) {
|
|
245
|
+
if ((0, ref_utils_1.isRef)(node)) {
|
|
246
246
|
const promise = followRef(rootNodeDocument, node, {
|
|
247
247
|
prev: null,
|
|
248
248
|
node,
|
|
@@ -259,9 +259,9 @@ function resolveDocument(opts) {
|
|
|
259
259
|
if (hasRef(refStack.prev, ref)) {
|
|
260
260
|
throw new Error('Self-referencing circular pointer');
|
|
261
261
|
}
|
|
262
|
-
if (ref_utils_1.isAnchor(ref.$ref)) {
|
|
262
|
+
if ((0, ref_utils_1.isAnchor)(ref.$ref)) {
|
|
263
263
|
// Wait for all anchors in the document to be collected firstly.
|
|
264
|
-
yield utils_1.nextTick();
|
|
264
|
+
yield (0, utils_1.nextTick)();
|
|
265
265
|
const resolvedRef = {
|
|
266
266
|
resolved: true,
|
|
267
267
|
isRemote: false,
|
|
@@ -273,7 +273,7 @@ function resolveDocument(opts) {
|
|
|
273
273
|
resolvedRefMap.set(refId, resolvedRef);
|
|
274
274
|
return resolvedRef;
|
|
275
275
|
}
|
|
276
|
-
const { uri, pointer } = ref_utils_1.parseRef(ref.$ref);
|
|
276
|
+
const { uri, pointer } = (0, ref_utils_1.parseRef)(ref.$ref);
|
|
277
277
|
const isRemote = uri !== null;
|
|
278
278
|
let targetDoc;
|
|
279
279
|
try {
|
|
@@ -308,9 +308,9 @@ function resolveDocument(opts) {
|
|
|
308
308
|
}
|
|
309
309
|
else if (target[segment] !== undefined) {
|
|
310
310
|
target = target[segment];
|
|
311
|
-
resolvedRef.nodePointer = ref_utils_1.joinPointer(resolvedRef.nodePointer, ref_utils_1.escapePointer(segment));
|
|
311
|
+
resolvedRef.nodePointer = (0, ref_utils_1.joinPointer)(resolvedRef.nodePointer, (0, ref_utils_1.escapePointer)(segment));
|
|
312
312
|
}
|
|
313
|
-
else if (ref_utils_1.isRef(target)) {
|
|
313
|
+
else if ((0, ref_utils_1.isRef)(target)) {
|
|
314
314
|
resolvedRef = yield followRef(targetDoc, target, pushRef(refStack, target));
|
|
315
315
|
targetDoc = resolvedRef.document || targetDoc;
|
|
316
316
|
if (typeof resolvedRef.node !== 'object') {
|
|
@@ -318,7 +318,7 @@ function resolveDocument(opts) {
|
|
|
318
318
|
break;
|
|
319
319
|
}
|
|
320
320
|
target = resolvedRef.node[segment];
|
|
321
|
-
resolvedRef.nodePointer = ref_utils_1.joinPointer(resolvedRef.nodePointer, ref_utils_1.escapePointer(segment));
|
|
321
|
+
resolvedRef.nodePointer = (0, ref_utils_1.joinPointer)(resolvedRef.nodePointer, (0, ref_utils_1.escapePointer)(segment));
|
|
322
322
|
}
|
|
323
323
|
else {
|
|
324
324
|
target = undefined;
|
|
@@ -328,7 +328,7 @@ function resolveDocument(opts) {
|
|
|
328
328
|
resolvedRef.node = target;
|
|
329
329
|
resolvedRef.document = targetDoc;
|
|
330
330
|
const refId = makeRefId(document.source.absoluteRef, ref.$ref);
|
|
331
|
-
if (resolvedRef.document && ref_utils_1.isRef(target)) {
|
|
331
|
+
if (resolvedRef.document && (0, ref_utils_1.isRef)(target)) {
|
|
332
332
|
resolvedRef = yield followRef(resolvedRef.document, target, pushRef(refStack, target));
|
|
333
333
|
}
|
|
334
334
|
resolvedRefMap.set(refId, resolvedRef);
|
package/lib/rules/ajv.js
CHANGED
|
@@ -71,7 +71,7 @@ function validateJsonSchema(data, schema, schemaLoc, instancePath, resolve, allo
|
|
|
71
71
|
if (error.keyword === 'additionalProperties' || error.keyword === 'unevaluatedProperties') {
|
|
72
72
|
const property = error.params.additionalProperty || error.params.unevaluatedProperty;
|
|
73
73
|
message = `${message} \`${property}\``;
|
|
74
|
-
error.instancePath += '/' + ref_utils_1.escapePointer(property);
|
|
74
|
+
error.instancePath += '/' + (0, ref_utils_1.escapePointer)(property);
|
|
75
75
|
}
|
|
76
76
|
return Object.assign(Object.assign({}, error), { message,
|
|
77
77
|
suggest });
|
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const rules:
|
|
3
|
-
spec: Async2Rule;
|
|
4
|
-
assertions: (opts: Record<string, import("../common/assertions").Assertion>) => (import("../../visitors").Oas3Visitor | import("../../visitors").Oas2Visitor)[];
|
|
5
|
-
'info-contact': import("../../visitors").Oas3Rule | import("../../visitors").Oas2Rule;
|
|
6
|
-
'operation-operationId': import("../../visitors").Oas3Rule | import("../../visitors").Oas2Rule;
|
|
7
|
-
'channels-kebab-case': Async2Rule;
|
|
8
|
-
'no-channel-trailing-slash': Async2Rule;
|
|
9
|
-
'tag-description': import("../../visitors").Oas3Rule | import("../../visitors").Oas2Rule;
|
|
10
|
-
'tags-alphabetical': import("../../visitors").Oas3Rule | import("../../visitors").Oas2Rule;
|
|
11
|
-
};
|
|
1
|
+
import type { Async2RuleSet } from '../../oas-types';
|
|
2
|
+
export declare const rules: Async2RuleSet<'built-in'>;
|
|
12
3
|
export declare const preprocessors: {};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { AssertionContext, AssertResult, CustomFunction } from 'core/src/config/types';
|
|
2
2
|
import { Location } from '../../../ref-utils';
|
|
3
|
-
export
|
|
3
|
+
export type AssertionFnContext = AssertionContext & {
|
|
4
4
|
baseLocation: Location;
|
|
5
5
|
rawValue?: any;
|
|
6
6
|
};
|
|
7
|
-
export
|
|
8
|
-
export
|
|
7
|
+
export type AssertionFn = (value: any, condition: any, ctx: AssertionFnContext) => AssertResult[];
|
|
8
|
+
export type Asserts = {
|
|
9
9
|
pattern: AssertionFn;
|
|
10
10
|
notPattern: AssertionFn;
|
|
11
11
|
enum: AssertionFn;
|