@redocly/openapi-core 1.17.1 → 1.18.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 (58) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/lib/bundle.d.ts +1 -1
  3. package/lib/bundle.js +15 -0
  4. package/lib/config/all.js +6 -0
  5. package/lib/config/builtIn.js +10 -2
  6. package/lib/config/config-resolvers.js +15 -4
  7. package/lib/config/config.d.ts +2 -2
  8. package/lib/config/config.js +15 -0
  9. package/lib/config/minimal.js +8 -0
  10. package/lib/config/recommended-strict.js +8 -0
  11. package/lib/config/recommended.js +8 -0
  12. package/lib/config/types.d.ts +10 -4
  13. package/lib/config/utils.js +13 -1
  14. package/lib/decorators/arazzo/index.d.ts +1 -0
  15. package/lib/decorators/arazzo/index.js +4 -0
  16. package/lib/decorators/async2/index.d.ts +1 -0
  17. package/lib/decorators/async2/index.js +4 -0
  18. package/lib/index.d.ts +1 -0
  19. package/lib/index.js +4 -2
  20. package/lib/oas-types.d.ts +12 -7
  21. package/lib/oas-types.js +10 -0
  22. package/lib/rules/arazzo/index.d.ts +3 -0
  23. package/lib/rules/arazzo/index.js +10 -0
  24. package/lib/rules/common/spec.d.ts +2 -2
  25. package/lib/types/arazzo.d.ts +1050 -0
  26. package/lib/types/arazzo.js +381 -0
  27. package/lib/types/oas3.js +0 -8
  28. package/lib/types/redocly-yaml.d.ts +4 -4
  29. package/lib/types/redocly-yaml.js +15 -5
  30. package/lib/typings/arazzo.d.ts +3 -0
  31. package/lib/typings/arazzo.js +2 -0
  32. package/lib/visitors.d.ts +11 -0
  33. package/package.json +2 -1
  34. package/src/bundle.ts +13 -0
  35. package/src/config/__tests__/__snapshots__/config-resolvers.test.ts.snap +20 -0
  36. package/src/config/__tests__/__snapshots__/config.test.ts.snap +3 -0
  37. package/src/config/__tests__/config.test.ts +6 -0
  38. package/src/config/all.ts +6 -0
  39. package/src/config/builtIn.ts +10 -2
  40. package/src/config/config-resolvers.ts +17 -3
  41. package/src/config/config.ts +17 -0
  42. package/src/config/minimal.ts +8 -0
  43. package/src/config/recommended-strict.ts +8 -0
  44. package/src/config/recommended.ts +8 -0
  45. package/src/config/types.ts +15 -2
  46. package/src/config/utils.ts +15 -0
  47. package/src/decorators/arazzo/index.ts +1 -0
  48. package/src/decorators/async2/index.ts +1 -0
  49. package/src/index.ts +1 -0
  50. package/src/oas-types.ts +25 -4
  51. package/src/rules/arazzo/index.ts +11 -0
  52. package/src/rules/common/spec.ts +2 -2
  53. package/src/types/arazzo.ts +386 -0
  54. package/src/types/oas3.ts +0 -7
  55. package/src/types/redocly-yaml.ts +18 -8
  56. package/src/typings/arazzo.ts +4 -0
  57. package/src/visitors.ts +18 -0
  58. package/tsconfig.tsbuildinfo +1 -1
