@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
@@ -8,8 +8,7 @@ import type { JSONSchema } from 'json-schema-to-ts';
8
8
  import type { NodeType } from '.';
9
9
  import type { Config } from '../config';
10
10
 
11
- const builtInCommonOASRules = [
12
- 'spec',
11
+ const builtInOAS2Rules = [
13
12
  'info-contact',
14
13
  'operation-operationId',
15
14
  'tag-description',
@@ -49,11 +48,6 @@ const builtInCommonOASRules = [
49
48
  'spec-strict-refs',
50
49
  'no-unresolved-refs',
51
50
  'no-required-schema-properties-undefined',
52
- ] as const;
53
-
54
- export type BuiltInCommonOASRuleId = typeof builtInCommonOASRules[number];
55
-
56
- const builtInOAS2Rules = [
57
51
  'boolean-parameter-prefixes',
58
52
  'request-mime-type',
59
53
  'response-contains-property',
@@ -63,6 +57,45 @@ const builtInOAS2Rules = [
63
57
  export type BuiltInOAS2RuleId = typeof builtInOAS2Rules[number];
64
58
 
65
59
  const builtInOAS3Rules = [
60
+ 'info-contact',
61
+ 'operation-operationId',
62
+ 'tag-description',
63
+ 'tags-alphabetical',
64
+ 'info-license-url',
65
+ 'info-license-strict',
66
+ 'info-license',
67
+ 'no-ambiguous-paths',
68
+ 'no-enum-type-mismatch',
69
+ 'no-http-verbs-in-paths',
70
+ 'no-identical-paths',
71
+ 'no-invalid-parameter-examples',
72
+ 'no-invalid-schema-examples',
73
+ 'no-path-trailing-slash',
74
+ 'operation-2xx-response',
75
+ 'operation-4xx-response',
76
+ 'operation-description',
77
+ 'operation-operationId-unique',
78
+ 'operation-operationId-url-safe',
79
+ 'operation-parameters-unique',
80
+ 'operation-singular-tag',
81
+ 'operation-summary',
82
+ 'operation-tag-defined',
83
+ 'parameter-description',
84
+ 'path-declaration-must-exist',
85
+ 'path-excludes-patterns',
86
+ 'path-http-verbs-order',
87
+ 'path-not-include-query',
88
+ 'path-params-defined',
89
+ 'path-parameters-defined',
90
+ 'path-segment-plural',
91
+ 'paths-kebab-case',
92
+ 'required-string-property-missing-min-length',
93
+ 'response-contains-header',
94
+ 'scalar-property-missing-example',
95
+ 'security-defined',
96
+ 'spec-strict-refs',
97
+ 'no-unresolved-refs',
98
+ 'no-required-schema-properties-undefined',
66
99
  'boolean-parameter-prefixes',
67
100
  'component-name-unique',
68
101
  'no-empty-servers',
@@ -84,7 +117,6 @@ const builtInOAS3Rules = [
84
117
  export type BuiltInOAS3RuleId = typeof builtInOAS3Rules[number];
85
118
 
86
119
  const builtInAsync2Rules = [
87
- 'spec',
88
120
  'info-contact',
89
121
  'info-license-strict',
90
122
  'operation-operationId',
@@ -95,7 +127,6 @@ const builtInAsync2Rules = [
95
127
  ] as const;
96
128
 
97
129
  const builtInAsync3Rules = [
98
- 'spec',
99
130
  'info-contact',
100
131
  'info-license-strict',
101
132
  'operation-operationId',
@@ -109,14 +140,14 @@ export type BuiltInAsync2RuleId = typeof builtInAsync2Rules[number];
109
140
 
110
141
  export type BuiltInAsync3RuleId = typeof builtInAsync3Rules[number];
111
142
 
112
- const builtInArazzoRules = [
113
- 'spec',
143
+ const builtInArazzo1Rules = [
114
144
  'parameters-not-in-body',
115
145
  'sourceDescription-type',
116
146
  'version-enum',
117
147
  'workflowId-unique',
118
148
  'stepId-unique',
119
149
  'sourceDescription-name-unique',
150
+ 'sourceDescriptions-not-empty',
120
151
  'workflow-dependsOn',
121
152
  'parameters-unique',
122
153
  'step-onSuccess-unique',
@@ -127,15 +158,16 @@ const builtInArazzoRules = [
127
158
  'criteria-unique',
128
159
  ] as const;
129
160
 
130
- export type BuiltInArazzoRuleId = typeof builtInArazzoRules[number];
161
+ export type BuiltInArazzo1RuleId = typeof builtInArazzo1Rules[number];
131
162
 
132
163
  const builtInRules = [
133
- ...builtInCommonOASRules,
134
164
  ...builtInOAS2Rules,
135
165
  ...builtInOAS3Rules,
136
166
  ...builtInAsync2Rules,
137
167
  ...builtInAsync3Rules,
138
- ...builtInArazzoRules,
168
+ ...builtInArazzo1Rules,
169
+ 'spec', // TODO: depricated in favor of struct
170
+ 'struct',
139
171
  ] as const;
140
172
 
141
173
  type BuiltInRuleId = typeof builtInRules[number];
@@ -278,7 +310,7 @@ const ConfigStyleguide: NodeType = {
278
310
  oas3_0Rules: 'Rules',
279
311
  oas3_1Rules: 'Rules',
280
312
  async2Rules: 'Rules',
281
- arazzoRules: 'Rules',
313
+ arazzo1Rules: 'Rules',
282
314
  preprocessors: { type: 'object' },
283
315
  oas2Preprocessors: { type: 'object' },
284
316
  oas3_0Preprocessors: { type: 'object' },
@@ -290,7 +322,7 @@ const ConfigStyleguide: NodeType = {
290
322
  oas3_0Decorators: { type: 'object' },
291
323
  oas3_1Decorators: { type: 'object' },
292
324
  async2Decorators: { type: 'object' },
293
- arazzoDecorators: { type: 'object' },
325
+ arazzo1Decorators: { type: 'object' },
294
326
  },
295
327
  };
296
328
 
@@ -12,22 +12,13 @@ export interface OpenAPISourceDescription {
12
12
  'x-serverUrl'?: string;
13
13
  }
14
14
 
15
- export interface NoneSourceDescription {
16
- name: string;
17
- type: 'none';
18
- 'x-serverUrl': string;
19
- }
20
-
21
15
  export interface ArazzoSourceDescription {
22
16
  name: string;
23
17
  type: 'arazzo';
24
18
  url: string;
25
19
  }
26
20
 
27
- export type SourceDescription =
28
- | OpenAPISourceDescription
29
- | NoneSourceDescription
30
- | ArazzoSourceDescription;
21
+ export type SourceDescription = OpenAPISourceDescription | ArazzoSourceDescription;
31
22
 
32
23
  export interface Parameter {
33
24
  in?: 'header' | 'query' | 'path' | 'cookie' | 'body';
@@ -59,15 +50,6 @@ export interface ExtendedOperation {
59
50
  | 'CONNECT';
60
51
  }
61
52
 
62
- export interface ExpectSchema {
63
- statusCode?: number;
64
- mimeType?: string;
65
- body?: any;
66
- schema?: {
67
- [key: string]: any;
68
- };
69
- }
70
-
71
53
  export interface Replacement {
72
54
  target: string;
73
55
  value: string | object | any[];
@@ -129,7 +111,6 @@ export interface Step {
129
111
  outputs?: {
130
112
  [key: string]: string | object | any[] | boolean | number;
131
113
  };
132
- 'x-expect'?: ExpectSchema;
133
114
  'x-operation'?: ExtendedOperation;
134
115
  requestBody?: RequestBody;
135
116
  }
package/src/utils.ts CHANGED
@@ -244,14 +244,16 @@ export function doesYamlFileExist(filePath: string): boolean {
244
244
  export function showWarningForDeprecatedField(
245
245
  deprecatedField: string,
246
246
  updatedField?: string,
247
- updatedObject?: string
247
+ updatedObject?: string,
248
+ link?: string
248
249
  ) {
250
+ const readMoreText = link ? `Read more about this change: ${link}` : '';
249
251
  logger.warn(
250
252
  `The '${colorize.red(deprecatedField)}' field is deprecated. ${
251
253
  updatedField
252
254
  ? `Use ${colorize.green(getUpdatedFieldName(updatedField, updatedObject))} instead. `
253
255
  : ''
254
- }Read more about this change: https://redocly.com/docs/api-registry/guides/migration-guide-config-file/#changed-properties\n`
256
+ }${readMoreText}\n`
255
257
  );
256
258
  }
257
259
 
package/src/visitors.ts CHANGED
@@ -55,10 +55,8 @@ import type {
55
55
  ArazzoDefinition,
56
56
  ArazzoSourceDescription,
57
57
  CriteriaObject,
58
- ExpectSchema,
59
58
  ExtendedOperation,
60
59
  InfoObject,
61
- NoneSourceDescription,
62
60
  OnFailureObject,
63
61
  OnSuccessObject,
64
62
  OpenAPISourceDescription,
@@ -240,11 +238,9 @@ type ArazzoFlatVisitor = {
240
238
  ParameterObject?: VisitFunctionOrObject<Parameter>;
241
239
  InfoObject?: VisitFunctionOrObject<InfoObject>;
242
240
  OpenAPISourceDescription?: VisitFunctionOrObject<OpenAPISourceDescription>;
243
- NoneSourceDescription?: VisitFunctionOrObject<NoneSourceDescription>;
244
241
  ArazzoSourceDescription?: VisitFunctionOrObject<ArazzoSourceDescription>;
245
242
  SourceDescription?: VisitFunctionOrObject<SourceDescription>;
246
243
  ExtendedOperation?: VisitFunctionOrObject<ExtendedOperation>;
247
- ExpectSchema?: VisitFunctionOrObject<ExpectSchema>;
248
244
  Replacement?: VisitFunctionOrObject<Replacement>;
249
245
  RequestBody?: VisitFunctionOrObject<RequestBody>;
250
246
  CriteriaObject?: VisitFunctionOrObject<CriteriaObject>;
@@ -321,7 +317,7 @@ export type Async3Visitor = BaseVisitor &
321
317
  Async3NestedVisitor &
322
318
  Record<string, VisitFunction<any> | NestedVisitObject<any, Async3NestedVisitor>>;
323
319
 
324
- export type ArazzoVisitor = BaseVisitor &
320
+ export type Arazzo1Visitor = BaseVisitor &
325
321
  ArazzoNestedVisitor &
326
322
  Record<string, VisitFunction<any> | NestedVisitObject<any, ArazzoNestedVisitor>>;
327
323
 
@@ -348,17 +344,17 @@ export type Oas3Rule = (options: Record<string, any>) => Oas3Visitor | Oas3Visit
348
344
  export type Oas2Rule = (options: Record<string, any>) => Oas2Visitor | Oas2Visitor[];
349
345
  export type Async2Rule = (options: Record<string, any>) => Async2Visitor | Async2Visitor[];
350
346
  export type Async3Rule = (options: Record<string, any>) => Async3Visitor | Async3Visitor[];
351
- export type ArazzoRule = (options: Record<string, any>) => ArazzoVisitor | ArazzoVisitor[];
347
+ export type Arazzo1Rule = (options: Record<string, any>) => Arazzo1Visitor | Arazzo1Visitor[];
352
348
  export type Oas3Preprocessor = (options: Record<string, any>) => Oas3Visitor;
353
349
  export type Oas2Preprocessor = (options: Record<string, any>) => Oas2Visitor;
354
350
  export type Async2Preprocessor = (options: Record<string, any>) => Async2Visitor;
355
351
  export type Async3Preprocessor = (options: Record<string, any>) => Async3Visitor;
356
- export type ArazzoPreprocessor = (options: Record<string, any>) => ArazzoVisitor;
352
+ export type Arazzo1Preprocessor = (options: Record<string, any>) => Arazzo1Visitor;
357
353
  export type Oas3Decorator = (options: Record<string, any>) => Oas3Visitor;
358
354
  export type Oas2Decorator = (options: Record<string, any>) => Oas2Visitor;
359
355
  export type Async2Decorator = (options: Record<string, any>) => Async2Visitor;
360
356
  export type Async3Decorator = (options: Record<string, any>) => Async3Visitor;
361
- export type ArazzoDecorator = (options: Record<string, any>) => ArazzoVisitor;
357
+ export type Arazzo1Decorator = (options: Record<string, any>) => Arazzo1Visitor;
362
358
 
363
359
  // alias for the latest version supported
364
360
  // every time we update it - consider semver