@redocly/openapi-core 1.0.0-beta.49 → 1.0.0-beta.53
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__/normalizeVisitors.test.ts +1 -1
- package/__tests__/utils.ts +1 -1
- package/__tests__/walk.test.ts +77 -4
- package/lib/benchmark/benches/recommended-oas3.bench.js +2 -1
- package/lib/benchmark/utils.d.ts +1 -1
- package/lib/bundle.d.ts +1 -1
- package/lib/bundle.js +10 -10
- package/lib/config/builtIn.d.ts +2 -1
- package/lib/config/builtIn.js +9 -1
- package/lib/config/config.d.ts +5 -7
- package/lib/config/config.js +40 -100
- package/lib/config/load.d.ts +2 -0
- package/lib/config/load.js +65 -0
- package/lib/config/rules.d.ts +1 -1
- package/lib/format/codeframes.js +1 -1
- package/lib/index.d.ts +4 -3
- package/lib/index.js +13 -11
- package/lib/lint.d.ts +6 -19
- package/lib/lint.js +13 -43
- package/lib/oas-types.d.ts +19 -0
- package/lib/oas-types.js +42 -0
- package/lib/resolve.d.ts +6 -2
- package/lib/resolve.js +18 -5
- package/lib/rules/ajv.d.ts +3 -3
- package/lib/rules/ajv.js +21 -18
- package/lib/rules/common/info-contact.js +2 -1
- package/lib/rules/common/info-description.js +2 -1
- package/lib/rules/common/info-license-url.js +2 -1
- package/lib/rules/common/license-url.js +2 -1
- package/lib/rules/common/no-ambiguous-paths.js +2 -1
- package/lib/rules/common/no-enum-type-mismatch.js +2 -1
- package/lib/rules/common/no-identical-paths.js +2 -1
- package/lib/rules/common/no-path-trailing-slash.js +2 -1
- package/lib/rules/common/operation-2xx-response.js +2 -1
- package/lib/rules/common/operation-description.js +2 -1
- package/lib/rules/common/operation-operationId-unique.js +2 -1
- package/lib/rules/common/operation-operationId-url-safe.js +2 -1
- package/lib/rules/common/operation-operationId.js +9 -4
- package/lib/rules/common/operation-parameters-unique.js +2 -1
- package/lib/rules/common/operation-security-defined.js +2 -1
- package/lib/rules/common/operation-singular-tag.js +2 -1
- package/lib/rules/common/operation-summary.js +2 -1
- package/lib/rules/common/operation-tag-defined.js +2 -1
- package/lib/rules/common/parameter-description.js +2 -1
- package/lib/rules/common/path-declaration-must-exist.js +2 -1
- package/lib/rules/common/path-http-verbs-order.js +2 -1
- package/lib/rules/common/path-not-include-query.js +2 -1
- package/lib/rules/common/path-params-defined.js +3 -2
- package/lib/rules/common/paths-kebab-case.js +2 -1
- package/lib/rules/common/registry-dependencies.js +2 -1
- package/lib/rules/common/spec.js +5 -2
- package/lib/rules/common/tag-description.js +2 -1
- package/lib/rules/common/tags-alphabetical.js +2 -1
- package/lib/rules/no-unresolved-refs.js +2 -1
- package/lib/rules/oas2/boolean-parameter-prefixes.js +2 -1
- package/lib/rules/oas2/index.d.ts +1 -1
- package/lib/rules/oas2/index.js +1 -1
- package/lib/rules/oas3/boolean-parameter-prefixes.js +2 -1
- package/lib/rules/oas3/index.d.ts +2 -1
- package/lib/rules/oas3/index.js +2 -2
- package/lib/rules/oas3/no-empty-servers.js +2 -1
- package/lib/rules/oas3/no-example-value-and-externalValue.js +2 -1
- package/lib/rules/oas3/no-invalid-media-type-examples.js +20 -10
- package/lib/rules/oas3/no-server-example.com.js +2 -1
- package/lib/rules/oas3/no-server-trailing-slash.js +2 -1
- package/lib/rules/oas3/no-servers-empty-enum.js +2 -1
- package/lib/rules/oas3/no-undefined-server-variable.js +2 -1
- package/lib/rules/oas3/no-unused-components.js +2 -1
- package/lib/rules/other/stats.js +2 -1
- package/lib/types/oas2.js +1 -1
- package/lib/types/oas3.js +1 -1
- package/lib/types/oas3_1.js +1 -1
- package/lib/utils.d.ts +1 -1
- package/lib/visitors.d.ts +3 -1
- package/lib/visitors.js +4 -4
- package/lib/walk.d.ts +1 -1
- package/lib/walk.js +11 -2
- package/package.json +7 -7
- package/src/__tests__/lint.test.ts +44 -0
- package/src/benchmark/benches/recommended-oas3.bench.ts +2 -1
- package/src/benchmark/benchmark.js +3 -1
- package/src/benchmark/utils.ts +1 -1
- package/src/bundle.ts +2 -2
- package/src/config/__tests__/resolve-plugins.test.ts +1 -1
- package/src/config/builtIn.ts +11 -1
- package/src/config/config.ts +30 -78
- package/src/config/load.ts +60 -0
- package/src/config/rules.ts +1 -1
- package/src/format/codeframes.ts +1 -1
- package/src/index.ts +4 -3
- package/src/lint.ts +19 -56
- package/src/oas-types.ts +58 -0
- package/src/resolve.ts +17 -4
- package/src/rules/__tests__/config.ts +10 -0
- package/src/rules/__tests__/no-unresolved-refs.test.ts +9 -21
- package/src/rules/ajv.ts +27 -23
- package/src/rules/common/__tests__/info-description.test.ts +8 -16
- package/src/rules/common/__tests__/info-license.test.ts +3 -3
- package/src/rules/common/__tests__/license-url.test.ts +3 -3
- package/src/rules/common/__tests__/no-ambiguous-paths.test.ts +2 -2
- package/src/rules/common/__tests__/no-enum-type-mismatch.test.ts +50 -5
- package/src/rules/common/__tests__/no-identical-paths.test.ts +2 -2
- package/src/rules/common/__tests__/no-path-trailing-slash.test.ts +4 -4
- package/src/rules/common/__tests__/operation-2xx-response.test.ts +4 -4
- package/src/rules/common/__tests__/operation-operationId-unique.test.ts +3 -3
- package/src/rules/common/__tests__/operation-operationId-url-safe.test.ts +2 -5
- package/src/rules/common/__tests__/operation-parameters-unique.test.ts +5 -17
- package/src/rules/common/__tests__/operation-security-defined.test.ts +3 -3
- package/src/rules/common/__tests__/operation-singular-tag.test.ts +3 -3
- package/src/rules/common/__tests__/path-http-verbs-order.test.ts +3 -3
- package/src/rules/common/__tests__/path-not-include-query.test.ts +3 -3
- package/src/rules/common/__tests__/path-params-defined.test.ts +4 -4
- package/src/rules/common/__tests__/paths-kebab-case.test.ts +3 -3
- package/src/rules/common/__tests__/tag-description.test.ts +3 -3
- package/src/rules/common/__tests__/tags-alphabetical.test.ts +3 -3
- package/src/rules/common/operation-operationId.ts +7 -3
- package/src/rules/common/spec.ts +4 -1
- package/src/rules/oas2/__tests__/boolean-parameter-prefixes.test.ts +7 -10
- package/src/rules/oas2/__tests__/spec/referenceableScalars.test.ts +3 -6
- package/src/rules/oas2/__tests__/spec/utils.ts +2 -0
- package/src/rules/oas2/index.ts +1 -10
- package/src/rules/oas3/__tests__/boolean-parameter-prefixes.test.ts +7 -10
- package/src/rules/oas3/__tests__/fixtures/common.yaml +11 -0
- package/src/rules/oas3/__tests__/no-empty-enum-servers.com.test.ts +7 -7
- package/src/rules/oas3/__tests__/no-example-value-and-externalValue.test.ts +3 -9
- package/src/rules/oas3/__tests__/no-invalid-media-type-examples.test.ts +103 -29
- package/src/rules/oas3/__tests__/no-server-example.com.test.ts +3 -3
- package/src/rules/oas3/__tests__/no-server-trailing-slash.test.ts +3 -3
- package/src/rules/oas3/__tests__/no-unused-components.test.ts +2 -2
- package/src/rules/oas3/__tests__/spec/spec.test.ts +3 -1
- package/src/rules/oas3/__tests__/spec/utils.ts +2 -0
- package/src/rules/oas3/index.ts +3 -4
- package/src/rules/oas3/no-invalid-media-type-examples.ts +27 -19
- package/src/visitors.ts +12 -8
- package/src/walk.ts +24 -8
- package/tsconfig.tsbuildinfo +1 -3084
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.OperationParametersUnique = void 0;
|
|
4
|
-
|
|
4
|
+
const OperationParametersUnique = () => {
|
|
5
5
|
let seenPathParams;
|
|
6
6
|
let seenOperationParams;
|
|
7
7
|
return {
|
|
@@ -37,3 +37,4 @@ exports.OperationParametersUnique = () => {
|
|
|
37
37
|
},
|
|
38
38
|
};
|
|
39
39
|
};
|
|
40
|
+
exports.OperationParametersUnique = OperationParametersUnique;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.OperationSecurityDefined = void 0;
|
|
4
|
-
|
|
4
|
+
const OperationSecurityDefined = () => {
|
|
5
5
|
let referencedSchemes = new Map();
|
|
6
6
|
return {
|
|
7
7
|
DefinitionRoot: {
|
|
@@ -38,3 +38,4 @@ exports.OperationSecurityDefined = () => {
|
|
|
38
38
|
},
|
|
39
39
|
};
|
|
40
40
|
};
|
|
41
|
+
exports.OperationSecurityDefined = OperationSecurityDefined;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.OperationSingularTag = void 0;
|
|
4
|
-
|
|
4
|
+
const OperationSingularTag = () => {
|
|
5
5
|
return {
|
|
6
6
|
Operation(operation, { report, location }) {
|
|
7
7
|
if (operation.tags && operation.tags.length > 1) {
|
|
@@ -13,3 +13,4 @@ exports.OperationSingularTag = () => {
|
|
|
13
13
|
},
|
|
14
14
|
};
|
|
15
15
|
};
|
|
16
|
+
exports.OperationSingularTag = OperationSingularTag;
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.OperationSummary = void 0;
|
|
4
4
|
const utils_1 = require("../utils");
|
|
5
|
-
|
|
5
|
+
const OperationSummary = () => {
|
|
6
6
|
return {
|
|
7
7
|
Operation(operation, ctx) {
|
|
8
8
|
utils_1.validateDefinedAndNonEmpty('summary', operation, ctx);
|
|
9
9
|
},
|
|
10
10
|
};
|
|
11
11
|
};
|
|
12
|
+
exports.OperationSummary = OperationSummary;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.OperationTagDefined = void 0;
|
|
4
|
-
|
|
4
|
+
const OperationTagDefined = () => {
|
|
5
5
|
let definedTags;
|
|
6
6
|
return {
|
|
7
7
|
DefinitionRoot(root) {
|
|
@@ -22,3 +22,4 @@ exports.OperationTagDefined = () => {
|
|
|
22
22
|
},
|
|
23
23
|
};
|
|
24
24
|
};
|
|
25
|
+
exports.OperationTagDefined = OperationTagDefined;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ParameterDescription = void 0;
|
|
4
|
-
|
|
4
|
+
const ParameterDescription = () => {
|
|
5
5
|
return {
|
|
6
6
|
Parameter(parameter, { report, location }) {
|
|
7
7
|
if (parameter.description === undefined) {
|
|
@@ -19,3 +19,4 @@ exports.ParameterDescription = () => {
|
|
|
19
19
|
},
|
|
20
20
|
};
|
|
21
21
|
};
|
|
22
|
+
exports.ParameterDescription = ParameterDescription;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PathDeclarationMustExist = void 0;
|
|
4
|
-
|
|
4
|
+
const PathDeclarationMustExist = () => {
|
|
5
5
|
return {
|
|
6
6
|
PathItem(_path, { report, key }) {
|
|
7
7
|
if (key.indexOf('{}') !== -1) {
|
|
@@ -13,3 +13,4 @@ exports.PathDeclarationMustExist = () => {
|
|
|
13
13
|
},
|
|
14
14
|
};
|
|
15
15
|
};
|
|
16
|
+
exports.PathDeclarationMustExist = PathDeclarationMustExist;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PathHttpVerbsOrder = void 0;
|
|
4
4
|
const defaultOrder = ['get', 'head', 'post', 'put', 'patch', 'delete', 'options', 'trace'];
|
|
5
|
-
|
|
5
|
+
const PathHttpVerbsOrder = (opts) => {
|
|
6
6
|
const order = (opts && opts.order) || defaultOrder;
|
|
7
7
|
if (!Array.isArray(order)) {
|
|
8
8
|
throw new Error('path-http-verbs-order `order` option must be an array');
|
|
@@ -23,3 +23,4 @@ exports.PathHttpVerbsOrder = (opts) => {
|
|
|
23
23
|
},
|
|
24
24
|
};
|
|
25
25
|
};
|
|
26
|
+
exports.PathHttpVerbsOrder = PathHttpVerbsOrder;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PathNotIncludeQuery = void 0;
|
|
4
|
-
|
|
4
|
+
const PathNotIncludeQuery = () => {
|
|
5
5
|
return {
|
|
6
6
|
PathMap: {
|
|
7
7
|
PathItem(_operation, { report, key }) {
|
|
@@ -15,3 +15,4 @@ exports.PathNotIncludeQuery = () => {
|
|
|
15
15
|
}
|
|
16
16
|
};
|
|
17
17
|
};
|
|
18
|
+
exports.PathNotIncludeQuery = PathNotIncludeQuery;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PathParamsDefined = void 0;
|
|
4
4
|
const pathRegex = /\{([a-zA-Z0-9_.-]+)\}+/g;
|
|
5
|
-
|
|
5
|
+
const PathParamsDefined = () => {
|
|
6
6
|
let pathTemplateParams;
|
|
7
7
|
let definedPathParams;
|
|
8
8
|
let currentPath;
|
|
@@ -30,7 +30,7 @@ exports.PathParamsDefined = () => {
|
|
|
30
30
|
if (!definedPathParams.has(templateParam)) {
|
|
31
31
|
report({
|
|
32
32
|
message: `The operation does not define the path parameter \`{${templateParam}}\` expected by path \`${currentPath}\`.`,
|
|
33
|
-
location: location.child(['parameters']).key(),
|
|
33
|
+
location: location.child(['parameters']).key(), // report on operation
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
36
|
}
|
|
@@ -50,3 +50,4 @@ exports.PathParamsDefined = () => {
|
|
|
50
50
|
},
|
|
51
51
|
};
|
|
52
52
|
};
|
|
53
|
+
exports.PathParamsDefined = PathParamsDefined;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PathsKebabCase = void 0;
|
|
4
|
-
|
|
4
|
+
const PathsKebabCase = () => {
|
|
5
5
|
return {
|
|
6
6
|
PathItem(_path, { report, key }) {
|
|
7
7
|
const segments = key.substr(1).split('/');
|
|
@@ -14,3 +14,4 @@ exports.PathsKebabCase = () => {
|
|
|
14
14
|
},
|
|
15
15
|
};
|
|
16
16
|
};
|
|
17
|
+
exports.PathsKebabCase = PathsKebabCase;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RegistryDependencies = void 0;
|
|
4
4
|
const redocly_1 = require("../../redocly");
|
|
5
|
-
|
|
5
|
+
const RegistryDependencies = () => {
|
|
6
6
|
let redoclyClient;
|
|
7
7
|
let registryDependencies = new Set();
|
|
8
8
|
return {
|
|
@@ -24,3 +24,4 @@ exports.RegistryDependencies = () => {
|
|
|
24
24
|
},
|
|
25
25
|
};
|
|
26
26
|
};
|
|
27
|
+
exports.RegistryDependencies = RegistryDependencies;
|
package/lib/rules/common/spec.js
CHANGED
|
@@ -4,9 +4,9 @@ exports.OasSpec = void 0;
|
|
|
4
4
|
const types_1 = require("../../types");
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
6
|
const ref_utils_1 = require("../../ref-utils");
|
|
7
|
-
|
|
7
|
+
const OasSpec = () => {
|
|
8
8
|
return {
|
|
9
|
-
any(node, { report, type, location, key, resolve }) {
|
|
9
|
+
any(node, { report, type, location, key, resolve, ignoreNextVisitorsOnNode }) {
|
|
10
10
|
var _a, _b;
|
|
11
11
|
const nodeType = utils_1.oasTypeOf(node);
|
|
12
12
|
if (type.items) {
|
|
@@ -14,6 +14,7 @@ exports.OasSpec = () => {
|
|
|
14
14
|
report({
|
|
15
15
|
message: `Expected type \`${type.name}\` (array) but got \`${nodeType}\``,
|
|
16
16
|
});
|
|
17
|
+
ignoreNextVisitorsOnNode();
|
|
17
18
|
}
|
|
18
19
|
return;
|
|
19
20
|
}
|
|
@@ -21,6 +22,7 @@ exports.OasSpec = () => {
|
|
|
21
22
|
report({
|
|
22
23
|
message: `Expected type \`${type.name}\` (object) but got \`${nodeType}\``,
|
|
23
24
|
});
|
|
25
|
+
ignoreNextVisitorsOnNode();
|
|
24
26
|
return;
|
|
25
27
|
}
|
|
26
28
|
const required = typeof type.required === 'function' ? type.required(node, key) : type.required;
|
|
@@ -108,3 +110,4 @@ exports.OasSpec = () => {
|
|
|
108
110
|
},
|
|
109
111
|
};
|
|
110
112
|
};
|
|
113
|
+
exports.OasSpec = OasSpec;
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TagDescription = void 0;
|
|
4
4
|
const utils_1 = require("../utils");
|
|
5
|
-
|
|
5
|
+
const TagDescription = () => {
|
|
6
6
|
return {
|
|
7
7
|
Tag(tag, ctx) {
|
|
8
8
|
utils_1.validateDefinedAndNonEmpty('description', tag, ctx);
|
|
9
9
|
},
|
|
10
10
|
};
|
|
11
11
|
};
|
|
12
|
+
exports.TagDescription = TagDescription;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TagsAlphabetical = void 0;
|
|
4
|
-
|
|
4
|
+
const TagsAlphabetical = () => {
|
|
5
5
|
return {
|
|
6
6
|
DefinitionRoot(root, { report, location }) {
|
|
7
7
|
if (!root.tags)
|
|
@@ -17,3 +17,4 @@ exports.TagsAlphabetical = () => {
|
|
|
17
17
|
},
|
|
18
18
|
};
|
|
19
19
|
};
|
|
20
|
+
exports.TagsAlphabetical = TagsAlphabetical;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.reportUnresolvedRef = exports.NoUnresolvedRefs = void 0;
|
|
4
4
|
const resolve_1 = require("../resolve");
|
|
5
|
-
|
|
5
|
+
const NoUnresolvedRefs = () => {
|
|
6
6
|
return {
|
|
7
7
|
ref: {
|
|
8
8
|
leave(_, { report, location }, resolved) {
|
|
@@ -21,6 +21,7 @@ exports.NoUnresolvedRefs = () => {
|
|
|
21
21
|
},
|
|
22
22
|
};
|
|
23
23
|
};
|
|
24
|
+
exports.NoUnresolvedRefs = NoUnresolvedRefs;
|
|
24
25
|
function reportUnresolvedRef(resolved, report, location) {
|
|
25
26
|
var _a;
|
|
26
27
|
const error = resolved.error;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BooleanParameterPrefixes = void 0;
|
|
4
|
-
|
|
4
|
+
const BooleanParameterPrefixes = (options) => {
|
|
5
5
|
const prefixes = options.prefixes || ['is', 'has'];
|
|
6
6
|
const regexp = new RegExp(`^(${prefixes.join('|')})[A-Z-_]`);
|
|
7
7
|
const wrappedPrefixes = prefixes.map((p) => `\`${p}\``);
|
|
@@ -19,3 +19,4 @@ exports.BooleanParameterPrefixes = (options) => {
|
|
|
19
19
|
},
|
|
20
20
|
};
|
|
21
21
|
};
|
|
22
|
+
exports.BooleanParameterPrefixes = BooleanParameterPrefixes;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Oas2Decorator, Oas2Rule } from '../../visitors';
|
|
2
2
|
export declare const rules: {
|
|
3
|
+
spec: Oas2Rule;
|
|
3
4
|
'info-description': Oas2Rule;
|
|
4
5
|
'info-contact': Oas2Rule;
|
|
5
6
|
'info-license': Oas2Rule;
|
|
@@ -29,7 +30,6 @@ export declare const rules: {
|
|
|
29
30
|
'no-identical-paths': Oas2Rule;
|
|
30
31
|
'no-ambiguous-paths': Oas2Rule;
|
|
31
32
|
'path-http-verbs-order': Oas2Rule;
|
|
32
|
-
spec: Oas2Rule;
|
|
33
33
|
};
|
|
34
34
|
export declare const preprocessors: {};
|
|
35
35
|
export declare const decorators: {
|
package/lib/rules/oas2/index.js
CHANGED
|
@@ -32,6 +32,7 @@ const operation_operationId_1 = require("../common/operation-operationId");
|
|
|
32
32
|
const operation_summary_1 = require("../common/operation-summary");
|
|
33
33
|
const no_ambiguous_paths_1 = require("../common/no-ambiguous-paths");
|
|
34
34
|
exports.rules = {
|
|
35
|
+
spec: spec_1.OasSpec,
|
|
35
36
|
'info-description': info_description_1.InfoDescription,
|
|
36
37
|
'info-contact': info_contact_1.InfoContact,
|
|
37
38
|
'info-license': info_license_url_1.InfoLicense,
|
|
@@ -61,7 +62,6 @@ exports.rules = {
|
|
|
61
62
|
'no-identical-paths': no_identical_paths_1.NoIdenticalPaths,
|
|
62
63
|
'no-ambiguous-paths': no_ambiguous_paths_1.NoAmbiguousPaths,
|
|
63
64
|
'path-http-verbs-order': path_http_verbs_order_1.PathHttpVerbsOrder,
|
|
64
|
-
spec: spec_1.OasSpec,
|
|
65
65
|
};
|
|
66
66
|
exports.preprocessors = {};
|
|
67
67
|
exports.decorators = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BooleanParameterPrefixes = void 0;
|
|
4
|
-
|
|
4
|
+
const BooleanParameterPrefixes = (options) => {
|
|
5
5
|
const prefixes = options.prefixes || ['is', 'has'];
|
|
6
6
|
const regexp = new RegExp(`^(${prefixes.join('|')})[A-Z-_]`);
|
|
7
7
|
const wrappedPrefixes = prefixes.map((p) => `\`${p}\``);
|
|
@@ -21,3 +21,4 @@ exports.BooleanParameterPrefixes = (options) => {
|
|
|
21
21
|
},
|
|
22
22
|
};
|
|
23
23
|
};
|
|
24
|
+
exports.BooleanParameterPrefixes = BooleanParameterPrefixes;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { Oas3RuleSet } from '../../oas-types';
|
|
1
2
|
import { Oas3Decorator } from '../../visitors';
|
|
2
|
-
export declare const rules:
|
|
3
|
+
export declare const rules: Oas3RuleSet;
|
|
3
4
|
export declare const preprocessors: {};
|
|
4
5
|
export declare const decorators: {
|
|
5
6
|
'registry-dependencies': Oas3Decorator;
|
package/lib/rules/oas3/index.js
CHANGED
|
@@ -40,6 +40,7 @@ const operation_summary_1 = require("../common/operation-summary");
|
|
|
40
40
|
const no_ambiguous_paths_1 = require("../common/no-ambiguous-paths");
|
|
41
41
|
const no_servers_empty_enum_1 = require("./no-servers-empty-enum");
|
|
42
42
|
exports.rules = {
|
|
43
|
+
spec: spec_1.OasSpec,
|
|
43
44
|
'info-description': info_description_1.InfoDescription,
|
|
44
45
|
'info-contact': info_contact_1.InfoContact,
|
|
45
46
|
'info-license': info_license_url_1.InfoLicense,
|
|
@@ -76,8 +77,7 @@ exports.rules = {
|
|
|
76
77
|
'no-identical-paths': no_identical_paths_1.NoIdenticalPaths,
|
|
77
78
|
'no-ambiguous-paths': no_ambiguous_paths_1.NoAmbiguousPaths,
|
|
78
79
|
'no-undefined-server-variable': no_undefined_server_variable_1.NoUndefinedServerVariable,
|
|
79
|
-
'no-servers-empty-enum': no_servers_empty_enum_1.NoEmptyEnumServers
|
|
80
|
-
spec: spec_1.OasSpec,
|
|
80
|
+
'no-servers-empty-enum': no_servers_empty_enum_1.NoEmptyEnumServers
|
|
81
81
|
};
|
|
82
82
|
exports.preprocessors = {};
|
|
83
83
|
exports.decorators = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NoEmptyServers = void 0;
|
|
4
|
-
|
|
4
|
+
const NoEmptyServers = () => {
|
|
5
5
|
return {
|
|
6
6
|
DefinitionRoot(root, { report, location }) {
|
|
7
7
|
if (!root.servers) {
|
|
@@ -19,3 +19,4 @@ exports.NoEmptyServers = () => {
|
|
|
19
19
|
},
|
|
20
20
|
};
|
|
21
21
|
};
|
|
22
|
+
exports.NoEmptyServers = NoEmptyServers;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NoExampleValueAndExternalValue = void 0;
|
|
4
|
-
|
|
4
|
+
const NoExampleValueAndExternalValue = () => {
|
|
5
5
|
return {
|
|
6
6
|
Example(example, { report, location }) {
|
|
7
7
|
if (example.value && example.externalValue) {
|
|
@@ -13,3 +13,4 @@ exports.NoExampleValueAndExternalValue = () => {
|
|
|
13
13
|
},
|
|
14
14
|
};
|
|
15
15
|
};
|
|
16
|
+
exports.NoExampleValueAndExternalValue = NoExampleValueAndExternalValue;
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ValidContentExamples = void 0;
|
|
4
4
|
const ajv_1 = require("../ajv");
|
|
5
5
|
const ref_utils_1 = require("../../ref-utils");
|
|
6
|
-
|
|
6
|
+
const ValidContentExamples = (opts) => {
|
|
7
7
|
var _a;
|
|
8
8
|
const disallowAdditionalProperties = (_a = opts.disallowAdditionalProperties) !== null && _a !== void 0 ? _a : true;
|
|
9
9
|
return {
|
|
@@ -29,19 +29,29 @@ exports.ValidContentExamples = (opts) => {
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
function validateExample(example, dataLoc) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
32
|
+
try {
|
|
33
|
+
const { valid, errors } = ajv_1.validateJsonSchema(example, mediaType.schema, location.child('schema'), dataLoc.pointer, resolve, disallowAdditionalProperties);
|
|
34
|
+
if (!valid) {
|
|
35
|
+
for (let error of errors) {
|
|
36
|
+
report({
|
|
37
|
+
message: `Example value must conform to the schema: ${error.message}.`,
|
|
38
|
+
location: Object.assign(Object.assign({}, new ref_utils_1.Location(dataLoc.source, error.instancePath)), { reportOnKey: error.keyword === 'additionalProperties' }),
|
|
39
|
+
from: location,
|
|
40
|
+
suggest: error.suggest,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
41
43
|
}
|
|
42
44
|
}
|
|
45
|
+
catch (e) {
|
|
46
|
+
report({
|
|
47
|
+
message: `Example validation errored: ${e.message}.`,
|
|
48
|
+
location: location.child('schema'),
|
|
49
|
+
from: location
|
|
50
|
+
});
|
|
51
|
+
}
|
|
43
52
|
}
|
|
44
53
|
},
|
|
45
54
|
},
|
|
46
55
|
};
|
|
47
56
|
};
|
|
57
|
+
exports.ValidContentExamples = ValidContentExamples;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NoServerExample = void 0;
|
|
4
|
-
|
|
4
|
+
const NoServerExample = () => {
|
|
5
5
|
return {
|
|
6
6
|
Server(server, { report, location }) {
|
|
7
7
|
if (['example.com', 'localhost'].indexOf(server.url) !== -1) {
|
|
@@ -13,3 +13,4 @@ exports.NoServerExample = () => {
|
|
|
13
13
|
},
|
|
14
14
|
};
|
|
15
15
|
};
|
|
16
|
+
exports.NoServerExample = NoServerExample;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NoServerTrailingSlash = void 0;
|
|
4
|
-
|
|
4
|
+
const NoServerTrailingSlash = () => {
|
|
5
5
|
return {
|
|
6
6
|
Server(server, { report, location }) {
|
|
7
7
|
if (!server.url)
|
|
@@ -15,3 +15,4 @@ exports.NoServerTrailingSlash = () => {
|
|
|
15
15
|
},
|
|
16
16
|
};
|
|
17
17
|
};
|
|
18
|
+
exports.NoServerTrailingSlash = NoServerTrailingSlash;
|
|
@@ -6,7 +6,7 @@ var enumError;
|
|
|
6
6
|
enumError["empty"] = "empty";
|
|
7
7
|
enumError["invalidDefaultValue"] = "invalidDefaultValue";
|
|
8
8
|
})(enumError || (enumError = {}));
|
|
9
|
-
|
|
9
|
+
const NoEmptyEnumServers = () => {
|
|
10
10
|
return {
|
|
11
11
|
DefinitionRoot(root, { report, location }) {
|
|
12
12
|
if (!root.servers || root.servers.length === 0)
|
|
@@ -43,6 +43,7 @@ exports.NoEmptyEnumServers = () => {
|
|
|
43
43
|
},
|
|
44
44
|
};
|
|
45
45
|
};
|
|
46
|
+
exports.NoEmptyEnumServers = NoEmptyEnumServers;
|
|
46
47
|
function checkEnumVariables(server) {
|
|
47
48
|
var _a;
|
|
48
49
|
if (server.variables && Object.keys(server.variables).length === 0)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NoUndefinedServerVariable = void 0;
|
|
4
|
-
|
|
4
|
+
const NoUndefinedServerVariable = () => {
|
|
5
5
|
return {
|
|
6
6
|
Server(server, { report, location }) {
|
|
7
7
|
var _a;
|
|
@@ -27,3 +27,4 @@ exports.NoUndefinedServerVariable = () => {
|
|
|
27
27
|
},
|
|
28
28
|
};
|
|
29
29
|
};
|
|
30
|
+
exports.NoUndefinedServerVariable = NoUndefinedServerVariable;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NoUnusedComponents = void 0;
|
|
4
|
-
|
|
4
|
+
const NoUnusedComponents = () => {
|
|
5
5
|
let components = new Map();
|
|
6
6
|
function registerComponent(location, name) {
|
|
7
7
|
var _a;
|
|
@@ -71,3 +71,4 @@ exports.NoUnusedComponents = () => {
|
|
|
71
71
|
},
|
|
72
72
|
};
|
|
73
73
|
};
|
|
74
|
+
exports.NoUnusedComponents = NoUnusedComponents;
|
package/lib/rules/other/stats.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Stats = void 0;
|
|
4
|
-
|
|
4
|
+
const Stats = (statsAccumulator) => {
|
|
5
5
|
return {
|
|
6
6
|
ExternalDocs: { leave() { statsAccumulator.externalDocs.total++; } },
|
|
7
7
|
ref: { enter(ref) { statsAccumulator.refs.items.add(ref['$ref']); } },
|
|
@@ -41,3 +41,4 @@ exports.Stats = (statsAccumulator) => {
|
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
43
|
};
|
|
44
|
+
exports.Stats = Stats;
|
package/lib/types/oas2.js
CHANGED
|
@@ -82,7 +82,7 @@ const Operation = {
|
|
|
82
82
|
deprecated: { type: 'boolean' },
|
|
83
83
|
security: _1.listOf('SecurityRequirement'),
|
|
84
84
|
'x-codeSamples': _1.listOf('XCodeSample'),
|
|
85
|
-
'x-code-samples': _1.listOf('XCodeSample'),
|
|
85
|
+
'x-code-samples': _1.listOf('XCodeSample'), // deprecated
|
|
86
86
|
},
|
|
87
87
|
required: ['responses'],
|
|
88
88
|
};
|
package/lib/types/oas3.js
CHANGED
|
@@ -198,7 +198,7 @@ const Operation = {
|
|
|
198
198
|
},
|
|
199
199
|
callbacks: _1.mapOf('Callback'),
|
|
200
200
|
'x-codeSamples': _1.listOf('XCodeSample'),
|
|
201
|
-
'x-code-samples': _1.listOf('XCodeSample'),
|
|
201
|
+
'x-code-samples': _1.listOf('XCodeSample'), // deprecated
|
|
202
202
|
},
|
|
203
203
|
required: ['responses'],
|
|
204
204
|
};
|
package/lib/types/oas3_1.js
CHANGED
package/lib/utils.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export declare function pushStack<T, P extends Stack<T> = Stack<T>>(head: P, val
|
|
|
9
9
|
prev: P;
|
|
10
10
|
value: T;
|
|
11
11
|
};
|
|
12
|
-
export declare function popStack<T, P extends Stack<T>>(head: P):
|
|
12
|
+
export declare function popStack<T, P extends Stack<T>>(head: P): StackFrame<T> | null;
|
|
13
13
|
export declare type BundleOutputFormat = 'json' | 'yml' | 'yaml';
|
|
14
14
|
export declare function loadYaml(filename: string): Promise<string | object | undefined>;
|
|
15
15
|
export declare function notUndefined<T>(x: T | undefined): x is T;
|
package/lib/visitors.d.ts
CHANGED
|
@@ -4,7 +4,9 @@ import { NormalizedNodeType } from './types';
|
|
|
4
4
|
import { Stack } from './utils';
|
|
5
5
|
import { UserContext, ResolveResult, ProblemSeverity } from './walk';
|
|
6
6
|
import { Location } from './ref-utils';
|
|
7
|
-
export declare type VisitFunction<T> = (node: T, ctx: UserContext
|
|
7
|
+
export declare type VisitFunction<T> = (node: T, ctx: UserContext & {
|
|
8
|
+
ignoreNextVisitorsOnNode: () => void;
|
|
9
|
+
}, parents?: any, context?: any) => void;
|
|
8
10
|
declare type VisitRefFunction = (node: OasRef, ctx: UserContext, resolved: ResolveResult<any>) => void;
|
|
9
11
|
declare type SkipFunction<T> = (node: T, key: string | number) => boolean;
|
|
10
12
|
declare type VisitObject<T> = {
|
package/lib/visitors.js
CHANGED
|
@@ -3,16 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.normalizeVisitors = void 0;
|
|
4
4
|
function normalizeVisitors(visitorsConfig, types) {
|
|
5
5
|
const normalizedVisitors = {};
|
|
6
|
+
normalizedVisitors.any = {
|
|
7
|
+
enter: [],
|
|
8
|
+
leave: [],
|
|
9
|
+
};
|
|
6
10
|
for (const typeName of Object.keys(types)) {
|
|
7
11
|
normalizedVisitors[typeName] = {
|
|
8
12
|
enter: [],
|
|
9
13
|
leave: [],
|
|
10
14
|
};
|
|
11
15
|
}
|
|
12
|
-
normalizedVisitors.any = {
|
|
13
|
-
enter: [],
|
|
14
|
-
leave: [],
|
|
15
|
-
};
|
|
16
16
|
normalizedVisitors.ref = {
|
|
17
17
|
enter: [],
|
|
18
18
|
leave: [],
|
package/lib/walk.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Referenced } from './typings/openapi';
|
|
|
2
2
|
import { Location } from './ref-utils';
|
|
3
3
|
import { NormalizedOasVisitors } from './visitors';
|
|
4
4
|
import { ResolvedRefMap, Document, ResolveError, YamlParseError, Source } from './resolve';
|
|
5
|
-
import { OasVersion } from './
|
|
5
|
+
import { OasVersion } from './oas-types';
|
|
6
6
|
import { NormalizedNodeType } from './types';
|
|
7
7
|
declare type NonUndefined = string | number | boolean | symbol | bigint | object | Record<string, any>;
|
|
8
8
|
export declare type ResolveResult<T extends NonUndefined> = {
|
package/lib/walk.js
CHANGED
|
@@ -97,7 +97,10 @@ function walkDocument(opts) {
|
|
|
97
97
|
if (!activatedOn.skipped) {
|
|
98
98
|
visitedBySome = true;
|
|
99
99
|
enteredContexts.add(context);
|
|
100
|
-
visitWithContext(visit, resolvedNode, context, ruleId, severity);
|
|
100
|
+
const ignoreNextVisitorsOnNode = visitWithContext(visit, resolvedNode, context, ruleId, severity);
|
|
101
|
+
if (ignoreNextVisitorsOnNode) {
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
101
104
|
}
|
|
102
105
|
}
|
|
103
106
|
}
|
|
@@ -190,8 +193,10 @@ function walkDocument(opts) {
|
|
|
190
193
|
}
|
|
191
194
|
}
|
|
192
195
|
}
|
|
196
|
+
// returns true ignores all the next visitors on the specific node
|
|
193
197
|
function visitWithContext(visit, node, context, ruleId, severity) {
|
|
194
198
|
const report = reportFn.bind(undefined, ruleId, severity);
|
|
199
|
+
let ignoreNextVisitorsOnNode = false;
|
|
195
200
|
visit(node, {
|
|
196
201
|
report,
|
|
197
202
|
resolve,
|
|
@@ -201,7 +206,11 @@ function walkDocument(opts) {
|
|
|
201
206
|
key,
|
|
202
207
|
parentLocations: collectParentsLocations(context),
|
|
203
208
|
oasVersion: ctx.oasVersion,
|
|
204
|
-
|
|
209
|
+
ignoreNextVisitorsOnNode: () => {
|
|
210
|
+
ignoreNextVisitorsOnNode = true;
|
|
211
|
+
},
|
|
212
|
+
}, collectParents(context), context);
|
|
213
|
+
return ignoreNextVisitorsOnNode;
|
|
205
214
|
}
|
|
206
215
|
function resolve(ref, from = currentLocation.source.absoluteRef) {
|
|
207
216
|
if (!ref_utils_1.isRef(ref))
|