@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
@@ -0,0 +1,381 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ArazzoTypes = exports.arazzoSchema = exports.ARAZZO_ROOT_TYPE = void 0;
4
+ const json_schema_adapter_1 = require("./json-schema-adapter");
5
+ exports.ARAZZO_ROOT_TYPE = 'Root';
6
+ const operationMethod = {
7
+ type: 'string',
8
+ enum: ['get', 'post', 'put', 'delete', 'patch'],
9
+ };
10
+ const expectSchema = {
11
+ type: 'object',
12
+ properties: {
13
+ statusCode: { type: 'number' },
14
+ mimeType: { type: 'string' },
15
+ body: {},
16
+ schema: {
17
+ type: 'object',
18
+ additionalProperties: true,
19
+ },
20
+ },
21
+ additionalProperties: false,
22
+ oneOf: [
23
+ { required: ['statusCode'] },
24
+ { required: ['mimeType'] },
25
+ { required: ['body'] },
26
+ { required: ['schema'] },
27
+ ],
28
+ };
29
+ const openAPISourceDescriptionSchema = {
30
+ type: 'object',
31
+ properties: {
32
+ name: { type: 'string' },
33
+ type: { type: 'string', enum: ['openapi'] },
34
+ url: { type: 'string' },
35
+ 'x-serverUrl': { type: 'string' },
36
+ },
37
+ additionalProperties: false,
38
+ required: ['name', 'type', 'url'],
39
+ };
40
+ const noneSourceDescriptionSchema = {
41
+ type: 'object',
42
+ properties: {
43
+ name: { type: 'string' },
44
+ type: { type: 'string', enum: ['none'] },
45
+ 'x-serverUrl': { type: 'string' },
46
+ },
47
+ additionalProperties: false,
48
+ required: ['name', 'type', 'x-serverUrl'],
49
+ };
50
+ const arazzoSourceDescriptionSchema = {
51
+ type: 'object',
52
+ properties: {
53
+ name: { type: 'string' },
54
+ type: { type: 'string', enum: ['arazzo'] },
55
+ url: { type: 'string' },
56
+ },
57
+ additionalProperties: false,
58
+ required: ['name', 'type', 'url'],
59
+ };
60
+ const sourceDescriptionSchema = {
61
+ type: 'object',
62
+ oneOf: [
63
+ openAPISourceDescriptionSchema,
64
+ noneSourceDescriptionSchema,
65
+ arazzoSourceDescriptionSchema,
66
+ ],
67
+ };
68
+ const sourceDescriptionsSchema = {
69
+ type: 'array',
70
+ items: sourceDescriptionSchema,
71
+ };
72
+ const extendedOperation = {
73
+ type: 'object',
74
+ properties: {
75
+ path: { type: 'string' },
76
+ method: operationMethod,
77
+ sourceDescriptionName: { type: 'string' },
78
+ serverUrl: { type: 'string' },
79
+ },
80
+ additionalProperties: false,
81
+ required: ['path', 'method'],
82
+ };
83
+ const parameter = {
84
+ type: 'object',
85
+ oneOf: [
86
+ {
87
+ type: 'object',
88
+ properties: {
89
+ in: { type: 'string', enum: ['header', 'query', 'path', 'cookie', 'body'] },
90
+ name: { type: 'string' },
91
+ value: {
92
+ oneOf: [{ type: 'string' }, { type: 'number' }, { type: 'boolean' }],
93
+ },
94
+ },
95
+ required: ['name', 'value'],
96
+ additionalProperties: false,
97
+ },
98
+ {
99
+ type: 'object',
100
+ properties: {
101
+ $ref: { type: 'string' },
102
+ value: {
103
+ oneOf: [{ type: 'string' }, { type: 'number' }, { type: 'boolean' }],
104
+ },
105
+ },
106
+ required: ['$ref'],
107
+ additionalProperties: false,
108
+ },
109
+ {
110
+ type: 'object',
111
+ properties: {
112
+ reference: { type: 'string' },
113
+ value: {
114
+ oneOf: [{ type: 'string' }, { type: 'number' }, { type: 'boolean' }],
115
+ },
116
+ },
117
+ required: ['reference'],
118
+ additionalProperties: false,
119
+ },
120
+ ],
121
+ };
122
+ const parameters = {
123
+ type: 'array',
124
+ items: parameter,
125
+ };
126
+ const infoObject = {
127
+ type: 'object',
128
+ properties: {
129
+ title: { type: 'string' },
130
+ description: { type: 'string' },
131
+ summary: { type: 'string' },
132
+ version: { type: 'string' },
133
+ },
134
+ additionalProperties: false,
135
+ required: ['title', 'version'],
136
+ };
137
+ const replacement = {
138
+ type: 'object',
139
+ properties: {
140
+ target: { type: 'string' },
141
+ value: {
142
+ oneOf: [
143
+ { type: 'string' },
144
+ { type: 'object' },
145
+ { type: 'array' },
146
+ { type: 'number' },
147
+ { type: 'boolean' },
148
+ ],
149
+ },
150
+ },
151
+ };
152
+ const requestBody = {
153
+ type: 'object',
154
+ properties: {
155
+ contentType: { type: 'string' },
156
+ payload: {
157
+ oneOf: [
158
+ { type: 'string' },
159
+ { type: 'object', additionalProperties: true },
160
+ { type: 'array' },
161
+ { type: 'number' },
162
+ { type: 'boolean' },
163
+ ],
164
+ },
165
+ encoding: { type: 'string' },
166
+ replacements: {
167
+ type: 'array',
168
+ items: replacement,
169
+ },
170
+ },
171
+ additionalProperties: false,
172
+ required: ['payload'],
173
+ };
174
+ const criteriaObject = {
175
+ type: 'object',
176
+ properties: {
177
+ condition: { type: 'string' },
178
+ context: { type: 'string' },
179
+ type: {
180
+ oneOf: [
181
+ { type: 'string', enum: ['regex', 'jsonpath', 'simple', 'xpath'] },
182
+ {
183
+ type: 'object',
184
+ properties: {
185
+ type: { type: 'string', enum: ['jsonpath'] },
186
+ version: { type: 'string', enum: ['draft-goessner-dispatch-jsonpath-00'] },
187
+ },
188
+ },
189
+ {
190
+ type: 'object',
191
+ properties: {
192
+ type: { type: 'string', enum: ['xpath'] },
193
+ version: { type: 'string', enum: ['xpath-30', 'xpath-20', 'xpath-10'] },
194
+ },
195
+ },
196
+ ],
197
+ },
198
+ },
199
+ required: ['condition'],
200
+ additionalProperties: false,
201
+ };
202
+ const criteriaObjects = {
203
+ type: 'array',
204
+ items: criteriaObject,
205
+ };
206
+ const inherit = {
207
+ type: 'string',
208
+ enum: ['auto', 'none'],
209
+ };
210
+ const onSuccessObject = {
211
+ type: 'object',
212
+ properties: {
213
+ name: { type: 'string' },
214
+ type: { type: 'string', enum: ['goto', 'end'] },
215
+ stepId: { type: 'string' },
216
+ workflowId: { type: 'string' },
217
+ criteria: criteriaObjects,
218
+ },
219
+ additionalProperties: false,
220
+ required: ['type', 'name'],
221
+ };
222
+ const onSuccessList = {
223
+ type: 'array',
224
+ items: onSuccessObject,
225
+ };
226
+ const onFailureObject = {
227
+ type: 'object',
228
+ properties: {
229
+ name: { type: 'string' },
230
+ type: { type: 'string', enum: ['goto', 'retry', 'end'] },
231
+ workflowId: { type: 'string' },
232
+ stepId: { type: 'string' },
233
+ retryAfter: { type: 'number' },
234
+ retryLimit: { type: 'number' },
235
+ criteria: criteriaObjects,
236
+ },
237
+ additionalProperties: false,
238
+ required: ['type', 'name'],
239
+ };
240
+ const onFailureList = {
241
+ type: 'array',
242
+ items: onFailureObject,
243
+ };
244
+ const step = {
245
+ type: 'object',
246
+ properties: {
247
+ stepId: { type: 'string' },
248
+ description: { type: 'string' },
249
+ operationId: { type: 'string' },
250
+ operationPath: { type: 'string' },
251
+ workflowId: { type: 'string' },
252
+ parameters: parameters,
253
+ successCriteria: criteriaObjects,
254
+ onSuccess: onSuccessList,
255
+ onFailure: onFailureList,
256
+ outputs: {
257
+ type: 'object',
258
+ additionalProperties: {
259
+ type: 'string',
260
+ },
261
+ },
262
+ 'x-inherit': inherit,
263
+ 'x-expect': expectSchema,
264
+ 'x-assert': { type: 'string' },
265
+ 'x-operation': extendedOperation,
266
+ requestBody: requestBody,
267
+ },
268
+ required: ['stepId'],
269
+ oneOf: [
270
+ { required: ['x-operation'] },
271
+ { required: ['operationId'] },
272
+ { required: ['operationPath'] },
273
+ { required: ['workflowId'] },
274
+ ],
275
+ };
276
+ const steps = {
277
+ type: 'array',
278
+ items: step,
279
+ };
280
+ const JSONSchema = {
281
+ type: 'object',
282
+ properties: {
283
+ type: {
284
+ type: 'string',
285
+ enum: ['object', 'array', 'string', 'number', 'integer', 'boolean', 'null'],
286
+ },
287
+ properties: {
288
+ type: 'object',
289
+ additionalProperties: true,
290
+ },
291
+ required: {
292
+ type: 'array',
293
+ items: { type: 'string' },
294
+ },
295
+ items: {
296
+ type: 'object',
297
+ additionalProperties: true,
298
+ },
299
+ },
300
+ required: ['type'],
301
+ additionalProperties: true,
302
+ };
303
+ const workflow = {
304
+ type: 'object',
305
+ properties: {
306
+ workflowId: { type: 'string' },
307
+ summary: { type: 'string' },
308
+ description: { type: 'string' },
309
+ parameters: parameters,
310
+ dependsOn: { type: 'array', items: { type: 'string' } },
311
+ inputs: JSONSchema,
312
+ outputs: {
313
+ type: 'object',
314
+ additionalProperties: {
315
+ type: 'string',
316
+ },
317
+ },
318
+ steps: steps,
319
+ successActions: {
320
+ type: 'array',
321
+ items: onSuccessObject,
322
+ },
323
+ failureActions: {
324
+ type: 'array',
325
+ items: onFailureObject,
326
+ },
327
+ },
328
+ additionalProperties: false,
329
+ required: ['workflowId', 'steps'],
330
+ };
331
+ const workflows = {
332
+ type: 'array',
333
+ items: workflow,
334
+ };
335
+ exports.arazzoSchema = {
336
+ type: 'object',
337
+ properties: {
338
+ arazzo: { type: 'string', enum: ['1.0.0'] },
339
+ info: infoObject,
340
+ sourceDescriptions: sourceDescriptionsSchema,
341
+ 'x-parameters': parameters,
342
+ workflows: workflows,
343
+ components: {
344
+ type: 'object',
345
+ properties: {
346
+ inputs: {
347
+ type: 'object',
348
+ additionalProperties: {
349
+ type: 'object',
350
+ additionalProperties: true,
351
+ properties: {
352
+ type: {
353
+ type: 'string',
354
+ },
355
+ properties: {
356
+ type: 'object',
357
+ additionalProperties: true,
358
+ },
359
+ },
360
+ required: ['type'],
361
+ },
362
+ },
363
+ parameters: {
364
+ type: 'object',
365
+ additionalProperties: parameter,
366
+ },
367
+ successActions: {
368
+ type: 'object',
369
+ additionalProperties: onSuccessObject,
370
+ },
371
+ failureActions: {
372
+ type: 'object',
373
+ additionalProperties: onFailureObject,
374
+ },
375
+ },
376
+ },
377
+ },
378
+ additionalProperties: false,
379
+ required: ['arazzo', 'info', 'sourceDescriptions', 'workflows'],
380
+ };
381
+ exports.ArazzoTypes = (0, json_schema_adapter_1.getNodeTypesFromJSONSchema)(exports.ARAZZO_ROOT_TYPE, exports.arazzoSchema);
package/lib/types/oas3.js CHANGED
@@ -316,14 +316,6 @@ const Schema = {
316
316
  return 'Schema';
317
317
  }
