@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.
Files changed (136) hide show
  1. package/__tests__/normalizeVisitors.test.ts +1 -1
  2. package/__tests__/utils.ts +1 -1
  3. package/__tests__/walk.test.ts +77 -4
  4. package/lib/benchmark/benches/recommended-oas3.bench.js +2 -1
  5. package/lib/benchmark/utils.d.ts +1 -1
  6. package/lib/bundle.d.ts +1 -1
  7. package/lib/bundle.js +10 -10
  8. package/lib/config/builtIn.d.ts +2 -1
  9. package/lib/config/builtIn.js +9 -1
  10. package/lib/config/config.d.ts +5 -7
  11. package/lib/config/config.js +40 -100
  12. package/lib/config/load.d.ts +2 -0
  13. package/lib/config/load.js +65 -0
  14. package/lib/config/rules.d.ts +1 -1
  15. package/lib/format/codeframes.js +1 -1
  16. package/lib/index.d.ts +4 -3
  17. package/lib/index.js +13 -11
  18. package/lib/lint.d.ts +6 -19
  19. package/lib/lint.js +13 -43
  20. package/lib/oas-types.d.ts +19 -0
  21. package/lib/oas-types.js +42 -0
  22. package/lib/resolve.d.ts +6 -2
  23. package/lib/resolve.js +18 -5
  24. package/lib/rules/ajv.d.ts +3 -3
  25. package/lib/rules/ajv.js +21 -18
  26. package/lib/rules/common/info-contact.js +2 -1
  27. package/lib/rules/common/info-description.js +2 -1
  28. package/lib/rules/common/info-license-url.js +2 -1
  29. package/lib/rules/common/license-url.js +2 -1
  30. package/lib/rules/common/no-ambiguous-paths.js +2 -1
  31. package/lib/rules/common/no-enum-type-mismatch.js +2 -1
  32. package/lib/rules/common/no-identical-paths.js +2 -1
  33. package/lib/rules/common/no-path-trailing-slash.js +2 -1
  34. package/lib/rules/common/operation-2xx-response.js +2 -1
  35. package/lib/rules/common/operation-description.js +2 -1
  36. package/lib/rules/common/operation-operationId-unique.js +2 -1
  37. package/lib/rules/common/operation-operationId-url-safe.js +2 -1
  38. package/lib/rules/common/operation-operationId.js +9 -4
  39. package/lib/rules/common/operation-parameters-unique.js +2 -1
  40. package/lib/rules/common/operation-security-defined.js +2 -1
  41. package/lib/rules/common/operation-singular-tag.js +2 -1
  42. package/lib/rules/common/operation-summary.js +2 -1
  43. package/lib/rules/common/operation-tag-defined.js +2 -1
  44. package/lib/rules/common/parameter-description.js +2 -1
  45. package/lib/rules/common/path-declaration-must-exist.js +2 -1
  46. package/lib/rules/common/path-http-verbs-order.js +2 -1
  47. package/lib/rules/common/path-not-include-query.js +2 -1
  48. package/lib/rules/common/path-params-defined.js +3 -2
  49. package/lib/rules/common/paths-kebab-case.js +2 -1
  50. package/lib/rules/common/registry-dependencies.js +2 -1
  51. package/lib/rules/common/spec.js +5 -2
  52. package/lib/rules/common/tag-description.js +2 -1
  53. package/lib/rules/common/tags-alphabetical.js +2 -1
  54. package/lib/rules/no-unresolved-refs.js +2 -1
  55. package/lib/rules/oas2/boolean-parameter-prefixes.js +2 -1
  56. package/lib/rules/oas2/index.d.ts +1 -1
  57. package/lib/rules/oas2/index.js +1 -1
  58. package/lib/rules/oas3/boolean-parameter-prefixes.js +2 -1
  59. package/lib/rules/oas3/index.d.ts +2 -1
  60. package/lib/rules/oas3/index.js +2 -2
  61. package/lib/rules/oas3/no-empty-servers.js +2 -1
  62. package/lib/rules/oas3/no-example-value-and-externalValue.js +2 -1
  63. package/lib/rules/oas3/no-invalid-media-type-examples.js +20 -10
  64. package/lib/rules/oas3/no-server-example.com.js +2 -1
  65. package/lib/rules/oas3/no-server-trailing-slash.js +2 -1
  66. package/lib/rules/oas3/no-servers-empty-enum.js +2 -1
  67. package/lib/rules/oas3/no-undefined-server-variable.js +2 -1
  68. package/lib/rules/oas3/no-unused-components.js +2 -1
  69. package/lib/rules/other/stats.js +2 -1
  70. package/lib/types/oas2.js +1 -1
  71. package/lib/types/oas3.js +1 -1
  72. package/lib/types/oas3_1.js +1 -1
  73. package/lib/utils.d.ts +1 -1
  74. package/lib/visitors.d.ts +3 -1
  75. package/lib/visitors.js +4 -4
  76. package/lib/walk.d.ts +1 -1
  77. package/lib/walk.js +11 -2
  78. package/package.json +7 -7
  79. package/src/__tests__/lint.test.ts +44 -0
  80. package/src/benchmark/benches/recommended-oas3.bench.ts +2 -1
  81. package/src/benchmark/benchmark.js +3 -1
  82. package/src/benchmark/utils.ts +1 -1
  83. package/src/bundle.ts +2 -2
  84. package/src/config/__tests__/resolve-plugins.test.ts +1 -1
  85. package/src/config/builtIn.ts +11 -1
  86. package/src/config/config.ts +30 -78
  87. package/src/config/load.ts +60 -0
  88. package/src/config/rules.ts +1 -1
  89. package/src/format/codeframes.ts +1 -1
  90. package/src/index.ts +4 -3
  91. package/src/lint.ts +19 -56
  92. package/src/oas-types.ts +58 -0
  93. package/src/resolve.ts +17 -4
  94. package/src/rules/__tests__/config.ts +10 -0
  95. package/src/rules/__tests__/no-unresolved-refs.test.ts +9 -21
  96. package/src/rules/ajv.ts +27 -23
  97. package/src/rules/common/__tests__/info-description.test.ts +8 -16
  98. package/src/rules/common/__tests__/info-license.test.ts +3 -3
  99. package/src/rules/common/__tests__/license-url.test.ts +3 -3
  100. package/src/rules/common/__tests__/no-ambiguous-paths.test.ts +2 -2
  101. package/src/rules/common/__tests__/no-enum-type-mismatch.test.ts +50 -5
  102. package/src/rules/common/__tests__/no-identical-paths.test.ts +2 -2
  103. package/src/rules/common/__tests__/no-path-trailing-slash.test.ts +4 -4
  104. package/src/rules/common/__tests__/operation-2xx-response.test.ts +4 -4
  105. package/src/rules/common/__tests__/operation-operationId-unique.test.ts +3 -3
  106. package/src/rules/common/__tests__/operation-operationId-url-safe.test.ts +2 -5
  107. package/src/rules/common/__tests__/operation-parameters-unique.test.ts +5 -17
  108. package/src/rules/common/__tests__/operation-security-defined.test.ts +3 -3
  109. package/src/rules/common/__tests__/operation-singular-tag.test.ts +3 -3
  110. package/src/rules/common/__tests__/path-http-verbs-order.test.ts +3 -3
  111. package/src/rules/common/__tests__/path-not-include-query.test.ts +3 -3
  112. package/src/rules/common/__tests__/path-params-defined.test.ts +4 -4
  113. package/src/rules/common/__tests__/paths-kebab-case.test.ts +3 -3
  114. package/src/rules/common/__tests__/tag-description.test.ts +3 -3
  115. package/src/rules/common/__tests__/tags-alphabetical.test.ts +3 -3
  116. package/src/rules/common/operation-operationId.ts +7 -3
  117. package/src/rules/common/spec.ts +4 -1
  118. package/src/rules/oas2/__tests__/boolean-parameter-prefixes.test.ts +7 -10
  119. package/src/rules/oas2/__tests__/spec/referenceableScalars.test.ts +3 -6
  120. package/src/rules/oas2/__tests__/spec/utils.ts +2 -0
  121. package/src/rules/oas2/index.ts +1 -10
  122. package/src/rules/oas3/__tests__/boolean-parameter-prefixes.test.ts +7 -10
  123. package/src/rules/oas3/__tests__/fixtures/common.yaml +11 -0
  124. package/src/rules/oas3/__tests__/no-empty-enum-servers.com.test.ts +7 -7
  125. package/src/rules/oas3/__tests__/no-example-value-and-externalValue.test.ts +3 -9
  126. package/src/rules/oas3/__tests__/no-invalid-media-type-examples.test.ts +103 -29
  127. package/src/rules/oas3/__tests__/no-server-example.com.test.ts +3 -3
  128. package/src/rules/oas3/__tests__/no-server-trailing-slash.test.ts +3 -3
  129. package/src/rules/oas3/__tests__/no-unused-components.test.ts +2 -2
  130. package/src/rules/oas3/__tests__/spec/spec.test.ts +3 -1
  131. package/src/rules/oas3/__tests__/spec/utils.ts +2 -0
  132. package/src/rules/oas3/index.ts +3 -4
  133. package/src/rules/oas3/no-invalid-media-type-examples.ts +27 -19
  134. package/src/visitors.ts +12 -8
  135. package/src/walk.ts +24 -8
  136. 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: new LintConfig({ extends: [], rules: { 'path-http-verbs-order': 'error' } }),
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: new LintConfig({ extends: [], rules: { 'path-http-verbs-order': 'error' } }),
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: new LintConfig({ extends: [], rules: { 'path-not-include-query': 'error' } }),
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: new LintConfig({ extends: [], rules: { 'path-not-include-query': 'error' } }),
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: new LintConfig({ extends: [], rules: { 'path-params-defined': 'error' } }),
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: new LintConfig({ extends: [], rules: { 'path-params-defined': 'error' } }),
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: new LintConfig({ extends: [], rules: { 'path-params-defined': 'error' } }),
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: new LintConfig({ extends: [], rules: { 'paths-kebab-case': 'error' } }),
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: new LintConfig({ extends: [], rules: { 'paths-kebab-case': 'error' } }),
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: new LintConfig({ extends: [], rules: { 'tag-description': 'error' } }),
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: new LintConfig({ extends: [], rules: { 'tag-description': 'error' } }),
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: new LintConfig({ extends: [], rules: { 'tags-alphabetical': 'error' } }),
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: new LintConfig({ extends: [], rules: { 'tags-alphabetical': 'error' } }),
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
- Operation(operation: Oas2Operation | Oas3Operation, ctx: UserContext) {
10
- validateDefinedAndNonEmpty('operationId', operation, ctx);
11
- },
9
+ DefinitionRoot: {
10
+ PathItem: {
11
+ Operation(operation: Oas2Operation | Oas3Operation, ctx: UserContext) {
12
+ validateDefinedAndNonEmpty('operationId', operation, ctx);
13
+ },
14
+ },
15
+ }
12
16
  };