@@ -117,6 +117,7 @@ describe('getMergedConfig', () => {
117
117
  "_usedVersions": Set {},
118
118
  "configFile": "redocly.yaml",
119
119
  "decorators": {
120
+ "arazzo": {},
120
121
  "async2": {},
121
122
  "oas2": {},
122
123
  "oas3_0": {},
@@ -128,6 +129,7 @@ describe('getMergedConfig', () => {
128
129
  "pluginPaths": [],
129
130
  "plugins": [],
130
131
  "preprocessors": {
132
+ "arazzo": {},
131
133
  "async2": {},
132
134
  "oas2": {},
133
135
  "oas3_0": {},
@@ -142,6 +144,7 @@ describe('getMergedConfig', () => {
142
144
  },
143
145
  "recommendedFallback": false,
144
146
  "rules": {
147
+ "arazzo": {},
145
148
  "async2": {
146
149
  "operation-summary": "warn",
147
150
  },
@@ -222,6 +225,7 @@ describe('getMergedConfig', () => {
222
225
  "_usedVersions": Set {},
223
226
  "configFile": "redocly.yaml",
224
227
  "decorators": {
228
+ "arazzo": {},
225
229
  "async2": {},
226
230
  "oas2": {},
227
231
  "oas3_0": {},
@@ -233,6 +237,7 @@ describe('getMergedConfig', () => {
233
237
  "pluginPaths": [],
234
238
  "plugins": [],
235
239
  "preprocessors": {
240
+ "arazzo": {},
236
241
  "async2": {},
237
242
  "oas2": {},
238
243
  "oas3_0": {},
@@ -249,6 +254,7 @@ describe('getMergedConfig', () => {
249
254
  },
250
255
  "recommendedFallback": false,
251
256
  "rules": {
257
+ "arazzo": {},
252
258
  "async2": {
253
259
  "no-empty-servers": "error",
254
260
  "operation-summary": "error",
package/src/config/all.ts CHANGED
@@ -106,9 +106,15 @@ const all: PluginStyleguideConfig<'built-in'> = {
106
106
  'array-parameter-serialization': 'error',
107
107
  },
108
108
  async2Rules: {
109
+ spec: 'error',
110
+ 'info-contact': 'error',
111
+ 'operation-operationId': 'error',
112
+ 'tag-description': 'error',
113
+ 'tags-alphabetical': 'error',
109
114
  'channels-kebab-case': 'error',
110
115
  'no-channel-trailing-slash': 'error',
111
116
  },
117
+ arazzoRules: { spec: 'error' },
112
118
  };
113
119
 
114
120
  export default all;
@@ -5,10 +5,15 @@ import minimal from './minimal';
5
5
  import { rules as oas3Rules } from '../rules/oas3';
6
6
  import { rules as oas2Rules } from '../rules/oas2';
7
7
  import { rules as async2Rules } from '../rules/async2';
8
+ import { rules as arazzoRules } from '../rules/arazzo';
8
9
  import { preprocessors as oas3Preprocessors } from '../rules/oas3';
9
10
  import { preprocessors as oas2Preprocessors } from '../rules/oas2';
11
+ import { preprocessors as async2Preprocessors } from '../rules/async2';
12
+ import { preprocessors as arazzoPreprocessors } from '../rules/arazzo';
10
13
  import { decorators as oas3Decorators } from '../decorators/oas3';
11
14
  import { decorators as oas2Decorators } from '../decorators/oas2';
15
+ import { decorators as async2Decorators } from '../decorators/async2';
16
+ import { decorators as arazzoDecorators } from '../decorators/arazzo';
12
17
 
13
18
  import type { CustomRulesConfig, StyleguideRawConfig, Plugin } from './types';
14
19
 
@@ -28,16 +33,19 @@ export const defaultPlugin: Plugin = {
28
33
  oas3: oas3Rules,
29
34
  oas2: oas2Rules,
30
35
  async2: async2Rules,
36
+ arazzo: arazzoRules,
31
37
  } as CustomRulesConfig,
32
38
  preprocessors: {
33
39
  oas3: oas3Preprocessors,
34
40
  oas2: oas2Preprocessors,
35
- async2: {},
41
+ async2: async2Preprocessors,
42
+ arazzo: arazzoPreprocessors,
36
43
  },
37
44
  decorators: {
38
45
  oas3: oas3Decorators,
39
46
  oas2: oas2Decorators,
40
- async2: {},
47
+ async2: async2Decorators,
48
+ arazzo: arazzoDecorators,
41
49
  },
42
50
  configs: builtInConfigs,
43
51
  };
@@ -180,7 +180,9 @@ export function resolvePlugins(
180
180
 
181
181
  if (pluginModule.rules) {
182
182
  if (!pluginModule.rules.oas3 && !pluginModule.rules.oas2 && !pluginModule.rules.async2) {
183
- throw new Error(`Plugin rules must have \`oas3\`, \`oas2\` or \`async2\` rules "${p}.`);
183
+ throw new Error(
184
+ `Plugin rules must have \`oas3\`, \`oas2\`, \`async2\`, or \`arazzo\` rules "${p}.`
185
+ );
184
186
  }
185
187
  plugin.rules = {};
186
188
  if (pluginModule.rules.oas3) {
@@ -192,12 +194,16 @@ export function resolvePlugins(
192
194
  if (pluginModule.rules.async2) {
193
195
  plugin.rules.async2 = prefixRules(pluginModule.rules.async2, id);
194
196
  }
197
+ if (pluginModule.rules.arazzo) {
198
+ plugin.rules.arazzo = prefixRules(pluginModule.rules.arazzo, id);
199
+ }
195
200
  }
196
201
  if (pluginModule.preprocessors) {
197
202
  if (
198
203
  !pluginModule.preprocessors.oas3 &&
199
204
  !pluginModule.preprocessors.oas2 &&
200
- !pluginModule.preprocessors.async2
205
+ !pluginModule.preprocessors.async2 &&
206
+ !pluginModule.preprocessors.arazzo
201
207
  ) {
202
208
  throw new Error(
203
209
  `Plugin \`preprocessors\` must have \`oas3\`, \`oas2\` or \`async2\` preprocessors "${p}.`
@@ -213,13 +219,17 @@ export function resolvePlugins(
213
219
  if (pluginModule.preprocessors.async2) {
214
220
  plugin.preprocessors.async2 = prefixRules(pluginModule.preprocessors.async2, id);
215
221
  }
222
+ if (pluginModule.preprocessors.arazzo) {
223
+ plugin.preprocessors.arazzo = prefixRules(pluginModule.preprocessors.arazzo, id);
224
+ }
216
225
  }
217
226
 
218
227
  if (pluginModule.decorators) {
219
228
  if (
220
229
  !pluginModule.decorators.oas3 &&
221
230
  !pluginModule.decorators.oas2 &&
222
- !pluginModule.decorators.async2
231
+ !pluginModule.decorators.async2 &&
232
+ !pluginModule.decorators.arazzo
223
233
  ) {
224
234
  throw new Error(
225
235
  `Plugin \`decorators\` must have \`oas3\`, \`oas2\` or \`async2\` decorators "${p}.`
@@ -235,6 +245,9 @@ export function resolvePlugins(
235
245
  if (pluginModule.decorators.async2) {
236
246
  plugin.decorators.async2 = prefixRules(pluginModule.decorators.async2, id);
237
247
  }
248
+ if (pluginModule.decorators.arazzo) {
249
+ plugin.decorators.arazzo = prefixRules(pluginModule.decorators.arazzo, id);
250
+ }
238
251
  }
239
252
 
240
253
  if (pluginModule.assertions) {
@@ -419,6 +432,7 @@ function getMergedRawStyleguideConfig(
419
432
  oas2Rules: { ...rootStyleguideConfig?.oas2Rules, ...apiStyleguideConfig?.oas2Rules },
420
433
  oas3_0Rules: { ...rootStyleguideConfig?.oas3_0Rules, ...apiStyleguideConfig?.oas3_0Rules },
421
434
  oas3_1Rules: { ...rootStyleguideConfig?.oas3_1Rules, ...apiStyleguideConfig?.oas3_1Rules },
435
+ arazzoRules: { ...rootStyleguideConfig?.arazzoRules, ...apiStyleguideConfig?.arazzoRules },
422
436
  preprocessors: {
423
437
  ...rootStyleguideConfig?.preprocessors,
424
438
  ...apiStyleguideConfig?.preprocessors,
@@ -9,6 +9,7 @@ import {
9
9
  Oas2RuleSet,
10
10
  Oas3RuleSet,
11
11
  Async2RuleSet,
12
+ ArazzoRuleSet,
12
13
  } from '../oas-types';
13
14
  import { isBrowser } from '../env';
14
15
 
@@ -71,6 +72,7 @@ export class StyleguideConfig {
71
72
  [SpecVersion.OAS3_0]: { ...rawConfig.rules, ...rawConfig.oas3_0Rules },
72
73
  [SpecVersion.OAS3_1]: { ...rawConfig.rules, ...rawConfig.oas3_1Rules },
73
74
  [SpecVersion.Async2]: { ...rawConfig.rules, ...rawConfig.async2Rules },
75
+ [SpecVersion.Arazzo]: { ...rawConfig.arazzoRules },
74
76
  };
75
77
 
76
78
  this.preprocessors = {
@@ -78,6 +80,7 @@ export class StyleguideConfig {
78
80
  [SpecVersion.OAS3_0]: { ...rawConfig.preprocessors, ...rawConfig.oas3_0Preprocessors },
79
81
  [SpecVersion.OAS3_1]: { ...rawConfig.preprocessors, ...rawConfig.oas3_1Preprocessors },
80
82
  [SpecVersion.Async2]: { ...rawConfig.preprocessors, ...rawConfig.async2Preprocessors },
83
+ [SpecVersion.Arazzo]: { ...rawConfig.arazzoPreprocessors },
81
84
  };
82
85
 
83
86
  this.decorators = {
@@ -85,6 +88,7 @@ export class StyleguideConfig {
85
88
  [SpecVersion.OAS3_0]: { ...rawConfig.decorators, ...rawConfig.oas3_0Decorators },
86
89
  [SpecVersion.OAS3_1]: { ...rawConfig.decorators, ...rawConfig.oas3_1Decorators },
87
90
  [SpecVersion.Async2]: { ...rawConfig.decorators, ...rawConfig.async2Decorators },
91
+ [SpecVersion.Arazzo]: { ...rawConfig.arazzoDecorators },
88
92
  };
89
93
 
90
94
  this.extendPaths = rawConfig.extendPaths || [];
@@ -178,6 +182,10 @@ export class StyleguideConfig {
178
182
  if (!plugin.typeExtension.async2) continue;
179
183
  extendedTypes = plugin.typeExtension.async2(extendedTypes, version);
180
184
  break;
185
+ case SpecVersion.Arazzo:
186
+ if (!plugin.typeExtension.arazzo) continue;
187
+ extendedTypes = plugin.typeExtension.arazzo(extendedTypes, version);
188
+ break;
181
189
  default:
182
190
  throw new Error('Not implemented');
183
191
  }
@@ -277,6 +285,15 @@ export class StyleguideConfig {
277
285
  (p) => p.decorators?.async2 && asyncApiRules.push(p.decorators.async2)
278
286
  );
279
287
  return asyncApiRules;
288
+ case SpecMajorVersion.Arazzo:
289
+ // eslint-disable-next-line no-case-declarations
290
+ const arazzoRules: ArazzoRuleSet[] = []; // default ruleset
291
+ this.plugins.forEach(
292
+ (p) => p.preprocessors?.arazzo && arazzoRules.push(p.preprocessors.arazzo)
293
+ );
294
+ this.plugins.forEach((p) => p.rules?.arazzo && arazzoRules.push(p.rules.arazzo));
295
+ this.plugins.forEach((p) => p.decorators?.arazzo && arazzoRules.push(p.decorators.arazzo));
296
+ return arazzoRules;
280
297
  }
281
298
  }
282
299
 
@@ -88,9 +88,17 @@ const minimal: PluginStyleguideConfig<'built-in'> = {
88
88
  'array-parameter-serialization': 'off',
89
89
  },
90
90
  async2Rules: {
91
+ spec: 'error',
92
+ 'info-contact': 'off',
93
+ 'operation-operationId': 'warn',
94
+ 'tag-description': 'warn',
95
+ 'tags-alphabetical': 'off',
91
96
  'channels-kebab-case': 'off',
92
97
  'no-channel-trailing-slash': 'off',
93
98
  },
99
+ arazzoRules: {
100
+ spec: 'error',
101
+ },
94
102
  };
95
103
 
96
104
  export default minimal;
@@ -88,9 +88,17 @@ const recommendedStrict: PluginStyleguideConfig<'built-in'> = {
88
88
  'array-parameter-serialization': 'off',
89
89
  },
90
90
  async2Rules: {
91
+ spec: 'error',
92
+ 'info-contact': 'off',
93
+ 'operation-operationId': 'error',
94
+ 'tag-description': 'error',
95
+ 'tags-alphabetical': 'off',
91
96
  'channels-kebab-case': 'off',
92
97
  'no-channel-trailing-slash': 'off',
93
98
  },
99
+ arazzoRules: {
100
+ spec: 'error',
101
+ },
94
102
  };
95
103
 
96
104
  export default recommendedStrict;
@@ -88,9 +88,17 @@ const recommended: PluginStyleguideConfig<'built-in'> = {
88
88
  'array-parameter-serialization': 'off',
89
89
  },
90
90
  async2Rules: {
91
+ spec: 'error',
92
+ 'info-contact': 'off',
93
+ 'operation-operationId': 'warn',
94
+ 'tag-description': 'warn',
95
+ 'tags-alphabetical': 'off',
91
96
  'channels-kebab-case': 'off',
92
97
  'no-channel-trailing-slash': 'off',
93
98
  },
99
+ arazzoRules: {
100
+ spec: 'error',
101
+ },
94
102
  };
95
103
 
96
104
  export default recommended;
@@ -11,6 +11,9 @@ import type {
11
11
  Async2PreprocessorsSet,
12
12
  Async2DecoratorsSet,
13
13
  Async2RuleSet,
14
+ ArazzoRuleSet,
15
+ ArazzoPreprocessorsSet,
16
+ ArazzoDecoratorsSet,
14
17
  RuleMap,
15
18
  } from '../oas-types';
16
19
 
@@ -20,9 +23,9 @@ import type { SkipFunctionContext } from '../visitors';
20
23
  import {
21
24
  BuiltInAsync2RuleId,
22
25
  BuiltInCommonOASRuleId,
23
- BuiltInCommonRuleId,
24
26
  BuiltInOAS2RuleId,
25
27
  BuiltInOAS3RuleId,
28
+ BuiltInArazzoRuleId,
26
29
  } from '../types/redocly-yaml';
27
30
 
28
31
  export type RuleSeverity = ProblemSeverity | 'off';
@@ -51,23 +54,26 @@ export type StyleguideRawConfig<T = undefined> = {
51
54
  doNotResolveExamples?: boolean;
52
55
  recommendedFallback?: boolean;
53
56
 
54
- rules?: RuleMap<BuiltInCommonRuleId | BuiltInCommonOASRuleId, RuleConfig, T>;
57
+ rules?: RuleMap<BuiltInCommonOASRuleId, RuleConfig, T>;
55
58
  oas2Rules?: RuleMap<BuiltInOAS2RuleId, RuleConfig, T>;
56
59
  oas3_0Rules?: RuleMap<BuiltInOAS3RuleId, RuleConfig, T>;
57
60
  oas3_1Rules?: RuleMap<BuiltInOAS3RuleId, RuleConfig, T>;
58
61
  async2Rules?: RuleMap<BuiltInAsync2RuleId, RuleConfig, T>;
62
+ arazzoRules?: RuleMap<BuiltInArazzoRuleId, RuleConfig, T>;
59
63
 
60
64
  preprocessors?: Record<string, PreprocessorConfig>;
61
65
  oas2Preprocessors?: Record<string, PreprocessorConfig>;
62
66
  oas3_0Preprocessors?: Record<string, PreprocessorConfig>;
63
67
  oas3_1Preprocessors?: Record<string, PreprocessorConfig>;
64
68
  async2Preprocessors?: Record<string, PreprocessorConfig>;
69
+ arazzoPreprocessors?: Record<string, PreprocessorConfig>;
65
70
 
66
71
  decorators?: Record<string, DecoratorConfig>;
67
72
  oas2Decorators?: Record<string, DecoratorConfig>;
68
73
  oas3_0Decorators?: Record<string, DecoratorConfig>;
69
74
  oas3_1Decorators?: Record<string, DecoratorConfig>;
70
75
  async2Decorators?: Record<string, DecoratorConfig>;
76
+ arazzoDecorators?: Record<string, DecoratorConfig>;
71
77
  };
72
78
 
73
79
  export type ApiStyleguideRawConfig = Omit<StyleguideRawConfig, 'plugins'>;
@@ -84,12 +90,14 @@ export type PreprocessorsConfig = {
84
90
  oas3?: Oas3PreprocessorsSet;
85
91
  oas2?: Oas2PreprocessorsSet;
86
92
  async2?: Async2PreprocessorsSet;
93
+ arazzo?: ArazzoPreprocessorsSet;
87
94
  };
88
95
 
89
96
  export type DecoratorsConfig = {
90
97
  oas3?: Oas3DecoratorsSet;
91
98
  oas2?: Oas2DecoratorsSet;
92
99
  async2?: Async2DecoratorsSet;
100
+ arazzo?: ArazzoDecoratorsSet;
93
101
  };
94
102
 
95
103
  export type TypesExtensionFn = (
@@ -103,6 +111,7 @@ export type CustomRulesConfig = {
103
111
  oas3?: Oas3RuleSet;
104
112
  oas2?: Oas2RuleSet;
105
113
  async2?: Async2RuleSet;
114
+ arazzo?: ArazzoRuleSet;
106
115
  };
107
116
 
108
117
  export type AssertionContext = Partial<UserContext> & SkipFunctionContext & { node: any };
@@ -227,19 +236,23 @@ export type ThemeRawConfig = {
227
236
  mockServer?: Record<string, any>;
228
237
  };
229
238
 
239
+ // TODO: sync types
230
240
  export type RulesFields =
231
241
  | 'rules'
232
242
  | 'oas2Rules'
233
243
  | 'oas3_0Rules'
234
244
  | 'oas3_1Rules'
235
245
  | 'async2Rules'
246
+ | 'arazzoRules'
236
247
  | 'preprocessors'
237
248
  | 'oas2Preprocessors'
238
249
  | 'oas3_0Preprocessors'
239
250
  | 'oas3_1Preprocessors'
240
251
  | 'async2Preprocessors'
252
+ | 'arazzoPreprocessors'
241
253
  | 'decorators'
242
254
  | 'oas2Decorators'
243
255
  | 'oas3_0Decorators'
244
256
  | 'oas3_1Decorators'
257
+ | 'arazzoDecorators'
245
258
  | 'async2Decorators';
@@ -56,18 +56,21 @@ function extractFlatConfig<
56
56
  oas3_0Rules,
57
57
  oas3_1Rules,
58
58
  async2Rules,
59
+ arazzoRules,
59
60
 
60
61
  preprocessors,
61
62
  oas2Preprocessors,
62
63
  oas3_0Preprocessors,
63
64
  oas3_1Preprocessors,
64
65
  async2Preprocessors,
66
+ arazzoPreprocessors,
65
67
 
66
68
  decorators,
67
69
  oas2Decorators,
68
70
  oas3_0Decorators,
69
71
  oas3_1Decorators,
70
72
  async2Decorators,
73
+ arazzoDecorators,
71
74
 
72
75
  ...rawConfigRest
73
76
  }: T): {
@@ -83,18 +86,21 @@ function extractFlatConfig<
83
86
  oas3_0Rules,
84
87
  oas3_1Rules,
85
88
  async2Rules,
89
+ arazzoRules,
86
90
 
87
91
  preprocessors,
88
92
  oas2Preprocessors,
89
93
  oas3_0Preprocessors,
90
94
  oas3_1Preprocessors,
91
95
  async2Preprocessors,
96
+ arazzoPreprocessors,
92
97
 
93
98
  decorators,
94
99
  oas2Decorators,
95
100
  oas3_0Decorators,
96
101
  oas3_1Decorators,
97
102
  async2Decorators,
103
+ arazzoDecorators,
98
104
 
99
105
  doNotResolveExamples: rawConfigRest.resolve?.doNotResolveExamples,
100
106
  };
@@ -152,18 +158,21 @@ export function mergeExtends(rulesConfList: ResolvedStyleguideConfig[]) {
152
158
  oas3_0Rules: {},
153
159
  oas3_1Rules: {},
154
160
  async2Rules: {},
161
+ arazzoRules: {},
155
162
 
156
163
  preprocessors: {},
157
164
  oas2Preprocessors: {},
158
165
  oas3_0Preprocessors: {},
159
166
  oas3_1Preprocessors: {},
160
167
  async2Preprocessors: {},
168
+ arazzoPreprocessors: {},
161
169
 
162
170
  decorators: {},
163
171
  oas2Decorators: {},
164
172
  oas3_0Decorators: {},
165
173
  oas3_1Decorators: {},
166
174
  async2Decorators: {},
175
+ arazzoDecorators: {},
167
176
 
168
177
  plugins: [],
169
178
  pluginPaths: [],
@@ -186,6 +195,8 @@ export function mergeExtends(rulesConfList: ResolvedStyleguideConfig[]) {
186
195
  assignExisting(result.oas3_1Rules, rulesConf.rules || {});
187
196
  Object.assign(result.async2Rules, rulesConf.async2Rules);
188
197
  assignExisting(result.async2Rules, rulesConf.rules || {});
198
+ Object.assign(result.arazzoRules, rulesConf.arazzoRules);
199
+ assignExisting(result.arazzoRules, rulesConf.rules || {});
189
200
 
190
201
  Object.assign(result.preprocessors, rulesConf.preprocessors);
191
202
  Object.assign(result.oas2Preprocessors, rulesConf.oas2Preprocessors);
@@ -196,6 +207,8 @@ export function mergeExtends(rulesConfList: ResolvedStyleguideConfig[]) {
196
207
  assignExisting(result.oas3_1Preprocessors, rulesConf.preprocessors || {});
197
208
  Object.assign(result.async2Preprocessors, rulesConf.async2Preprocessors);
198
209
  assignExisting(result.async2Preprocessors, rulesConf.preprocessors || {});
210
+ Object.assign(result.arazzoPreprocessors, rulesConf.arazzoPreprocessors);
211
+ assignExisting(result.arazzoPreprocessors, rulesConf.preprocessors || {});
199
212
 
200
213
  Object.assign(result.decorators, rulesConf.decorators);
201
214
  Object.assign(result.oas2Decorators, rulesConf.oas2Decorators);
@@ -206,6 +219,8 @@ export function mergeExtends(rulesConfList: ResolvedStyleguideConfig[]) {
206
219
  assignExisting(result.oas3_1Decorators, rulesConf.decorators || {});
207
220
  Object.assign(result.async2Decorators, rulesConf.async2Decorators);
208
221
  assignExisting(result.async2Decorators, rulesConf.decorators || {});
222
+ Object.assign(result.arazzoDecorators, rulesConf.arazzoDecorators);
223
+ assignExisting(result.arazzoDecorators, rulesConf.decorators || {});
209
224
 
210
225
  result.plugins!.push(...(rulesConf.plugins || []));
211
226
  result.pluginPaths!.push(...(rulesConf.pluginPaths || []));
@@ -0,0 +1 @@
1
+ export const decorators = {};
@@ -0,0 +1 @@
1
+ export const decorators = {};
package/src/index.ts CHANGED
@@ -8,6 +8,7 @@ export {
8
8
  pause,
9
9
  } from './utils';
10
10
  export { Oas3_1Types } from './types/oas3_1';
11
+ export { ArazzoTypes } from './types/arazzo';
11
12
  export { Oas3Types } from './types/oas3';
12
13
  export { Oas2Types } from './types/oas2';
13
14
  export { AsyncApi2Types } from './types/asyncapi';
package/src/oas-types.ts CHANGED
@@ -5,15 +5,18 @@ import {
5
5
  Oas2Preprocessor,
6
6
  Async2Preprocessor,
7
7
  Async2Rule,
8
+ ArazzoPreprocessor,
9
+ ArazzoRule,
8
10
  } from './visitors';
9
11
  import { Oas2Types } from './types/oas2';
10
12
  import { Oas3Types } from './types/oas3';
11
13
  import { Oas3_1Types } from './types/oas3_1';
12
14
  import { AsyncApi2Types } from './types/asyncapi';
15
+ import { ArazzoTypes } from './types/arazzo';
13
16
  import {
14
17
  BuiltInAsync2RuleId,
15
18
  BuiltInCommonOASRuleId,
16
- BuiltInCommonRuleId,
19
+ BuiltInArazzoRuleId,
17
20
  BuiltInOAS2RuleId,
18
21
  BuiltInOAS3RuleId,
19
22
  } from './types/redocly-yaml';
@@ -25,12 +28,14 @@ export enum SpecVersion {
25
28
  OAS3_0 = 'oas3_0',
26
29
  OAS3_1 = 'oas3_1',
27
30
  Async2 = 'async2', // todo split into 2.x maybe?
31
+ Arazzo = 'arazzo',
28
32
  }
29
33
 
30
34
  export enum SpecMajorVersion {
31
35
  OAS2 = 'oas2',
32
36
  OAS3 = 'oas3',
33
37
  Async2 = 'async2',
38
+ Arazzo = 'arazzo',
34
39
  }
35
40
 
36
41
  const typesMap = {
@@ -38,6 +43,7 @@ const typesMap = {
38
43
  [SpecVersion.OAS3_0]: Oas3Types,
39
44
  [SpecVersion.OAS3_1]: Oas3_1Types,
40
45
  [SpecVersion.Async2]: AsyncApi2Types,
46
+ [SpecVersion.Arazzo]: ArazzoTypes,
41
47
  };
42
48
 
43
49
  export type RuleMap<Key extends string, RuleConfig, T> = Record<
@@ -45,26 +51,35 @@ export type RuleMap<Key extends string, RuleConfig, T> = Record<
45
51
  RuleConfig
46
52
  >;
47
53
  export type Oas3RuleSet<T = undefined> = RuleMap<
48
- BuiltInCommonRuleId | BuiltInCommonOASRuleId | BuiltInOAS3RuleId | 'assertions',
54
+ BuiltInCommonOASRuleId | BuiltInOAS3RuleId | 'assertions',
49
55
  Oas3Rule,
50
56
  T
51
57
  >;
52
58
  export type Oas2RuleSet<T = undefined> = RuleMap<
53
- BuiltInCommonRuleId | BuiltInCommonOASRuleId | BuiltInOAS2RuleId | 'assertions',
59
+ BuiltInCommonOASRuleId | BuiltInOAS2RuleId | 'assertions',
54
60
  Oas2Rule,
55
61
  T
56
62
  >;
57
63
  export type Async2RuleSet<T = undefined> = RuleMap<
58
- BuiltInCommonRuleId | BuiltInAsync2RuleId | 'assertions',
64
+ BuiltInAsync2RuleId | 'assertions',
59
65
  Async2Rule,
60
66
  T
61
67
  >;
68
+ export type ArazzoRuleSet<T = undefined> = RuleMap<
69
+ BuiltInArazzoRuleId | 'assertions',
70
+ ArazzoRule,
71
+ T
72
+ >;
73
+
62
74
  export type Oas3PreprocessorsSet = Record<string, Oas3Preprocessor>;
63
75
  export type Oas2PreprocessorsSet = Record<string, Oas2Preprocessor>;
64
76
  export type Async2PreprocessorsSet = Record<string, Async2Preprocessor>;
77
+ export type ArazzoPreprocessorsSet = Record<string, ArazzoPreprocessor>;
78
+
65
79
  export type Oas3DecoratorsSet = Record<string, Oas3Preprocessor>;
66
80
  export type Oas2DecoratorsSet = Record<string, Oas2Preprocessor>;
67
81
  export type Async2DecoratorsSet = Record<string, Async2Preprocessor>;
82
+ export type ArazzoDecoratorsSet = Record<string, ArazzoPreprocessor>;
68
83
 
69
84
  export function detectSpec(root: any): SpecVersion {
70
85
  if (typeof root !== 'object') {
@@ -100,6 +115,10 @@ export function detectSpec(root: any): SpecVersion {
100
115
  throw new Error(`Unsupported AsyncAPI version: ${root.asyncapi}`);
101
116
  }
102
117
 
118
+ if (root.arazzo && root.arazzo.startsWith('1.')) {
119
+ return SpecVersion.Arazzo;
120
+ }
121
+
103
122
  throw new Error(`Unsupported specification`);
104
123
  }
105
124
 
@@ -108,6 +127,8 @@ export function getMajorSpecVersion(version: SpecVersion): SpecMajorVersion {
108
127
  return SpecMajorVersion.OAS2;
109
128
  } else if (version === SpecVersion.Async2) {
110
129
  return SpecMajorVersion.Async2;
130
+ } else if (version === SpecVersion.Arazzo) {
131
+ return SpecMajorVersion.Arazzo;
111
132
  } else {
112
133
  return SpecMajorVersion.OAS3;
113
134
  }
@@ -0,0 +1,11 @@
1
+ import { ArazzoRule } from '../../visitors';
2
+ import { Spec } from '../common/spec';
3
+ import type { ArazzoRuleSet } from '../../oas-types';
4
+ import { Assertions } from '../common/assertions';
5
+
6
+ export const rules: ArazzoRuleSet<'built-in'> = {
7
+ spec: Spec as ArazzoRule,
8
+ assertions: Assertions,
9
+ };
10
+
11
+ export const preprocessors = {};
@@ -1,11 +1,11 @@
1
- import type { Oas3Rule, Oas2Rule, Async2Rule } from '../../visitors';
1
+ import type { Oas3Rule, Oas2Rule, Async2Rule, ArazzoRule } from '../../visitors';
2
2
  import { isNamedType, SpecExtension } from '../../types';
3
3
  import { oasTypeOf, matchesJsonSchemaType, getSuggest, validateSchemaEnumType } from '../utils';
4
4
  import { isRef } from '../../ref-utils';
5
5
  import { isPlainObject } from '../../utils';
6
6
  import { UserContext } from '../../walk';
7
7
 
8
- export const Spec: Oas3Rule | Oas2Rule | Async2Rule = () => {
8
+ export const Spec: Oas3Rule | Oas2Rule | Async2Rule | ArazzoRule = () => {
9
9
  return {
10
10
  any(
11
11
  node: any,