@redocly/openapi-core 1.25.14 → 1.26.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.
Files changed (126) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/__tests__/utils.ts +0 -3
  3. package/lib/bundle.js +3 -3
  4. package/lib/config/all.js +130 -48
  5. package/lib/config/builtIn.d.ts +1 -1
  6. package/lib/config/builtIn.js +5 -3
  7. package/lib/config/config-resolvers.js +9 -9
  8. package/lib/config/config.d.ts +2 -2
  9. package/lib/config/config.js +38 -20
  10. package/lib/config/minimal.js +125 -49
  11. package/lib/config/recommended-strict.js +124 -48
  12. package/lib/config/recommended.js +123 -47
  13. package/lib/config/rules.d.ts +2 -2
  14. package/lib/config/spec.d.ts +3 -0
  15. package/lib/config/spec.js +31 -0
  16. package/lib/config/types.d.ts +23 -23
  17. package/lib/config/utils.d.ts +1 -1
  18. package/lib/config/utils.js +33 -23
  19. package/lib/index.d.ts +1 -1
  20. package/lib/index.js +2 -2
  21. package/lib/lint.js +3 -3
  22. package/lib/oas-types.d.ts +11 -11
  23. package/lib/oas-types.js +6 -6
  24. package/lib/rules/arazzo/criteria-unique.d.ts +2 -2
  25. package/lib/rules/arazzo/index.d.ts +2 -2
  26. package/lib/rules/arazzo/index.js +6 -4
  27. package/lib/rules/arazzo/parameters-unique.d.ts +2 -2
  28. package/lib/rules/arazzo/requestBody-replacements-unique.d.ts +2 -2
  29. package/lib/rules/arazzo/sourceDescription-type.d.ts +2 -0
  30. package/lib/rules/arazzo/{source-description-type.js → sourceDescription-type.js} +5 -3
  31. package/lib/rules/arazzo/sourceDescriptions-name-unique.d.ts +2 -2
  32. package/lib/rules/arazzo/sourceDescriptions-not-empty.d.ts +2 -0
  33. package/lib/rules/arazzo/sourceDescriptions-not-empty.js +18 -0
  34. package/lib/rules/arazzo/step-onFailure-unique.d.ts +2 -2
  35. package/lib/rules/arazzo/step-onSuccess-unique.d.ts +2 -2
  36. package/lib/rules/arazzo/stepId-unique.d.ts +2 -2
  37. package/lib/rules/arazzo/workflow-dependsOn.d.ts +2 -2
  38. package/lib/rules/arazzo/workflowId-unique.d.ts +2 -2
  39. package/lib/rules/async2/index.js +5 -2
  40. package/lib/rules/async3/index.js +5 -2
  41. package/lib/rules/common/assertions/index.d.ts +2 -2
  42. package/lib/rules/common/struct.d.ts +2 -0
  43. package/lib/rules/common/{spec.js → struct.js} +3 -3
  44. package/lib/rules/oas2/index.js +5 -2
  45. package/lib/rules/oas3/index.js +5 -2
  46. package/lib/rules/spot/no-actions-type-end.d.ts +2 -2
  47. package/lib/rules/spot/no-criteria-xpath.d.ts +2 -2
  48. package/lib/rules/spot/parameters-not-in-body.d.ts +2 -2
  49. package/lib/rules/spot/version-enum.d.ts +2 -2
  50. package/lib/types/arazzo.d.ts +1 -1
  51. package/lib/types/arazzo.js +3 -27
  52. package/lib/types/redocly-yaml.d.ts +6 -8
  53. package/lib/types/redocly-yaml.js +47 -12
  54. package/lib/typings/arazzo.d.ts +1 -15
  55. package/lib/utils.d.ts +1 -1
  56. package/lib/utils.js +3 -2
  57. package/lib/visitors.d.ts +5 -7
  58. package/package.json +2 -2
  59. package/src/__tests__/lint.test.ts +3 -3
  60. package/src/bundle.ts +3 -3
  61. package/src/config/__tests__/__snapshots__/config-resolvers.test.ts.snap +228 -70
  62. package/src/config/__tests__/__snapshots__/config.test.ts.snap +16 -3
  63. package/src/config/__tests__/config-resolvers.test.ts +14 -2
  64. package/src/config/__tests__/config.test.ts +11 -6
  65. package/src/config/all.ts +130 -48
  66. package/src/config/builtIn.ts +10 -8
  67. package/src/config/config-resolvers.ts +9 -9
  68. package/src/config/config.ts +46 -22
  69. package/src/config/minimal.ts +125 -49
  70. package/src/config/recommended-strict.ts +124 -48
  71. package/src/config/recommended.ts +123 -47
  72. package/src/config/rules.ts +2 -2
  73. package/src/config/spec.ts +32 -0
  74. package/src/config/types.ts +27 -33
  75. package/src/config/utils.ts +38 -26
  76. package/src/index.ts +1 -1
  77. package/src/lint.ts +6 -6
  78. package/src/oas-types.ts +19 -20
  79. package/src/rules/arazzo/__tests__/criteria-unique.test.ts +1 -2
  80. package/src/rules/arazzo/__tests__/no-actions-type-end.test.ts +1 -2
  81. package/src/rules/arazzo/__tests__/no-criteria-xpath.test.ts +1 -2
  82. package/src/rules/arazzo/__tests__/parameters-not-in-body.test.ts +1 -2
  83. package/src/rules/arazzo/__tests__/parameters-unique.test.ts +1 -2
  84. package/src/rules/arazzo/__tests__/requestBody-replacements-unique.test.ts +1 -2
  85. package/src/rules/arazzo/__tests__/source-description-type.test.ts +2 -4
  86. package/src/rules/arazzo/__tests__/sourceDescription-name-unique.test.ts +1 -2
  87. package/src/rules/arazzo/__tests__/sourceDescriptions-not-empty.test.ts +104 -0
  88. package/src/rules/arazzo/__tests__/step-onFailure-unique.test.ts +1 -2
  89. package/src/rules/arazzo/__tests__/step-onSuccess-unique.test.ts +1 -2
  90. package/src/rules/arazzo/__tests__/stepId-unique.test.ts +1 -2
  91. package/src/rules/arazzo/__tests__/version-enum.test.ts +1 -2
  92. package/src/rules/arazzo/__tests__/workflow-dependsOn.test.ts +3 -6
  93. package/src/rules/arazzo/__tests__/workflowId-unique.test.ts +2 -4
  94. package/src/rules/arazzo/criteria-unique.ts +2 -2
  95. package/src/rules/arazzo/index.ts +23 -21
  96. package/src/rules/arazzo/parameters-unique.ts +2 -2
  97. package/src/rules/arazzo/requestBody-replacements-unique.ts +2 -2
  98. package/src/rules/arazzo/{source-description-type.ts → sourceDescription-type.ts} +6 -5
  99. package/src/rules/arazzo/sourceDescriptions-name-unique.ts +2 -2
  100. package/src/rules/arazzo/sourceDescriptions-not-empty.ts +17 -0
  101. package/src/rules/arazzo/step-onFailure-unique.ts +2 -2
  102. package/src/rules/arazzo/step-onSuccess-unique.ts +2 -2
  103. package/src/rules/arazzo/stepId-unique.ts +2 -2
  104. package/src/rules/arazzo/workflow-dependsOn.ts +2 -2
  105. package/src/rules/arazzo/workflowId-unique.ts +2 -2
  106. package/src/rules/async2/index.ts +5 -2
  107. package/src/rules/async3/index.ts +5 -2
  108. package/src/rules/common/__tests__/no-enum-type-mismatch.test.ts +1 -1
  109. package/src/rules/common/__tests__/{spec.test.ts → struct.test.ts} +35 -35
  110. package/src/rules/common/assertions/index.ts +2 -2
  111. package/src/rules/common/{spec.ts → struct.ts} +2 -2
  112. package/src/rules/oas2/index.ts +5 -2
  113. package/src/rules/oas3/__tests__/spec/spec.test.ts +10 -10
  114. package/src/rules/oas3/index.ts +5 -2
  115. package/src/rules/spot/no-actions-type-end.ts +2 -2
  116. package/src/rules/spot/no-criteria-xpath.ts +2 -2
  117. package/src/rules/spot/parameters-not-in-body.ts +2 -2
  118. package/src/rules/spot/version-enum.ts +2 -2
  119. package/src/types/arazzo.ts +2 -25
  120. package/src/types/redocly-yaml.ts +48 -16
  121. package/src/typings/arazzo.ts +1 -20
  122. package/src/utils.ts +4 -2
  123. package/src/visitors.ts +4 -8
  124. package/tsconfig.tsbuildinfo +1 -1
  125. package/lib/rules/arazzo/source-description-type.d.ts +0 -2
  126. package/lib/rules/common/spec.d.ts +0 -2