13
17
  };
@@ -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: new LintConfig({ extends: [], rules: { 'boolean-parameter-prefixes': 'error' } }),
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: new LintConfig({ extends: [], rules: { 'boolean-parameter-prefixes': 'error' } }),
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: new LintConfig({
102
- extends: [],
103
- rules: {
104
- 'boolean-parameter-prefixes': {
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: new LintConfig({
26
- extends: [],
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
  }),
@@ -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: new LintConfig({ extends: [], rules: { 'boolean-parameter-prefixes': 'error' } }),
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: new LintConfig({ extends: [], rules: { 'boolean-parameter-prefixes': 'error' } }),
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: new LintConfig({
103
- extends: [],
104
- rules: {
105
- 'boolean-parameter-prefixes': {
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
  });
@@ -0,0 +1,11 @@
1
+ components:
2
+ schemas:
3
+ A:
4
+ type: object
5
+ properties:
6
+ a:
7
+ type: string
8
+ b:
9
+ $ref: '#/components/schemas/B'
10
+ B:
11
+ type: string
@@ -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: new LintConfig({ extends: [], rules: { 'no-servers-empty-enum': 'error' } }),
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: new LintConfig({ extends: [], rules: { 'no-servers-empty-enum': 'error' } }),
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: new LintConfig({ extends: [], rules: { 'no-servers-empty-enum': 'error' } }),
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: new LintConfig({ extends: [], rules: { 'no-servers-empty-enum': 'error' } }),
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: new LintConfig({ extends: [], rules: { 'no-servers-empty-enum': 'error' } }),
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: new LintConfig({ extends: [], rules: { 'no-servers-empty-enum': 'error' } }),
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: new LintConfig({
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: new LintConfig({
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 []`);