@redocly/openapi-core 1.0.0-beta.108 → 1.0.0-beta.110
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/lib/benchmark/benches/resolve-with-no-external.bench.js +1 -1
- package/lib/bundle.d.ts +1 -1
- package/lib/bundle.js +4 -4
- package/lib/config/all.js +3 -1
- package/lib/config/config-resolvers.js +22 -4
- package/lib/config/config.d.ts +1 -0
- package/lib/config/config.js +1 -0
- package/lib/config/load.d.ts +8 -2
- package/lib/config/load.js +4 -2
- package/lib/config/minimal.js +3 -1
- package/lib/config/recommended.js +3 -1
- package/lib/config/rules.js +1 -1
- package/lib/config/types.d.ts +17 -0
- package/lib/config/utils.d.ts +2 -2
- package/lib/config/utils.js +44 -6
- package/lib/decorators/common/registry-dependencies.js +1 -1
- package/lib/format/format.d.ts +1 -1
- package/lib/format/format.js +22 -1
- package/lib/lint.js +2 -2
- package/lib/redocly/registry-api.d.ts +0 -1
- package/lib/redocly/registry-api.js +5 -4
- package/lib/resolve.js +3 -1
- package/lib/rules/ajv.d.ts +1 -1
- package/lib/rules/ajv.js +5 -5
- package/lib/rules/common/assertions/asserts.d.ts +3 -5
- package/lib/rules/common/assertions/asserts.js +137 -97
- package/lib/rules/common/assertions/index.js +2 -6
- package/lib/rules/common/assertions/utils.d.ts +12 -6
- package/lib/rules/common/assertions/utils.js +33 -20
- package/lib/rules/common/no-ambiguous-paths.js +1 -1
- package/lib/rules/common/no-identical-paths.js +1 -1
- package/lib/rules/common/operation-2xx-response.js +1 -1
- package/lib/rules/common/operation-4xx-response.js +1 -1
- package/lib/rules/common/operation-operationId.js +1 -1
- package/lib/rules/common/operation-tag-defined.js +1 -1
- package/lib/rules/common/path-not-include-query.js +1 -1
- package/lib/rules/common/security-defined.d.ts +2 -0
- package/lib/rules/common/{operation-security-defined.js → security-defined.js} +18 -4
- package/lib/rules/common/spec.js +12 -1
- package/lib/rules/common/tags-alphabetical.js +1 -1
- package/lib/rules/oas2/index.d.ts +1 -1
- package/lib/rules/oas2/index.js +2 -2
- package/lib/rules/oas2/remove-unused-components.js +1 -1
- package/lib/rules/oas2/request-mime-type.js +1 -1
- package/lib/rules/oas2/response-mime-type.js +1 -1
- package/lib/rules/oas3/index.js +6 -2
- package/lib/rules/oas3/no-empty-servers.js +1 -1
- package/lib/rules/oas3/no-server-variables-empty-enum.js +1 -1
- package/lib/rules/oas3/no-unused-components.js +1 -1
- package/lib/rules/oas3/operation-4xx-problem-details-rfc7807.d.ts +5 -0
- package/lib/rules/oas3/operation-4xx-problem-details-rfc7807.js +36 -0
- package/lib/rules/oas3/remove-unused-components.js +1 -1
- package/lib/rules/oas3/request-mime-type.js +1 -1
- package/lib/rules/oas3/response-mime-type.js +1 -1
- package/lib/rules/oas3/spec-components-invalid-map-name.d.ts +2 -0
- package/lib/rules/oas3/spec-components-invalid-map-name.js +46 -0
- package/lib/rules/other/stats.d.ts +2 -2
- package/lib/rules/other/stats.js +2 -2
- package/lib/rules/utils.js +1 -1
- package/lib/types/oas2.js +5 -5
- package/lib/types/oas3.js +27 -20
- package/lib/types/oas3_1.js +3 -3
- package/lib/types/redocly-yaml.js +60 -54
- package/lib/utils.d.ts +3 -3
- package/lib/utils.js +5 -5
- package/lib/visitors.d.ts +11 -11
- package/lib/visitors.js +13 -1
- package/package.json +3 -5
- package/src/__tests__/__snapshots__/bundle.test.ts.snap +3 -3
- package/src/__tests__/fixtures/extension.js +3 -3
- package/src/__tests__/format.test.ts +76 -0
- package/src/__tests__/lint.test.ts +184 -121
- package/src/__tests__/resolve-http.test.ts +1 -1
- package/src/__tests__/resolve.test.ts +9 -9
- package/src/__tests__/walk.test.ts +78 -10
- package/src/benchmark/benches/resolve-with-no-external.bench.ts +1 -1
- package/src/bundle.ts +4 -4
- package/src/config/__tests__/__snapshots__/config-resolvers.test.ts.snap +6 -2
- package/src/config/__tests__/config-resolvers.test.ts +37 -1
- package/src/config/__tests__/config.test.ts +5 -0
- package/src/config/__tests__/fixtures/plugin-config.yaml +2 -3
- package/src/config/__tests__/fixtures/resolve-config/api/nested-config.yaml +11 -12
- package/src/config/__tests__/fixtures/resolve-config/local-config-with-circular.yaml +7 -8
- package/src/config/__tests__/fixtures/resolve-config/local-config-with-custom-function.yaml +16 -0
- package/src/config/__tests__/fixtures/resolve-config/local-config-with-file.yaml +18 -19
- package/src/config/__tests__/fixtures/resolve-config/local-config-with-wrong-custom-function.yaml +16 -0
- package/src/config/__tests__/fixtures/resolve-config/local-config.yaml +9 -10
- package/src/config/__tests__/fixtures/resolve-config/plugin.js +11 -0
- package/src/config/__tests__/fixtures/resolve-remote-configs/nested-remote-config.yaml +3 -4
- package/src/config/__tests__/fixtures/resolve-remote-configs/remote-config.yaml +4 -5
- package/src/config/__tests__/load.test.ts +13 -16
- package/src/config/__tests__/resolve-plugins.test.ts +3 -3
- package/src/config/__tests__/utils.test.ts +64 -4
- package/src/config/all.ts +3 -1
- package/src/config/config-resolvers.ts +30 -7
- package/src/config/config.ts +2 -0
- package/src/config/load.ts +13 -6
- package/src/config/minimal.ts +3 -1
- package/src/config/recommended.ts +3 -1
- package/src/config/rules.ts +2 -2
- package/src/config/types.ts +24 -0
- package/src/config/utils.ts +103 -13
- package/src/decorators/common/registry-dependencies.ts +1 -1
- package/src/format/format.ts +32 -2
- package/src/lint.ts +2 -2
- package/src/redocly/registry-api.ts +5 -4
- package/src/resolve.ts +3 -1
- package/src/rules/__tests__/utils.test.ts +1 -1
- package/src/rules/ajv.ts +4 -4
- package/src/rules/common/__tests__/no-enum-type-mismatch.test.ts +1 -0
- package/src/rules/common/__tests__/operation-2xx-response.test.ts +1 -1
- package/src/rules/common/__tests__/operation-4xx-response.test.ts +26 -3
- package/src/rules/common/__tests__/security-defined.test.ts +175 -0
- package/src/rules/common/__tests__/spec.test.ts +79 -0
- package/src/rules/common/assertions/__tests__/asserts.test.ts +491 -428
- package/src/rules/common/assertions/__tests__/utils.test.ts +2 -2
- package/src/rules/common/assertions/asserts.ts +155 -97
- package/src/rules/common/assertions/index.ts +2 -11
- package/src/rules/common/assertions/utils.ts +66 -36
- package/src/rules/common/no-ambiguous-paths.ts +1 -1
- package/src/rules/common/no-identical-paths.ts +1 -1
- package/src/rules/common/operation-2xx-response.ts +1 -1
- package/src/rules/common/operation-4xx-response.ts +1 -1
- package/src/rules/common/operation-operationId.ts +1 -1
- package/src/rules/common/operation-tag-defined.ts +1 -1
- package/src/rules/common/path-not-include-query.ts +1 -1
- package/src/rules/common/{operation-security-defined.ts → security-defined.ts} +19 -4
- package/src/rules/common/spec.ts +15 -1
- package/src/rules/common/tags-alphabetical.ts +1 -1
- package/src/rules/oas2/index.ts +2 -2
- package/src/rules/oas2/remove-unused-components.ts +1 -1
- package/src/rules/oas2/request-mime-type.ts +1 -1
- package/src/rules/oas2/response-mime-type.ts +1 -1
- package/src/rules/oas3/__tests__/no-invalid-media-type-examples.test.ts +51 -2
- package/src/rules/oas3/__tests__/operation-4xx-problem-details-rfc7807.test.ts +145 -0
- package/src/rules/oas3/__tests__/spec/spec.test.ts +10 -0
- package/src/rules/oas3/__tests__/spec-components-invalid-map-name.test.ts +217 -0
- package/src/rules/oas3/index.ts +6 -2
- package/src/rules/oas3/no-empty-servers.ts +1 -1
- package/src/rules/oas3/no-server-variables-empty-enum.ts +1 -1
- package/src/rules/oas3/no-unused-components.ts +1 -1
- package/src/rules/oas3/operation-4xx-problem-details-rfc7807.ts +36 -0
- package/src/rules/oas3/remove-unused-components.ts +1 -1
- package/src/rules/oas3/request-mime-type.ts +1 -1
- package/src/rules/oas3/response-mime-type.ts +1 -1
- package/src/rules/oas3/spec-components-invalid-map-name.ts +53 -0
- package/src/rules/other/stats.ts +2 -2
- package/src/rules/utils.ts +2 -1
- package/src/types/index.ts +2 -2
- package/src/types/oas2.ts +5 -5
- package/src/types/oas3.ts +27 -20
- package/src/types/oas3_1.ts +3 -3
- package/src/types/redocly-yaml.ts +66 -38
- package/src/utils.ts +11 -7
- package/src/visitors.ts +29 -13
- package/tsconfig.tsbuildinfo +1 -1
- package/lib/rules/common/operation-security-defined.d.ts +0 -2
- package/src/rules/common/__tests__/operation-security-defined.test.ts +0 -69
package/lib/rules/common/spec.js
CHANGED
|
@@ -7,13 +7,15 @@ const ref_utils_1 = require("../../ref-utils");
|
|
|
7
7
|
const utils_2 = require("../../utils");
|
|
8
8
|
const OasSpec = () => {
|
|
9
9
|
return {
|
|
10
|
-
any(node, { report, type, location, key, resolve, ignoreNextVisitorsOnNode }) {
|
|
10
|
+
any(node, { report, type, location, rawLocation, key, resolve, ignoreNextVisitorsOnNode }) {
|
|
11
11
|
var _a, _b, _c, _d;
|
|
12
12
|
const nodeType = utils_1.oasTypeOf(node);
|
|
13
|
+
const refLocation = rawLocation !== location ? rawLocation : undefined;
|
|
13
14
|
if (type.items) {
|
|
14
15
|
if (nodeType !== 'array') {
|
|
15
16
|
report({
|
|
16
17
|
message: `Expected type \`${type.name}\` (array) but got \`${nodeType}\``,
|
|
18
|
+
from: refLocation,
|
|
17
19
|
});
|
|
18
20
|
ignoreNextVisitorsOnNode();
|
|
19
21
|
}
|
|
@@ -22,6 +24,7 @@ const OasSpec = () => {
|
|
|
22
24
|
else if (nodeType !== 'object') {
|
|
23
25
|
report({
|
|
24
26
|
message: `Expected type \`${type.name}\` (object) but got \`${nodeType}\``,
|
|
27
|
+
from: refLocation,
|
|
25
28
|
});
|
|
26
29
|
ignoreNextVisitorsOnNode();
|
|
27
30
|
return;
|
|
@@ -31,6 +34,7 @@ const OasSpec = () => {
|
|
|
31
34
|
if (!node.hasOwnProperty(propName)) {
|
|
32
35
|
report({
|
|
33
36
|
message: `The field \`${propName}\` must be present on this level.`,
|
|
37
|
+
from: refLocation,
|
|
34
38
|
location: [{ reportOnKey: true }],
|
|
35
39
|
});
|
|
36
40
|
}
|
|
@@ -45,6 +49,7 @@ const OasSpec = () => {
|
|
|
45
49
|
}
|
|
46
50
|
report({
|
|
47
51
|
message: `The field \`${propName}\` is not allowed here.`,
|
|
52
|
+
from: refLocation,
|
|
48
53
|
location: location.child([propName]).key(),
|
|
49
54
|
});
|
|
50
55
|
}
|
|
@@ -60,6 +65,7 @@ const OasSpec = () => {
|
|
|
60
65
|
if (!hasProperty)
|
|
61
66
|
report({
|
|
62
67
|
message: `Must contain at least one of the following fields: ${(_b = type.requiredOneOf) === null || _b === void 0 ? void 0 : _b.join(', ')}.`,
|
|
68
|
+
from: refLocation,
|
|
63
69
|
location: [{ reportOnKey: true }],
|
|
64
70
|
});
|
|
65
71
|
}
|
|
@@ -82,6 +88,7 @@ const OasSpec = () => {
|
|
|
82
88
|
report({
|
|
83
89
|
message: `Property \`${propName}\` is not expected here.`,
|
|
84
90
|
suggest: utils_1.getSuggest(propName, Object.keys(type.properties)),
|
|
91
|
+
from: refLocation,
|
|
85
92
|
location: propLocation.key(),
|
|
86
93
|
});
|
|
87
94
|
continue;
|
|
@@ -99,6 +106,7 @@ const OasSpec = () => {
|
|
|
99
106
|
message: `\`${propName}\` can be one of the following only: ${propSchema.enum
|
|
100
107
|
.map((i) => `"${i}"`)
|
|
101
108
|
.join(', ')}.`,
|
|
109
|
+
from: refLocation,
|
|
102
110
|
suggest: utils_1.getSuggest(propValue, propSchema.enum),
|
|
103
111
|
});
|
|
104
112
|
}
|
|
@@ -106,6 +114,7 @@ const OasSpec = () => {
|
|
|
106
114
|
else if (propSchema.type && !utils_1.matchesJsonSchemaType(propValue, propSchema.type, false)) {
|
|
107
115
|
report({
|
|
108
116
|
message: `Expected type \`${propSchema.type}\` but got \`${propValueType}\`.`,
|
|
117
|
+
from: refLocation,
|
|
109
118
|
location: propLocation,
|
|
110
119
|
});
|
|
111
120
|
}
|
|
@@ -116,6 +125,7 @@ const OasSpec = () => {
|
|
|
116
125
|
if (!utils_1.matchesJsonSchemaType(item, itemsType, false)) {
|
|
117
126
|
report({
|
|
118
127
|
message: `Expected type \`${itemsType}\` but got \`${utils_1.oasTypeOf(item)}\`.`,
|
|
128
|
+
from: refLocation,
|
|
119
129
|
location: propLocation.child([i]),
|
|
120
130
|
});
|
|
121
131
|
}
|
|
@@ -125,6 +135,7 @@ const OasSpec = () => {
|
|
|
125
135
|
if (propSchema.minimum > node[propName]) {
|
|
126
136
|
report({
|
|
127
137
|
message: `The value of the ${propName} field must be greater than or equal to ${propSchema.minimum}`,
|
|
138
|
+
from: refLocation,
|
|
128
139
|
location: location.child([propName]),
|
|
129
140
|
});
|
|
130
141
|
}
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.TagsAlphabetical = void 0;
|
|
4
4
|
const TagsAlphabetical = () => {
|
|
5
5
|
return {
|
|
6
|
-
|
|
6
|
+
Root(root, { report, location }) {
|
|
7
7
|
if (!root.tags)
|
|
8
8
|
return;
|
|
9
9
|
for (let i = 0; i < root.tags.length - 1; i++) {
|
|
@@ -29,7 +29,7 @@ export declare const rules: {
|
|
|
29
29
|
'path-params-defined': Oas2Rule;
|
|
30
30
|
'parameter-description': Oas2Rule;
|
|
31
31
|
'operation-singular-tag': Oas2Rule;
|
|
32
|
-
'
|
|
32
|
+
'security-defined': Oas2Rule;
|
|
33
33
|
'no-unresolved-refs': Oas2Rule;
|
|
34
34
|
'no-identical-paths': Oas2Rule;
|
|
35
35
|
'no-ambiguous-paths': Oas2Rule;
|
package/lib/rules/oas2/index.js
CHANGED
|
@@ -27,7 +27,7 @@ const operation_description_1 = require("../common/operation-description");
|
|
|
27
27
|
const path_not_include_query_1 = require("../common/path-not-include-query");
|
|
28
28
|
const parameter_description_1 = require("../common/parameter-description");
|
|
29
29
|
const operation_singular_tag_1 = require("../common/operation-singular-tag");
|
|
30
|
-
const
|
|
30
|
+
const security_defined_1 = require("../common/security-defined");
|
|
31
31
|
const no_unresolved_refs_1 = require("../no-unresolved-refs");
|
|
32
32
|
const path_http_verbs_order_1 = require("../common/path-http-verbs-order");
|
|
33
33
|
const no_identical_paths_1 = require("../common/no-identical-paths");
|
|
@@ -72,7 +72,7 @@ exports.rules = {
|
|
|
72
72
|
'path-params-defined': path_params_defined_1.PathParamsDefined,
|
|
73
73
|
'parameter-description': parameter_description_1.ParameterDescription,
|
|
74
74
|
'operation-singular-tag': operation_singular_tag_1.OperationSingularTag,
|
|
75
|
-
'
|
|
75
|
+
'security-defined': security_defined_1.SecurityDefined,
|
|
76
76
|
'no-unresolved-refs': no_unresolved_refs_1.NoUnresolvedRefs,
|
|
77
77
|
'no-identical-paths': no_identical_paths_1.NoIdenticalPaths,
|
|
78
78
|
'no-ambiguous-paths': no_ambiguous_paths_1.NoAmbiguousPaths,
|
|
@@ -4,7 +4,7 @@ exports.RequestMimeType = void 0;
|
|
|
4
4
|
const utils_1 = require("../../utils");
|
|
5
5
|
const RequestMimeType = ({ allowedValues }) => {
|
|
6
6
|
return {
|
|
7
|
-
|
|
7
|
+
Root(root, ctx) {
|
|
8
8
|
utils_1.validateMimeType({ type: 'consumes', value: root }, ctx, allowedValues);
|
|
9
9
|
},
|
|
10
10
|
Operation: {
|
|
@@ -4,7 +4,7 @@ exports.ResponseMimeType = void 0;
|
|
|
4
4
|
const utils_1 = require("../../utils");
|
|
5
5
|
const ResponseMimeType = ({ allowedValues }) => {
|
|
6
6
|
return {
|
|
7
|
-
|
|
7
|
+
Root(root, ctx) {
|
|
8
8
|
utils_1.validateMimeType({ type: 'produces', value: root }, ctx, allowedValues);
|
|
9
9
|
},
|
|
10
10
|
Operation: {
|
package/lib/rules/oas3/index.js
CHANGED
|
@@ -27,7 +27,7 @@ const no_unused_components_1 = require("./no-unused-components");
|
|
|
27
27
|
const path_not_include_query_1 = require("../common/path-not-include-query");
|
|
28
28
|
const parameter_description_1 = require("../common/parameter-description");
|
|
29
29
|
const operation_singular_tag_1 = require("../common/operation-singular-tag");
|
|
30
|
-
const
|
|
30
|
+
const security_defined_1 = require("../common/security-defined");
|
|
31
31
|
const no_unresolved_refs_1 = require("../no-unresolved-refs");
|
|
32
32
|
const boolean_parameter_prefixes_1 = require("./boolean-parameter-prefixes");
|
|
33
33
|
const paths_kebab_case_1 = require("../common/paths-kebab-case");
|
|
@@ -50,6 +50,8 @@ const no_invalid_parameter_examples_1 = require("../common/no-invalid-parameter-
|
|
|
50
50
|
const response_contains_header_1 = require("../common/response-contains-header");
|
|
51
51
|
const response_contains_property_1 = require("./response-contains-property");
|
|
52
52
|
const scalar_property_missing_example_1 = require("../common/scalar-property-missing-example");
|
|
53
|
+
const spec_components_invalid_map_name_1 = require("./spec-components-invalid-map-name");
|
|
54
|
+
const operation_4xx_problem_details_rfc7807_1 = require("./operation-4xx-problem-details-rfc7807");
|
|
53
55
|
exports.rules = {
|
|
54
56
|
spec: spec_1.OasSpec,
|
|
55
57
|
'info-description': info_description_1.InfoDescription,
|
|
@@ -58,6 +60,7 @@ exports.rules = {
|
|
|
58
60
|
'info-license-url': info_license_url_1.InfoLicenseUrl,
|
|
59
61
|
'operation-2xx-response': operation_2xx_response_1.Operation2xxResponse,
|
|
60
62
|
'operation-4xx-response': operation_4xx_response_1.Operation4xxResponse,
|
|
63
|
+
'operation-4xx-problem-details-rfc7807': operation_4xx_problem_details_rfc7807_1.Operation4xxProblemDetailsRfc7807,
|
|
61
64
|
assertions: assertions_1.Assertions,
|
|
62
65
|
'operation-operationId-unique': operation_operationId_unique_1.OperationIdUnique,
|
|
63
66
|
'operation-parameters-unique': operation_parameters_unique_1.OperationParametersUnique,
|
|
@@ -81,7 +84,7 @@ exports.rules = {
|
|
|
81
84
|
'path-params-defined': path_params_defined_1.PathParamsDefined,
|
|
82
85
|
'parameter-description': parameter_description_1.ParameterDescription,
|
|
83
86
|
'operation-singular-tag': operation_singular_tag_1.OperationSingularTag,
|
|
84
|
-
'
|
|
87
|
+
'security-defined': security_defined_1.SecurityDefined,
|
|
85
88
|
'no-unresolved-refs': no_unresolved_refs_1.NoUnresolvedRefs,
|
|
86
89
|
'paths-kebab-case': paths_kebab_case_1.PathsKebabCase,
|
|
87
90
|
'boolean-parameter-prefixes': boolean_parameter_prefixes_1.BooleanParameterPrefixes,
|
|
@@ -101,5 +104,6 @@ exports.rules = {
|
|
|
101
104
|
'response-contains-header': response_contains_header_1.ResponseContainsHeader,
|
|
102
105
|
'response-contains-property': response_contains_property_1.ResponseContainsProperty,
|
|
103
106
|
'scalar-property-missing-example': scalar_property_missing_example_1.ScalarPropertyMissingExample,
|
|
107
|
+
'spec-components-invalid-map-name': spec_components_invalid_map_name_1.SpecComponentsInvalidMapName,
|
|
104
108
|
};
|
|
105
109
|
exports.preprocessors = {};
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.NoEmptyServers = void 0;
|
|
4
4
|
const NoEmptyServers = () => {
|
|
5
5
|
return {
|
|
6
|
-
|
|
6
|
+
Root(root, { report, location }) {
|
|
7
7
|
if (!root.hasOwnProperty('servers')) {
|
|
8
8
|
report({
|
|
9
9
|
message: 'Servers must be present.',
|
|
@@ -8,7 +8,7 @@ var enumError;
|
|
|
8
8
|
})(enumError || (enumError = {}));
|
|
9
9
|
const NoServerVariablesEmptyEnum = () => {
|
|
10
10
|
return {
|
|
11
|
-
|
|
11
|
+
Root(root, { report, location }) {
|
|
12
12
|
if (!root.servers || root.servers.length === 0)
|
|
13
13
|
return;
|
|
14
14
|
const invalidVariables = [];
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Operation4xxProblemDetailsRfc7807 = void 0;
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
/**
|
|
6
|
+
* Validation according rfc7807 - https://datatracker.ietf.org/doc/html/rfc7807
|
|
7
|
+
*/
|
|
8
|
+
const Operation4xxProblemDetailsRfc7807 = () => {
|
|
9
|
+
return {
|
|
10
|
+
Response: {
|
|
11
|
+
skip(_response, key) {
|
|
12
|
+
return !/4[Xx0-9]{2}/.test(`${key}`);
|
|
13
|
+
},
|
|
14
|
+
enter(response, { report, location }) {
|
|
15
|
+
if (!response.content || !response.content['application/problem+json'])
|
|
16
|
+
report({
|
|
17
|
+
message: 'Response `4xx` must have content-type `application/problem+json`.',
|
|
18
|
+
location: location.key(),
|
|
19
|
+
});
|
|
20
|
+
},
|
|
21
|
+
MediaType: {
|
|
22
|
+
skip(_response, key) {
|
|
23
|
+
return key !== 'application/problem+json';
|
|
24
|
+
},
|
|
25
|
+
enter(media, ctx) {
|
|
26
|
+
utils_1.validateDefinedAndNonEmpty('schema', media, ctx);
|
|
27
|
+
},
|
|
28
|
+
SchemaProperties(schema, ctx) {
|
|
29
|
+
utils_1.validateDefinedAndNonEmpty('type', schema, ctx);
|
|
30
|
+
utils_1.validateDefinedAndNonEmpty('title', schema, ctx);
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
exports.Operation4xxProblemDetailsRfc7807 = Operation4xxProblemDetailsRfc7807;
|
|
@@ -4,7 +4,7 @@ exports.RequestMimeType = void 0;
|
|
|
4
4
|
const utils_1 = require("../../utils");
|
|
5
5
|
const RequestMimeType = ({ allowedValues }) => {
|
|
6
6
|
return {
|
|
7
|
-
|
|
7
|
+
PathsMap: {
|
|
8
8
|
RequestBody: {
|
|
9
9
|
leave(requestBody, ctx) {
|
|
10
10
|
utils_1.validateMimeTypeOAS3({ type: 'consumes', value: requestBody }, ctx, allowedValues);
|
|
@@ -4,7 +4,7 @@ exports.ResponseMimeType = void 0;
|
|
|
4
4
|
const utils_1 = require("../../utils");
|
|
5
5
|
const ResponseMimeType = ({ allowedValues }) => {
|
|
6
6
|
return {
|
|
7
|
-
|
|
7
|
+
PathsMap: {
|
|
8
8
|
Response: {
|
|
9
9
|
leave(response, ctx) {
|
|
10
10
|
utils_1.validateMimeTypeOAS3({ type: 'produces', value: response }, ctx, allowedValues);
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SpecComponentsInvalidMapName = void 0;
|
|
4
|
+
const SpecComponentsInvalidMapName = () => {
|
|
5
|
+
const KEYS_REGEX = '^[a-zA-Z0-9\\.\\-_]+$';
|
|
6
|
+
function validateKey(key, report, location, component) {
|
|
7
|
+
if (!new RegExp(KEYS_REGEX).test(key)) {
|
|
8
|
+
report({
|
|
9
|
+
message: `The map key in ${component} "${key}" does not match the regular expression "${KEYS_REGEX}"`,
|
|
10
|
+
location: location.key(),
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return {
|
|
15
|
+
Components: {
|
|
16
|
+
Parameter(_node, { key, report, location }) {
|
|
17
|
+
validateKey(key, report, location, 'parameters');
|
|
18
|
+
},
|
|
19
|
+
Response(_node, { key, report, location }) {
|
|
20
|
+
validateKey(key, report, location, 'responses');
|
|
21
|
+
},
|
|
22
|
+
Schema(_node, { key, report, location }) {
|
|
23
|
+
validateKey(key, report, location, 'schemas');
|
|
24
|
+
},
|
|
25
|
+
Example(_node, { key, report, location }) {
|
|
26
|
+
validateKey(key, report, location, 'examples');
|
|
27
|
+
},
|
|
28
|
+
RequestBody(_node, { key, report, location }) {
|
|
29
|
+
validateKey(key, report, location, 'requestBodies');
|
|
30
|
+
},
|
|
31
|
+
Header(_node, { key, report, location }) {
|
|
32
|
+
validateKey(key, report, location, 'headers');
|
|
33
|
+
},
|
|
34
|
+
SecurityScheme(_node, { key, report, location }) {
|
|
35
|
+
validateKey(key, report, location, 'securitySchemas');
|
|
36
|
+
},
|
|
37
|
+
Link(_node, { key, report, location }) {
|
|
38
|
+
validateKey(key, report, location, 'links');
|
|
39
|
+
},
|
|
40
|
+
Callback(_node, { key, report, location }) {
|
|
41
|
+
validateKey(key, report, location, 'callbacks');
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
exports.SpecComponentsInvalidMapName = SpecComponentsInvalidMapName;
|
|
@@ -14,7 +14,7 @@ export declare const Stats: (statsAccumulator: StatsAccumulator) => {
|
|
|
14
14
|
Link: {
|
|
15
15
|
leave(link: any): void;
|
|
16
16
|
};
|
|
17
|
-
|
|
17
|
+
Root: {
|
|
18
18
|
leave(): void;
|
|
19
19
|
};
|
|
20
20
|
WebhooksMap: {
|
|
@@ -22,7 +22,7 @@ export declare const Stats: (statsAccumulator: StatsAccumulator) => {
|
|
|
22
22
|
leave(operation: any): void;
|
|
23
23
|
};
|
|
24
24
|
};
|
|
25
|
-
|
|
25
|
+
PathsMap: {
|
|
26
26
|
PathItem: {
|
|
27
27
|
leave(): void;
|
|
28
28
|
Operation: {
|
package/lib/rules/other/stats.js
CHANGED
|
@@ -23,7 +23,7 @@ const Stats = (statsAccumulator) => {
|
|
|
23
23
|
statsAccumulator.links.items.add(link.operationId);
|
|
24
24
|
},
|
|
25
25
|
},
|
|
26
|
-
|
|
26
|
+
Root: {
|
|
27
27
|
leave() {
|
|
28
28
|
statsAccumulator.parameters.total = statsAccumulator.parameters.items.size;
|
|
29
29
|
statsAccumulator.refs.total = statsAccumulator.refs.items.size;
|
|
@@ -40,7 +40,7 @@ const Stats = (statsAccumulator) => {
|
|
|
40
40
|
},
|
|
41
41
|
},
|
|
42
42
|
},
|
|
43
|
-
|
|
43
|
+
PathsMap: {
|
|
44
44
|
PathItem: {
|
|
45
45
|
leave() {
|
|
46
46
|
statsAccumulator.pathItems.total++;
|
package/lib/rules/utils.js
CHANGED
|
@@ -93,7 +93,7 @@ function validateExample(example, schema, dataLoc, { resolve, location, report }
|
|
|
93
93
|
for (const error of errors) {
|
|
94
94
|
report({
|
|
95
95
|
message: `Example value must conform to the schema: ${error.message}.`,
|
|
96
|
-
location: Object.assign(Object.assign({}, new ref_utils_1.Location(dataLoc.source, error.instancePath)), { reportOnKey: error.keyword === 'additionalProperties' }),
|
|
96
|
+
location: Object.assign(Object.assign({}, new ref_utils_1.Location(dataLoc.source, error.instancePath)), { reportOnKey: error.keyword === 'unevaluatedProperties' || error.keyword === 'additionalProperties' }),
|
|
97
97
|
from: location,
|
|
98
98
|
suggest: error.suggest,
|
|
99
99
|
});
|
package/lib/types/oas2.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Oas2Types = void 0;
|
|
4
4
|
const _1 = require(".");
|
|
5
5
|
const responseCodeRegexp = /^[0-9][0-9Xx]{2}$/;
|
|
6
|
-
const
|
|
6
|
+
const Root = {
|
|
7
7
|
properties: {
|
|
8
8
|
swagger: { type: 'string' },
|
|
9
9
|
info: 'Info',
|
|
@@ -12,7 +12,7 @@ const DefinitionRoot = {
|
|
|
12
12
|
schemes: { type: 'array', items: { type: 'string' } },
|
|
13
13
|
consumes: { type: 'array', items: { type: 'string' } },
|
|
14
14
|
produces: { type: 'array', items: { type: 'string' } },
|
|
15
|
-
paths: '
|
|
15
|
+
paths: 'PathsMap',
|
|
16
16
|
definitions: 'NamedSchemas',
|
|
17
17
|
parameters: 'NamedParameters',
|
|
18
18
|
responses: 'NamedResponses',
|
|
@@ -48,7 +48,7 @@ const License = {
|
|
|
48
48
|
},
|
|
49
49
|
required: ['name'],
|
|
50
50
|
};
|
|
51
|
-
const
|
|
51
|
+
const PathsMap = {
|
|
52
52
|
properties: {},
|
|
53
53
|
additionalProperties: (_value, key) => key.startsWith('/') ? 'PathItem' : undefined,
|
|
54
54
|
};
|
|
@@ -352,14 +352,14 @@ const SecurityRequirement = {
|
|
|
352
352
|
additionalProperties: { type: 'array', items: { type: 'string' } },
|
|
353
353
|
};
|
|
354
354
|
exports.Oas2Types = {
|
|
355
|
-
|
|
355
|
+
Root,
|
|
356
356
|
Tag,
|
|
357
357
|
ExternalDocs,
|
|
358
358
|
SecurityRequirement,
|
|
359
359
|
Info,
|
|
360
360
|
Contact,
|
|
361
361
|
License,
|
|
362
|
-
|
|
362
|
+
PathsMap,
|
|
363
363
|
PathItem,
|
|
364
364
|
Parameter,
|
|
365
365
|
ParameterItems,
|
package/lib/types/oas3.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.Oas3Types = void 0;
|
|
|
4
4
|
const _1 = require(".");
|
|
5
5
|
const ref_utils_1 = require("../ref-utils");
|
|
6
6
|
const responseCodeRegexp = /^[0-9][0-9Xx]{2}$/;
|
|
7
|
-
const
|
|
7
|
+
const Root = {
|
|
8
8
|
properties: {
|
|
9
9
|
openapi: null,
|
|
10
10
|
info: 'Info',
|
|
@@ -12,7 +12,7 @@ const DefinitionRoot = {
|
|
|
12
12
|
security: _1.listOf('SecurityRequirement'),
|
|
13
13
|
tags: _1.listOf('Tag'),
|
|
14
14
|
externalDocs: 'ExternalDocs',
|
|
15
|
-
paths: '
|
|
15
|
+
paths: 'PathsMap',
|
|
16
16
|
components: 'Components',
|
|
17
17
|
'x-webhooks': 'WebhooksMap',
|
|
18
18
|
},
|
|
@@ -37,7 +37,7 @@ const Server = {
|
|
|
37
37
|
properties: {
|
|
38
38
|
url: { type: 'string' },
|
|
39
39
|
description: { type: 'string' },
|
|
40
|
-
variables:
|
|
40
|
+
variables: 'ServerVariablesMap',
|
|
41
41
|
},
|
|
42
42
|
required: ['url'],
|
|
43
43
|
};
|
|
@@ -81,7 +81,7 @@ const License = {
|
|
|
81
81
|
},
|
|
82
82
|
required: ['name'],
|
|
83
83
|
};
|
|
84
|
-
const
|
|
84
|
+
const PathsMap = {
|
|
85
85
|
properties: {},
|
|
86
86
|
additionalProperties: (_value, key) => key.startsWith('/') ? 'PathItem' : undefined,
|
|
87
87
|
};
|
|
@@ -121,8 +121,8 @@ const Parameter = {
|
|
|
121
121
|
allowReserved: { type: 'boolean' },
|
|
122
122
|
schema: 'Schema',
|
|
123
123
|
example: { isExample: true },
|
|
124
|
-
examples:
|
|
125
|
-
content: '
|
|
124
|
+
examples: 'ExamplesMap',
|
|
125
|
+
content: 'MediaTypesMap',
|
|
126
126
|
},
|
|
127
127
|
required: ['name', 'in'],
|
|
128
128
|
requiredOneOf: ['schema', 'content'],
|
|
@@ -143,7 +143,7 @@ const Operation = {
|
|
|
143
143
|
requestBody: 'RequestBody',
|
|
144
144
|
responses: 'ResponsesMap',
|
|
145
145
|
deprecated: { type: 'boolean' },
|
|
146
|
-
callbacks:
|
|
146
|
+
callbacks: 'CallbacksMap',
|
|
147
147
|
'x-codeSamples': _1.listOf('XCodeSample'),
|
|
148
148
|
'x-code-samples': _1.listOf('XCodeSample'),
|
|
149
149
|
'x-hideTryItPanel': { type: 'boolean' },
|
|
@@ -161,11 +161,11 @@ const RequestBody = {
|
|
|
161
161
|
properties: {
|
|
162
162
|
description: { type: 'string' },
|
|
163
163
|
required: { type: 'boolean' },
|
|
164
|
-
content: '
|
|
164
|
+
content: 'MediaTypesMap',
|
|
165
165
|
},
|
|
166
166
|
required: ['content'],
|
|
167
167
|
};
|
|
168
|
-
const
|
|
168
|
+
const MediaTypesMap = {
|
|
169
169
|
properties: {},
|
|
170
170
|
additionalProperties: 'MediaType',
|
|
171
171
|
};
|
|
@@ -173,8 +173,8 @@ const MediaType = {
|
|
|
173
173
|
properties: {
|
|
174
174
|
schema: 'Schema',
|
|
175
175
|
example: { isExample: true },
|
|
176
|
-
examples:
|
|
177
|
-
encoding:
|
|
176
|
+
examples: 'ExamplesMap',
|
|
177
|
+
encoding: 'EncodingsMap',
|
|
178
178
|
},
|
|
179
179
|
};
|
|
180
180
|
const Example = {
|
|
@@ -188,7 +188,7 @@ const Example = {
|
|
|
188
188
|
const Encoding = {
|
|
189
189
|
properties: {
|
|
190
190
|
contentType: { type: 'string' },
|
|
191
|
-
headers:
|
|
191
|
+
headers: 'HeadersMap',
|
|
192
192
|
style: {
|
|
193
193
|
enum: ['form', 'simple', 'label', 'matrix', 'spaceDelimited', 'pipeDelimited', 'deepObject'],
|
|
194
194
|
},
|
|
@@ -209,9 +209,10 @@ const Header = {
|
|
|
209
209
|
allowReserved: { type: 'boolean' },
|
|
210
210
|
schema: 'Schema',
|
|
211
211
|
example: { isExample: true },
|
|
212
|
-
examples:
|
|
213
|
-
content: '
|
|
212
|
+
examples: 'ExamplesMap',
|
|
213
|
+
content: 'MediaTypesMap',
|
|
214
214
|
},
|
|
215
|
+
requiredOneOf: ['schema', 'content'],
|
|
215
216
|
};
|
|
216
217
|
const ResponsesMap = {
|
|
217
218
|
properties: { default: 'Response' },
|
|
@@ -220,9 +221,9 @@ const ResponsesMap = {
|
|
|
220
221
|
const Response = {
|
|
221
222
|
properties: {
|
|
222
223
|
description: { type: 'string' },
|
|
223
|
-
headers:
|
|
224
|
-
content: '
|
|
225
|
-
links:
|
|
224
|
+
headers: 'HeadersMap',
|
|
225
|
+
content: 'MediaTypesMap',
|
|
226
|
+
links: 'LinksMap',
|
|
226
227
|
},
|
|
227
228
|
required: ['description'],
|
|
228
229
|
};
|
|
@@ -427,26 +428,31 @@ const SecurityScheme = {
|
|
|
427
428
|
extensionsPrefix: 'x-',
|
|
428
429
|
};
|
|
429
430
|
exports.Oas3Types = {
|
|
430
|
-
|
|
431
|
+
Root,
|
|
431
432
|
Tag,
|
|
432
433
|
ExternalDocs,
|
|
433
434
|
Server,
|
|
434
435
|
ServerVariable,
|
|
436
|
+
ServerVariablesMap: _1.mapOf('ServerVariable'),
|
|
435
437
|
SecurityRequirement,
|
|
436
438
|
Info,
|
|
437
439
|
Contact,
|
|
438
440
|
License,
|
|
439
|
-
|
|
441
|
+
PathsMap,
|
|
440
442
|
PathItem,
|
|
441
443
|
Parameter,
|
|
442
444
|
Operation,
|
|
443
445
|
Callback: _1.mapOf('PathItem'),
|
|
446
|
+
CallbacksMap: _1.mapOf('Callback'),
|
|
444
447
|
RequestBody,
|
|
445
|
-
|
|
448
|
+
MediaTypesMap,
|
|
446
449
|
MediaType,
|
|
447
450
|
Example,
|
|
451
|
+
ExamplesMap: _1.mapOf('Example'),
|
|
448
452
|
Encoding,
|
|
453
|
+
EncodingsMap: _1.mapOf('Encoding'),
|
|
449
454
|
Header,
|
|
455
|
+
HeadersMap: _1.mapOf('Header'),
|
|
450
456
|
ResponsesMap,
|
|
451
457
|
Response,
|
|
452
458
|
Link,
|
|
@@ -456,6 +462,7 @@ exports.Oas3Types = {
|
|
|
456
462
|
DiscriminatorMapping,
|
|
457
463
|
Discriminator,
|
|
458
464
|
Components,
|
|
465
|
+
LinksMap: _1.mapOf('Link'),
|
|
459
466
|
NamedSchemas: _1.mapOf('Schema'),
|
|
460
467
|
NamedResponses: _1.mapOf('Response'),
|
|
461
468
|
NamedParameters: _1.mapOf('Parameter'),
|
package/lib/types/oas3_1.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Oas3_1Types = void 0;
|
|
4
4
|
const _1 = require(".");
|
|
5
5
|
const oas3_1 = require("./oas3");
|
|
6
|
-
const
|
|
6
|
+
const Root = {
|
|
7
7
|
properties: {
|
|
8
8
|
openapi: null,
|
|
9
9
|
info: 'Info',
|
|
@@ -11,7 +11,7 @@ const DefinitionRoot = {
|
|
|
11
11
|
security: _1.listOf('SecurityRequirement'),
|
|
12
12
|
tags: _1.listOf('Tag'),
|
|
13
13
|
externalDocs: 'ExternalDocs',
|
|
14
|
-
paths: '
|
|
14
|
+
paths: 'PathsMap',
|
|
15
15
|
webhooks: 'WebhooksMap',
|
|
16
16
|
components: 'Components',
|
|
17
17
|
jsonSchemaDialect: { type: 'string' },
|
|
@@ -237,7 +237,7 @@ const SecurityScheme = {
|
|
|
237
237
|
extensionsPrefix: 'x-',
|
|
238
238
|
};
|
|
239
239
|
exports.Oas3_1Types = Object.assign(Object.assign({}, oas3_1.Oas3Types), { Info,
|
|
240
|
-
|
|
240
|
+
Root,
|
|
241
241
|
Schema,
|
|
242
242
|
License,
|
|
243
243
|
Components, NamedPathItems: _1.mapOf('PathItem'), SecurityScheme,
|