@redocly/openapi-core 1.17.0 → 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 (61) hide show
  1. package/CHANGELOG.md +17 -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 +13 -8
  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/oas3_1.js +7 -1
  29. package/lib/types/redocly-yaml.d.ts +5 -5
  30. package/lib/types/redocly-yaml.js +16 -5
  31. package/lib/typings/arazzo.d.ts +3 -0
  32. package/lib/typings/arazzo.js +2 -0
  33. package/lib/visitors.d.ts +11 -0
  34. package/package.json +3 -2
  35. package/src/__tests__/lint.test.ts +124 -0
  36. package/src/bundle.ts +13 -0
  37. package/src/config/__tests__/__snapshots__/config-resolvers.test.ts.snap +20 -0
  38. package/src/config/__tests__/__snapshots__/config.test.ts.snap +3 -0
  39. package/src/config/__tests__/config.test.ts +6 -0
  40. package/src/config/all.ts +6 -0
  41. package/src/config/builtIn.ts +10 -2
  42. package/src/config/config-resolvers.ts +17 -3
  43. package/src/config/config.ts +17 -0
  44. package/src/config/minimal.ts +8 -0
  45. package/src/config/recommended-strict.ts +8 -0
  46. package/src/config/recommended.ts +8 -0
  47. package/src/config/types.ts +15 -2
  48. package/src/config/utils.ts +15 -0
  49. package/src/decorators/arazzo/index.ts +1 -0
  50. package/src/decorators/async2/index.ts +1 -0
  51. package/src/index.ts +1 -0
  52. package/src/oas-types.ts +25 -4
  53. package/src/rules/arazzo/index.ts +11 -0
  54. package/src/rules/common/spec.ts +2 -2
  55. package/src/types/arazzo.ts +386 -0
  56. package/src/types/oas3.ts +0 -7
  57. package/src/types/oas3_1.ts +7 -0
  58. package/src/types/redocly-yaml.ts +19 -8
  59. package/src/typings/arazzo.ts +4 -0
  60. package/src/visitors.ts +18 -0
  61. package/tsconfig.tsbuildinfo +1 -1
@@ -8,17 +8,12 @@ import type { JSONSchema } from 'json-schema-to-ts';
8
8
  import { SpecVersion, getTypes } from '../oas-types';
9
9
  import { Config } from '../config';
10
10
 
