@redocly/openapi-core 1.3.0 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/lib/benchmark/benches/lint-with-many-rules.bench.js +4 -4
- package/lib/benchmark/benches/lint-with-nested-rule.bench.js +4 -4
- package/lib/benchmark/benches/lint-with-no-rules.bench.js +4 -4
- package/lib/benchmark/benches/lint-with-top-level-rule-report.bench.js +4 -4
- package/lib/benchmark/benches/lint-with-top-level-rule.bench.js +4 -4
- package/lib/benchmark/benches/recommended-oas3.bench.js +4 -4
- package/lib/benchmark/benches/resolve-with-no-external.bench.js +3 -3
- package/lib/benchmark/utils.js +3 -3
- package/lib/bundle.d.ts +4 -4
- package/lib/bundle.js +25 -25
- package/lib/config/all.d.ts +2 -2
- package/lib/config/all.js +44 -8
- package/lib/config/builtIn.js +2 -0
- package/lib/config/config-resolvers.js +25 -25
- package/lib/config/config.js +9 -9
- package/lib/config/index.js +5 -1
- package/lib/config/load.d.ts +1 -1
- package/lib/config/load.js +6 -6
- package/lib/config/minimal.d.ts +2 -2
- package/lib/config/minimal.js +34 -3
- package/lib/config/recommended-strict.d.ts +3 -0
- package/lib/config/recommended-strict.js +92 -0
- package/lib/config/recommended.d.ts +2 -2
- package/lib/config/recommended.js +34 -3
- package/lib/config/rules.d.ts +1 -1
- package/lib/config/types.d.ts +47 -46
- package/lib/config/types.js +2 -2
- package/lib/config/utils.js +26 -14
- package/lib/decorators/common/filters/filter-helper.js +4 -4
- package/lib/decorators/common/filters/filter-in.js +2 -2
- package/lib/decorators/common/filters/filter-out.js +2 -2
- package/lib/decorators/common/info-description-override.js +1 -1
- package/lib/decorators/common/media-type-examples-override.js +3 -3
- package/lib/decorators/common/operation-description-override.js +1 -1
- package/lib/decorators/common/registry-dependencies.js +1 -1
- package/lib/decorators/common/remove-x-internal.js +4 -4
- package/lib/decorators/common/tag-description-override.js +1 -1
- package/lib/decorators/oas2/remove-unused-components.d.ts +2 -0
- package/lib/{rules → decorators}/oas2/remove-unused-components.js +1 -1
- package/lib/decorators/oas3/remove-unused-components.d.ts +2 -0
- package/lib/{rules → decorators}/oas3/remove-unused-components.js +2 -2
- package/lib/env.js +1 -1
- package/lib/format/codeframes.d.ts +6 -6
- package/lib/format/format.d.ts +2 -2
- package/lib/format/format.js +12 -12
- package/lib/js-yaml/index.d.ts +2 -2
- package/lib/js-yaml/index.js +2 -2
- package/lib/lint.js +18 -18
- package/lib/oas-types.d.ts +12 -10
- package/lib/oas-types.js +2 -2
- package/lib/redocly/index.js +10 -10
- package/lib/redocly/registry-api.js +2 -2
- package/lib/resolve.d.ts +4 -4
- package/lib/resolve.js +18 -18
- package/lib/rules/ajv.js +1 -1
- package/lib/rules/async2/index.d.ts +2 -11
- package/lib/rules/common/assertions/asserts.d.ts +3 -3
- package/lib/rules/common/assertions/asserts.js +21 -21
- package/lib/rules/common/assertions/index.d.ts +4 -4
- package/lib/rules/common/assertions/index.js +3 -3
- package/lib/rules/common/assertions/utils.d.ts +4 -4
- package/lib/rules/common/assertions/utils.js +3 -3
- package/lib/rules/common/info-contact.js +1 -1
- package/lib/rules/common/info-license-url.js +1 -1
- package/lib/rules/common/info-license.js +1 -1
- package/lib/rules/common/no-enum-type-mismatch.js +3 -3
- package/lib/rules/common/no-http-verbs-in-paths.js +2 -2
- package/lib/rules/common/no-invalid-parameter-examples.js +3 -3
- package/lib/rules/common/no-invalid-schema-examples.js +3 -3
- package/lib/rules/common/operation-2xx-response.js +2 -2
- package/lib/rules/common/operation-4xx-response.js +2 -2
- package/lib/rules/common/operation-description.js +1 -1
- package/lib/rules/common/operation-operationId.js +1 -1
- package/lib/rules/common/operation-summary.js +1 -1
- package/lib/rules/common/path-segment-plural.js +1 -1
- package/lib/rules/common/response-contains-header.js +2 -2
- package/lib/rules/common/spec-strict-refs.js +1 -1
- package/lib/rules/common/spec.js +11 -11
- package/lib/rules/common/tag-description.js +1 -1
- package/lib/rules/oas2/boolean-parameter-prefixes.d.ts +1 -1
- package/lib/rules/oas2/index.d.ts +2 -46
- package/lib/rules/oas2/request-mime-type.js +2 -2
- package/lib/rules/oas2/response-contains-property.js +2 -2
- package/lib/rules/oas2/response-mime-type.js +2 -2
- package/lib/rules/oas3/boolean-parameter-prefixes.d.ts +1 -1
- package/lib/rules/oas3/index.d.ts +1 -1
- package/lib/rules/oas3/index.js +1 -1
- package/lib/rules/oas3/no-invalid-media-type-examples.js +3 -3
- package/lib/rules/oas3/operation-4xx-problem-details-rfc7807.js +3 -3
- package/lib/rules/oas3/request-mime-type.js +3 -3
- package/lib/rules/oas3/response-contains-property.js +2 -2
- package/lib/rules/oas3/response-mime-type.js +3 -3
- package/lib/rules/utils.js +3 -3
- package/lib/types/asyncapi.js +21 -21
- package/lib/types/index.d.ts +8 -8
- package/lib/types/oas2.js +14 -14
- package/lib/types/oas3.js +27 -27
- package/lib/types/oas3_1.js +18 -6
- package/lib/types/redocly-yaml.d.ts +11 -0
- package/lib/types/redocly-yaml.js +71 -53
- package/lib/types/theme-config.js +1 -1
- package/lib/typings/common.d.ts +2 -2
- package/lib/typings/openapi.d.ts +6 -6
- package/lib/typings/swagger.d.ts +3 -3
- package/lib/utils.d.ts +5 -5
- package/lib/utils.js +3 -3
- package/lib/visitors.d.ts +38 -40
- package/lib/walk.d.ts +14 -15
- package/lib/walk.js +11 -11
- package/package.json +2 -2
- package/src/__tests__/lint.test.ts +40 -40
- package/src/__tests__/normalizeVisitors.test.ts +23 -5
- package/src/__tests__/ref-utils.test.ts +7 -7
- package/src/__tests__/resolve-http.test.ts +10 -10
- package/src/__tests__/resolve.test.ts +39 -39
- package/src/__tests__/walk.test.ts +48 -48
- package/src/bundle.ts +4 -4
- package/src/config/__tests__/__snapshots__/config-resolvers.test.ts.snap +95 -32
- package/src/config/__tests__/__snapshots__/config.test.ts.snap +81 -81
- package/src/config/__tests__/config-resolvers.test.ts +30 -1
- package/src/config/__tests__/config.test.ts +88 -88
- package/src/config/__tests__/load.test.ts +12 -8
- package/src/config/__tests__/utils.test.ts +18 -18
- package/src/config/all.ts +46 -9
- package/src/config/builtIn.ts +2 -0
- package/src/config/minimal.ts +36 -4
- package/src/config/recommended-strict.ts +93 -0
- package/src/config/recommended.ts +36 -4
- package/src/config/types.ts +22 -8
- package/src/config/utils.ts +15 -0
- package/src/decorators/common/media-type-examples-override.ts +2 -2
- package/src/{rules → decorators}/oas2/remove-unused-components.ts +3 -3
- package/src/{rules → decorators}/oas3/remove-unused-components.ts +3 -3
- package/src/env.ts +1 -1
- package/src/lint.ts +3 -3
- package/src/oas-types.ts +26 -3
- package/src/rules/__tests__/no-unresolved-refs.test.ts +26 -26
- package/src/rules/async2/__tests__/channels-kebab-case.test.ts +12 -12
- package/src/rules/async2/__tests__/no-channel-trailing-slash.test.ts +7 -7
- package/src/rules/async2/index.ts +2 -1
- package/src/rules/common/__tests__/info-license.test.ts +6 -6
- package/src/rules/common/__tests__/license-url.test.ts +6 -6
- package/src/rules/common/__tests__/no-ambiguous-paths.test.ts +13 -13
- package/src/rules/common/__tests__/no-enum-type-mismatch.test.ts +18 -18
- package/src/rules/common/__tests__/no-identical-paths.test.ts +5 -5
- package/src/rules/common/__tests__/no-path-trailing-slash.test.ts +12 -12
- package/src/rules/common/__tests__/operation-2xx-response.test.ts +18 -18
- package/src/rules/common/__tests__/operation-4xx-response.test.ts +23 -23
- package/src/rules/common/__tests__/operation-operationId-unique.test.ts +6 -6
- package/src/rules/common/__tests__/operation-operationId-url-safe.test.ts +5 -5
- package/src/rules/common/__tests__/operation-parameters-unique.test.ts +16 -16
- package/src/rules/common/__tests__/operation-singular-tag.test.ts +6 -6
- package/src/rules/common/__tests__/path-http-verbs-order.test.ts +10 -10
- package/src/rules/common/__tests__/path-not-include-query.test.ts +6 -6
- package/src/rules/common/__tests__/path-params-defined.test.ts +21 -21
- package/src/rules/common/__tests__/paths-kebab-case.test.ts +11 -11
- package/src/rules/common/__tests__/scalar-property-missing-example.test.ts +18 -18
- package/src/rules/common/__tests__/security-defined.test.ts +21 -21
- package/src/rules/common/__tests__/spec-strict-refs.test.ts +9 -9
- package/src/rules/common/__tests__/spec.test.ts +102 -102
- package/src/rules/common/__tests__/tag-description.test.ts +6 -6
- package/src/rules/common/__tests__/tags-alphabetical.test.ts +12 -12
- package/src/rules/common/assertions/__tests__/index.test.ts +15 -15
- package/src/rules/common/assertions/__tests__/utils.test.ts +9 -9
- package/src/rules/oas2/__tests__/boolean-parameter-prefixes.test.ts +7 -7
- package/src/rules/oas2/__tests__/response-contains-header.test.ts +13 -13
- package/src/rules/oas2/__tests__/response-contains-property.test.ts +8 -8
- package/src/rules/oas2/__tests__/spec/info.test.ts +21 -21
- package/src/rules/oas2/__tests__/spec/operation.test.ts +4 -4
- package/src/rules/oas2/__tests__/spec/paths.test.ts +12 -12
- package/src/rules/oas2/__tests__/spec/referenceableScalars.test.ts +1 -1
- package/src/rules/oas2/index.ts +3 -1
- package/src/rules/oas3/__tests__/boolean-parameter-prefixes.test.ts +7 -7
- package/src/rules/oas3/__tests__/component-name-unique.test.ts +186 -186
- package/src/rules/oas3/__tests__/no-empty-enum-servers.com.test.ts +18 -18
- package/src/rules/oas3/__tests__/no-example-value-and-externalValue.test.ts +6 -6
- package/src/rules/oas3/__tests__/no-invalid-media-type-examples.test.ts +36 -36
- package/src/rules/oas3/__tests__/no-server-example.com.test.ts +11 -11
- package/src/rules/oas3/__tests__/no-server-trailing-slash.test.ts +7 -7
- package/src/rules/oas3/__tests__/no-unused-components.test.ts +31 -31
- package/src/rules/oas3/__tests__/operation-4xx-problem-details-rfc7807.test.ts +15 -15
- package/src/rules/oas3/__tests__/response-contains-header.test.ts +26 -26
- package/src/rules/oas3/__tests__/response-contains-property.test.ts +27 -27
- package/src/rules/oas3/__tests__/spec/callbacks.test.ts +1 -1
- package/src/rules/oas3/__tests__/spec/info.test.ts +21 -21
- package/src/rules/oas3/__tests__/spec/operation.test.ts +10 -10
- package/src/rules/oas3/__tests__/spec/paths.test.ts +13 -13
- package/src/rules/oas3/__tests__/spec/referenceableScalars.test.ts +2 -2
- package/src/rules/oas3/__tests__/spec/servers.test.ts +25 -25
- package/src/rules/oas3/__tests__/spec/spec.test.ts +56 -56
- package/src/rules/oas3/__tests__/spec-components-invalid-map-name.test.ts +28 -28
- package/src/rules/oas3/index.ts +3 -3
- package/src/types/oas3_1.ts +12 -0
- package/src/types/redocly-yaml.ts +75 -40
- package/src/visitors.ts +10 -21
- package/src/walk.ts +23 -10
- package/tsconfig.tsbuildinfo +1 -1
- package/lib/rules/oas2/remove-unused-components.d.ts +0 -2
- package/lib/rules/oas3/remove-unused-components.d.ts +0 -2
- /package/src/{rules → decorators}/oas2/__tests__/remove-unused-components.test.ts +0 -0
- /package/src/{rules → decorators}/oas3/__tests__/remove-unused-components.test.ts +0 -0
|
@@ -23,10 +23,10 @@ describe('Oas3 tags-alphabetical', () => {
|
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"location":
|
|
29
|
-
|
|
26
|
+
[
|
|
27
|
+
{
|
|
28
|
+
"location": [
|
|
29
|
+
{
|
|
30
30
|
"pointer": "#/tags/0",
|
|
31
31
|
"reportOnKey": false,
|
|
32
32
|
"source": "foobar.yaml",
|
|
@@ -35,7 +35,7 @@ describe('Oas3 tags-alphabetical', () => {
|
|
|
35
35
|
"message": "The \`tags\` array should be in alphabetical order.",
|
|
36
36
|
"ruleId": "tags-alphabetical",
|
|
37
37
|
"severity": "error",
|
|
38
|
-
"suggest":
|
|
38
|
+
"suggest": [],
|
|
39
39
|
},
|
|
40
40
|
]
|
|
41
41
|
`);
|
|
@@ -59,7 +59,7 @@ describe('Oas3 tags-alphabetical', () => {
|
|
|
59
59
|
config: await makeConfig({ 'tags-alphabetical': 'error' }),
|
|
60
60
|
});
|
|
61
61
|
|
|
62
|
-
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
62
|
+
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
|
|
63
63
|
});
|
|
64
64
|
|
|
65
65
|
it('should report on tags object if not sorted alphabetically not ignoring case', async () => {
|
|
@@ -81,10 +81,10 @@ describe('Oas3 tags-alphabetical', () => {
|
|
|
81
81
|
});
|
|
82
82
|
|
|
83
83
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
"location":
|
|
87
|
-
|
|
84
|
+
[
|
|
85
|
+
{
|
|
86
|
+
"location": [
|
|
87
|
+
{
|
|
88
88
|
"pointer": "#/tags/0",
|
|
89
89
|
"reportOnKey": false,
|
|
90
90
|
"source": "foobar.yaml",
|
|
@@ -93,7 +93,7 @@ describe('Oas3 tags-alphabetical', () => {
|
|
|
93
93
|
"message": "The \`tags\` array should be in alphabetical order.",
|
|
94
94
|
"ruleId": "tags-alphabetical",
|
|
95
95
|
"severity": "error",
|
|
96
|
-
"suggest":
|
|
96
|
+
"suggest": [],
|
|
97
97
|
},
|
|
98
98
|
]
|
|
99
99
|
`);
|
|
@@ -117,6 +117,6 @@ describe('Oas3 tags-alphabetical', () => {
|
|
|
117
117
|
config: await makeConfig({ 'tags-alphabetical': { severity: 'error', ignoreCase: true } }),
|
|
118
118
|
});
|
|
119
119
|
|
|
120
|
-
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
120
|
+
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
|
|
121
121
|
});
|
|
122
122
|
});
|
|
@@ -58,39 +58,39 @@ describe('Oas3 assertions', () => {
|
|
|
58
58
|
it('should return the right visitor structure', () => {
|
|
59
59
|
const visitors = Assertions(opts as any);
|
|
60
60
|
expect(visitors).toMatchInlineSnapshot(`
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
"Operation":
|
|
61
|
+
[
|
|
62
|
+
{
|
|
63
|
+
"Operation": {
|
|
64
64
|
"enter": [Function],
|
|
65
65
|
},
|
|
66
66
|
},
|
|
67
|
-
|
|
68
|
-
"Operation":
|
|
69
|
-
"PathItem":
|
|
67
|
+
{
|
|
68
|
+
"Operation": {
|
|
69
|
+
"PathItem": {
|
|
70
70
|
"enter": [Function],
|
|
71
71
|
},
|
|
72
72
|
"skip": [Function],
|
|
73
73
|
},
|
|
74
74
|
},
|
|
75
|
-
|
|
76
|
-
"Operation":
|
|
77
|
-
"PathItem":
|
|
75
|
+
{
|
|
76
|
+
"Operation": {
|
|
77
|
+
"PathItem": {
|
|
78
78
|
"enter": [Function],
|
|
79
79
|
},
|
|
80
80
|
"skip": [Function],
|
|
81
81
|
},
|
|
82
82
|
},
|
|
83
|
-
|
|
84
|
-
"Bar":
|
|
85
|
-
"Baz":
|
|
86
|
-
"Foo":
|
|
83
|
+
{
|
|
84
|
+
"Bar": {
|
|
85
|
+
"Baz": {
|
|
86
|
+
"Foo": {
|
|
87
87
|
"enter": [Function],
|
|
88
88
|
},
|
|
89
89
|
},
|
|
90
90
|
},
|
|
91
91
|
},
|
|
92
|
-
|
|
93
|
-
"any":
|
|
92
|
+
{
|
|
93
|
+
"any": {
|
|
94
94
|
"enter": [Function],
|
|
95
95
|
},
|
|
96
96
|
},
|
|
@@ -59,11 +59,11 @@ describe('Oas3 assertions', () => {
|
|
|
59
59
|
);
|
|
60
60
|
|
|
61
61
|
expect(visitors).toMatchInlineSnapshot(`
|
|
62
|
-
|
|
63
|
-
"Foo":
|
|
64
|
-
"Bar":
|
|
65
|
-
"Roof":
|
|
66
|
-
"Bar":
|
|
62
|
+
{
|
|
63
|
+
"Foo": {
|
|
64
|
+
"Bar": {
|
|
65
|
+
"Roof": {
|
|
66
|
+
"Bar": {
|
|
67
67
|
"enter": [Function],
|
|
68
68
|
},
|
|
69
69
|
"skip": [Function],
|
|
@@ -100,10 +100,10 @@ describe('Oas3 assertions', () => {
|
|
|
100
100
|
);
|
|
101
101
|
|
|
102
102
|
expect(visitors).toMatchInlineSnapshot(`
|
|
103
|
-
|
|
104
|
-
"Operation":
|
|
105
|
-
"Responses":
|
|
106
|
-
"MediaTypesMap":
|
|
103
|
+
{
|
|
104
|
+
"Operation": {
|
|
105
|
+
"Responses": {
|
|
106
|
+
"MediaTypesMap": {
|
|
107
107
|
"enter": [Function],
|
|
108
108
|
},
|
|
109
109
|
"skip": [Function],
|
|
@@ -25,10 +25,10 @@ describe('oas2 boolean-parameter-prefixes', () => {
|
|
|
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/parameters/0/name",
|
|
33
33
|
"reportOnKey": false,
|
|
34
34
|
"source": "foobar.yaml",
|
|
@@ -37,7 +37,7 @@ describe('oas2 boolean-parameter-prefixes', () => {
|
|
|
37
37
|
"message": "Boolean parameter \`a\` should have \`is\` or \`has\` prefix.",
|
|
38
38
|
"ruleId": "boolean-parameter-prefixes",
|
|
39
39
|
"severity": "error",
|
|
40
|
-
"suggest":
|
|
40
|
+
"suggest": [],
|
|
41
41
|
},
|
|
42
42
|
]
|
|
43
43
|
`);
|
|
@@ -76,7 +76,7 @@ describe('oas2 boolean-parameter-prefixes', () => {
|
|
|
76
76
|
config: await makeConfig({ 'boolean-parameter-prefixes': 'error' }),
|
|
77
77
|
});
|
|
78
78
|
|
|
79
|
-
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
79
|
+
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
|
|
80
80
|
});
|
|
81
81
|
|
|
82
82
|
it('should not report on boolean param with custom prefix', async () => {
|
|
@@ -105,6 +105,6 @@ describe('oas2 boolean-parameter-prefixes', () => {
|
|
|
105
105
|
}),
|
|
106
106
|
});
|
|
107
107
|
|
|
108
|
-
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
108
|
+
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
|
|
109
109
|
});
|
|
110
110
|
});
|
|
@@ -36,10 +36,10 @@ describe('Oas2 response-contains-header', () => {
|
|
|
36
36
|
}),
|
|
37
37
|
});
|
|
38
38
|
expect(results).toMatchInlineSnapshot(`
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
"location":
|
|
42
|
-
|
|
39
|
+
[
|
|
40
|
+
{
|
|
41
|
+
"location": [
|
|
42
|
+
{
|
|
43
43
|
"pointer": "#/paths/~1accounts~1{accountId}/get/responses/201/headers",
|
|
44
44
|
"reportOnKey": true,
|
|
45
45
|
"source": Source {
|
|
@@ -66,14 +66,14 @@ describe('Oas2 response-contains-header', () => {
|
|
|
66
66
|
},
|
|
67
67
|
},
|
|
68
68
|
],
|
|
69
|
-
"message": "Response object must contain a
|
|
69
|
+
"message": "Response object must contain a "Content-Length" header.",
|
|
70
70
|
"ruleId": "response-contains-header",
|
|
71
71
|
"severity": "error",
|
|
72
|
-
"suggest":
|
|
72
|
+
"suggest": [],
|
|
73
73
|
},
|
|
74
|
-
|
|
75
|
-
"location":
|
|
76
|
-
|
|
74
|
+
{
|
|
75
|
+
"location": [
|
|
76
|
+
{
|
|
77
77
|
"pointer": "#/paths/~1accounts~1{accountId}/get/responses/404/headers",
|
|
78
78
|
"reportOnKey": true,
|
|
79
79
|
"source": Source {
|
|
@@ -100,10 +100,10 @@ describe('Oas2 response-contains-header', () => {
|
|
|
100
100
|
},
|
|
101
101
|
},
|
|
102
102
|
],
|
|
103
|
-
"message": "Response object must contain a
|
|
103
|
+
"message": "Response object must contain a "Content-Length" header.",
|
|
104
104
|
"ruleId": "response-contains-header",
|
|
105
105
|
"severity": "error",
|
|
106
|
-
"suggest":
|
|
106
|
+
"suggest": [],
|
|
107
107
|
},
|
|
108
108
|
]
|
|
109
109
|
`);
|
|
@@ -142,7 +142,7 @@ describe('Oas2 response-contains-header', () => {
|
|
|
142
142
|
},
|
|
143
143
|
}),
|
|
144
144
|
});
|
|
145
|
-
expect(results).toMatchInlineSnapshot(`
|
|
145
|
+
expect(results).toMatchInlineSnapshot(`[]`);
|
|
146
146
|
});
|
|
147
147
|
|
|
148
148
|
it('should not report a response object when there is no `names` section defined', async () => {
|
|
@@ -169,6 +169,6 @@ describe('Oas2 response-contains-header', () => {
|
|
|
169
169
|
},
|
|
170
170
|
}),
|
|
171
171
|
});
|
|
172
|
-
expect(results).toMatchInlineSnapshot(`
|
|
172
|
+
expect(results).toMatchInlineSnapshot(`[]`);
|
|
173
173
|
});
|
|
174
174
|
});
|
|
@@ -42,10 +42,10 @@ describe('Oas2 response-contains-property', () => {
|
|
|
42
42
|
}),
|
|
43
43
|
});
|
|
44
44
|
expect(results).toMatchInlineSnapshot(`
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
"location":
|
|
48
|
-
|
|
45
|
+
[
|
|
46
|
+
{
|
|
47
|
+
"location": [
|
|
48
|
+
{
|
|
49
49
|
"pointer": "#/paths/~1accounts~1{accountId}/get/responses/200/schema/properties",
|
|
50
50
|
"reportOnKey": true,
|
|
51
51
|
"source": Source {
|
|
@@ -78,10 +78,10 @@ describe('Oas2 response-contains-property', () => {
|
|
|
78
78
|
},
|
|
79
79
|
},
|
|
80
80
|
],
|
|
81
|
-
"message": "Response object must contain a top-level
|
|
81
|
+
"message": "Response object must contain a top-level "id" property.",
|
|
82
82
|
"ruleId": "response-contains-property",
|
|
83
83
|
"severity": "error",
|
|
84
|
-
"suggest":
|
|
84
|
+
"suggest": [],
|
|
85
85
|
},
|
|
86
86
|
]
|
|
87
87
|
`);
|
|
@@ -123,7 +123,7 @@ describe('Oas2 response-contains-property', () => {
|
|
|
123
123
|
},
|
|
124
124
|
}),
|
|
125
125
|
});
|
|
126
|
-
expect(results).toMatchInlineSnapshot(`
|
|
126
|
+
expect(results).toMatchInlineSnapshot(`[]`);
|
|
127
127
|
});
|
|
128
128
|
|
|
129
129
|
it('should not report a response object when there is no `names` section defined', async () => {
|
|
@@ -150,6 +150,6 @@ describe('Oas2 response-contains-property', () => {
|
|
|
150
150
|
},
|
|
151
151
|
}),
|
|
152
152
|
});
|
|
153
|
-
expect(results).toMatchInlineSnapshot(`
|
|
153
|
+
expect(results).toMatchInlineSnapshot(`[]`);
|
|
154
154
|
});
|
|
155
155
|
});
|
|
@@ -22,8 +22,8 @@ describe('OpenAPI Schema 2.0', () => {
|
|
|
22
22
|
spec: 'error',
|
|
23
23
|
})
|
|
24
24
|
).toMatchInlineSnapshot(`
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
[
|
|
26
|
+
{
|
|
27
27
|
"location": "#/info/title",
|
|
28
28
|
"message": "Expected type \`string\` but got \`null\`.",
|
|
29
29
|
},
|
|
@@ -52,8 +52,8 @@ describe('OpenAPI Schema 2.0', () => {
|
|
|
52
52
|
spec: 'error',
|
|
53
53
|
})
|
|
54
54
|
).toMatchInlineSnapshot(`
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
[
|
|
56
|
+
{
|
|
57
57
|
"location": "#/info/description",
|
|
58
58
|
"message": "Expected type \`string\` but got \`null\`.",
|
|
59
59
|
},
|
|
@@ -82,8 +82,8 @@ describe('OpenAPI Schema 2.0', () => {
|
|
|
82
82
|
spec: 'error',
|
|
83
83
|
})
|
|
84
84
|
).toMatchInlineSnapshot(`
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
[
|
|
86
|
+
{
|
|
87
87
|
"location": "#/info/termsOfService",
|
|
88
88
|
"message": "Expected type \`string\` but got \`null\`.",
|
|
89
89
|
},
|
|
@@ -115,7 +115,7 @@ describe('OpenAPI Schema 2.0', () => {
|
|
|
115
115
|
await lintDoc(source, {
|
|
116
116
|
spec: 'error',
|
|
117
117
|
})
|
|
118
|
-
).toMatchInlineSnapshot(`
|
|
118
|
+
).toMatchInlineSnapshot(`[]`);
|
|
119
119
|
});
|
|
120
120
|
|
|
121
121
|
it('should report if in the Contact Object in URL field is not string', async () => {
|
|
@@ -142,8 +142,8 @@ describe('OpenAPI Schema 2.0', () => {
|
|
|
142
142
|
spec: 'error',
|
|
143
143
|
})
|
|
144
144
|
).toMatchInlineSnapshot(`
|
|
145
|
-
|
|
146
|
-
|
|
145
|
+
[
|
|
146
|
+
{
|
|
147
147
|
"location": "#/info/contact/url",
|
|
148
148
|
"message": "Expected type \`string\` but got \`null\`.",
|
|
149
149
|
},
|
|
@@ -175,8 +175,8 @@ describe('OpenAPI Schema 2.0', () => {
|
|
|
175
175
|
spec: 'error',
|
|
176
176
|
})
|
|
177
177
|
).toMatchInlineSnapshot(`
|
|
178
|
-
|
|
179
|
-
|
|
178
|
+
[
|
|
179
|
+
{
|
|
180
180
|
"location": "#/info/contact/email",
|
|
181
181
|
"message": "Expected type \`string\` but got \`null\`.",
|
|
182
182
|
},
|
|
@@ -206,7 +206,7 @@ describe('OpenAPI Schema 2.0', () => {
|
|
|
206
206
|
await lintDoc(source, {
|
|
207
207
|
spec: 'error',
|
|
208
208
|
})
|
|
209
|
-
).toMatchInlineSnapshot(`
|
|
209
|
+
).toMatchInlineSnapshot(`[]`);
|
|
210
210
|
});
|
|
211
211
|
|
|
212
212
|
it('should report if the License Object missing field Name', async () => {
|
|
@@ -231,8 +231,8 @@ describe('OpenAPI Schema 2.0', () => {
|
|
|
231
231
|
spec: 'error',
|
|
232
232
|
})
|
|
233
233
|
).toMatchInlineSnapshot(`
|
|
234
|
-
|
|
235
|
-
|
|
234
|
+
[
|
|
235
|
+
{
|
|
236
236
|
"location": "#/info/license",
|
|
237
237
|
"message": "The field \`name\` must be present on this level.",
|
|
238
238
|
},
|
|
@@ -263,8 +263,8 @@ describe('OpenAPI Schema 2.0', () => {
|
|
|
263
263
|
spec: 'error',
|
|
264
264
|
})
|
|
265
265
|
).toMatchInlineSnapshot(`
|
|
266
|
-
|
|
267
|
-
|
|
266
|
+
[
|
|
267
|
+
{
|
|
268
268
|
"location": "#/info/license/url",
|
|
269
269
|
"message": "Expected type \`string\` but got \`null\`.",
|
|
270
270
|
},
|
|
@@ -293,7 +293,7 @@ describe('OpenAPI Schema 2.0', () => {
|
|
|
293
293
|
await lintDoc(source, {
|
|
294
294
|
spec: 'error',
|
|
295
295
|
})
|
|
296
|
-
).toMatchInlineSnapshot(`
|
|
296
|
+
).toMatchInlineSnapshot(`[]`);
|
|
297
297
|
});
|
|
298
298
|
|
|
299
299
|
it('should report if the Version field is not provided', async () => {
|
|
@@ -315,8 +315,8 @@ describe('OpenAPI Schema 2.0', () => {
|
|
|
315
315
|
spec: 'error',
|
|
316
316
|
})
|
|
317
317
|
).toMatchInlineSnapshot(`
|
|
318
|
-
|
|
319
|
-
|
|
318
|
+
[
|
|
319
|
+
{
|
|
320
320
|
"location": "#/info",
|
|
321
321
|
"message": "The field \`version\` must be present on this level.",
|
|
322
322
|
},
|
|
@@ -344,8 +344,8 @@ describe('OpenAPI Schema 2.0', () => {
|
|
|
344
344
|
spec: 'error',
|
|
345
345
|
})
|
|
346
346
|
).toMatchInlineSnapshot(`
|
|
347
|
-
|
|
348
|
-
|
|
347
|
+
[
|
|
348
|
+
{
|
|
349
349
|
"location": "#/info/version",
|
|
350
350
|
"message": "Expected type \`string\` but got \`null\`.",
|
|
351
351
|
},
|
|
@@ -21,7 +21,7 @@ describe('OpenAPI Schema 2.0', () => {
|
|
|
21
21
|
await lintDoc(source, {
|
|
22
22
|
spec: 'error',
|
|
23
23
|
})
|
|
24
|
-
).toMatchInlineSnapshot(`
|
|
24
|
+
).toMatchInlineSnapshot(`[]`);
|
|
25
25
|
});
|
|
26
26
|
|
|
27
27
|
it('should not report of a valid PUT operation object', async () => {
|
|
@@ -48,7 +48,7 @@ describe('OpenAPI Schema 2.0', () => {
|
|
|
48
48
|
await lintDoc(source, {
|
|
49
49
|
spec: 'error',
|
|
50
50
|
})
|
|
51
|
-
).toMatchInlineSnapshot(`
|
|
51
|
+
).toMatchInlineSnapshot(`[]`);
|
|
52
52
|
});
|
|
53
53
|
|
|
54
54
|
it('should not report of a valid Post operation object', async () => {
|
|
@@ -82,7 +82,7 @@ describe('OpenAPI Schema 2.0', () => {
|
|
|
82
82
|
await lintDoc(source, {
|
|
83
83
|
spec: 'error',
|
|
84
84
|
})
|
|
85
|
-
).toMatchInlineSnapshot(`
|
|
85
|
+
).toMatchInlineSnapshot(`[]`);
|
|
86
86
|
});
|
|
87
87
|
|
|
88
88
|
it('should not report of a valid delete operation object', async () => {
|
|
@@ -118,6 +118,6 @@ describe('OpenAPI Schema 2.0', () => {
|
|
|
118
118
|
await lintDoc(source, {
|
|
119
119
|
spec: 'error',
|
|
120
120
|
})
|
|
121
|
-
).toMatchInlineSnapshot(`
|
|
121
|
+
).toMatchInlineSnapshot(`[]`);
|
|
122
122
|
});
|
|
123
123
|
});
|
|
@@ -21,7 +21,7 @@ describe('OpenAPI Schema', () => {
|
|
|
21
21
|
await lintDoc(source, {
|
|
22
22
|
spec: 'error',
|
|
23
23
|
})
|
|
24
|
-
).toMatchInlineSnapshot(`
|
|
24
|
+
).toMatchInlineSnapshot(`[]`);
|
|
25
25
|
});
|
|
26
26
|
|
|
27
27
|
it('should not report if Path object is empty ', async () => {
|
|
@@ -38,7 +38,7 @@ describe('OpenAPI Schema', () => {
|
|
|
38
38
|
await lintDoc(source, {
|
|
39
39
|
spec: 'error',
|
|
40
40
|
})
|
|
41
|
-
).toMatchInlineSnapshot(`
|
|
41
|
+
).toMatchInlineSnapshot(`[]`);
|
|
42
42
|
});
|
|
43
43
|
|
|
44
44
|
it('should report if Path object is not present ', async () => {
|
|
@@ -54,8 +54,8 @@ describe('OpenAPI Schema', () => {
|
|
|
54
54
|
spec: 'error',
|
|
55
55
|
})
|
|
56
56
|
).toMatchInlineSnapshot(`
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
[
|
|
58
|
+
{
|
|
59
59
|
"location": "#/",
|
|
60
60
|
"message": "The field \`paths\` must be present on this level.",
|
|
61
61
|
},
|
|
@@ -77,7 +77,7 @@ describe('OpenAPI Schema', () => {
|
|
|
77
77
|
await lintDoc(source, {
|
|
78
78
|
spec: 'error',
|
|
79
79
|
})
|
|
80
|
-
).toMatchInlineSnapshot(`
|
|
80
|
+
).toMatchInlineSnapshot(`[]`);
|
|
81
81
|
});
|
|
82
82
|
|
|
83
83
|
//Check: no error
|
|
@@ -101,8 +101,8 @@ describe('OpenAPI Schema', () => {
|
|
|
101
101
|
spec: 'error',
|
|
102
102
|
})
|
|
103
103
|
).toMatchInlineSnapshot(`
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
[
|
|
105
|
+
{
|
|
106
106
|
"location": "#/paths/ping",
|
|
107
107
|
"message": "Property \`ping\` is not expected here.",
|
|
108
108
|
},
|
|
@@ -134,7 +134,7 @@ describe('OpenAPI Schema', () => {
|
|
|
134
134
|
await lintDoc(source, {
|
|
135
135
|
'paths-identical': 'error',
|
|
136
136
|
})
|
|
137
|
-
).toMatchInlineSnapshot(`
|
|
137
|
+
).toMatchInlineSnapshot(`[]`);
|
|
138
138
|
});
|
|
139
139
|
|
|
140
140
|
it('should not report valid matching URLs', async () => {
|
|
@@ -161,7 +161,7 @@ describe('OpenAPI Schema', () => {
|
|
|
161
161
|
await lintDoc(source, {
|
|
162
162
|
spec: 'error',
|
|
163
163
|
})
|
|
164
|
-
).toMatchInlineSnapshot(`
|
|
164
|
+
).toMatchInlineSnapshot(`[]`);
|
|
165
165
|
});
|
|
166
166
|
|
|
167
167
|
it('should not report in case of ambiguous matching ', async () => {
|
|
@@ -188,7 +188,7 @@ describe('OpenAPI Schema', () => {
|
|
|
188
188
|
await lintDoc(source, {
|
|
189
189
|
spec: 'error',
|
|
190
190
|
})
|
|
191
|
-
).toMatchInlineSnapshot(`
|
|
191
|
+
).toMatchInlineSnapshot(`[]`);
|
|
192
192
|
});
|
|
193
193
|
|
|
194
194
|
it('should not report if Path Item is empty ', async () => {
|
|
@@ -206,7 +206,7 @@ describe('OpenAPI Schema', () => {
|
|
|
206
206
|
await lintDoc(source, {
|
|
207
207
|
spec: 'error',
|
|
208
208
|
})
|
|
209
|
-
).toMatchInlineSnapshot(`
|
|
209
|
+
).toMatchInlineSnapshot(`[]`);
|
|
210
210
|
});
|
|
211
211
|
|
|
212
212
|
it('should not report of a valid Parameter Object', async () => {
|
|
@@ -240,6 +240,6 @@ describe('OpenAPI Schema', () => {
|
|
|
240
240
|
await lintDoc(source, {
|
|
241
241
|
spec: 'error',
|
|
242
242
|
})
|
|
243
|
-
).toMatchInlineSnapshot(`
|
|
243
|
+
).toMatchInlineSnapshot(`[]`);
|
|
244
244
|
});
|
|
245
245
|
});
|
package/src/rules/oas2/index.ts
CHANGED
|
@@ -42,7 +42,9 @@ import { ScalarPropertyMissingExample } from '../common/scalar-property-missing-
|
|
|
42
42
|
import { RequiredStringPropertyMissingMinLength } from '../common/required-string-property-missing-min-length';
|
|
43
43
|
import { SpecStrictRefs } from '../common/spec-strict-refs';
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
import type { Oas2RuleSet } from 'core/src/oas-types';
|
|
46
|
+
|
|
47
|
+
export const rules: Oas2RuleSet<'built-in'> = {
|
|
46
48
|
spec: Spec as Oas2Rule,
|
|
47
49
|
'no-invalid-schema-examples': NoInvalidSchemaExamples,
|
|
48
50
|
'no-invalid-parameter-examples': NoInvalidParameterExamples,
|
|
@@ -26,10 +26,10 @@ describe('oas3 boolean-parameter-prefixes', () => {
|
|
|
26
26
|
});
|
|
27
27
|
|
|
28
28
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"location":
|
|
32
|
-
|
|
29
|
+
[
|
|
30
|
+
{
|
|
31
|
+
"location": [
|
|
32
|
+
{
|
|
33
33
|
"pointer": "#/paths/~1test/parameters/0/name",
|
|
34
34
|
"reportOnKey": false,
|
|
35
35
|
"source": "foobar.yaml",
|
|
@@ -38,7 +38,7 @@ describe('oas3 boolean-parameter-prefixes', () => {
|
|
|
38
38
|
"message": "Boolean parameter \`a\` should have \`is\` or \`has\` prefix.",
|
|
39
39
|
"ruleId": "boolean-parameter-prefixes",
|
|
40
40
|
"severity": "error",
|
|
41
|
-
"suggest":
|
|
41
|
+
"suggest": [],
|
|
42
42
|
},
|
|
43
43
|
]
|
|
44
44
|
`);
|
|
@@ -77,7 +77,7 @@ describe('oas3 boolean-parameter-prefixes', () => {
|
|
|
77
77
|
config: await makeConfig({ 'boolean-parameter-prefixes': 'error' }),
|
|
78
78
|
});
|
|
79
79
|
|
|
80
|
-
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
80
|
+
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
|
|
81
81
|
});
|
|
82
82
|
|
|
83
83
|
it('should not report on boolean param with custom prefix', async () => {
|
|
@@ -106,6 +106,6 @@ describe('oas3 boolean-parameter-prefixes', () => {
|
|
|
106
106
|
}),
|
|
107
107
|
});
|
|
108
108
|
|
|
109
|
-
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
109
|
+
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
|
|
110
110
|
});
|
|
111
111
|
});
|