318
318
  },
319
- additionalItems: (value) => {
320
- if (typeof value === 'boolean') {
321
- return { type: 'boolean' };
322
- }
323
- else {
324
- return 'Schema';
325
- }
326
- },
327
319
  additionalProperties: (value) => {
328
320
  if (typeof value === 'boolean') {
329
321
  return { type: 'boolean' };
@@ -1,16 +1,16 @@
1
1
  import type { NodeType } from '.';
2
2
  import type { JSONSchema } from 'json-schema-to-ts';
3
3
  import { Config } from '../config';
4
- declare const builtInCommonRules: readonly ["spec", "info-contact", "operation-operationId", "tag-description", "tags-alphabetical"];
5
- export type BuiltInCommonRuleId = typeof builtInCommonRules[number];
6
- declare const builtInCommonOASRules: readonly ["info-license-url", "info-license", "no-ambiguous-paths", "no-enum-type-mismatch", "no-http-verbs-in-paths", "no-identical-paths", "no-invalid-parameter-examples", "no-invalid-schema-examples", "no-path-trailing-slash", "operation-2xx-response", "operation-4xx-response", "operation-description", "operation-operationId-unique", "operation-operationId-url-safe", "operation-parameters-unique", "operation-singular-tag", "operation-summary", "operation-tag-defined", "parameter-description", "path-declaration-must-exist", "path-excludes-patterns", "path-http-verbs-order", "path-not-include-query", "path-params-defined", "path-parameters-defined", "path-segment-plural", "paths-kebab-case", "required-string-property-missing-min-length", "response-contains-header", "scalar-property-missing-example", "security-defined", "spec-strict-refs", "no-unresolved-refs", "no-required-schema-properties-undefined"];
4
+ declare const builtInCommonOASRules: readonly ["spec", "info-contact", "operation-operationId", "tag-description", "tags-alphabetical", "info-license-url", "info-license", "no-ambiguous-paths", "no-enum-type-mismatch", "no-http-verbs-in-paths", "no-identical-paths", "no-invalid-parameter-examples", "no-invalid-schema-examples", "no-path-trailing-slash", "operation-2xx-response", "operation-4xx-response", "operation-description", "operation-operationId-unique", "operation-operationId-url-safe", "operation-parameters-unique", "operation-singular-tag", "operation-summary", "operation-tag-defined", "parameter-description", "path-declaration-must-exist", "path-excludes-patterns", "path-http-verbs-order", "path-not-include-query", "path-params-defined", "path-parameters-defined", "path-segment-plural", "paths-kebab-case", "required-string-property-missing-min-length", "response-contains-header", "scalar-property-missing-example", "security-defined", "spec-strict-refs", "no-unresolved-refs", "no-required-schema-properties-undefined"];
7
5
  export type BuiltInCommonOASRuleId = typeof builtInCommonOASRules[number];
8
6
  declare const builtInOAS2Rules: readonly ["boolean-parameter-prefixes", "request-mime-type", "response-contains-property", "response-mime-type"];
9
7
  export type BuiltInOAS2RuleId = typeof builtInOAS2Rules[number];
10
8
  declare const builtInOAS3Rules: readonly ["boolean-parameter-prefixes", "component-name-unique", "no-empty-servers", "no-example-value-and-externalValue", "no-invalid-media-type-examples", "no-server-example.com", "no-server-trailing-slash", "no-server-variables-empty-enum", "no-undefined-server-variable", "no-unused-components", "operation-4xx-problem-details-rfc7807", "request-mime-type", "response-contains-property", "response-mime-type", "spec-components-invalid-map-name", "array-parameter-serialization"];
11
9
  export type BuiltInOAS3RuleId = typeof builtInOAS3Rules[number];
12
- declare const builtInAsync2Rules: readonly ["channels-kebab-case", "no-channel-trailing-slash"];
10
+ declare const builtInAsync2Rules: readonly ["spec", "info-contact", "operation-operationId", "tag-description", "tags-alphabetical", "channels-kebab-case", "no-channel-trailing-slash"];
13
11
  export type BuiltInAsync2RuleId = typeof builtInAsync2Rules[number];
12
+ declare const builtInArazzoRules: readonly ["spec"];
13
+ export type BuiltInArazzoRuleId = typeof builtInArazzoRules[number];
14
14
  declare const oas2NodeTypesList: readonly ["Root", "Tag", "TagList", "ExternalDocs", "SecurityRequirement", "SecurityRequirementList", "Info", "Contact", "License", "Paths", "PathItem", "Parameter", "ParameterList", "ParameterItems", "Operation", "Example", "ExamplesMap", "Examples", "Header", "Responses", "Response", "Schema", "Xml", "SchemaProperties", "NamedSchemas", "NamedResponses", "NamedParameters", "NamedSecuritySchemes", "SecurityScheme", "TagGroup", "TagGroups", "EnumDescriptions", "Logo", "XCodeSample", "XCodeSampleList", "XServer", "XServerList"];
15
15
  export type Oas2NodeType = typeof oas2NodeTypesList[number];
16
16
  declare const oas3NodeTypesList: readonly ["Root", "Tag", "TagList", "ExternalDocs", "Server", "ServerList", "ServerVariable", "ServerVariablesMap", "SecurityRequirement", "SecurityRequirementList", "Info", "Contact", "License", "Paths", "PathItem", "Parameter", "ParameterList", "Operation", "Callback", "CallbacksMap", "RequestBody", "MediaTypesMap", "MediaType", "Example", "ExamplesMap", "Encoding", "EncodingMap", "Header", "HeadersMap", "Responses", "Response", "Link", "LinksMap", "Schema", "Xml", "SchemaProperties", "DiscriminatorMapping", "Discriminator", "Components", "NamedSchemas", "NamedResponses", "NamedParameters", "NamedExamples", "NamedRequestBodies", "NamedHeaders", "NamedSecuritySchemes", "NamedLinks", "NamedCallbacks", "ImplicitFlow", "PasswordFlow", "ClientCredentials", "AuthorizationCode", "OAuth2Flows", "SecurityScheme", "TagGroup", "TagGroups", "EnumDescriptions", "Logo", "XCodeSample", "XCodeSampleList", "XUsePkce", "WebhooksMap"];
@@ -6,14 +6,12 @@ const _1 = require(".");
6
6
  const utils_1 = require("../utils");
7
7
  const json_schema_adapter_1 = require("./json-schema-adapter");
8
8
  const oas_types_1 = require("../oas-types");
9
- const builtInCommonRules = [
9
+ const builtInCommonOASRules = [
10
10
  'spec',
11
11
  'info-contact',
12
12
  'operation-operationId',
13
13
  'tag-description',
14
14
  'tags-alphabetical',
15
- ];
16
- const builtInCommonOASRules = [
17
15
  'info-license-url',
18
16
  'info-license',
19
17
  'no-ambiguous-paths',
@@ -73,13 +71,22 @@ const builtInOAS3Rules = [
73
71
  'spec-components-invalid-map-name',
74
72
  'array-parameter-serialization',
75
73
  ];
76
- const builtInAsync2Rules = ['channels-kebab-case', 'no-channel-trailing-slash'];
74
+ const builtInAsync2Rules = [
75
+ 'spec',
76
+ 'info-contact',
77
+ 'operation-operationId',
78
+ 'tag-description',
79
+ 'tags-alphabetical',
80
+ 'channels-kebab-case',
81
+ 'no-channel-trailing-slash',
82
+ ];
83
+ const builtInArazzoRules = ['spec'];
77
84
  const builtInRules = [
78
- ...builtInCommonRules,
79
85
  ...builtInCommonOASRules,
80
86
  ...builtInOAS2Rules,
81
87
  ...builtInOAS3Rules,
82
88
  ...builtInAsync2Rules,
89
+ ...builtInArazzoRules,
83
90
  ];
84
91
  const oas2NodeTypesList = [
85
92
  'Root',
@@ -209,16 +216,19 @@ const ConfigStyleguide = {
209
216
  oas3_0Rules: 'Rules',
210
217
  oas3_1Rules: 'Rules',
211
218
  async2Rules: 'Rules',
219
+ arazzoRules: 'Rules',
212
220
  preprocessors: { type: 'object' },
213
221
  oas2Preprocessors: { type: 'object' },
214
222
  oas3_0Preprocessors: { type: 'object' },
215
223
  oas3_1Preprocessors: { type: 'object' },
216
224
  async2Preprocessors: { type: 'object' },
225
+ arazzoPreprocessors: { type: 'object' },
217
226
  decorators: { type: 'object' },
218
227
  oas2Decorators: { type: 'object' },
219
228
  oas3_0Decorators: { type: 'object' },
220
229
  oas3_1Decorators: { type: 'object' },
221
230
  async2Decorators: { type: 'object' },
231
+ arazzoDecorators: { type: 'object' },
222
232
  },
223
233
  };
224
234
  const createConfigRoot = (nodeTypes) => (Object.assign(Object.assign({}, nodeTypes.rootRedoclyConfigSchema), { properties: Object.assign(Object.assign(Object.assign({}, nodeTypes.rootRedoclyConfigSchema.properties), ConfigStyleguide.properties), { apis: 'ConfigApis', 'features.openapi': 'ConfigReferenceDocs', 'features.mockServer': 'ConfigMockServer', organization: { type: 'string' }, region: { enum: ['us', 'eu'] }, telemetry: { enum: ['on', 'off'] }, resolve: {
@@ -0,0 +1,3 @@
1
+ import type { FromSchema } from 'json-schema-to-ts';
2
+ import type { arazzoSchema } from '../types/arazzo';
3
+ export type ArazzoDefinition = FromSchema<typeof arazzoSchema>;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/lib/visitors.d.ts CHANGED
@@ -5,6 +5,7 @@ import type { Location } from './ref-utils';
5
5
  import type { Oas3Definition, Oas3ExternalDocs, Oas3Info, Oas3Contact, Oas3Components, Oas3License, Oas3Schema, Oas3Header, Oas3Parameter, Oas3Operation, Oas3PathItem, Oas3ServerVariable, Oas3Server, Oas3MediaType, Oas3Response, Oas3Example, Oas3RequestBody, Oas3Tag, OasRef, Oas3SecurityScheme, Oas3SecurityRequirement, Oas3Encoding, Oas3Link, Oas3Xml, Oas3Discriminator, Oas3Callback } from './typings/openapi';
6
6
  import type { Oas2Definition, Oas2Tag, Oas2ExternalDocs, Oas2SecurityRequirement, Oas2Info, Oas2Contact, Oas2License, Oas2PathItem, Oas2Operation, Oas2Header, Oas2Response, Oas2Schema, Oas2Xml, Oas2Parameter, Oas2SecurityScheme } from './typings/swagger';
7
7
  import type { Async2Definition } from './typings/asyncapi';
8
+ import type { ArazzoDefinition } from './typings/arazzo';
8
9
  export type SkipFunctionContext = Pick<UserContext, 'location' | 'rawNode' | 'resolve' | 'rawLocation'>;
9
10
  export type VisitFunction<T> = (node: T, ctx: UserContext & {
10
11
  ignoreNextVisitorsOnNode: () => void;
@@ -139,6 +140,9 @@ type Oas2FlatVisitor = {
139
140
  type Async2FlatVisitor = {
140
141
  Root?: VisitFunctionOrObject<Async2Definition>;
141
142
  };
143
+ type ArazzoFlatVisitor = {
144
+ Root?: VisitFunctionOrObject<ArazzoDefinition>;
145
+ };
142
146
  type Oas3NestedVisitor = {
143
147
  [T in keyof Oas3FlatVisitor]: Oas3FlatVisitor[T] extends Function ? Oas3FlatVisitor[T] : Oas3FlatVisitor[T] & NestedVisitor<Oas3NestedVisitor>;
144
148
  };
@@ -148,9 +152,13 @@ type Oas2NestedVisitor = {
148
152
  type Async2NestedVisitor = {
149
153
  [T in keyof Async2FlatVisitor]: Async2FlatVisitor[T] extends Function ? Async2FlatVisitor[T] : Async2FlatVisitor[T] & NestedVisitor<Async2NestedVisitor>;
150
154
  };
155
+ type ArazzoNestedVisitor = {
156
+ [T in keyof ArazzoFlatVisitor]: ArazzoFlatVisitor[T] extends Function ? ArazzoFlatVisitor[T] : ArazzoFlatVisitor[T] & NestedVisitor<ArazzoNestedVisitor>;
157
+ };
151
158
  export type Oas3Visitor = BaseVisitor & Oas3NestedVisitor & Record<string, VisitFunction<any> | NestedVisitObject<any, Oas3NestedVisitor>>;
152
159
  export type Oas2Visitor = BaseVisitor & Oas2NestedVisitor & Record<string, VisitFunction<any> | NestedVisitObject<any, Oas2NestedVisitor>>;
153
160
  export type Async2Visitor = BaseVisitor & Async2NestedVisitor & Record<string, VisitFunction<any> | NestedVisitObject<any, Async2NestedVisitor>>;
161
+ export type ArazzoVisitor = BaseVisitor & ArazzoNestedVisitor & Record<string, VisitFunction<any> | NestedVisitObject<any, ArazzoNestedVisitor>>;
154
162
  export type NestedVisitor<T> = Exclude<T, 'any' | 'ref' | 'Root'>;
155
163
  export type NormalizedOasVisitors<T extends BaseVisitor> = {
156
164
  [V in keyof T]-?: {
@@ -170,12 +178,15 @@ export type NormalizedOasVisitors<T extends BaseVisitor> = {
170
178
  export type Oas3Rule = (options: Record<string, any>) => Oas3Visitor | Oas3Visitor[];
171
179
  export type Oas2Rule = (options: Record<string, any>) => Oas2Visitor | Oas2Visitor[];
172
180
  export type Async2Rule = (options: Record<string, any>) => Async2Visitor | Async2Visitor[];
181
+ export type ArazzoRule = (options: Record<string, any>) => ArazzoVisitor | ArazzoVisitor[];
173
182
  export type Oas3Preprocessor = (options: Record<string, any>) => Oas3Visitor;
174
183
  export type Oas2Preprocessor = (options: Record<string, any>) => Oas2Visitor;
175
184
  export type Async2Preprocessor = (options: Record<string, any>) => Async2Visitor;
185
+ export type ArazzoPreprocessor = (options: Record<string, any>) => ArazzoVisitor;
176
186
  export type Oas3Decorator = (options: Record<string, any>) => Oas3Visitor;
177
187
  export type Oas2Decorator = (options: Record<string, any>) => Oas2Visitor;
178
188
  export type Async2Decorator = (options: Record<string, any>) => Async2Visitor;
189
+ export type ArazzoDecorator = (options: Record<string, any>) => ArazzoVisitor;
179
190
  export type OasRule = Oas3Rule;
180
191
  export type OasPreprocessor = Oas3Preprocessor;
181
192
  export type OasDecorator = Oas3Decorator;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redocly/openapi-core",
3
- "version": "1.17.1",
3
+ "version": "1.18.0",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "engines": {
@@ -55,6 +55,7 @@
55
55
  "@types/node": "^20.11.5",
56
56
  "@types/node-fetch": "^2.5.7",
57
57
  "@types/pluralize": "^0.0.29",
58
+ "json-schema-to-ts": "^3.1.0",
58
59
  "typescript": "^5.2.2"
59
60
  }
60
61
  }
package/src/bundle.ts CHANGED
@@ -293,6 +293,15 @@ export function mapTypeToComponent(typeName: string, version: SpecMajorVersion)
293
293
  default:
294
294
  return null;
295
295
  }
296
+ case SpecMajorVersion.Arazzo:
297
+ switch (typeName) {
298
+ case 'Root.x-parameters_items':
299
+ case 'Root.workflows_items.parameters_items':
300
+ case 'Root.workflows_items.steps_items.parameters_items':
301
+ return 'parameters';
302
+ default:
303
+ return null;
304
+ }
296
305
  }
297
306
  }
298
307
 
@@ -367,6 +376,10 @@ function makeBundleVisitor(
367
376
  components = root.components = root.components || {};
368
377
  } else if (version === SpecMajorVersion.OAS2) {
369
378
  components = root;
379
+ } else if (version === SpecMajorVersion.Async2) {
380
+ components = root.components = root.components || {};
381
+ } else if (version === SpecMajorVersion.Arazzo) {
382
+ components = root.components = root.components || {};
370
383
  }
371
384
  },
372
385
  },
@@ -2,11 +2,21 @@
2
2
 
3
3
  exports[`resolveConfig should ignore minimal from the root and read local file 1`] = `
4
4
  {
5
+ "arazzoDecorators": {},
6
+ "arazzoPreprocessors": {},
7
+ "arazzoRules": {
8
+ "spec": "error",
9
+ },
5
10
  "async2Decorators": {},
6
11
  "async2Preprocessors": {},
7
12
  "async2Rules": {
8
13
  "channels-kebab-case": "off",
14
+ "info-contact": "off",
9
15
  "no-channel-trailing-slash": "off",
16
+ "operation-operationId": "warn",
17
+ "spec": "error",
18
+ "tag-description": "warn",
19
+ "tags-alphabetical": "off",
10
20
  },
11
21
  "decorators": {},
12
22
  "doNotResolveExamples": undefined,
@@ -109,11 +119,21 @@ exports[`resolveConfig should ignore minimal from the root and read local file 1
109
119
 
110
120
  exports[`resolveStyleguideConfig should resolve extends with local file config which contains path to nested config 1`] = `
111
121
  {
122
+ "arazzoDecorators": {},
123
+ "arazzoPreprocessors": {},
124
+ "arazzoRules": {
125
+ "spec": "error",
126
+ },
112
127
  "async2Decorators": {},
113
128
  "async2Preprocessors": {},
114
129
  "async2Rules": {
115
130
  "channels-kebab-case": "off",
131
+ "info-contact": "off",
116
132
  "no-channel-trailing-slash": "off",
133
+ "operation-operationId": "warn",
134
+ "spec": "error",
135
+ "tag-description": "warn",
136
+ "tags-alphabetical": "off",
117
137
  },
118
138
  "decorators": {},
119
139
  "doNotResolveExamples": undefined,
@@ -6,6 +6,7 @@ StyleguideConfig {
6
6
  "_usedVersions": Set {},
7
7
  "configFile": undefined,
8
8
  "decorators": {
9
+ "arazzo": {},
9
10
  "async2": {
10
11
  "oas2": {},
11
12
  "oas3_0": {},
@@ -44,6 +45,7 @@ StyleguideConfig {
44
45
  "pluginPaths": [],
45
46
  "plugins": [],
46
47
  "preprocessors": {
48
+ "arazzo": {},
47
49
  "async2": {
48
50
  "oas2": {},
49
51
  "oas3_0": {},
@@ -107,6 +109,7 @@ StyleguideConfig {
107
109
  },
108
110
  "recommendedFallback": false,
109
111
  "rules": {
112
+ "arazzo": {},
110
113
  "async2": {
111
114
  "oas2": {
112
115
  "no-empty-servers": "error",