@redocly/openapi-core 1.0.0-beta.49 → 1.0.0-beta.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__tests__/normalizeVisitors.test.ts +1 -1
- package/__tests__/utils.ts +1 -1
- package/__tests__/walk.test.ts +77 -4
- package/lib/benchmark/benches/recommended-oas3.bench.js +2 -1
- package/lib/benchmark/utils.d.ts +1 -1
- package/lib/bundle.d.ts +1 -1
- package/lib/bundle.js +10 -10
- package/lib/config/builtIn.d.ts +2 -1
- package/lib/config/builtIn.js +9 -1
- package/lib/config/config.d.ts +5 -7
- package/lib/config/config.js +40 -100
- package/lib/config/load.d.ts +2 -0
- package/lib/config/load.js +65 -0
- package/lib/config/rules.d.ts +1 -1
- package/lib/format/codeframes.js +1 -1
- package/lib/index.d.ts +4 -3
- package/lib/index.js +13 -11
- package/lib/lint.d.ts +6 -19
- package/lib/lint.js +13 -43
- package/lib/oas-types.d.ts +19 -0
- package/lib/oas-types.js +42 -0
- package/lib/resolve.d.ts +6 -2
- package/lib/resolve.js +18 -5
- package/lib/rules/ajv.d.ts +3 -3
- package/lib/rules/ajv.js +21 -18
- package/lib/rules/common/info-contact.js +2 -1
- package/lib/rules/common/info-description.js +2 -1
- package/lib/rules/common/info-license-url.js +2 -1
- package/lib/rules/common/license-url.js +2 -1
- package/lib/rules/common/no-ambiguous-paths.js +2 -1
- package/lib/rules/common/no-enum-type-mismatch.js +2 -1
- package/lib/rules/common/no-identical-paths.js +2 -1
- package/lib/rules/common/no-path-trailing-slash.js +2 -1
- package/lib/rules/common/operation-2xx-response.js +2 -1
- package/lib/rules/common/operation-description.js +2 -1
- package/lib/rules/common/operation-operationId-unique.js +2 -1
- package/lib/rules/common/operation-operationId-url-safe.js +2 -1
- package/lib/rules/common/operation-operationId.js +9 -4
- package/lib/rules/common/operation-parameters-unique.js +2 -1
- package/lib/rules/common/operation-security-defined.js +2 -1
- package/lib/rules/common/operation-singular-tag.js +2 -1
- package/lib/rules/common/operation-summary.js +2 -1
- package/lib/rules/common/operation-tag-defined.js +2 -1
- package/lib/rules/common/parameter-description.js +2 -1
- package/lib/rules/common/path-declaration-must-exist.js +2 -1
- package/lib/rules/common/path-http-verbs-order.js +2 -1
- package/lib/rules/common/path-not-include-query.js +2 -1
- package/lib/rules/common/path-params-defined.js +3 -2
- package/lib/rules/common/paths-kebab-case.js +2 -1
- package/lib/rules/common/registry-dependencies.js +2 -1
- package/lib/rules/common/spec.js +5 -2
- package/lib/rules/common/tag-description.js +2 -1
- package/lib/rules/common/tags-alphabetical.js +2 -1
- package/lib/rules/no-unresolved-refs.js +2 -1
- package/lib/rules/oas2/boolean-parameter-prefixes.js +2 -1
- package/lib/rules/oas2/index.d.ts +1 -1
- package/lib/rules/oas2/index.js +1 -1
- package/lib/rules/oas3/boolean-parameter-prefixes.js +2 -1
- package/lib/rules/oas3/index.d.ts +2 -1
- package/lib/rules/oas3/index.js +2 -2
- package/lib/rules/oas3/no-empty-servers.js +2 -1
- package/lib/rules/oas3/no-example-value-and-externalValue.js +2 -1
- package/lib/rules/oas3/no-invalid-media-type-examples.js +20 -10
- package/lib/rules/oas3/no-server-example.com.js +2 -1
- package/lib/rules/oas3/no-server-trailing-slash.js +2 -1
- package/lib/rules/oas3/no-servers-empty-enum.js +2 -1
- package/lib/rules/oas3/no-undefined-server-variable.js +2 -1
- package/lib/rules/oas3/no-unused-components.js +2 -1
- package/lib/rules/other/stats.js +2 -1
- package/lib/types/oas2.js +1 -1
- package/lib/types/oas3.js +1 -1
- package/lib/types/oas3_1.js +1 -1
- package/lib/utils.d.ts +1 -1
- package/lib/visitors.d.ts +3 -1
- package/lib/visitors.js +4 -4
- package/lib/walk.d.ts +1 -1
- package/lib/walk.js +11 -2
- package/package.json +7 -7
- package/src/__tests__/lint.test.ts +44 -0
- package/src/benchmark/benches/recommended-oas3.bench.ts +2 -1
- package/src/benchmark/benchmark.js +3 -1
- package/src/benchmark/utils.ts +1 -1
- package/src/bundle.ts +2 -2
- package/src/config/__tests__/resolve-plugins.test.ts +1 -1
- package/src/config/builtIn.ts +11 -1
- package/src/config/config.ts +30 -78
- package/src/config/load.ts +60 -0
- package/src/config/rules.ts +1 -1
- package/src/format/codeframes.ts +1 -1
- package/src/index.ts +4 -3
- package/src/lint.ts +19 -56
- package/src/oas-types.ts +58 -0
- package/src/resolve.ts +17 -4
- package/src/rules/__tests__/config.ts +10 -0
- package/src/rules/__tests__/no-unresolved-refs.test.ts +9 -21
- package/src/rules/ajv.ts +27 -23
- package/src/rules/common/__tests__/info-description.test.ts +8 -16
- package/src/rules/common/__tests__/info-license.test.ts +3 -3
- package/src/rules/common/__tests__/license-url.test.ts +3 -3
- package/src/rules/common/__tests__/no-ambiguous-paths.test.ts +2 -2
- package/src/rules/common/__tests__/no-enum-type-mismatch.test.ts +50 -5
- package/src/rules/common/__tests__/no-identical-paths.test.ts +2 -2
- package/src/rules/common/__tests__/no-path-trailing-slash.test.ts +4 -4
- package/src/rules/common/__tests__/operation-2xx-response.test.ts +4 -4
- package/src/rules/common/__tests__/operation-operationId-unique.test.ts +3 -3
- package/src/rules/common/__tests__/operation-operationId-url-safe.test.ts +2 -5
- package/src/rules/common/__tests__/operation-parameters-unique.test.ts +5 -17
- package/src/rules/common/__tests__/operation-security-defined.test.ts +3 -3
- package/src/rules/common/__tests__/operation-singular-tag.test.ts +3 -3
- package/src/rules/common/__tests__/path-http-verbs-order.test.ts +3 -3
- package/src/rules/common/__tests__/path-not-include-query.test.ts +3 -3
- package/src/rules/common/__tests__/path-params-defined.test.ts +4 -4
- package/src/rules/common/__tests__/paths-kebab-case.test.ts +3 -3
- package/src/rules/common/__tests__/tag-description.test.ts +3 -3
- package/src/rules/common/__tests__/tags-alphabetical.test.ts +3 -3
- package/src/rules/common/operation-operationId.ts +7 -3
- package/src/rules/common/spec.ts +4 -1
- package/src/rules/oas2/__tests__/boolean-parameter-prefixes.test.ts +7 -10
- package/src/rules/oas2/__tests__/spec/referenceableScalars.test.ts +3 -6
- package/src/rules/oas2/__tests__/spec/utils.ts +2 -0
- package/src/rules/oas2/index.ts +1 -10
- package/src/rules/oas3/__tests__/boolean-parameter-prefixes.test.ts +7 -10
- package/src/rules/oas3/__tests__/fixtures/common.yaml +11 -0
- package/src/rules/oas3/__tests__/no-empty-enum-servers.com.test.ts +7 -7
- package/src/rules/oas3/__tests__/no-example-value-and-externalValue.test.ts +3 -9
- package/src/rules/oas3/__tests__/no-invalid-media-type-examples.test.ts +103 -29
- package/src/rules/oas3/__tests__/no-server-example.com.test.ts +3 -3
- package/src/rules/oas3/__tests__/no-server-trailing-slash.test.ts +3 -3
- package/src/rules/oas3/__tests__/no-unused-components.test.ts +2 -2
- package/src/rules/oas3/__tests__/spec/spec.test.ts +3 -1
- package/src/rules/oas3/__tests__/spec/utils.ts +2 -0
- package/src/rules/oas3/index.ts +3 -4
- package/src/rules/oas3/no-invalid-media-type-examples.ts +27 -19
- package/src/visitors.ts +12 -8
- package/src/walk.ts +24 -8
- package/tsconfig.tsbuildinfo +1 -3084
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { outdent } from 'outdent';
|
|
2
|
-
import { LintConfig } from '../../../config/config';
|
|
3
2
|
import { lintDocument } from '../../../lint';
|
|
4
3
|
import { parseYamlToDocument, replaceSourceWithRef } from '../../../../__tests__/utils';
|
|
4
|
+
import { makeConfig } from '../../__tests__/config';
|
|
5
5
|
import { BaseResolver } from '../../../resolve';
|
|
6
6
|
|
|
7
7
|
describe('Common path-http-verbs-order', () => {
|
|
@@ -24,7 +24,7 @@ describe('Common path-http-verbs-order', () => {
|
|
|
24
24
|
const results = await lintDocument({
|
|
25
25
|
externalRefResolver: new BaseResolver(),
|
|
26
26
|
document,
|
|
27
|
-
config:
|
|
27
|
+
config: makeConfig({ 'path-http-verbs-order': 'error' }),
|
|
28
28
|
});
|
|
29
29
|
|
|
30
30
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
@@ -88,7 +88,7 @@ describe('Common path-http-verbs-order', () => {
|
|
|
88
88
|
const results = await lintDocument({
|
|
89
89
|
externalRefResolver: new BaseResolver(),
|
|
90
90
|
document,
|
|
91
|
-
config:
|
|
91
|
+
config: makeConfig({ 'path-http-verbs-order': 'error' }),
|
|
92
92
|
});
|
|
93
93
|
|
|
94
94
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { outdent } from 'outdent';
|
|
2
|
-
import { LintConfig } from '../../../config/config';
|
|
3
2
|
import { lintDocument } from '../../../lint';
|
|
4
3
|
import { parseYamlToDocument, replaceSourceWithRef } from '../../../../__tests__/utils';
|
|
4
|
+
import { makeConfig } from '../../__tests__/config';
|
|
5
5
|
import { BaseResolver } from '../../../resolve';
|
|
6
6
|
|
|
7
7
|
describe('Oas3 path-not-include-query', () => {
|
|
@@ -20,7 +20,7 @@ describe('Oas3 path-not-include-query', () => {
|
|
|
20
20
|
const results = await lintDocument({
|
|
21
21
|
externalRefResolver: new BaseResolver(),
|
|
22
22
|
document,
|
|
23
|
-
config:
|
|
23
|
+
config: makeConfig({ 'path-not-include-query': 'error' }),
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
@@ -57,7 +57,7 @@ describe('Oas3 path-not-include-query', () => {
|
|
|
57
57
|
const results = await lintDocument({
|
|
58
58
|
externalRefResolver: new BaseResolver(),
|
|
59
59
|
document,
|
|
60
|
-
config:
|
|
60
|
+
config: makeConfig({ 'path-not-include-query': 'error' }),
|
|
61
61
|
});
|
|
62
62
|
|
|
63
63
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { outdent } from 'outdent';
|
|
2
|
-
import { LintConfig } from '../../../config/config';
|
|
3
2
|
import { lintDocument } from '../../../lint';
|
|
4
3
|
import { parseYamlToDocument, replaceSourceWithRef } from '../../../../__tests__/utils';
|
|
4
|
+
import { makeConfig } from '../../__tests__/config';
|
|
5
5
|
import { BaseResolver } from '../../../resolve';
|
|
6
6
|
|
|
7
7
|
describe('Oas3 path-params-defined', () => {
|
|
@@ -25,7 +25,7 @@ describe('Oas3 path-params-defined', () => {
|
|
|
25
25
|
const results = await lintDocument({
|
|
26
26
|
externalRefResolver: new BaseResolver(),
|
|
27
27
|
document,
|
|
28
|
-
config:
|
|
28
|
+
config: makeConfig({ 'path-params-defined': 'error' }),
|
|
29
29
|
});
|
|
30
30
|
|
|
31
31
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
|
|
@@ -53,7 +53,7 @@ describe('Oas3 path-params-defined', () => {
|
|
|
53
53
|
const results = await lintDocument({
|
|
54
54
|
externalRefResolver: new BaseResolver(),
|
|
55
55
|
document,
|
|
56
|
-
config:
|
|
56
|
+
config: makeConfig({ 'path-params-defined': 'error' }),
|
|
57
57
|
});
|
|
58
58
|
|
|
59
59
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
@@ -97,7 +97,7 @@ describe('Oas3 path-params-defined', () => {
|
|
|
97
97
|
const results = await lintDocument({
|
|
98
98
|
externalRefResolver: new BaseResolver(),
|
|
99
99
|
document,
|
|
100
|
-
config:
|
|
100
|
+
config: makeConfig({ 'path-params-defined': 'error' }),
|
|
101
101
|
});
|
|
102
102
|
|
|
103
103
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { outdent } from 'outdent';
|
|
2
|
-
import { LintConfig } from '../../../config/config';
|
|
3
2
|
import { lintDocument } from '../../../lint';
|
|
4
3
|
import { parseYamlToDocument, replaceSourceWithRef } from '../../../../__tests__/utils';
|
|
4
|
+
import { makeConfig } from '../../__tests__/config';
|
|
5
5
|
import { BaseResolver } from '../../../resolve';
|
|
6
6
|
|
|
7
7
|
describe('Oas3 paths-kebab-case', () => {
|
|
@@ -23,7 +23,7 @@ describe('Oas3 paths-kebab-case', () => {
|
|
|
23
23
|
const results = await lintDocument({
|
|
24
24
|
externalRefResolver: new BaseResolver(),
|
|
25
25
|
document,
|
|
26
|
-
config:
|
|
26
|
+
config: makeConfig({ 'paths-kebab-case': 'error' }),
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
@@ -62,7 +62,7 @@ describe('Oas3 paths-kebab-case', () => {
|
|
|
62
62
|
const results = await lintDocument({
|
|
63
63
|
externalRefResolver: new BaseResolver(),
|
|
64
64
|
document,
|
|
65
|
-
config:
|
|
65
|
+
config: makeConfig({ 'paths-kebab-case': 'error' }),
|
|
66
66
|
});
|
|
67
67
|
|
|
68
68
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { outdent } from 'outdent';
|
|
2
|
-
import { LintConfig } from '../../../config/config';
|
|
3
2
|
import { lintDocument } from '../../../lint';
|
|
4
3
|
import { parseYamlToDocument, replaceSourceWithRef } from '../../../../__tests__/utils';
|
|
4
|
+
import { makeConfig } from '../../__tests__/config';
|
|
5
5
|
import { BaseResolver } from '../../../resolve';
|
|
6
6
|
|
|
7
7
|
describe('Oas3 tag-description', () => {
|
|
@@ -20,7 +20,7 @@ describe('Oas3 tag-description', () => {
|
|
|
20
20
|
const results = await lintDocument({
|
|
21
21
|
externalRefResolver: new BaseResolver(),
|
|
22
22
|
document,
|
|
23
|
-
config:
|
|
23
|
+
config: makeConfig({ 'tag-description': 'error' }),
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
@@ -58,7 +58,7 @@ describe('Oas3 tag-description', () => {
|
|
|
58
58
|
const results = await lintDocument({
|
|
59
59
|
externalRefResolver: new BaseResolver(),
|
|
60
60
|
document,
|
|
61
|
-
config:
|
|
61
|
+
config: makeConfig({ 'tag-description': 'error' }),
|
|
62
62
|
});
|
|
63
63
|
|
|
64
64
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { outdent } from 'outdent';
|
|
2
|
-
import { LintConfig } from '../../../config/config';
|
|
3
2
|
import { lintDocument } from '../../../lint';
|
|
4
3
|
import { parseYamlToDocument, replaceSourceWithRef } from '../../../../__tests__/utils';
|
|
4
|
+
import { makeConfig } from '../../__tests__/config';
|
|
5
5
|
import { BaseResolver } from '../../../resolve';
|
|
6
6
|
|
|
7
7
|
describe('Oas3 tags-alphabetical', () => {
|
|
@@ -20,7 +20,7 @@ describe('Oas3 tags-alphabetical', () => {
|
|
|
20
20
|
const results = await lintDocument({
|
|
21
21
|
externalRefResolver: new BaseResolver(),
|
|
22
22
|
document,
|
|
23
|
-
config:
|
|
23
|
+
config: makeConfig({ 'tags-alphabetical': 'error' }),
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
@@ -57,7 +57,7 @@ describe('Oas3 tags-alphabetical', () => {
|
|
|
57
57
|
const results = await lintDocument({
|
|
58
58
|
externalRefResolver: new BaseResolver(),
|
|
59
59
|
document,
|
|
60
|
-
config:
|
|
60
|
+
config: makeConfig({ 'tags-alphabetical': 'error' }),
|
|
61
61
|
});
|
|
62
62
|
|
|
63
63
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
|
|
@@ -6,8 +6,12 @@ import { Oas3Operation } from '../../typings/openapi';
|
|
|
6
6
|
|
|
7
7
|
export const OperationOperationId: Oas3Rule | Oas2Rule = () => {
|
|
8
8
|
return {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
DefinitionRoot: {
|
|
10
|
+
PathItem: {
|
|
11
|
+
Operation(operation: Oas2Operation | Oas3Operation, ctx: UserContext) {
|
|
12
|
+
validateDefinedAndNonEmpty('operationId', operation, ctx);
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
}
|
|
12
16
|
};
|
|
13
17
|
};
|
package/src/rules/common/spec.ts
CHANGED
|
@@ -5,19 +5,22 @@ import { isRef } from '../../ref-utils';
|
|
|
5
5
|
|
|
6
6
|
export const OasSpec: Oas3Rule | Oas2Rule = () => {
|
|
7
7
|
return {
|
|
8
|
-
any(node: any, { report, type, location, key, resolve }) {
|
|
8
|
+
any(node: any, { report, type, location, key, resolve, ignoreNextVisitorsOnNode } ) {
|
|
9
9
|
const nodeType = oasTypeOf(node);
|
|
10
|
+
|
|
10
11
|
if (type.items) {
|
|
11
12
|
if (nodeType !== 'array') {
|
|
12
13
|
report({
|
|
13
14
|
message: `Expected type \`${type.name}\` (array) but got \`${nodeType}\``,
|
|
14
15
|
});
|
|
16
|
+
ignoreNextVisitorsOnNode();
|
|
15
17
|
}
|
|
16
18
|
return;
|
|
17
19
|
} else if (nodeType !== 'object') {
|
|
18
20
|
report({
|
|
19
21
|
message: `Expected type \`${type.name}\` (object) but got \`${nodeType}\``,
|
|
20
22
|
});
|
|
23
|
+
ignoreNextVisitorsOnNode();
|
|
21
24
|
return;
|
|
22
25
|
}
|
|
23
26
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { outdent } from 'outdent';
|
|
2
2
|
import { parseYamlToDocument, replaceSourceWithRef } from '../../../../__tests__/utils';
|
|
3
|
+
import { makeConfig } from '../../__tests__/config';
|
|
3
4
|
import { lintDocument } from '../../../lint';
|
|
4
|
-
import { LintConfig } from '../../..';
|
|
5
5
|
import { BaseResolver } from '../../../resolve';
|
|
6
6
|
|
|
7
7
|
describe('oas2 boolean-parameter-prefixes', () => {
|
|
@@ -22,7 +22,7 @@ describe('oas2 boolean-parameter-prefixes', () => {
|
|
|
22
22
|
const results = await lintDocument({
|
|
23
23
|
externalRefResolver: new BaseResolver(),
|
|
24
24
|
document,
|
|
25
|
-
config:
|
|
25
|
+
config: makeConfig({ 'boolean-parameter-prefixes': 'error' }),
|
|
26
26
|
});
|
|
27
27
|
|
|
28
28
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
@@ -74,7 +74,7 @@ describe('oas2 boolean-parameter-prefixes', () => {
|
|
|
74
74
|
const results = await lintDocument({
|
|
75
75
|
externalRefResolver: new BaseResolver(),
|
|
76
76
|
document,
|
|
77
|
-
config:
|
|
77
|
+
config: makeConfig({ 'boolean-parameter-prefixes': 'error' }),
|
|
78
78
|
});
|
|
79
79
|
|
|
80
80
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
|
|
@@ -98,13 +98,10 @@ describe('oas2 boolean-parameter-prefixes', () => {
|
|
|
98
98
|
const results = await lintDocument({
|
|
99
99
|
externalRefResolver: new BaseResolver(),
|
|
100
100
|
document,
|
|
101
|
-
config:
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
severity: 'error',
|
|
106
|
-
prefixes: ['should'],
|
|
107
|
-
},
|
|
101
|
+
config: makeConfig({
|
|
102
|
+
'boolean-parameter-prefixes': {
|
|
103
|
+
severity: 'error',
|
|
104
|
+
prefixes: ['should'],
|
|
108
105
|
},
|
|
109
106
|
}),
|
|
110
107
|
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { outdent } from 'outdent';
|
|
2
2
|
import { parseYamlToDocument, replaceSourceWithRef } from '../../../../../__tests__/utils';
|
|
3
3
|
import { lintDocument } from '../../../../lint';
|
|
4
|
-
import { LintConfig } from '../../../..';
|
|
5
4
|
import { BaseResolver } from '../../../../resolve';
|
|
5
|
+
import { makeConfig } from '../../../__tests__/config';
|
|
6
6
|
|
|
7
7
|
describe('Referenceable scalars', () => {
|
|
8
8
|
it('should not report $ref description', async () => {
|
|
@@ -22,11 +22,8 @@ describe('Referenceable scalars', () => {
|
|
|
22
22
|
const results = await lintDocument({
|
|
23
23
|
externalRefResolver: new BaseResolver(),
|
|
24
24
|
document,
|
|
25
|
-
config:
|
|
26
|
-
|
|
27
|
-
rules: {
|
|
28
|
-
spec: 'error',
|
|
29
|
-
},
|
|
25
|
+
config: makeConfig({
|
|
26
|
+
spec: 'error',
|
|
30
27
|
}),
|
|
31
28
|
});
|
|
32
29
|
|
|
@@ -2,6 +2,7 @@ import { LintConfig, RuleConfig } from '../../../../config/config';
|
|
|
2
2
|
import { parseYamlToDocument } from '../../../../../__tests__/utils';
|
|
3
3
|
import { lintDocument } from '../../../../lint';
|
|
4
4
|
import { BaseResolver } from '../../../../resolve';
|
|
5
|
+
import { defaultPlugin } from '../../../../config/builtIn';
|
|
5
6
|
|
|
6
7
|
export async function lintDoc(
|
|
7
8
|
source: string,
|
|
@@ -13,6 +14,7 @@ export async function lintDoc(
|
|
|
13
14
|
externalRefResolver: new BaseResolver(),
|
|
14
15
|
document,
|
|
15
16
|
config: new LintConfig({
|
|
17
|
+
plugins: [defaultPlugin],
|
|
16
18
|
extends: [],
|
|
17
19
|
rules,
|
|
18
20
|
}),
|
package/src/rules/oas2/index.ts
CHANGED
|
@@ -3,7 +3,6 @@ import { InfoDescription } from '../common/info-description';
|
|
|
3
3
|
import { InfoContact } from '../common/info-contact';
|
|
4
4
|
import { InfoLicense } from '../common/info-license-url';
|
|
5
5
|
import { InfoLicenseUrl } from '../common/license-url';
|
|
6
|
-
|
|
7
6
|
import { BooleanParameterPrefixes } from './boolean-parameter-prefixes';
|
|
8
7
|
import { TagDescription } from '../common/tag-description';
|
|
9
8
|
import { TagsAlphabetical } from '../common/tags-alphabetical';
|
|
@@ -32,31 +31,26 @@ import { OperationSummary } from '../common/operation-summary';
|
|
|
32
31
|
import { NoAmbiguousPaths } from '../common/no-ambiguous-paths';
|
|
33
32
|
|
|
34
33
|
export const rules = {
|
|
34
|
+
spec: OasSpec as Oas2Rule,
|
|
35
35
|
'info-description': InfoDescription as Oas2Rule,
|
|
36
36
|
'info-contact': InfoContact as Oas2Rule,
|
|
37
37
|
'info-license': InfoLicense as Oas2Rule,
|
|
38
38
|
'info-license-url': InfoLicenseUrl as Oas2Rule,
|
|
39
|
-
|
|
40
39
|
'tag-description': TagDescription as Oas2Rule,
|
|
41
40
|
'tags-alphabetical': TagsAlphabetical as Oas2Rule,
|
|
42
|
-
|
|
43
41
|
'paths-kebab-case': PathsKebabCase as Oas2Rule,
|
|
44
42
|
'no-enum-type-mismatch': NoEnumTypeMismatch as Oas2Rule,
|
|
45
|
-
|
|
46
43
|
'boolean-parameter-prefixes': BooleanParameterPrefixes as Oas2Rule,
|
|
47
44
|
'no-path-trailing-slash': NoPathTrailingSlash as Oas2Rule,
|
|
48
45
|
'operation-2xx-response': Operation2xxResponse as Oas2Rule,
|
|
49
|
-
|
|
50
46
|
'operation-operationId-unique': OperationIdUnique as Oas2Rule,
|
|
51
47
|
'operation-parameters-unique': OperationParametersUnique as Oas2Rule,
|
|
52
48
|
'path-parameters-defined': PathParamsDefined as Oas2Rule,
|
|
53
49
|
'operation-tag-defined': OperationTagDefined as Oas2Rule,
|
|
54
|
-
|
|
55
50
|
'path-declaration-must-exist': PathDeclarationMustExist as Oas2Rule,
|
|
56
51
|
'operation-operationId-url-safe': OperationIdUrlSafe as Oas2Rule,
|
|
57
52
|
'operation-operationId': OperationOperationId as Oas2Rule,
|
|
58
53
|
'operation-summary': OperationSummary as Oas2Rule,
|
|
59
|
-
|
|
60
54
|
'operation-description': OperationDescription as Oas2Rule,
|
|
61
55
|
'path-not-include-query': PathNotIncludeQuery as Oas2Rule,
|
|
62
56
|
'path-params-defined': PathParamsDefined as Oas2Rule,
|
|
@@ -66,10 +60,7 @@ export const rules = {
|
|
|
66
60
|
'no-unresolved-refs': NoUnresolvedRefs as Oas2Rule,
|
|
67
61
|
'no-identical-paths': NoIdenticalPaths as Oas2Rule,
|
|
68
62
|
'no-ambiguous-paths': NoAmbiguousPaths as Oas2Rule,
|
|
69
|
-
|
|
70
63
|
'path-http-verbs-order': PathHttpVerbsOrder as Oas2Rule,
|
|
71
|
-
|
|
72
|
-
spec: OasSpec as Oas2Rule,
|
|
73
64
|
};
|
|
74
65
|
|
|
75
66
|
export const preprocessors = {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { outdent } from 'outdent';
|
|
2
2
|
import { parseYamlToDocument, replaceSourceWithRef } from '../../../../__tests__/utils';
|
|
3
|
+
import { makeConfig } from '../../__tests__/config';
|
|
3
4
|
import { lintDocument } from '../../../lint';
|
|
4
|
-
import { LintConfig } from '../../..';
|
|
5
5
|
import { BaseResolver } from '../../../resolve';
|
|
6
6
|
|
|
7
7
|
describe('oas3 boolean-parameter-prefixes', () => {
|
|
@@ -23,7 +23,7 @@ describe('oas3 boolean-parameter-prefixes', () => {
|
|
|
23
23
|
const results = await lintDocument({
|
|
24
24
|
externalRefResolver: new BaseResolver(),
|
|
25
25
|
document,
|
|
26
|
-
config:
|
|
26
|
+
config: makeConfig({ 'boolean-parameter-prefixes': 'error' }),
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
@@ -75,7 +75,7 @@ describe('oas3 boolean-parameter-prefixes', () => {
|
|
|
75
75
|
const results = await lintDocument({
|
|
76
76
|
externalRefResolver: new BaseResolver(),
|
|
77
77
|
document,
|
|
78
|
-
config:
|
|
78
|
+
config: makeConfig({ 'boolean-parameter-prefixes': 'error' }),
|
|
79
79
|
});
|
|
80
80
|
|
|
81
81
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
|
|
@@ -99,13 +99,10 @@ describe('oas3 boolean-parameter-prefixes', () => {
|
|
|
99
99
|
const results = await lintDocument({
|
|
100
100
|
externalRefResolver: new BaseResolver(),
|
|
101
101
|
document,
|
|
102
|
-
config:
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
severity: 'error',
|
|
107
|
-
prefixes: ['should'],
|
|
108
|
-
},
|
|
102
|
+
config: makeConfig({
|
|
103
|
+
'boolean-parameter-prefixes': {
|
|
104
|
+
severity: 'error',
|
|
105
|
+
prefixes: ['should'],
|
|
109
106
|
},
|
|
110
107
|
}),
|
|
111
108
|
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { outdent } from 'outdent';
|
|
2
|
-
import { LintConfig } from '../../../config/config';
|
|
3
2
|
import { lintDocument } from '../../../lint';
|
|
4
3
|
import { parseYamlToDocument, replaceSourceWithRef } from '../../../../__tests__/utils';
|
|
5
4
|
import { BaseResolver } from '../../../resolve';
|
|
5
|
+
import { makeConfig } from '../../__tests__/config';
|
|
6
6
|
|
|
7
7
|
describe('Oas3 as3-no-servers-empty-enum', () => {
|
|
8
8
|
it('oas3-no-servers-empty-enum: should report on server object with empty enum and unknown enum value', async () => {
|
|
@@ -25,7 +25,7 @@ describe('Oas3 as3-no-servers-empty-enum', () => {
|
|
|
25
25
|
const results = await lintDocument({
|
|
26
26
|
externalRefResolver: new BaseResolver(),
|
|
27
27
|
document,
|
|
28
|
-
config:
|
|
28
|
+
config: makeConfig({ 'no-servers-empty-enum': 'error' }),
|
|
29
29
|
});
|
|
30
30
|
|
|
31
31
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
@@ -79,7 +79,7 @@ describe('Oas3 as3-no-servers-empty-enum', () => {
|
|
|
79
79
|
const results = await lintDocument({
|
|
80
80
|
externalRefResolver: new BaseResolver(),
|
|
81
81
|
document,
|
|
82
|
-
config:
|
|
82
|
+
config: makeConfig({ 'no-servers-empty-enum': 'error' }),
|
|
83
83
|
});
|
|
84
84
|
|
|
85
85
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
@@ -118,7 +118,7 @@ describe('Oas3 as3-no-servers-empty-enum', () => {
|
|
|
118
118
|
const results = await lintDocument({
|
|
119
119
|
externalRefResolver: new BaseResolver(),
|
|
120
120
|
document,
|
|
121
|
-
config:
|
|
121
|
+
config: makeConfig({ 'no-servers-empty-enum': 'error' }),
|
|
122
122
|
});
|
|
123
123
|
|
|
124
124
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
|
|
@@ -142,7 +142,7 @@ describe('Oas3 as3-no-servers-empty-enum', () => {
|
|
|
142
142
|
const results = await lintDocument({
|
|
143
143
|
externalRefResolver: new BaseResolver(),
|
|
144
144
|
document,
|
|
145
|
-
config:
|
|
145
|
+
config: makeConfig({ 'no-servers-empty-enum': 'error' }),
|
|
146
146
|
});
|
|
147
147
|
|
|
148
148
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
|
|
@@ -169,7 +169,7 @@ describe('Oas3 as3-no-servers-empty-enum', () => {
|
|
|
169
169
|
const results = await lintDocument({
|
|
170
170
|
externalRefResolver: new BaseResolver(),
|
|
171
171
|
document,
|
|
172
|
-
config:
|
|
172
|
+
config: makeConfig({ 'no-servers-empty-enum': 'error' }),
|
|
173
173
|
});
|
|
174
174
|
|
|
175
175
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
|
|
@@ -198,7 +198,7 @@ describe('Oas3 as3-no-servers-empty-enum', () => {
|
|
|
198
198
|
const results = await lintDocument({
|
|
199
199
|
externalRefResolver: new BaseResolver(),
|
|
200
200
|
document,
|
|
201
|
-
config:
|
|
201
|
+
config: makeConfig({ 'no-servers-empty-enum': 'error' }),
|
|
202
202
|
});
|
|
203
203
|
|
|
204
204
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { outdent } from 'outdent';
|
|
2
|
-
import { LintConfig } from '../../../config/config';
|
|
3
2
|
import { lintDocument } from '../../../lint';
|
|
4
3
|
import { parseYamlToDocument, replaceSourceWithRef } from '../../../../__tests__/utils';
|
|
5
4
|
import { BaseResolver } from '../../../resolve';
|
|
5
|
+
import { makeConfig } from '../../__tests__/config';
|
|
6
6
|
|
|
7
7
|
describe('Oas3 oas3-no-example-value-and-externalValue', () => {
|
|
8
8
|
it('oas3-no-example-value-and-externalValue: should report on example object with both value and external value', async () => {
|
|
@@ -21,10 +21,7 @@ describe('Oas3 oas3-no-example-value-and-externalValue', () => {
|
|
|
21
21
|
const results = await lintDocument({
|
|
22
22
|
externalRefResolver: new BaseResolver(),
|
|
23
23
|
document,
|
|
24
|
-
config:
|
|
25
|
-
extends: [],
|
|
26
|
-
rules: { 'no-example-value-and-externalValue': 'error' },
|
|
27
|
-
}),
|
|
24
|
+
config: makeConfig({ 'no-example-value-and-externalValue': 'error' }),
|
|
28
25
|
});
|
|
29
26
|
|
|
30
27
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
@@ -61,10 +58,7 @@ describe('Oas3 oas3-no-example-value-and-externalValue', () => {
|
|
|
61
58
|
const results = await lintDocument({
|
|
62
59
|
externalRefResolver: new BaseResolver(),
|
|
63
60
|
document,
|
|
64
|
-
config:
|
|
65
|
-
extends: [],
|
|
66
|
-
rules: { 'no-example-value-and-externalValue': 'error' },
|
|
67
|
-
}),
|
|
61
|
+
config: makeConfig({ 'no-example-value-and-externalValue': 'error' }),
|
|
68
62
|
});
|
|
69
63
|
|
|
70
64
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
|