@redocly/openapi-core 1.3.0 → 1.4.0
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 +6 -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 +23 -23
- 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/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/remove-unused-components.js +1 -1
- 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/remove-unused-components.js +2 -2
- 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 +6 -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 +40 -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/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/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/redocly-yaml.ts +75 -40
- package/src/visitors.ts +3 -3
- package/src/walk.ts +23 -10
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -27,10 +27,10 @@ describe('oas3 boolean-parameter-prefixes', () => {
|
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
expect(replaceSourceWithRef(results, __dirname)).toMatchInlineSnapshot(`
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"location":
|
|
33
|
-
|
|
30
|
+
[
|
|
31
|
+
{
|
|
32
|
+
"location": [
|
|
33
|
+
{
|
|
34
34
|
"pointer": "#/paths/~1test/put/requestBody",
|
|
35
35
|
"reportOnKey": false,
|
|
36
36
|
"source": "foobar.yaml",
|
|
@@ -39,7 +39,7 @@ describe('oas3 boolean-parameter-prefixes', () => {
|
|
|
39
39
|
"message": "Can't resolve $ref: ENOENT: no such file or directory 'invalid.yaml'",
|
|
40
40
|
"ruleId": "no-unresolved-refs",
|
|
41
41
|
"severity": "error",
|
|
42
|
-
"suggest":
|
|
42
|
+
"suggest": [],
|
|
43
43
|
},
|
|
44
44
|
]
|
|
45
45
|
`);
|
|
@@ -67,36 +67,36 @@ describe('oas3 boolean-parameter-prefixes', () => {
|
|
|
67
67
|
});
|
|
68
68
|
|
|
69
69
|
expect(replaceSourceWithRef(results, __dirname)).toMatchInlineSnapshot(`
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
"location":
|
|
73
|
-
|
|
70
|
+
[
|
|
71
|
+
{
|
|
72
|
+
"location": [
|
|
73
|
+
{
|
|
74
74
|
"pointer": undefined,
|
|
75
75
|
"reportOnKey": false,
|
|
76
76
|
"source": "fixtures/invalid-yaml.yaml",
|
|
77
|
-
"start":
|
|
77
|
+
"start": {
|
|
78
78
|
"col": 1,
|
|
79
79
|
"line": 2,
|
|
80
80
|
},
|
|
81
81
|
},
|
|
82
82
|
],
|
|
83
|
-
"message": "Failed to parse: unexpected end of the stream within a single quoted scalar in
|
|
83
|
+
"message": "Failed to parse: unexpected end of the stream within a single quoted scalar in "fixtures/invalid-yaml.yaml" (2:1)",
|
|
84
84
|
"ruleId": "no-unresolved-refs",
|
|
85
85
|
"severity": "error",
|
|
86
|
-
"suggest":
|
|
86
|
+
"suggest": [],
|
|
87
87
|
},
|
|
88
|
-
|
|
89
|
-
"location":
|
|
90
|
-
|
|
88
|
+
{
|
|
89
|
+
"location": [
|
|
90
|
+
{
|
|
91
91
|
"pointer": "#/paths/~1test/put/requestBody",
|
|
92
92
|
"reportOnKey": false,
|
|
93
93
|
"source": "foobar.yaml",
|
|
94
94
|
},
|
|
95
95
|
],
|
|
96
|
-
"message": "Can't resolve $ref: unexpected end of the stream within a single quoted scalar in
|
|
96
|
+
"message": "Can't resolve $ref: unexpected end of the stream within a single quoted scalar in "fixtures/invalid-yaml.yaml" (2:1)",
|
|
97
97
|
"ruleId": "no-unresolved-refs",
|
|
98
98
|
"severity": "error",
|
|
99
|
-
"suggest":
|
|
99
|
+
"suggest": [],
|
|
100
100
|
},
|
|
101
101
|
]
|
|
102
102
|
`);
|
|
@@ -123,7 +123,7 @@ describe('oas3 boolean-parameter-prefixes', () => {
|
|
|
123
123
|
}),
|
|
124
124
|
});
|
|
125
125
|
|
|
126
|
-
expect(replaceSourceWithRef(results, __dirname)).toMatchInlineSnapshot(`
|
|
126
|
+
expect(replaceSourceWithRef(results, __dirname)).toMatchInlineSnapshot(`[]`);
|
|
127
127
|
});
|
|
128
128
|
|
|
129
129
|
it('should report on unresolved localr ref', async () => {
|
|
@@ -148,10 +148,10 @@ describe('oas3 boolean-parameter-prefixes', () => {
|
|
|
148
148
|
});
|
|
149
149
|
|
|
150
150
|
expect(replaceSourceWithRef(results, __dirname)).toMatchInlineSnapshot(`
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
"location":
|
|
154
|
-
|
|
151
|
+
[
|
|
152
|
+
{
|
|
153
|
+
"location": [
|
|
154
|
+
{
|
|
155
155
|
"pointer": "#/paths/~1test/put/requestBody",
|
|
156
156
|
"reportOnKey": false,
|
|
157
157
|
"source": "foobar.yaml",
|
|
@@ -160,7 +160,7 @@ describe('oas3 boolean-parameter-prefixes', () => {
|
|
|
160
160
|
"message": "Can't resolve $ref",
|
|
161
161
|
"ruleId": "no-unresolved-refs",
|
|
162
162
|
"severity": "error",
|
|
163
|
-
"suggest":
|
|
163
|
+
"suggest": [],
|
|
164
164
|
},
|
|
165
165
|
]
|
|
166
166
|
`);
|
|
@@ -194,7 +194,7 @@ describe('oas3 boolean-parameter-prefixes', () => {
|
|
|
194
194
|
}),
|
|
195
195
|
});
|
|
196
196
|
|
|
197
|
-
expect(replaceSourceWithRef(results, __dirname)).toMatchInlineSnapshot(`
|
|
197
|
+
expect(replaceSourceWithRef(results, __dirname)).toMatchInlineSnapshot(`[]`);
|
|
198
198
|
});
|
|
199
199
|
|
|
200
200
|
it('should not report on nested refs inside specification extensions', async () => {
|
|
@@ -223,7 +223,7 @@ describe('oas3 boolean-parameter-prefixes', () => {
|
|
|
223
223
|
}),
|
|
224
224
|
});
|
|
225
225
|
|
|
226
|
-
expect(replaceSourceWithRef(results, __dirname)).toMatchInlineSnapshot(`
|
|
226
|
+
expect(replaceSourceWithRef(results, __dirname)).toMatchInlineSnapshot(`[]`);
|
|
227
227
|
});
|
|
228
228
|
|
|
229
229
|
it('should not report on nested refs inside specification extensions for 3.1', async () => {
|
|
@@ -252,6 +252,6 @@ describe('oas3 boolean-parameter-prefixes', () => {
|
|
|
252
252
|
}),
|
|
253
253
|
});
|
|
254
254
|
|
|
255
|
-
expect(replaceSourceWithRef(results, __dirname)).toMatchInlineSnapshot(`
|
|
255
|
+
expect(replaceSourceWithRef(results, __dirname)).toMatchInlineSnapshot(`[]`);
|
|
256
256
|
});
|
|
257
257
|
});
|
|
@@ -27,10 +27,10 @@ describe('Async2 channels-kebab-case', () => {
|
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"location":
|
|
33
|
-
|
|
30
|
+
[
|
|
31
|
+
{
|
|
32
|
+
"location": [
|
|
33
|
+
{
|
|
34
34
|
"pointer": "#/channels/NOT_A_KEBAB",
|
|
35
35
|
"reportOnKey": true,
|
|
36
36
|
"source": "asyncapi.yaml",
|
|
@@ -39,7 +39,7 @@ describe('Async2 channels-kebab-case', () => {
|
|
|
39
39
|
"message": "\`NOT_A_KEBAB\` does not use kebab-case.",
|
|
40
40
|
"ruleId": "channels-kebab-case",
|
|
41
41
|
"severity": "error",
|
|
42
|
-
"suggest":
|
|
42
|
+
"suggest": [],
|
|
43
43
|
},
|
|
44
44
|
]
|
|
45
45
|
`);
|
|
@@ -68,10 +68,10 @@ describe('Async2 channels-kebab-case', () => {
|
|
|
68
68
|
});
|
|
69
69
|
|
|
70
70
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
"location":
|
|
74
|
-
|
|
71
|
+
[
|
|
72
|
+
{
|
|
73
|
+
"location": [
|
|
74
|
+
{
|
|
75
75
|
"pointer": "#/channels/snake_kebab",
|
|
76
76
|
"reportOnKey": true,
|
|
77
77
|
"source": "asyncapi.yaml",
|
|
@@ -80,7 +80,7 @@ describe('Async2 channels-kebab-case', () => {
|
|
|
80
80
|
"message": "\`snake_kebab\` does not use kebab-case.",
|
|
81
81
|
"ruleId": "channels-kebab-case",
|
|
82
82
|
"severity": "error",
|
|
83
|
-
"suggest":
|
|
83
|
+
"suggest": [],
|
|
84
84
|
},
|
|
85
85
|
]
|
|
86
86
|
`);
|
|
@@ -110,7 +110,7 @@ describe('Async2 channels-kebab-case', () => {
|
|
|
110
110
|
'no-path-trailing-slash': 'off',
|
|
111
111
|
}),
|
|
112
112
|
});
|
|
113
|
-
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
113
|
+
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
|
|
114
114
|
});
|
|
115
115
|
|
|
116
116
|
it('words with hyphens are allowed with "channels-kebab-case" rule', async () => {
|
|
@@ -136,6 +136,6 @@ describe('Async2 channels-kebab-case', () => {
|
|
|
136
136
|
'paths-kebab-case': 'error',
|
|
137
137
|
}),
|
|
138
138
|
});
|
|
139
|
-
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
139
|
+
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
|
|
140
140
|
});
|
|
141
141
|
});
|
|
@@ -27,10 +27,10 @@ describe('no-channel-trailing-slash', () => {
|
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"location":
|
|
33
|
-
|
|
30
|
+
[
|
|
31
|
+
{
|
|
32
|
+
"location": [
|
|
33
|
+
{
|
|
34
34
|
"pointer": "#/channels/~1trailing~1",
|
|
35
35
|
"reportOnKey": true,
|
|
36
36
|
"source": "asyncapi.yaml",
|
|
@@ -39,7 +39,7 @@ describe('no-channel-trailing-slash', () => {
|
|
|
39
39
|
"message": "\`/trailing/\` should not have a trailing slash.",
|
|
40
40
|
"ruleId": "no-channel-trailing-slash",
|
|
41
41
|
"severity": "error",
|
|
42
|
-
"suggest":
|
|
42
|
+
"suggest": [],
|
|
43
43
|
},
|
|
44
44
|
]
|
|
45
45
|
`);
|
|
@@ -67,7 +67,7 @@ describe('no-channel-trailing-slash', () => {
|
|
|
67
67
|
config: await makeConfig({ 'no-channel-trailing-slash': 'error' }),
|
|
68
68
|
});
|
|
69
69
|
|
|
70
|
-
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
70
|
+
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
|
|
71
71
|
});
|
|
72
72
|
|
|
73
73
|
it('should not report on trailing slash in path if the path is root', async () => {
|
|
@@ -92,6 +92,6 @@ describe('no-channel-trailing-slash', () => {
|
|
|
92
92
|
config: await makeConfig({ 'no-channel-trailing-slash': 'error' }),
|
|
93
93
|
});
|
|
94
94
|
|
|
95
|
-
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
95
|
+
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
|
|
96
96
|
});
|
|
97
97
|
});
|
|
@@ -7,8 +7,9 @@ import { TagDescription } from '../common/tag-description';
|
|
|
7
7
|
import { TagsAlphabetical } from '../common/tags-alphabetical';
|
|
8
8
|
import { ChannelsKebabCase } from './channels-kebab-case';
|
|
9
9
|
import { NoChannelTrailingSlash } from './no-channel-trailing-slash';
|
|
10
|
+
import type { Async2RuleSet } from '../../oas-types';
|
|
10
11
|
|
|
11
|
-
export const rules = {
|
|
12
|
+
export const rules: Async2RuleSet<'built-in'> = {
|
|
12
13
|
spec: Spec as Async2Rule,
|
|
13
14
|
assertions: Assertions,
|
|
14
15
|
'info-contact': InfoContact,
|
|
@@ -21,10 +21,10 @@ describe('Oas3 info-license', () => {
|
|
|
21
21
|
});
|
|
22
22
|
|
|
23
23
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"location":
|
|
27
|
-
|
|
24
|
+
[
|
|
25
|
+
{
|
|
26
|
+
"location": [
|
|
27
|
+
{
|
|
28
28
|
"pointer": "#/info",
|
|
29
29
|
"reportOnKey": true,
|
|
30
30
|
"source": "foobar.yaml",
|
|
@@ -33,7 +33,7 @@ describe('Oas3 info-license', () => {
|
|
|
33
33
|
"message": "Info object should contain \`license\` field.",
|
|
34
34
|
"ruleId": "info-license",
|
|
35
35
|
"severity": "error",
|
|
36
|
-
"suggest":
|
|
36
|
+
"suggest": [],
|
|
37
37
|
},
|
|
38
38
|
]
|
|
39
39
|
`);
|
|
@@ -57,6 +57,6 @@ describe('Oas3 info-license', () => {
|
|
|
57
57
|
config: await makeConfig({ 'info-license': 'error' }),
|
|
58
58
|
});
|
|
59
59
|
|
|
60
|
-
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
60
|
+
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
|
|
61
61
|
});
|
|
62
62
|
});
|
|
@@ -22,10 +22,10 @@ describe('Oas3 license-url', () => {
|
|
|
22
22
|
});
|
|
23
23
|
|
|
24
24
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"location":
|
|
28
|
-
|
|
25
|
+
[
|
|
26
|
+
{
|
|
27
|
+
"location": [
|
|
28
|
+
{
|
|
29
29
|
"pointer": "#/info/license/url",
|
|
30
30
|
"reportOnKey": true,
|
|
31
31
|
"source": "foobar.yaml",
|
|
@@ -34,7 +34,7 @@ describe('Oas3 license-url', () => {
|
|
|
34
34
|
"message": "License object should contain \`url\` field.",
|
|
35
35
|
"ruleId": "info-license-url",
|
|
36
36
|
"severity": "error",
|
|
37
|
-
"suggest":
|
|
37
|
+
"suggest": [],
|
|
38
38
|
},
|
|
39
39
|
]
|
|
40
40
|
`);
|
|
@@ -58,6 +58,6 @@ describe('Oas3 license-url', () => {
|
|
|
58
58
|
config: await makeConfig({ 'info-license-url': 'error' }),
|
|
59
59
|
});
|
|
60
60
|
|
|
61
|
-
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
61
|
+
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
|
|
62
62
|
});
|
|
63
63
|
});
|
|
@@ -50,10 +50,10 @@ describe('no-ambiguous-paths', () => {
|
|
|
50
50
|
});
|
|
51
51
|
|
|
52
52
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
"location":
|
|
56
|
-
|
|
53
|
+
[
|
|
54
|
+
{
|
|
55
|
+
"location": [
|
|
56
|
+
{
|
|
57
57
|
"pointer": "#/paths/~1{id}~1ambiguous",
|
|
58
58
|
"reportOnKey": true,
|
|
59
59
|
"source": "foobar.yaml",
|
|
@@ -62,11 +62,11 @@ describe('no-ambiguous-paths', () => {
|
|
|
62
62
|
"message": "Paths should resolve unambiguously. Found two ambiguous paths: \`/good/{id}\` and \`/{id}/ambiguous\`.",
|
|
63
63
|
"ruleId": "no-ambiguous-paths",
|
|
64
64
|
"severity": "error",
|
|
65
|
-
"suggest":
|
|
65
|
+
"suggest": [],
|
|
66
66
|
},
|
|
67
|
-
|
|
68
|
-
"location":
|
|
69
|
-
|
|
67
|
+
{
|
|
68
|
+
"location": [
|
|
69
|
+
{
|
|
70
70
|
"pointer": "#/paths/~1ambiguous~1{id}",
|
|
71
71
|
"reportOnKey": true,
|
|
72
72
|
"source": "foobar.yaml",
|
|
@@ -75,11 +75,11 @@ describe('no-ambiguous-paths', () => {
|
|
|
75
75
|
"message": "Paths should resolve unambiguously. Found two ambiguous paths: \`/{id}/ambiguous\` and \`/ambiguous/{id}\`.",
|
|
76
76
|
"ruleId": "no-ambiguous-paths",
|
|
77
77
|
"severity": "error",
|
|
78
|
-
"suggest":
|
|
78
|
+
"suggest": [],
|
|
79
79
|
},
|
|
80
|
-
|
|
81
|
-
"location":
|
|
82
|
-
|
|
80
|
+
{
|
|
81
|
+
"location": [
|
|
82
|
+
{
|
|
83
83
|
"pointer": "#/paths/~1{entity}~1{id}~1last",
|
|
84
84
|
"reportOnKey": true,
|
|
85
85
|
"source": "foobar.yaml",
|
|
@@ -88,7 +88,7 @@ describe('no-ambiguous-paths', () => {
|
|
|
88
88
|
"message": "Paths should resolve unambiguously. Found two ambiguous paths: \`/good/{id}/{pet}\` and \`/{entity}/{id}/last\`.",
|
|
89
89
|
"ruleId": "no-ambiguous-paths",
|
|
90
90
|
"severity": "error",
|
|
91
|
-
"suggest":
|
|
91
|
+
"suggest": [],
|
|
92
92
|
},
|
|
93
93
|
]
|
|
94
94
|
`);
|
|
@@ -32,7 +32,7 @@ describe('Oas3 typed enum', () => {
|
|
|
32
32
|
config: await makeConfig({ 'no-enum-type-mismatch': 'error' }),
|
|
33
33
|
});
|
|
34
34
|
|
|
35
|
-
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
35
|
+
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
|
|
36
36
|
});
|
|
37
37
|
|
|
38
38
|
it('should not report on enum object if all items match type and enum is nullable', async () => {
|
|
@@ -65,7 +65,7 @@ describe('Oas3 typed enum', () => {
|
|
|
65
65
|
config: await makeConfig({ 'no-enum-type-mismatch': 'error' }),
|
|
66
66
|
});
|
|
67
67
|
|
|
68
|
-
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
68
|
+
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
|
|
69
69
|
});
|
|
70
70
|
|
|
71
71
|
it('should report on enum object if not all items match type', async () => {
|
|
@@ -96,19 +96,19 @@ describe('Oas3 typed enum', () => {
|
|
|
96
96
|
});
|
|
97
97
|
|
|
98
98
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
"location":
|
|
102
|
-
|
|
99
|
+
[
|
|
100
|
+
{
|
|
101
|
+
"location": [
|
|
102
|
+
{
|
|
103
103
|
"pointer": "#/paths/~1some/get/responses/200/content/application~1json/schema/enum/1",
|
|
104
104
|
"reportOnKey": false,
|
|
105
105
|
"source": "foobar.yaml",
|
|
106
106
|
},
|
|
107
107
|
],
|
|
108
|
-
"message": "All values of \`enum\` field must be of the same type as the \`type\` field: expected
|
|
108
|
+
"message": "All values of \`enum\` field must be of the same type as the \`type\` field: expected "integer" but received "string".",
|
|
109
109
|
"ruleId": "no-enum-type-mismatch",
|
|
110
110
|
"severity": "error",
|
|
111
|
-
"suggest":
|
|
111
|
+
"suggest": [],
|
|
112
112
|
},
|
|
113
113
|
]
|
|
114
114
|
`);
|
|
@@ -144,10 +144,10 @@ describe('Oas3 typed enum', () => {
|
|
|
144
144
|
});
|
|
145
145
|
|
|
146
146
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
"location":
|
|
150
|
-
|
|
147
|
+
[
|
|
148
|
+
{
|
|
149
|
+
"location": [
|
|
150
|
+
{
|
|
151
151
|
"pointer": "#/paths/~1some/get/responses/200/content/application~1json/schema/enum/1",
|
|
152
152
|
"reportOnKey": false,
|
|
153
153
|
"source": "foobar.yaml",
|
|
@@ -156,7 +156,7 @@ describe('Oas3 typed enum', () => {
|
|
|
156
156
|
"message": "Enum value \`string\` must be of allowed types: \`integer,array\`.",
|
|
157
157
|
"ruleId": "no-enum-type-mismatch",
|
|
158
158
|
"severity": "error",
|
|
159
|
-
"suggest":
|
|
159
|
+
"suggest": [],
|
|
160
160
|
},
|
|
161
161
|
]
|
|
162
162
|
`);
|
|
@@ -189,11 +189,11 @@ describe('Oas3 typed enum', () => {
|
|
|
189
189
|
});
|
|
190
190
|
|
|
191
191
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
192
|
-
|
|
193
|
-
|
|
192
|
+
[
|
|
193
|
+
{
|
|
194
194
|
"from": undefined,
|
|
195
|
-
"location":
|
|
196
|
-
|
|
195
|
+
"location": [
|
|
196
|
+
{
|
|
197
197
|
"pointer": "#/paths/~1some/get/responses/200/content/application~1json/schema",
|
|
198
198
|
"reportOnKey": false,
|
|
199
199
|
"source": "foobar.yaml",
|
|
@@ -202,7 +202,7 @@ describe('Oas3 typed enum', () => {
|
|
|
202
202
|
"message": "Expected type \`Schema\` (object) but got \`null\`",
|
|
203
203
|
"ruleId": "spec",
|
|
204
204
|
"severity": "error",
|
|
205
|
-
"suggest":
|
|
205
|
+
"suggest": [],
|
|
206
206
|
},
|
|
207
207
|
]
|
|
208
208
|
`);
|
|
@@ -38,10 +38,10 @@ describe('no-identical-paths', () => {
|
|
|
38
38
|
});
|
|
39
39
|
|
|
40
40
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
"location":
|
|
44
|
-
|
|
41
|
+
[
|
|
42
|
+
{
|
|
43
|
+
"location": [
|
|
44
|
+
{
|
|
45
45
|
"pointer": "#/paths/~1good~1{hash}",
|
|
46
46
|
"reportOnKey": true,
|
|
47
47
|
"source": "foobar.yaml",
|
|
@@ -50,7 +50,7 @@ describe('no-identical-paths', () => {
|
|
|
50
50
|
"message": "The path already exists which differs only by path parameter name(s): \`/good/{id}\` and \`/good/{hash}\`.",
|
|
51
51
|
"ruleId": "no-identical-paths",
|
|
52
52
|
"severity": "error",
|
|
53
|
-
"suggest":
|
|
53
|
+
"suggest": [],
|
|
54
54
|
},
|
|
55
55
|
]
|
|
56
56
|
`);
|
|
@@ -23,10 +23,10 @@ describe('no-path-trailing-slash', () => {
|
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"location":
|
|
29
|
-
|
|
26
|
+
[
|
|
27
|
+
{
|
|
28
|
+
"location": [
|
|
29
|
+
{
|
|
30
30
|
"pointer": "#/paths/~1bad~1",
|
|
31
31
|
"reportOnKey": true,
|
|
32
32
|
"source": "foobar.yaml",
|
|
@@ -35,7 +35,7 @@ describe('no-path-trailing-slash', () => {
|
|
|
35
35
|
"message": "\`/bad/\` should not have a trailing slash.",
|
|
36
36
|
"ruleId": "no-path-trailing-slash",
|
|
37
37
|
"severity": "error",
|
|
38
|
-
"suggest":
|
|
38
|
+
"suggest": [],
|
|
39
39
|
},
|
|
40
40
|
]
|
|
41
41
|
`);
|
|
@@ -64,10 +64,10 @@ describe('no-path-trailing-slash', () => {
|
|
|
64
64
|
});
|
|
65
65
|
|
|
66
66
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
"location":
|
|
70
|
-
|
|
67
|
+
[
|
|
68
|
+
{
|
|
69
|
+
"location": [
|
|
70
|
+
{
|
|
71
71
|
"pointer": "#/paths/~1bad~1",
|
|
72
72
|
"reportOnKey": true,
|
|
73
73
|
"source": "foobar.yaml",
|
|
@@ -76,7 +76,7 @@ describe('no-path-trailing-slash', () => {
|
|
|
76
76
|
"message": "\`/bad/\` should not have a trailing slash.",
|
|
77
77
|
"ruleId": "no-path-trailing-slash",
|
|
78
78
|
"severity": "error",
|
|
79
|
-
"suggest":
|
|
79
|
+
"suggest": [],
|
|
80
80
|
},
|
|
81
81
|
]
|
|
82
82
|
`);
|
|
@@ -100,7 +100,7 @@ describe('no-path-trailing-slash', () => {
|
|
|
100
100
|
config: await makeConfig({ 'no-path-trailing-slash': 'error' }),
|
|
101
101
|
});
|
|
102
102
|
|
|
103
|
-
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
103
|
+
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
|
|
104
104
|
});
|
|
105
105
|
|
|
106
106
|
it('should not report on trailing slash in path if the path is root', async () => {
|
|
@@ -121,6 +121,6 @@ describe('no-path-trailing-slash', () => {
|
|
|
121
121
|
config: await makeConfig({ 'no-path-trailing-slash': 'error' }),
|
|
122
122
|
});
|
|
123
123
|
|
|
124
|
-
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
124
|
+
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
|
|
125
125
|
});
|
|
126
126
|
});
|
|
@@ -25,10 +25,10 @@ describe('Oas3 operation-2xx-response', () => {
|
|
|
25
25
|
});
|
|
26
26
|
|
|
27
27
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
"location":
|
|
31
|
-
|
|
28
|
+
[
|
|
29
|
+
{
|
|
30
|
+
"location": [
|
|
31
|
+
{
|
|
32
32
|
"pointer": "#/paths/~1test/put/responses",
|
|
33
33
|
"reportOnKey": true,
|
|
34
34
|
"source": "foobar.yaml",
|
|
@@ -37,7 +37,7 @@ describe('Oas3 operation-2xx-response', () => {
|
|
|
37
37
|
"message": "Operation must have at least one \`2XX\` response.",
|
|
38
38
|
"ruleId": "operation-2xx-response",
|
|
39
39
|
"severity": "error",
|
|
40
|
-
"suggest":
|
|
40
|
+
"suggest": [],
|
|
41
41
|
},
|
|
42
42
|
]
|
|
43
43
|
`);
|
|
@@ -63,7 +63,7 @@ describe('Oas3 operation-2xx-response', () => {
|
|
|
63
63
|
config: await makeConfig({ 'operation-2xx-response': 'error' }),
|
|
64
64
|
});
|
|
65
65
|
|
|
66
|
-
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
66
|
+
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
|
|
67
67
|
});
|
|
68
68
|
|
|
69
69
|
it('should not report for present default', async () => {
|
|
@@ -86,7 +86,7 @@ describe('Oas3 operation-2xx-response', () => {
|
|
|
86
86
|
config: await makeConfig({ 'operation-2xx-response': 'error' }),
|
|
87
87
|
});
|
|
88
88
|
|
|
89
|
-
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
89
|
+
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
|
|
90
90
|
});
|
|
91
91
|
|
|
92
92
|
it('should report even if the responses are null', async () => {
|
|
@@ -108,10 +108,10 @@ describe('Oas3 operation-2xx-response', () => {
|
|
|
108
108
|
});
|
|
109
109
|
|
|
110
110
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
"location":
|
|
114
|
-
|
|
111
|
+
[
|
|
112
|
+
{
|
|
113
|
+
"location": [
|
|
114
|
+
{
|
|
115
115
|
"pointer": "#/paths/~1test~1/put/responses",
|
|
116
116
|
"reportOnKey": true,
|
|
117
117
|
"source": "foobar.yaml",
|
|
@@ -120,7 +120,7 @@ describe('Oas3 operation-2xx-response', () => {
|
|
|
120
120
|
"message": "Operation must have at least one \`2XX\` response.",
|
|
121
121
|
"ruleId": "operation-2xx-response",
|
|
122
122
|
"severity": "error",
|
|
123
|
-
"suggest":
|
|
123
|
+
"suggest": [],
|
|
124
124
|
},
|
|
125
125
|
]
|
|
126
126
|
`);
|
|
@@ -149,10 +149,10 @@ describe('Oas3 operation-2xx-response', () => {
|
|
|
149
149
|
});
|
|
150
150
|
|
|
151
151
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
"location":
|
|
155
|
-
|
|
152
|
+
[
|
|
153
|
+
{
|
|
154
|
+
"location": [
|
|
155
|
+
{
|
|
156
156
|
"pointer": "#/webhooks/~1test~1/put/responses",
|
|
157
157
|
"reportOnKey": true,
|
|
158
158
|
"source": "foobar.yaml",
|
|
@@ -161,7 +161,7 @@ describe('Oas3 operation-2xx-response', () => {
|
|
|
161
161
|
"message": "Operation must have at least one \`2XX\` response.",
|
|
162
162
|
"ruleId": "operation-2xx-response",
|
|
163
163
|
"severity": "error",
|
|
164
|
-
"suggest":
|
|
164
|
+
"suggest": [],
|
|
165
165
|
},
|
|
166
166
|
]
|
|
167
167
|
`);
|
|
@@ -187,6 +187,6 @@ describe('Oas3 operation-2xx-response', () => {
|
|
|
187
187
|
config: await makeConfig({ 'operation-2xx-response': 'error' }),
|
|
188
188
|
});
|
|
189
189
|
|
|
190
|
-
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
190
|
+
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
|
|
191
191
|
});
|
|
192
192
|
});
|