11
- const builtInCommonRules = [
11
+ const builtInCommonOASRules = [
12
12
  'spec',
13
13
  'info-contact',
14
14
  'operation-operationId',
15
15
  'tag-description',
16
16
  'tags-alphabetical',
17
- ] as const;
18
-
19
- export type BuiltInCommonRuleId = typeof builtInCommonRules[number];
20
-
21
- const builtInCommonOASRules = [
22
17
  'info-license-url',
23
18
  'info-license',
24
19
  'no-ambiguous-paths',
@@ -87,16 +82,28 @@ const builtInOAS3Rules = [
87
82
 
88
83
  export type BuiltInOAS3RuleId = typeof builtInOAS3Rules[number];
89
84
 
90
- const builtInAsync2Rules = ['channels-kebab-case', 'no-channel-trailing-slash'] as const;
85
+ const builtInAsync2Rules = [
86
+ 'spec',
87
+ 'info-contact',
88
+ 'operation-operationId',
89
+ 'tag-description',
90
+ 'tags-alphabetical',
91
+ 'channels-kebab-case',
92
+ 'no-channel-trailing-slash',
93
+ ] as const;
91
94
 
92
95
  export type BuiltInAsync2RuleId = typeof builtInAsync2Rules[number];
93
96
 
97
+ const builtInArazzoRules = ['spec'] as const;
98
+
99
+ export type BuiltInArazzoRuleId = typeof builtInArazzoRules[number];
100
+
94
101
  const builtInRules = [
95
- ...builtInCommonRules,
96
102
  ...builtInCommonOASRules,
97
103
  ...builtInOAS2Rules,
98
104
  ...builtInOAS3Rules,
99
105
  ...builtInAsync2Rules,
106
+ ...builtInArazzoRules,
100
107
  ] as const;
101
108
 
102
109
  type BuiltInRuleId = typeof builtInRules[number];
@@ -220,6 +227,7 @@ const oas3_1NodeTypesList = [
220
227
  'NamedPathItems',
221
228
  'SecurityScheme',
222
229
  'Operation',
230
+ 'DependentRequired',
223
231
  ] as const;
224
232
 
225
233
  export type Oas3_1NodeType = typeof oas3_1NodeTypesList[number];
@@ -237,16 +245,19 @@ const ConfigStyleguide: NodeType = {
237
245
  oas3_0Rules: 'Rules',
238
246
  oas3_1Rules: 'Rules',
239
247
  async2Rules: 'Rules',
248
+ arazzoRules: 'Rules',
240
249
  preprocessors: { type: 'object' },
241
250
  oas2Preprocessors: { type: 'object' },
242
251
  oas3_0Preprocessors: { type: 'object' },
243
252
  oas3_1Preprocessors: { type: 'object' },
244
253
  async2Preprocessors: { type: 'object' },
254
+ arazzoPreprocessors: { type: 'object' },
245
255
  decorators: { type: 'object' },
246
256
  oas2Decorators: { type: 'object' },
247
257
  oas3_0Decorators: { type: 'object' },
248
258
  oas3_1Decorators: { type: 'object' },
249
259
  async2Decorators: { type: 'object' },
260
+ arazzoDecorators: { type: 'object' },
250
261
  },
251
262
  };
252
263
 
@@ -0,0 +1,4 @@
1
+ import type { FromSchema } from 'json-schema-to-ts';
2
+ import type { arazzoSchema } from '../types/arazzo';
3
+
4
+ export type ArazzoDefinition = FromSchema<typeof arazzoSchema>;
package/src/visitors.ts CHANGED
@@ -50,6 +50,7 @@ import type {
50
50
  Oas2SecurityScheme,
51
51
  } from './typings/swagger';
52
52
  import type { Async2Definition } from './typings/asyncapi';
53
+ import type { ArazzoDefinition } from './typings/arazzo';
53
54
 
54
55
  export type SkipFunctionContext = Pick<
55
56
  UserContext,
@@ -212,6 +213,10 @@ type Async2FlatVisitor = {
212
213
  Root?: VisitFunctionOrObject<Async2Definition>;
213
214
  };
214
215
 
216
+ type ArazzoFlatVisitor = {
217
+ Root?: VisitFunctionOrObject<ArazzoDefinition>;
218
+ };
219
+
215
220
  const legacyTypesMap = {
216
221
  Root: 'DefinitionRoot',
217
222
  ServerVariablesMap: 'ServerVariableMap',
@@ -244,6 +249,12 @@ type Async2NestedVisitor = {
244
249
  : Async2FlatVisitor[T] & NestedVisitor<Async2NestedVisitor>;
245
250
  };
246
251
 
252
+ type ArazzoNestedVisitor = {
253
+ [T in keyof ArazzoFlatVisitor]: ArazzoFlatVisitor[T] extends Function
254
+ ? ArazzoFlatVisitor[T]
255
+ : ArazzoFlatVisitor[T] & NestedVisitor<ArazzoNestedVisitor>;
256
+ };
257
+
247
258
  export type Oas3Visitor = BaseVisitor &
248
259
  Oas3NestedVisitor &
249
260
  Record<string, VisitFunction<any> | NestedVisitObject<any, Oas3NestedVisitor>>;
@@ -256,6 +267,10 @@ export type Async2Visitor = BaseVisitor &
256
267
  Async2NestedVisitor &
257
268
  Record<string, VisitFunction<any> | NestedVisitObject<any, Async2NestedVisitor>>;
258
269
 
270
+ export type ArazzoVisitor = BaseVisitor &
271
+ ArazzoNestedVisitor &
272
+ Record<string, VisitFunction<any> | NestedVisitObject<any, ArazzoNestedVisitor>>;
273
+
259
274
  export type NestedVisitor<T> = Exclude<T, 'any' | 'ref' | 'Root'>;
260
275
 
261
276
  export type NormalizedOasVisitors<T extends BaseVisitor> = {
@@ -278,12 +293,15 @@ export type NormalizedOasVisitors<T extends BaseVisitor> = {
278
293
  export type Oas3Rule = (options: Record<string, any>) => Oas3Visitor | Oas3Visitor[];
279
294
  export type Oas2Rule = (options: Record<string, any>) => Oas2Visitor | Oas2Visitor[];
280
295
  export type Async2Rule = (options: Record<string, any>) => Async2Visitor | Async2Visitor[];
296
+ export type ArazzoRule = (options: Record<string, any>) => ArazzoVisitor | ArazzoVisitor[];
281
297
  export type Oas3Preprocessor = (options: Record<string, any>) => Oas3Visitor;
282
298
  export type Oas2Preprocessor = (options: Record<string, any>) => Oas2Visitor;
283
299
  export type Async2Preprocessor = (options: Record<string, any>) => Async2Visitor;
300
+ export type ArazzoPreprocessor = (options: Record<string, any>) => ArazzoVisitor;
284
301
  export type Oas3Decorator = (options: Record<string, any>) => Oas3Visitor;
285
302
  export type Oas2Decorator = (options: Record<string, any>) => Oas2Visitor;
286
303
  export type Async2Decorator = (options: Record<string, any>) => Async2Visitor;
304
+ export type ArazzoDecorator = (options: Record<string, any>) => ArazzoVisitor;
287
305
 
288
306
  // alias for the latest version supported
289
307
  // every time we update it - consider semver