package/src/oas-types.ts CHANGED
@@ -3,15 +3,14 @@ import { Oas3Types } from './types/oas3';
3
3
  import { Oas3_1Types } from './types/oas3_1';
4
4
  import { AsyncApi2Types } from './types/asyncapi2';
5
5
  import { AsyncApi3Types } from './types/asyncapi3';
6
- import { ArazzoTypes } from './types/arazzo';
6
+ import { Arazzo1Types } from './types/arazzo';
7
7
  import { isPlainObject } from './utils';
8
8
  import { VERSION_PATTERN } from './typings/arazzo';
9
9
 
10
10
  import type {
11
11
  BuiltInAsync2RuleId,
12
12
  BuiltInAsync3RuleId,
13
- BuiltInCommonOASRuleId,
14
- BuiltInArazzoRuleId,
13
+ BuiltInArazzo1RuleId,
15
14
  BuiltInOAS2RuleId,
16
15
  BuiltInOAS3RuleId,
17
16
  } from './types/redocly-yaml';
@@ -24,8 +23,8 @@ import type {
24
23
  Async2Rule,
25
24
  Async3Preprocessor,
26
25
  Async3Rule,
27
- ArazzoPreprocessor,
28
- ArazzoRule,
26
+ Arazzo1Preprocessor,
27
+ Arazzo1Rule,
29
28
  } from './visitors';
