@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/config/all.ts CHANGED
@@ -2,52 +2,47 @@ import type { PluginStyleguideConfig } from './types';
2
2
 
3
3
  const all: PluginStyleguideConfig<'built-in'> = {
4
4
  rules: {
5
+ struct: 'error',
6
+ },
7
+ oas2Rules: {
8
+ 'boolean-parameter-prefixes': 'error',
5
9
  'info-contact': 'error',
6
10
  'info-license': 'error',
7
11
  'info-license-url': 'error',
8
12
  'info-license-strict': 'error',
9
- 'tag-description': 'error',
10
- 'tags-alphabetical': 'error',
11
- 'parameter-description': 'error',
13
+ 'no-path-trailing-slash': 'error',
12
14
  'no-identical-paths': 'error',
13
15
  'no-ambiguous-paths': 'error',
14
- 'no-path-trailing-slash': 'error',
15
- 'path-segment-plural': 'error',
16
- 'path-declaration-must-exist': 'error',
17
- 'path-not-include-query': 'error',
18
- 'path-parameters-defined': 'error',
19
- 'operation-description': 'error',
20
- 'operation-2xx-response': 'error',
21
- 'operation-4xx-response': 'error',
22
- 'operation-operationId': 'error',
16
+ 'no-invalid-schema-examples': 'error',
17
+ 'no-invalid-parameter-examples': 'error',
18
+ 'no-http-verbs-in-paths': 'error',
19
+ 'no-enum-type-mismatch': 'error',
20
+ 'no-unresolved-refs': 'error',
21
+ 'no-required-schema-properties-undefined': 'error',
23
22
  'operation-summary': 'error',
23
+ 'operation-operationId': 'error',
24
24
  'operation-operationId-unique': 'error',
25
25
  'operation-operationId-url-safe': 'error',
26
+ 'operation-description': 'error',
27
+ 'operation-2xx-response': 'error',
28
+ 'operation-4xx-response': 'error',
26
29
  'operation-parameters-unique': 'error',
27
30
  'operation-tag-defined': 'error',
28
- 'security-defined': 'error',
29
31
  'operation-singular-tag': 'error',
30
- 'no-unresolved-refs': 'error',
31
- 'no-enum-type-mismatch': 'error',
32
+ 'parameter-description': 'error',
33
+ 'path-declaration-must-exist': 'error',
34
+ 'path-not-include-query': 'error',
35
+ 'path-parameters-defined': 'error',
32
36
  'paths-kebab-case': 'error',
33
- 'no-http-verbs-in-paths': 'error',
34
37
  'path-excludes-patterns': {
35
38
  severity: 'error',
36
39
  patterns: [],
37
40
  },
38
- spec: 'error',
39
- 'no-invalid-schema-examples': 'error',
40
- 'no-invalid-parameter-examples': 'error',
41
- 'scalar-property-missing-example': 'error',
42
- 'spec-strict-refs': 'error',
43
41
  'path-http-verbs-order': 'error',
44
42
  'path-params-defined': 'error',
43
+ 'path-segment-plural': 'error',
45
44
  'required-string-property-missing-min-length': 'error',
46
45
  'response-contains-header': 'error',
47
- 'no-required-schema-properties-undefined': 'error',
48
- },
49
- oas2Rules: {
50
- 'boolean-parameter-prefixes': 'error',
51
46
  'request-mime-type': {
52
47
  severity: 'error',
53
48
  allowedValues: ['application/json'],
@@ -57,8 +52,29 @@ const all: PluginStyleguideConfig<'built-in'> = {
57
52
  allowedValues: ['application/json'],
58
53
  },
59
54
  'response-contains-property': 'error',
55
+ 'security-defined': 'error',
56
+ 'spec-strict-refs': 'error',
57
+ 'scalar-property-missing-example': 'error',
58
+ 'tag-description': 'error',
59
+ 'tags-alphabetical': 'error',
60
60
  },
61
61
  oas3_0Rules: {
62
+ 'array-parameter-serialization': 'error',
63
+ 'boolean-parameter-prefixes': 'error',
64
+ 'component-name-unique': 'error',
65
+ 'info-contact': 'error',
66
+ 'info-license': 'error',
67
+ 'info-license-url': 'error',
68
+ 'info-license-strict': 'error',
69
+ 'no-path-trailing-slash': 'error',
70
+ 'no-identical-paths': 'error',
71
+ 'no-ambiguous-paths': 'error',
72
+ 'no-invalid-schema-examples': 'error',
73
+ 'no-invalid-parameter-examples': 'error',
74
+ 'no-http-verbs-in-paths': 'error',
75
+ 'no-enum-type-mismatch': 'error',
76
+ 'no-unresolved-refs': 'error',
77
+ 'no-required-schema-properties-undefined': 'error',
62
78
  'no-invalid-media-type-examples': 'error',
63
79
  'no-server-example.com': 'error',
64
80
  'no-server-trailing-slash': 'error',
@@ -67,8 +83,31 @@ const all: PluginStyleguideConfig<'built-in'> = {
67
83
  'no-unused-components': 'error',
68
84
  'no-undefined-server-variable': 'error',
69
85
  'no-server-variables-empty-enum': 'error',
86
+ 'operation-summary': 'error',
87
+ 'operation-operationId': 'error',
88
+ 'operation-operationId-unique': 'error',
89
+ 'operation-operationId-url-safe': 'error',
90
+ 'operation-description': 'error',
91
+ 'operation-2xx-response': 'error',
92
+ 'operation-4xx-response': 'error',
70
93
  'operation-4xx-problem-details-rfc7807': 'error',
71
- 'boolean-parameter-prefixes': 'error',
94
+ 'operation-parameters-unique': 'error',
95
+ 'operation-tag-defined': 'error',
96
+ 'operation-singular-tag': 'error',
97
+ 'parameter-description': 'error',
98
+ 'path-declaration-must-exist': 'error',
99
+ 'path-not-include-query': 'error',
100
+ 'path-parameters-defined': 'error',
101
+ 'paths-kebab-case': 'error',
102
+ 'path-excludes-patterns': {
103
+ severity: 'error',
104
+ patterns: [],
105
+ },
106
+ 'path-http-verbs-order': 'error',
107
+ 'path-params-defined': 'error',
108
+ 'path-segment-plural': 'error',
109
+ 'required-string-property-missing-min-length': 'error',
110
+ 'response-contains-header': 'error',
72
111
  'request-mime-type': {
73
112
  severity: 'error',
74
113
  allowedValues: ['application/json'],
@@ -77,12 +116,31 @@ const all: PluginStyleguideConfig<'built-in'> = {
77
116
  severity: 'error',
78
117
  allowedValues: ['application/json'],
79
118
  },
80
- 'component-name-unique': 'error',
81
119
  'response-contains-property': 'error',
120
+ 'security-defined': 'error',
121
+ 'spec-strict-refs': 'error',
122
+ 'scalar-property-missing-example': 'error',
82
123
  'spec-components-invalid-map-name': 'error',
83
- 'array-parameter-serialization': 'error',
124
+ 'tag-description': 'error',
125
+ 'tags-alphabetical': 'error',
84
126
  },
85
127
  oas3_1Rules: {
128
+ 'array-parameter-serialization': 'error',
129
+ 'boolean-parameter-prefixes': 'error',
130
+ 'component-name-unique': 'error',
131
+ 'info-contact': 'error',
132
+ 'info-license': 'error',
133
+ 'info-license-url': 'error',
134
+ 'info-license-strict': 'error',
135
+ 'no-path-trailing-slash': 'error',
136
+ 'no-identical-paths': 'error',
137
+ 'no-ambiguous-paths': 'error',
138
+ 'no-invalid-schema-examples': 'error',
139
+ 'no-invalid-parameter-examples': 'error',
140
+ 'no-http-verbs-in-paths': 'error',
141
+ 'no-enum-type-mismatch': 'error',
142
+ 'no-unresolved-refs': 'error',
143
+ 'no-required-schema-properties-undefined': 'error',
86
144
  'no-invalid-media-type-examples': 'error',
87
145
  'no-server-example.com': 'error',
88
146
  'no-server-trailing-slash': 'error',
@@ -91,8 +149,31 @@ const all: PluginStyleguideConfig<'built-in'> = {
91
149
  'no-unused-components': 'error',
92
150
  'no-undefined-server-variable': 'error',
93
151
  'no-server-variables-empty-enum': 'error',
152
+ 'parameter-description': 'error',
153
+ 'path-declaration-must-exist': 'error',
154
+ 'path-not-include-query': 'error',
155
+ 'path-parameters-defined': 'error',
156
+ 'paths-kebab-case': 'error',
157
+ 'path-excludes-patterns': {
158
+ severity: 'error',
159
+ patterns: [],
160
+ },
161
+ 'path-http-verbs-order': 'error',
162
+ 'path-params-defined': 'error',
163
+ 'path-segment-plural': 'error',
164
+ 'operation-summary': 'error',
165
+ 'operation-operationId': 'error',
166
+ 'operation-operationId-unique': 'error',
167
+ 'operation-operationId-url-safe': 'error',
168
+ 'operation-description': 'error',
169
+ 'operation-2xx-response': 'error',
170
+ 'operation-4xx-response': 'error',
94
171
  'operation-4xx-problem-details-rfc7807': 'error',
95
- 'boolean-parameter-prefixes': 'error',
172
+ 'operation-parameters-unique': 'error',
173
+ 'operation-tag-defined': 'error',
174
+ 'operation-singular-tag': 'error',
175
+ 'required-string-property-missing-min-length': 'error',
176
+ 'response-contains-header': 'error',
96
177
  'request-mime-type': {
97
178
  severity: 'error',
98
179
  allowedValues: ['application/json'],
@@ -101,47 +182,48 @@ const all: PluginStyleguideConfig<'built-in'> = {
101
182
  severity: 'error',
102
183
  allowedValues: ['application/json'],
103
184
  },
104
- 'component-name-unique': 'error',
105
185
  'response-contains-property': 'error',
186
+ 'security-defined': 'error',
187
+ 'spec-strict-refs': 'error',
188
+ 'scalar-property-missing-example': 'error',
106
189
  'spec-components-invalid-map-name': 'error',
107
- 'array-parameter-serialization': 'error',
190
+ 'tag-description': 'error',
191
+ 'tags-alphabetical': 'error',
108
192
  },
109
193
  async2Rules: {
110
- spec: 'error',
194
+ 'channels-kebab-case': 'error',
111
195
  'info-contact': 'error',
112
196
  'info-license-strict': 'error',
197
+ 'no-channel-trailing-slash': 'error',
113
198
  'operation-operationId': 'error',
114
199
  'tag-description': 'error',
115
200
  'tags-alphabetical': 'error',
116
- 'channels-kebab-case': 'error',
117
- 'no-channel-trailing-slash': 'error',
118
201
  },
119
202
  async3Rules: {
120
- spec: 'error',
203
+ 'channels-kebab-case': 'error',
121
204
  'info-contact': 'error',
122
205
  'info-license-strict': 'error',
206
+ 'no-channel-trailing-slash': 'error',
123
207
  'operation-operationId': 'error',
124
208
  'tag-description': 'error',
125
209
  'tags-alphabetical': 'error',
126
- 'channels-kebab-case': 'error',
127
- 'no-channel-trailing-slash': 'error',
128
210
  },
129
- arazzoRules: {
130
- spec: 'error',
211
+ arazzo1Rules: {
212
+ 'criteria-unique': 'error',
213
+ 'no-criteria-xpath': 'error',
214
+ 'no-actions-type-end': 'error',
131
215
  'parameters-not-in-body': 'error',
216
+ 'parameters-unique': 'error',
217
+ 'requestBody-replacements-unique': 'error',
132
218
  'sourceDescription-type': 'error',
133
- 'version-enum': 'error',
134
- 'workflowId-unique': 'error',
219
+ 'step-onSuccess-unique': 'error',
220
+ 'step-onFailure-unique': 'error',
135
221
  'stepId-unique': 'error',
136
222
  'sourceDescription-name-unique': 'error',
223
+ 'sourceDescriptions-not-empty': 'error',
224
+ 'version-enum': 'error',
225
+ 'workflowId-unique': 'error',
137
226
  'workflow-dependsOn': 'error',
138
- 'parameters-unique': 'error',
139
- 'step-onSuccess-unique': 'error',
140
- 'step-onFailure-unique': 'error',
141
- 'requestBody-replacements-unique': 'error',
142
- 'no-criteria-xpath': 'error',
143
- 'no-actions-type-end': 'error',
144
- 'criteria-unique': 'error',
145
227
  },
146
228
  };
147
229
 
@@ -2,51 +2,53 @@ import recommended from './recommended';
2
2
  import recommendedStrict from './recommended-strict';
3
3
  import all from './all';
4
4
  import minimal from './minimal';
5
+ import spec from './spec';
5
6
  import { rules as oas3Rules, preprocessors as oas3Preprocessors } from '../rules/oas3';
6
7
  import { rules as oas2Rules, preprocessors as oas2Preprocessors } from '../rules/oas2';
7
8
  import { rules as async2Rules, preprocessors as async2Preprocessors } from '../rules/async2';
8
9
  import { rules as async3Rules, preprocessors as async3Preprocessors } from '../rules/async3';
9
- import { rules as arazzoRules, preprocessors as arazzoPreprocessors } from '../rules/arazzo';
10
+ import { rules as arazzo1Rules, preprocessors as arazzoPreprocessors } from '../rules/arazzo';
10
11
  import { decorators as oas3Decorators } from '../decorators/oas3';
11
12
  import { decorators as oas2Decorators } from '../decorators/oas2';
12
13
  import { decorators as async2Decorators } from '../decorators/async2';
13
14
  import { decorators as async3Decorators } from '../decorators/async3';
14
- import { decorators as arazzoDecorators } from '../decorators/arazzo';
15
+ import { decorators as arazzo1Decorators } from '../decorators/arazzo';
15
16
 
16
- import type { CustomRulesConfig, StyleguideRawConfig, Plugin } from './types';
17
+ import type { StyleguideRawConfig, Plugin } from './types';
17
18
 
18
19
  export const builtInConfigs: Record<string, StyleguideRawConfig> = {
19
20
  recommended,
20
21
  'recommended-strict': recommendedStrict,
21
22
  minimal,
22
23
  all,
24
+ spec,
23
25
  'redocly-registry': {
24
26
  decorators: { 'registry-dependencies': 'on' },
25
27
  },
26
28
  };
27
29
 
28
- export const defaultPlugin: Plugin = {
30
+ export const defaultPlugin: Plugin<'built-in'> = {
29
31
  id: '', // default plugin doesn't have id
30
32
  rules: {
31
33
  oas3: oas3Rules,
32
34
  oas2: oas2Rules,
33
35
  async2: async2Rules,
34
36
  async3: async3Rules,
35
- arazzo: arazzoRules,
36
- } as CustomRulesConfig,
37
+ arazzo1: arazzo1Rules,
38
+ },
37
39
  preprocessors: {
38
40
  oas3: oas3Preprocessors,
39
41
  oas2: oas2Preprocessors,
40
42
  async2: async2Preprocessors,
41
43
  async3: async3Preprocessors,
42
- arazzo: arazzoPreprocessors,
44
+ arazzo1: arazzoPreprocessors,
43
45
  },
44
46
  decorators: {
45
47
  oas3: oas3Decorators,
46
48
  oas2: oas2Decorators,
47
49
  async2: async2Decorators,
48
50
  async3: async3Decorators,
49
- arazzo: arazzoDecorators,
51
+ arazzo1: arazzo1Decorators,
50
52
  },
51
53
  configs: builtInConfigs,
52
54
  };
@@ -261,8 +261,8 @@ export async function resolvePlugins(
261
261
  if (pluginModule.rules.async3) {
262
262
  plugin.rules.async3 = prefixRules(pluginModule.rules.async3, id);
263
263
  }
264
- if (pluginModule.rules.arazzo) {
265
- plugin.rules.arazzo = prefixRules(pluginModule.rules.arazzo, id);
264
+ if (pluginModule.rules.arazzo1) {
265
+ plugin.rules.arazzo1 = prefixRules(pluginModule.rules.arazzo1, id);
266
266
  }
267
267
  }
268
268
  if (pluginModule.preprocessors) {
@@ -271,7 +271,7 @@ export async function resolvePlugins(
271
271
  !pluginModule.preprocessors.oas2 &&
272
272
  !pluginModule.preprocessors.async2 &&
273
273
  !pluginModule.preprocessors.async3 &&
274
- !pluginModule.preprocessors.arazzo
274
+ !pluginModule.preprocessors.arazzo1
275
275
  ) {
276
276
  throw new Error(
277
277
  `Plugin \`preprocessors\` must have \`oas3\`, \`oas2\` or \`async2\` preprocessors "${p}.`
@@ -290,8 +290,8 @@ export async function resolvePlugins(
290
290
  if (pluginModule.preprocessors.async3) {
291
291
  plugin.preprocessors.async3 = prefixRules(pluginModule.preprocessors.async3, id);
292
292
  }
293
- if (pluginModule.preprocessors.arazzo) {
294
- plugin.preprocessors.arazzo = prefixRules(pluginModule.preprocessors.arazzo, id);
293
+ if (pluginModule.preprocessors.arazzo1) {
294
+ plugin.preprocessors.arazzo1 = prefixRules(pluginModule.preprocessors.arazzo1, id);
295
295
  }
296
296
  }
297
297
 
@@ -301,7 +301,7 @@ export async function resolvePlugins(
301
301
  !pluginModule.decorators.oas2 &&
302
302
  !pluginModule.decorators.async2 &&
303
303
  !pluginModule.decorators.async3 &&
304
- !pluginModule.decorators.arazzo
304
+ !pluginModule.decorators.arazzo1
305
305
  ) {
306
306
  throw new Error(
307
307
  `Plugin \`decorators\` must have \`oas3\`, \`oas2\`, \`async2\` or \`async3\` decorators "${p}.`
@@ -320,8 +320,8 @@ export async function resolvePlugins(
320
320
  if (pluginModule.decorators.async3) {
321
321
  plugin.decorators.async3 = prefixRules(pluginModule.decorators.async3, id);
322
322
  }
323
- if (pluginModule.decorators.arazzo) {
324
- plugin.decorators.arazzo = prefixRules(pluginModule.decorators.arazzo, id);
323
+ if (pluginModule.decorators.arazzo1) {
324
+ plugin.decorators.arazzo1 = prefixRules(pluginModule.decorators.arazzo1, id);
325
325
  }
326
326
  }
327
327
 
@@ -520,7 +520,7 @@ function getMergedRawStyleguideConfig(
520
520
  oas3_1Rules: { ...rootStyleguideConfig?.oas3_1Rules, ...apiStyleguideConfig?.oas3_1Rules },
521
521
  async2Rules: { ...rootStyleguideConfig?.async2Rules, ...apiStyleguideConfig?.async2Rules },
522
522
  async3Rules: { ...rootStyleguideConfig?.async3Rules, ...apiStyleguideConfig?.async3Rules },
523
- arazzoRules: { ...rootStyleguideConfig?.arazzoRules, ...apiStyleguideConfig?.arazzoRules },
523
+ arazzo1Rules: { ...rootStyleguideConfig?.arazzo1Rules, ...apiStyleguideConfig?.arazzo1Rules },
524
524
  preprocessors: {
525
525
  ...rootStyleguideConfig?.preprocessors,
526
526
  ...apiStyleguideConfig?.preprocessors,
@@ -1,7 +1,7 @@
1
1
  import * as fs from 'fs';
2
2
  import * as path from 'path';
3
3
  import { parseYaml, stringifyYaml } from '../js-yaml';
4
- import { slash, doesYamlFileExist } from '../utils';
4
+ import { slash, doesYamlFileExist, isPlainObject, showWarningForDeprecatedField } from '../utils';
5
5
  import { SpecVersion, SpecMajorVersion } from '../oas-types';
6
6
  import { isBrowser } from '../env';
7
7
  import { getResolveConfig } from './utils';
@@ -13,7 +13,7 @@ import type {
13
13
  Oas3RuleSet,
14
14
  Async2RuleSet,
15
15
  Async3RuleSet,
16
- ArazzoRuleSet,
16
+ Arazzo1RuleSet,
17
17
  } from '../oas-types';
18
18
  import type { NodeType } from '../types';
19
19
  import type {
@@ -67,16 +67,25 @@ export class StyleguideConfig {
67
67
  this.doNotResolveExamples = !!rawConfig.doNotResolveExamples;
68
68
  this.recommendedFallback = rawConfig.recommendedFallback || false;
69
69
 
70
+ const ruleGroups: (keyof ResolvedStyleguideConfig)[] = [
71
+ 'rules',
72
+ 'oas2Rules',
73
+ 'oas3_0Rules',
74
+ 'oas3_1Rules',
75
+ 'async2Rules',
76
+ 'async3Rules',
77
+ 'arazzo1Rules',
78
+ ];
79
+
80
+ replaceSpecWithStruct(ruleGroups, rawConfig);
81
+
70
82
  this.rules = {
71
83
  [SpecVersion.OAS2]: { ...rawConfig.rules, ...rawConfig.oas2Rules },
72
84
  [SpecVersion.OAS3_0]: { ...rawConfig.rules, ...rawConfig.oas3_0Rules },
73
85
  [SpecVersion.OAS3_1]: { ...rawConfig.rules, ...rawConfig.oas3_1Rules },
74
86
  [SpecVersion.Async2]: { ...rawConfig.rules, ...rawConfig.async2Rules },
75
87
  [SpecVersion.Async3]: { ...rawConfig.rules, ...rawConfig.async3Rules },
76
- [SpecVersion.Arazzo]: {
77
- ...(rawConfig.arazzoRules || {}),
78
- ...(rawConfig.rules?.assertions ? { assertions: rawConfig.rules.assertions } : {}),
79
- },
88
+ [SpecVersion.Arazzo1]: { ...rawConfig.rules, ...rawConfig.arazzo1Rules },
80
89
  };
81
90
 
82
91
  this.preprocessors = {
@@ -85,7 +94,7 @@ export class StyleguideConfig {
85
94
  [SpecVersion.OAS3_1]: { ...rawConfig.preprocessors, ...rawConfig.oas3_1Preprocessors },
86
95
  [SpecVersion.Async2]: { ...rawConfig.preprocessors, ...rawConfig.async2Preprocessors },
87
96
  [SpecVersion.Async3]: { ...rawConfig.preprocessors, ...rawConfig.async3Preprocessors },
88
- [SpecVersion.Arazzo]: { ...rawConfig.arazzoPreprocessors },
97
+ [SpecVersion.Arazzo1]: { ...rawConfig.arazzo1Preprocessors },
89
98
  };
90
99
 
91
100
  this.decorators = {
@@ -94,7 +103,7 @@ export class StyleguideConfig {
94
103
  [SpecVersion.OAS3_1]: { ...rawConfig.decorators, ...rawConfig.oas3_1Decorators },
95
104
  [SpecVersion.Async2]: { ...rawConfig.decorators, ...rawConfig.async2Decorators },
96
105
  [SpecVersion.Async3]: { ...rawConfig.decorators, ...rawConfig.async3Decorators },
97
- [SpecVersion.Arazzo]: { ...rawConfig.arazzoDecorators },
106
+ [SpecVersion.Arazzo1]: { ...rawConfig.arazzo1Decorators },
98
107
  };
99
108
 
100
109
  this.extendPaths = rawConfig.extendPaths || [];
@@ -111,6 +120,8 @@ export class StyleguideConfig {
111
120
  Record<string, Set<string>>
112
121
  >) || {};
113
122
 
123
+ replaceSpecWithStruct(Object.keys(this.ignore), this.ignore);
124
+
114
125
  // resolve ignore paths
115
126
  for (const fileName of Object.keys(this.ignore)) {
116
127
  this.ignore[
@@ -192,9 +203,9 @@ export class StyleguideConfig {
192
203
  if (!plugin.typeExtension.async3) continue;
193
204
  extendedTypes = plugin.typeExtension.async3(extendedTypes, version);
194
205
  break;
195
- case SpecVersion.Arazzo:
196
- if (!plugin.typeExtension.arazzo) continue;
197
- extendedTypes = plugin.typeExtension.arazzo(extendedTypes, version);
206
+ case SpecVersion.Arazzo1:
207
+ if (!plugin.typeExtension.arazzo1) continue;
208
+ extendedTypes = plugin.typeExtension.arazzo1(extendedTypes, version);
198
209
  break;
199
210
  default:
200
211
  throw new Error('Not implemented');
@@ -268,25 +279,25 @@ export class StyleguideConfig {
268
279
  };
269
280
  }
270
281
 
271
- getRulesForOasVersion(version: SpecMajorVersion) {
282
+ getRulesForSpecVersion(version: SpecMajorVersion) {
272
283
  switch (version) {
273
284
  case SpecMajorVersion.OAS3:
274
285
  // eslint-disable-next-line no-case-declarations
275
- const oas3Rules: Oas3RuleSet[] = []; // default ruleset
286
+ const oas3Rules: Oas3RuleSet[] = [];
276
287
  this.plugins.forEach((p) => p.preprocessors?.oas3 && oas3Rules.push(p.preprocessors.oas3));
277
288
  this.plugins.forEach((p) => p.rules?.oas3 && oas3Rules.push(p.rules.oas3));
278
289
  this.plugins.forEach((p) => p.decorators?.oas3 && oas3Rules.push(p.decorators.oas3));
279
290
  return oas3Rules;
280
291
  case SpecMajorVersion.OAS2:
281
292
  // eslint-disable-next-line no-case-declarations
282
- const oas2Rules: Oas2RuleSet[] = []; // default ruleset
293
+ const oas2Rules: Oas2RuleSet[] = [];
283
294
  this.plugins.forEach((p) => p.preprocessors?.oas2 && oas2Rules.push(p.preprocessors.oas2));
284
295
  this.plugins.forEach((p) => p.rules?.oas2 && oas2Rules.push(p.rules.oas2));
285
296
  this.plugins.forEach((p) => p.decorators?.oas2 && oas2Rules.push(p.decorators.oas2));
286
297
  return oas2Rules;
287
298
  case SpecMajorVersion.Async2:
288
299
  // eslint-disable-next-line no-case-declarations
289
- const asyncApi2Rules: Async2RuleSet[] = []; // default ruleset
300
+ const asyncApi2Rules: Async2RuleSet[] = [];
290
301
  this.plugins.forEach(
291
302
  (p) => p.preprocessors?.async2 && asyncApi2Rules.push(p.preprocessors.async2)
292
303
  );
@@ -297,7 +308,7 @@ export class StyleguideConfig {
297
308
  return asyncApi2Rules;
298
309
  case SpecMajorVersion.Async3:
299
310
  // eslint-disable-next-line no-case-declarations
300
- const asyncApi3Rules: Async3RuleSet[] = []; // default ruleset
311
+ const asyncApi3Rules: Async3RuleSet[] = [];
301
312
  this.plugins.forEach(
302
313
  (p) => p.preprocessors?.async3 && asyncApi3Rules.push(p.preprocessors.async3)
303
314
  );
@@ -306,15 +317,17 @@ export class StyleguideConfig {
306
317
  (p) => p.decorators?.async3 && asyncApi3Rules.push(p.decorators.async3)
307
318
  );
308
319
  return asyncApi3Rules;
309
- case SpecMajorVersion.Arazzo:
320
+ case SpecMajorVersion.Arazzo1:
310
321
  // eslint-disable-next-line no-case-declarations
311
- const arazzoRules: ArazzoRuleSet[] = []; // default ruleset
322
+ const arazzo1Rules: Arazzo1RuleSet[] = [];
323
+ this.plugins.forEach(
324
+ (p) => p.preprocessors?.arazzo1 && arazzo1Rules.push(p.preprocessors.arazzo1)
325
+ );
326
+ this.plugins.forEach((p) => p.rules?.arazzo1 && arazzo1Rules.push(p.rules.arazzo1));
312
327
  this.plugins.forEach(
313
- (p) => p.preprocessors?.arazzo && arazzoRules.push(p.preprocessors.arazzo)
328
+ (p) => p.decorators?.arazzo1 && arazzo1Rules.push(p.decorators.arazzo1)
314
329
  );
315
- this.plugins.forEach((p) => p.rules?.arazzo && arazzoRules.push(p.rules.arazzo));
316
- this.plugins.forEach((p) => p.decorators?.arazzo && arazzoRules.push(p.decorators.arazzo));
317
- return arazzoRules;
330
+ return arazzo1Rules;
318
331
  }
319
332
  }
320
333
 
@@ -356,6 +369,17 @@ export class StyleguideConfig {
356
369
  }
357
370
  }
358
371
 
372
+ // To support backwards compatibility with the old `spec` key we rename it to `struct`.
373
+ function replaceSpecWithStruct(ruleGroups: string[], config: Record<string, unknown>) {
374
+ for (const ruleGroup of ruleGroups) {
375
+ if (config[ruleGroup] && isPlainObject(config[ruleGroup]) && 'spec' in config[ruleGroup]) {
376
+ showWarningForDeprecatedField('spec', 'struct');
377
+ config[ruleGroup].struct = config[ruleGroup].spec;
378
+ delete config[ruleGroup].spec;
379
+ }
380
+ }
381
+ }
382
+
359
383
  export class Config {
360
384
  apis: Record<string, ResolvedApi>;
361
385
  styleguide: StyleguideConfig;