30
29
 
31
30
  export enum SpecVersion {
@@ -34,7 +33,7 @@ export enum SpecVersion {
34
33
  OAS3_1 = 'oas3_1',
35
34
  Async2 = 'async2',
36
35
  Async3 = 'async3',
37
- Arazzo = 'arazzo',
36
+ Arazzo1 = 'arazzo1',
38
37
  }
39
38
 
40
39
  export enum SpecMajorVersion {
@@ -42,7 +41,7 @@ export enum SpecMajorVersion {
42
41
  OAS3 = 'oas3',
43
42
  Async2 = 'async2',
44
43
  Async3 = 'async3',
45
- Arazzo = 'arazzo',
44
+ Arazzo1 = 'arazzo1',
46
45
  }
47
46
 
48
47
  const typesMap = {
@@ -51,7 +50,7 @@ const typesMap = {
51
50
  [SpecVersion.OAS3_1]: Oas3_1Types,
52
51
  [SpecVersion.Async2]: AsyncApi2Types,
53
52
  [SpecVersion.Async3]: AsyncApi3Types,
54
- [SpecVersion.Arazzo]: ArazzoTypes,
53
+ [SpecVersion.Arazzo1]: Arazzo1Types,
55
54
  };
56
55
 
57
56
  export type RuleMap<Key extends string, RuleConfig, T> = Record<
@@ -59,28 +58,28 @@ export type RuleMap<Key extends string, RuleConfig, T> = Record<
59
58
  RuleConfig
60
59
  >;
61
60
  export type Oas3RuleSet<T = undefined> = RuleMap<
62
- BuiltInCommonOASRuleId | BuiltInOAS3RuleId | 'assertions',
61
+ BuiltInOAS3RuleId | 'struct' | 'assertions',
63
62
  Oas3Rule,
64
63
  T
65
64
  >;
66
65
  export type Oas2RuleSet<T = undefined> = RuleMap<
67
- BuiltInCommonOASRuleId | BuiltInOAS2RuleId | 'assertions',
66
+ BuiltInOAS2RuleId | 'struct' | 'assertions',
68
67
  Oas2Rule,
69
68
  T
70
69
  >;
71
70
  export type Async2RuleSet<T = undefined> = RuleMap<
72
- BuiltInAsync2RuleId | 'assertions',
71
+ BuiltInAsync2RuleId | 'struct' | 'assertions',
73
72
  Async2Rule,
74
73
  T
75
74
  >;
76
75
  export type Async3RuleSet<T = undefined> = RuleMap<
77
- BuiltInAsync3RuleId | 'assertions',
76
+ BuiltInAsync3RuleId | 'struct' | 'assertions',
78
77
  Async3Rule,
79
78
  T
80
79
  >;
81
- export type ArazzoRuleSet<T = undefined> = RuleMap<
82
- BuiltInArazzoRuleId | 'assertions',
83
- ArazzoRule,
80
+ export type Arazzo1RuleSet<T = undefined> = RuleMap<
81
+ BuiltInArazzo1RuleId | 'struct' | 'assertions',
82
+ Arazzo1Rule,
84
83
  T
85
84
  >;
86
85
 
@@ -88,13 +87,13 @@ export type Oas3PreprocessorsSet = Record<string, Oas3Preprocessor>;
88
87
  export type Oas2PreprocessorsSet = Record<string, Oas2Preprocessor>;
89
88
  export type Async2PreprocessorsSet = Record<string, Async2Preprocessor>;
90
89
  export type Async3PreprocessorsSet = Record<string, Async3Preprocessor>;
91
- export type ArazzoPreprocessorsSet = Record<string, ArazzoPreprocessor>;
90
+ export type Arazzo1PreprocessorsSet = Record<string, Arazzo1Preprocessor>;
92
91
 
93
92
  export type Oas3DecoratorsSet = Record<string, Oas3Preprocessor>;
94
93
  export type Oas2DecoratorsSet = Record<string, Oas2Preprocessor>;
95
94
  export type Async2DecoratorsSet = Record<string, Async2Preprocessor>;
96
95
  export type Async3DecoratorsSet = Record<string, Async3Preprocessor>;
97
- export type ArazzoDecoratorsSet = Record<string, ArazzoPreprocessor>;
96
+ export type Arazzo1DecoratorsSet = Record<string, Arazzo1Preprocessor>;
98
97
 
99
98
  export function detectSpec(root: unknown): SpecVersion {
100
99
  if (!isPlainObject(root)) {
@@ -134,7 +133,7 @@ export function detectSpec(root: unknown): SpecVersion {
134
133
  }
135
134
 
136
135
  if (typeof root.arazzo === 'string' && VERSION_PATTERN.test(root.arazzo)) {
137
- return SpecVersion.Arazzo;
136
+ return SpecVersion.Arazzo1;
138
137
  }
139
138
 
140
139
  throw new Error(`Unsupported specification`);
@@ -147,8 +146,8 @@ export function getMajorSpecVersion(version: SpecVersion): SpecMajorVersion {
147
146
  return SpecMajorVersion.Async2;
148
147
  } else if (version === SpecVersion.Async3) {
149
148
  return SpecMajorVersion.Async3;
150
- } else if (version === SpecVersion.Arazzo) {
151
- return SpecMajorVersion.Arazzo;
149
+ } else if (version === SpecVersion.Arazzo1) {
150
+ return SpecMajorVersion.Arazzo1;
152
151
  } else {
153
152
  return SpecMajorVersion.OAS3;
154
153
  }
@@ -84,8 +84,7 @@ describe('Arazzo criteria-unique', () => {
84
84
  externalRefResolver: new BaseResolver(),
85
85
  document,
86
86
  config: await makeConfig({
87
- rules: {},
88
- arazzoRules: { 'criteria-unique': 'error' },
87
+ rules: { 'criteria-unique': 'error' },
89
88
  }),
90
89
  });
91
90
 
@@ -71,8 +71,7 @@ describe('Arazzo no-actions-type-end', () => {
71
71
  externalRefResolver: new BaseResolver(),
72
72
  document,
73
73
  config: await makeConfig({
74
- rules: {},
75
- arazzoRules: { 'no-actions-type-end': 'error' },
74
+ rules: { 'no-actions-type-end': 'error' },
76
75
  }),
77
76
  });
78
77
 
@@ -76,8 +76,7 @@ describe('Arazzo no-criteria-xpath', () => {
76
76
  externalRefResolver: new BaseResolver(),
77
77
  document,
78
78
  config: await makeConfig({
79
- rules: {},
80
- arazzoRules: { 'no-criteria-xpath': 'error' },
79
+ rules: { 'no-criteria-xpath': 'error' },
81
80
  }),
82
81
  });
83
82
 
@@ -48,8 +48,7 @@ describe('Spot parameters-not-in-body', () => {
48
48
  externalRefResolver: new BaseResolver(),
49
49
  document,
50
50
  config: await makeConfig({
51
- rules: {},
52
- arazzoRules: { 'parameters-not-in-body': 'error' },
51
+ rules: { 'parameters-not-in-body': 'error' },
53
52
  }),
54
53
  });
55
54
 
@@ -62,8 +62,7 @@ describe('Arazzo parameters-unique', () => {
62
62
  externalRefResolver: new BaseResolver(),
63
63
  document,
64
64
  config: await makeConfig({
65
- rules: {},
66
- arazzoRules: { 'parameters-unique': 'error' },
65
+ rules: { 'parameters-unique': 'error' },
67
66
  }),
68
67
  });
69
68
 
@@ -71,8 +71,7 @@ describe('Arazzo requestBody-replacements-unique', () => {
71
71
  externalRefResolver: new BaseResolver(),
72
72
  document,
73
73
  config: await makeConfig({
74
- rules: {},
75
- arazzoRules: { 'requestBody-replacements-unique': 'error' },
74
+ rules: { 'requestBody-replacements-unique': 'error' },
76
75
  }),
77
76
  });
78
77
 
@@ -41,8 +41,7 @@ describe('Arazzo sourceDescription-type', () => {
41
41
  externalRefResolver: new BaseResolver(),
42
42
  document,
43
43
  config: await makeConfig({
44
- rules: {},
45
- arazzoRules: { 'sourceDescription-type': 'error' },
44
+ rules: { 'sourceDescription-type': 'error' },
46
45
  }),
47
46
  });
48
47
 
@@ -70,8 +69,7 @@ describe('Arazzo sourceDescription-type', () => {
70
69
  externalRefResolver: new BaseResolver(),
71
70
  document,
72
71
  config: await makeConfig({
73
- rules: {},
74
- arazzoRules: { 'sourceDescription-type': 'off' },
72
+ rules: { 'sourceDescription-type': 'off' },
75
73
  }),
76
74
  });
77
75
 
@@ -41,8 +41,7 @@ describe('Arazzo sourceDescription-name-unique', () => {
41
41
  externalRefResolver: new BaseResolver(),
42
42
  document,
43
43
  config: await makeConfig({
44
- rules: {},
45
- arazzoRules: { 'sourceDescription-name-unique': 'error' },
44
+ rules: { 'sourceDescription-name-unique': 'error' },
46
45
  }),
47
46
  });
48
47
 
@@ -0,0 +1,104 @@
1
+ import { outdent } from 'outdent';
2
+ import { lintDocument } from '../../../lint';
3
+ import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils';
4
+ import { BaseResolver } from '../../../resolve';
5
+
6
+ describe('Arazzo sourceDescriptions-not-empty', () => {
7
+ const document1 = parseYamlToDocument(
8
+ outdent`
9
+ arazzo: '1.0.0'
10
+ info:
11
+ title: Cool API
12
+ version: 1.0.0
13
+ description: A cool API
14
+ sourceDescriptions:
15
+ - name: museum-api
16
+ type: openapi
17
+ url: openapi.yaml
18
+ - name: museum-api
19
+ type: openapi
20
+ url: openapi.yaml
21
+ workflows:
22
+ - workflowId: get-museum-hours
23
+ description: This workflow demonstrates how to get the museum opening hours and buy tickets.
24
+ parameters:
25
+ - in: header
26
+ name: Authorization
27
+ value: Basic Og==
28
+ steps:
29
+ - stepId: get-museum-hours
30
+ description: >-
31
+ Get museum hours by resolving request details with getMuseumHours operationId from openapi.yaml description.
32
+ operationId: museum-api.getMuseumHours
33
+ successCriteria:
34
+ - condition: $statusCode == 200
35
+ `,
36
+ 'arazzo.yaml'
37
+ );
38
+
39
+ const document2 = parseYamlToDocument(
40
+ outdent`
41
+ arazzo: '1.0.0'
42
+ info:
43
+ title: Cool API
44
+ version: 1.0.0
45
+ description: A cool API
46
+ sourceDescriptions: []
47
+ workflows:
48
+ - workflowId: get-museum-hours
49
+ description: This workflow demonstrates how to get the museum opening hours and buy tickets.
50
+ parameters:
51
+ - in: header
52
+ name: Authorization
53
+ value: Basic Og==
54
+ steps:
55
+ - stepId: get-museum-hours
56
+ description: >-
57
+ Get museum hours by resolving request details with getMuseumHours operationId from openapi.yaml description.
58
+ operationId: museum-api.getMuseumHours
59
+ successCriteria:
60
+ - condition: $statusCode == 200
61
+ `,
62
+ 'arazzo.yaml'
63
+ );
64
+
65
+ it('should not report an error when sourceDescriptions have at least one entry.', async () => {
66
+ const results = await lintDocument({
67
+ externalRefResolver: new BaseResolver(),
68
+ document: document1,
69
+ config: await makeConfig({
70
+ rules: { 'sourceDescriptions-not-empty': 'error' },
71
+ }),
72
+ });
73
+
74
+ expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
75
+ });
76
+
77
+ it('should report an error when sourceDescriptions is empty list.', async () => {
78
+ const results = await lintDocument({
79
+ externalRefResolver: new BaseResolver(),
80
+ document: document2,
81
+ config: await makeConfig({
82
+ rules: { 'sourceDescriptions-not-empty': 'error' },
83
+ }),
84
+ });
85
+
86
+ expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
87
+ [
88
+ {
89
+ "location": [
90
+ {
91
+ "pointer": "#/sourceDescriptions",
92
+ "reportOnKey": false,
93
+ "source": "arazzo.yaml",
94
+ },
95
+ ],
96
+ "message": "The \`sourceDescriptions\` list must have at least one entry.",
97
+ "ruleId": "sourceDescriptions-not-empty",
98
+ "severity": "error",
99
+ "suggest": [],
100
+ },
101
+ ]
102
+ `);
103
+ });
104
+ });
@@ -60,8 +60,7 @@ describe('Arazzo step-onFailure-unique', () => {
60
60
  externalRefResolver: new BaseResolver(),
61
61
  document,
62
62
  config: await makeConfig({
63
- rules: {},
64
- arazzoRules: { 'step-onFailure-unique': 'error' },
63
+ rules: { 'step-onFailure-unique': 'error' },
65
64
  }),
66
65
  });
67
66
 
@@ -60,8 +60,7 @@ describe('Arazzo step-onSuccess-unique', () => {
60
60
  externalRefResolver: new BaseResolver(),
61
61
  document,
62
62
  config: await makeConfig({
63
- rules: {},
64
- arazzoRules: { 'step-onSuccess-unique': 'error' },
63
+ rules: { 'step-onSuccess-unique': 'error' },
65
64
  }),
66
65
  });
67
66
 
@@ -57,8 +57,7 @@ describe('Arazzo stepId-unique', () => {
57
57
  externalRefResolver: new BaseResolver(),
58
58
  document,
59
59
  config: await makeConfig({
60
- rules: {},
61
- arazzoRules: { 'stepId-unique': 'error' },
60
+ rules: { 'stepId-unique': 'error' },
62
61
  }),
63
62
  });
64
63
 
@@ -38,8 +38,7 @@ describe('Arazzo version-enum', () => {
38
38
  externalRefResolver: new BaseResolver(),
39
39
  document,
40
40
  config: await makeConfig({
41
- rules: {},
42
- arazzoRules: { 'version-enum': 'error' },
41
+ rules: { 'version-enum': 'error' },
43
42
  }),
44
43
  });
45
44
 
@@ -131,8 +131,7 @@ describe('Arazzo workflow-dependsOn', () => {
131
131
  externalRefResolver: new BaseResolver(),
132
132
  document,
133
133
  config: await makeConfig({
134
- rules: {},
135
- arazzoRules: { 'workflow-dependsOn': 'error' },
134
+ rules: { 'workflow-dependsOn': 'error' },
136
135
  }),
137
136
  });
138
137
 
@@ -160,8 +159,7 @@ describe('Arazzo workflow-dependsOn', () => {
160
159
  externalRefResolver: new BaseResolver(),
161
160
  document,
162
161
  config: await makeConfig({
163
- rules: {},
164
- arazzoRules: { 'workflow-dependsOn': 'off' },
162
+ rules: { 'workflow-dependsOn': 'off' },
165
163
  }),
166
164
  });
167
165
 
@@ -173,8 +171,7 @@ describe('Arazzo workflow-dependsOn', () => {
173
171
  externalRefResolver: new BaseResolver(),
174
172
  document: documentWithNotExistingWorkflows,
175
173
  config: await makeConfig({
176
- rules: {},
177
- arazzoRules: { 'workflow-dependsOn': 'error' },
174
+ rules: { 'workflow-dependsOn': 'error' },
178
175
  }),
179
176
  });
180
177
 
@@ -51,8 +51,7 @@ describe('Arazzo workflowId-unique', () => {
51
51
  externalRefResolver: new BaseResolver(),
52
52
  document,
53
53
  config: await makeConfig({
54
- rules: {},
55
- arazzoRules: { 'workflowId-unique': 'error' },
54
+ rules: { 'workflowId-unique': 'error' },
56
55
  }),
57
56
  });
58
57
 
@@ -80,8 +79,7 @@ describe('Arazzo workflowId-unique', () => {
80
79
  externalRefResolver: new BaseResolver(),
81
80
  document,
82
81
  config: await makeConfig({
83
- rules: {},
84
- arazzoRules: { 'workflowId-unique': 'off' },
82
+ rules: { 'workflowId-unique': 'off' },
85
83
  }),
86
84
  });
87
85
 
@@ -1,7 +1,7 @@
1
- import type { ArazzoRule } from '../../visitors';
1
+ import type { Arazzo1Rule } from '../../visitors';
2
2
  import type { UserContext } from '../../walk';
3
3
 
4
- export const CriteriaUnique: ArazzoRule = () => {
4
+ export const CriteriaUnique: Arazzo1Rule = () => {
5
5
  return {
6
6
  FailureActionObject: {
7
7
  enter(action, { report, location }: UserContext) {
@@ -1,7 +1,8 @@
1
- import { Spec } from '../common/spec';
1
+ import { Struct } from '../common/struct';
2
2
  import { Assertions } from '../common/assertions';
3
3
  import { ParametersNotInBody } from '../spot/parameters-not-in-body';
4
- import { SourceDescriptionType } from '../arazzo/source-description-type';
4
+ import { SourceDescriptionType } from '../arazzo/sourceDescription-type';
5
+ import { SourceDescriptionsNotEmpty } from './sourceDescriptions-not-empty';
5
6
  import { VersionEnum } from '../spot/version-enum';
6
7
  import { WorkflowIdUnique } from './workflowId-unique';
7
8
  import { StepIdUnique } from './stepId-unique';
@@ -15,26 +16,27 @@ import { NoCriteriaXpath } from '../spot/no-criteria-xpath';
15
16
  import { NoActionsTypeEnd } from '../spot/no-actions-type-end';
16
17
  import { CriteriaUnique } from './criteria-unique';
17
18
 
18
- import type { ArazzoRule } from '../../visitors';
19
- import type { ArazzoRuleSet } from '../../oas-types';
19
+ import type { Arazzo1Rule } from '../../visitors';
20
+ import type { Arazzo1RuleSet } from '../../oas-types';
20
21
 
21
- export const rules: ArazzoRuleSet<'built-in'> = {
22
- spec: Spec as ArazzoRule,
23
- assertions: Assertions as ArazzoRule,
24
- 'parameters-not-in-body': ParametersNotInBody as ArazzoRule,
25
- 'sourceDescription-type': SourceDescriptionType as ArazzoRule,
26
- 'version-enum': VersionEnum as ArazzoRule,
27
- 'workflowId-unique': WorkflowIdUnique as ArazzoRule,
28
- 'stepId-unique': StepIdUnique as ArazzoRule,
29
- 'sourceDescription-name-unique': SourceDescriptionsNameUnique as ArazzoRule,
30
- 'workflow-dependsOn': WorkflowDependsOn as ArazzoRule,
31
- 'parameters-unique': ParametersUnique as ArazzoRule,
32
- 'step-onSuccess-unique': StepOnSuccessUnique as ArazzoRule,
33
- 'step-onFailure-unique': StepOnFailureUnique as ArazzoRule,
34
- 'requestBody-replacements-unique': RequestBodyReplacementsUnique as ArazzoRule,
35
- 'no-criteria-xpath': NoCriteriaXpath as ArazzoRule,
36
- 'no-actions-type-end': NoActionsTypeEnd as ArazzoRule,
37
- 'criteria-unique': CriteriaUnique as ArazzoRule,
22
+ export const rules: Arazzo1RuleSet<'built-in'> = {
23
+ struct: Struct as Arazzo1Rule,
24
+ assertions: Assertions as Arazzo1Rule,
25
+ 'parameters-not-in-body': ParametersNotInBody,
26
+ 'sourceDescription-type': SourceDescriptionType,
27
+ 'version-enum': VersionEnum,
28
+ 'workflowId-unique': WorkflowIdUnique,
29
+ 'stepId-unique': StepIdUnique,
30
+ 'sourceDescription-name-unique': SourceDescriptionsNameUnique,
31
+ 'sourceDescriptions-not-empty': SourceDescriptionsNotEmpty,
32
+ 'workflow-dependsOn': WorkflowDependsOn,
33
+ 'parameters-unique': ParametersUnique,
34
+ 'step-onSuccess-unique': StepOnSuccessUnique,
35
+ 'step-onFailure-unique': StepOnFailureUnique,
36
+ 'requestBody-replacements-unique': RequestBodyReplacementsUnique,
37
+ 'no-criteria-xpath': NoCriteriaXpath,
38
+ 'no-actions-type-end': NoActionsTypeEnd,
39
+ 'criteria-unique': CriteriaUnique,
38
40
  };
39
41
 
40
42
  export const preprocessors = {};
@@ -1,7 +1,7 @@
1
- import type { ArazzoRule } from '../../visitors';
1
+ import type { Arazzo1Rule } from '../../visitors';
2
2
  import type { UserContext } from '../../walk';
3
3
 
4
- export const ParametersUnique: ArazzoRule = () => {
4
+ export const ParametersUnique: Arazzo1Rule = () => {
5
5
  return {
6
6
  Parameters: {
7
7
  enter(parameters, { report, location }: UserContext) {
@@ -1,7 +1,7 @@
1
- import type { ArazzoRule } from '../../visitors';
1
+ import type { Arazzo1Rule } from '../../visitors';
2
2
  import type { UserContext } from '../../walk';
3
3
 
4
- export const RequestBodyReplacementsUnique: ArazzoRule = () => {
4
+ export const RequestBodyReplacementsUnique: Arazzo1Rule = () => {
5
5
  const seenReplacements = new Set();
6
6
 
7
7
  return {
@@ -1,16 +1,17 @@
1
- import type { ArazzoRule } from '../../visitors';
1
+ import type { Arazzo1Rule } from '../../visitors';
2
2
  import type { UserContext } from '../../walk';
3
3
 
4
- export const SourceDescriptionType: ArazzoRule = () => {
4
+ export const SourceDescriptionType: Arazzo1Rule = () => {
5
5
  return {
6
6
  SourceDescriptions: {
7
- enter(SourceDescriptions, { report, location }: UserContext) {
8
- for (const sourceDescription of SourceDescriptions) {
7
+ enter(sourceDescriptions, { report, location }: UserContext) {
8
+ if (!sourceDescriptions.length) return;
9
+ for (const sourceDescription of sourceDescriptions) {
9
10
  if (!['openapi', 'arazzo'].includes(sourceDescription?.type)) {
10
11
  report({
11
12
  message:
12
13
  'The `type` property of the `sourceDescription` object must be either `openapi` or `arazzo`.',
13
- location: location.child([SourceDescriptions.indexOf(sourceDescription)]),
14
+ location: location.child([sourceDescriptions.indexOf(sourceDescription)]),
14
15
  });
15
16
  }
16
17
  }
@@ -1,7 +1,7 @@
1
- import type { ArazzoRule } from '../../visitors';
1
+ import type { Arazzo1Rule } from '../../visitors';
2
2
  import type { UserContext } from '../../walk';
3
3
 
4
- export const SourceDescriptionsNameUnique: ArazzoRule = () => {
4
+ export const SourceDescriptionsNameUnique: Arazzo1Rule = () => {
5
5
  const seenSourceDescriptions = new Set();
6
6
 
7
7
  return {
@@ -0,0 +1,17 @@
1
+ import type { Arazzo1Rule } from '../../visitors';
2
+ import type { UserContext } from '../../walk';
3
+
4
+ export const SourceDescriptionsNotEmpty: Arazzo1Rule = () => {
5
+ return {
6
+ SourceDescriptions: {
7
+ enter(sourceDescriptions, { report, location }: UserContext) {
8
+ if (!sourceDescriptions?.length) {
9
+ report({
10
+ message: 'The `sourceDescriptions` list must have at least one entry.',
11
+ location,
12
+ });
13
+ }
14
+ },
15
+ },
16
+ };
17
+ };
@@ -1,7 +1,7 @@
1
- import type { ArazzoRule } from '../../visitors';
1
+ import type { Arazzo1Rule } from '../../visitors';
2
2
  import type { UserContext } from '../../walk';
3
3
 
4
- export const StepOnFailureUnique: ArazzoRule = () => {
4
+ export const StepOnFailureUnique: Arazzo1Rule = () => {
5
5
  return {
6
6
  OnFailureActionList: {
7
7
  enter(onFailureActionList, { report, location }: UserContext) {
@@ -1,7 +1,7 @@
1
- import type { ArazzoRule } from '../../visitors';
1
+ import type { Arazzo1Rule } from '../../visitors';
2
2
  import type { UserContext } from '../../walk';
3
3
 
4
- export const StepOnSuccessUnique: ArazzoRule = () => {
4
+ export const StepOnSuccessUnique: Arazzo1Rule = () => {
5
5
  return {
6
6
  OnSuccessActionList: {
7
7
  enter(onSuccessActionList, { report, location }: UserContext) {
@@ -1,7 +1,7 @@
1
- import type { ArazzoRule } from '../../visitors';
1
+ import type { Arazzo1Rule } from '../../visitors';
2
2
  import type { UserContext } from '../../walk';
3
3
 
4
- export const StepIdUnique: ArazzoRule = () => {
4
+ export const StepIdUnique: Arazzo1Rule = () => {
5
5
  return {
6
6
  Workflow: {
7
7
  enter(workflow, { report, location }: UserContext) {
@@ -1,7 +1,7 @@
1
- import type { ArazzoRule } from '../../visitors';
1
+ import type { Arazzo1Rule } from '../../visitors';
2
2
  import type { UserContext } from '../../walk';
3
3
 
4
- export const WorkflowDependsOn: ArazzoRule = () => {
4
+ export const WorkflowDependsOn: Arazzo1Rule = () => {
5
5
  const seenWorkflow = new Set();
6
6
  const existingSourceDescriptions = new Set();
7
7
  const existingWorkflowIds = new Set();
@@ -1,7 +1,7 @@
1
- import type { ArazzoRule } from '../../visitors';
1
+ import type { Arazzo1Rule } from '../../visitors';
2
2
  import type { UserContext } from '../../walk';
3
3
 
4
- export const WorkflowIdUnique: ArazzoRule = () => {
4
+ export const WorkflowIdUnique: Arazzo1Rule = () => {
5
5
  const seenWorkflow = new Set();
6
6
 
7
7
  return {
@@ -1,5 +1,5 @@
1
1
  import { Assertions } from '../common/assertions';
2
- import { Spec } from '../common/spec';
2
+ import { Struct } from '../common/struct';
3
3
  import { InfoContact } from '../common/info-contact';
4
4
  import { InfoLicenseStrict } from '../common/info-license-strict';
5
5
  import { OperationOperationId } from '../common/operation-operationId';
@@ -12,7 +12,10 @@ import type { Async2Rule } from '../../visitors';
12
12
  import type { Async2RuleSet } from '../../oas-types';
13
13
 
14
14
  export const rules: Async2RuleSet<'built-in'> = {
15
- spec: Spec as Async2Rule,
15
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
16
+ //@ts-ignore TODO: This is depricated property `spec` and should be removed in the future
17
+ spec: Struct as Async2Rule,
18
+ struct: Struct as Async2Rule,
16
19
  assertions: Assertions as Async2Rule,
17
20
  'info-contact': InfoContact as Async2Rule,
18
21
  'info-license-strict': InfoLicenseStrict as Async2Rule,