@redocly/openapi-core 1.17.1 → 1.18.1
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.
- package/CHANGELOG.md +20 -0
- package/lib/bundle.d.ts +1 -1
- package/lib/bundle.js +16 -2
- package/lib/config/all.js +6 -0
- package/lib/config/builtIn.js +10 -2
- package/lib/config/config-resolvers.js +15 -4
- package/lib/config/config.d.ts +2 -2
- package/lib/config/config.js +15 -0
- package/lib/config/load.d.ts +1 -2
- package/lib/config/minimal.js +8 -0
- package/lib/config/recommended-strict.js +8 -0
- package/lib/config/recommended.js +8 -0
- package/lib/config/types.d.ts +10 -4
- package/lib/config/utils.js +13 -1
- package/lib/decorators/arazzo/index.d.ts +1 -0
- package/lib/decorators/arazzo/index.js +4 -0
- package/lib/decorators/async2/index.d.ts +1 -0
- package/lib/decorators/async2/index.js +4 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +4 -2
- package/lib/oas-types.d.ts +13 -8
- package/lib/oas-types.js +10 -0
- package/lib/rules/arazzo/index.d.ts +3 -0
- package/lib/rules/arazzo/index.js +10 -0
- package/lib/rules/common/path-segment-plural.js +2 -1
- package/lib/rules/common/spec.d.ts +2 -2
- package/lib/types/arazzo.d.ts +2276 -0
- package/lib/types/arazzo.js +386 -0
- package/lib/types/asyncapi.js +17 -43
- package/lib/types/oas3.js +0 -8
- package/lib/types/oas3_1.js +2 -2
- package/lib/types/redocly-yaml.d.ts +4 -4
- package/lib/types/redocly-yaml.js +15 -5
- package/lib/typings/arazzo.d.ts +30 -0
- package/lib/typings/arazzo.js +2 -0
- package/lib/utils.d.ts +8 -4
- package/lib/utils.js +38 -7
- package/lib/visitors.d.ts +11 -0
- package/package.json +3 -2
- package/src/__tests__/lint.test.ts +0 -50
- package/src/bundle.ts +15 -3
- package/src/config/__tests__/__snapshots__/config-resolvers.test.ts.snap +20 -0
- package/src/config/__tests__/__snapshots__/config.test.ts.snap +3 -0
- package/src/config/__tests__/config.test.ts +6 -0
- package/src/config/all.ts +6 -0
- package/src/config/builtIn.ts +10 -2
- package/src/config/config-resolvers.ts +17 -3
- package/src/config/config.ts +17 -0
- package/src/config/load.ts +1 -2
- package/src/config/minimal.ts +8 -0
- package/src/config/recommended-strict.ts +8 -0
- package/src/config/recommended.ts +8 -0
- package/src/config/types.ts +15 -2
- package/src/config/utils.ts +15 -0
- package/src/decorators/arazzo/index.ts +1 -0
- package/src/decorators/async2/index.ts +1 -0
- package/src/index.ts +1 -0
- package/src/oas-types.ts +25 -4
- package/src/rules/arazzo/index.ts +11 -0
- package/src/rules/common/__tests__/spec.test.ts +47 -0
- package/src/rules/common/no-invalid-schema-examples.ts +3 -2
- package/src/rules/common/path-segment-plural.ts +3 -2
- package/src/rules/common/spec.ts +2 -2
- package/src/types/arazzo.ts +391 -0
- package/src/types/asyncapi.ts +22 -43
- package/src/types/oas3.ts +0 -7
- package/src/types/oas3_1.ts +2 -2
- package/src/types/redocly-yaml.ts +18 -8
- package/src/typings/arazzo.ts +44 -0
- package/src/utils.ts +41 -8
- package/src/visitors.ts +18 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ArazzoTypes = exports.arazzoSchema = exports.workflow = exports.step = exports.inherit = exports.criteriaObject = exports.requestBody = exports.replacement = exports.infoObject = exports.parameter = exports.sourceDescriptionSchema = exports.expectSchema = exports.operationMethod = exports.ARAZZO_ROOT_TYPE = void 0;
|
|
4
|
+
const json_schema_adapter_1 = require("./json-schema-adapter");
|
|
5
|
+
exports.ARAZZO_ROOT_TYPE = 'Root';
|
|
6
|
+
exports.operationMethod = {
|
|
7
|
+
type: 'string',
|
|
8
|
+
enum: ['get', 'post', 'put', 'delete', 'patch'],
|
|
9
|
+
};
|
|
10
|
+
exports.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
|
+
exports.sourceDescriptionSchema = {
|
|
61
|
+
type: 'object',
|
|
62
|
+
oneOf: [
|
|
63
|
+
openAPISourceDescriptionSchema,
|
|
64
|
+
noneSourceDescriptionSchema,
|
|
65
|
+
arazzoSourceDescriptionSchema,
|
|
66
|
+
],
|
|
67
|
+
};
|
|
68
|
+
const sourceDescriptionsSchema = {
|
|
69
|
+
type: 'array',
|
|
70
|
+
items: exports.sourceDescriptionSchema,
|
|
71
|
+
};
|
|
72
|
+
const extendedOperation = {
|
|
73
|
+
type: 'object',
|
|
74
|
+
properties: {
|
|
75
|
+
path: { type: 'string' },
|
|
76
|
+
method: exports.operationMethod,
|
|
77
|
+
sourceDescriptionName: { type: 'string' },
|
|
78
|
+
serverUrl: { type: 'string' },
|
|
79
|
+
},
|
|
80
|
+
additionalProperties: false,
|
|
81
|
+
required: ['path', 'method'],
|
|
82
|
+
};
|
|
83
|
+
exports.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
|
+
reference: { type: 'string' },
|
|
102
|
+
value: {
|
|
103
|
+
oneOf: [{ type: 'string' }, { type: 'number' }, { type: 'boolean' }],
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
required: ['reference'],
|
|
107
|
+
additionalProperties: false,
|
|
108
|
+
},
|
|
109
|
+
],
|
|
110
|
+
};
|
|
111
|
+
const parameters = {
|
|
112
|
+
type: 'array',
|
|
113
|
+
items: exports.parameter,
|
|
114
|
+
};
|
|
115
|
+
exports.infoObject = {
|
|
116
|
+
type: 'object',
|
|
117
|
+
properties: {
|
|
118
|
+
title: { type: 'string' },
|
|
119
|
+
description: { type: 'string' },
|
|
120
|
+
summary: { type: 'string' },
|
|
121
|
+
version: { type: 'string' },
|
|
122
|
+
},
|
|
123
|
+
additionalProperties: false,
|
|
124
|
+
required: ['title', 'version'],
|
|
125
|
+
};
|
|
126
|
+
exports.replacement = {
|
|
127
|
+
type: 'object',
|
|
128
|
+
properties: {
|
|
129
|
+
target: { type: 'string' },
|
|
130
|
+
value: {
|
|
131
|
+
oneOf: [
|
|
132
|
+
{ type: 'string' },
|
|
133
|
+
{ type: 'object' },
|
|
134
|
+
{ type: 'array' },
|
|
135
|
+
{ type: 'number' },
|
|
136
|
+
{ type: 'boolean' },
|
|
137
|
+
],
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
};
|
|
141
|
+
exports.requestBody = {
|
|
142
|
+
type: 'object',
|
|
143
|
+
properties: {
|
|
144
|
+
contentType: { type: 'string' },
|
|
145
|
+
payload: {
|
|
146
|
+
oneOf: [
|
|
147
|
+
{ type: 'string' },
|
|
148
|
+
{ type: 'object', additionalProperties: true },
|
|
149
|
+
{ type: 'array' },
|
|
150
|
+
{ type: 'number' },
|
|
151
|
+
{ type: 'boolean' },
|
|
152
|
+
],
|
|
153
|
+
},
|
|
154
|
+
encoding: { type: 'string' },
|
|
155
|
+
replacements: {
|
|
156
|
+
type: 'array',
|
|
157
|
+
items: exports.replacement,
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
additionalProperties: false,
|
|
161
|
+
required: ['payload'],
|
|
162
|
+
};
|
|
163
|
+
exports.criteriaObject = {
|
|
164
|
+
type: 'object',
|
|
165
|
+
properties: {
|
|
166
|
+
condition: { type: 'string' },
|
|
167
|
+
context: { type: 'string' },
|
|
168
|
+
type: {
|
|
169
|
+
oneOf: [
|
|
170
|
+
{ type: 'string', enum: ['regex', 'jsonpath', 'simple', 'xpath'] },
|
|
171
|
+
{
|
|
172
|
+
type: 'object',
|
|
173
|
+
properties: {
|
|
174
|
+
type: { type: 'string', enum: ['jsonpath'] },
|
|
175
|
+
version: { type: 'string', enum: ['draft-goessner-dispatch-jsonpath-00'] },
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
type: 'object',
|
|
180
|
+
properties: {
|
|
181
|
+
type: { type: 'string', enum: ['xpath'] },
|
|
182
|
+
version: { type: 'string', enum: ['xpath-30', 'xpath-20', 'xpath-10'] },
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
],
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
required: ['condition'],
|
|
189
|
+
additionalProperties: false,
|
|
190
|
+
};
|
|
191
|
+
const criteriaObjects = {
|
|
192
|
+
type: 'array',
|
|
193
|
+
items: exports.criteriaObject,
|
|
194
|
+
};
|
|
195
|
+
exports.inherit = {
|
|
196
|
+
type: 'string',
|
|
197
|
+
enum: ['auto', 'none'],
|
|
198
|
+
};
|
|
199
|
+
const onSuccessObject = {
|
|
200
|
+
type: 'object',
|
|
201
|
+
properties: {
|
|
202
|
+
name: { type: 'string' },
|
|
203
|
+
type: { type: 'string', enum: ['goto', 'end'] },
|
|
204
|
+
stepId: { type: 'string' },
|
|
205
|
+
workflowId: { type: 'string' },
|
|
206
|
+
criteria: criteriaObjects,
|
|
207
|
+
},
|
|
208
|
+
additionalProperties: false,
|
|
209
|
+
required: ['type', 'name'],
|
|
210
|
+
};
|
|
211
|
+
const onSuccessList = {
|
|
212
|
+
type: 'array',
|
|
213
|
+
items: onSuccessObject,
|
|
214
|
+
};
|
|
215
|
+
const onFailureObject = {
|
|
216
|
+
type: 'object',
|
|
217
|
+
properties: {
|
|
218
|
+
name: { type: 'string' },
|
|
219
|
+
type: { type: 'string', enum: ['goto', 'retry', 'end'] },
|
|
220
|
+
workflowId: { type: 'string' },
|
|
221
|
+
stepId: { type: 'string' },
|
|
222
|
+
retryAfter: { type: 'number' },
|
|
223
|
+
retryLimit: { type: 'number' },
|
|
224
|
+
criteria: criteriaObjects,
|
|
225
|
+
},
|
|
226
|
+
additionalProperties: false,
|
|
227
|
+
required: ['type', 'name'],
|
|
228
|
+
};
|
|
229
|
+
const onFailureList = {
|
|
230
|
+
type: 'array',
|
|
231
|
+
items: onFailureObject,
|
|
232
|
+
};
|
|
233
|
+
exports.step = {
|
|
234
|
+
type: 'object',
|
|
235
|
+
properties: {
|
|
236
|
+
stepId: { type: 'string' },
|
|
237
|
+
description: { type: 'string' },
|
|
238
|
+
operationId: { type: 'string' },
|
|
239
|
+
operationPath: { type: 'string' },
|
|
240
|
+
workflowId: { type: 'string' },
|
|
241
|
+
parameters: parameters,
|
|
242
|
+
successCriteria: criteriaObjects,
|
|
243
|
+
onSuccess: onSuccessList,
|
|
244
|
+
onFailure: onFailureList,
|
|
245
|
+
outputs: {
|
|
246
|
+
type: 'object',
|
|
247
|
+
additionalProperties: {
|
|
248
|
+
oneOf: [
|
|
249
|
+
{
|
|
250
|
+
type: 'string',
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
type: 'object',
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
type: 'array',
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
type: 'boolean',
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
type: 'number',
|
|
263
|
+
},
|
|
264
|
+
],
|
|
265
|
+
},
|
|
266
|
+
},
|
|
267
|
+
'x-inherit': exports.inherit,
|
|
268
|
+
'x-expect': exports.expectSchema,
|
|
269
|
+
'x-assert': { type: 'string' },
|
|
270
|
+
'x-operation': extendedOperation,
|
|
271
|
+
requestBody: exports.requestBody,
|
|
272
|
+
},
|
|
273
|
+
required: ['stepId'],
|
|
274
|
+
oneOf: [
|
|
275
|
+
{ required: ['x-operation'] },
|
|
276
|
+
{ required: ['operationId'] },
|
|
277
|
+
{ required: ['operationPath'] },
|
|
278
|
+
{ required: ['workflowId'] },
|
|
279
|
+
],
|
|
280
|
+
};
|
|
281
|
+
const steps = {
|
|
282
|
+
type: 'array',
|
|
283
|
+
items: exports.step,
|
|
284
|
+
};
|
|
285
|
+
const JSONSchema = {
|
|
286
|
+
type: 'object',
|
|
287
|
+
properties: {
|
|
288
|
+
type: {
|
|
289
|
+
type: 'string',
|
|
290
|
+
enum: ['object', 'array', 'string', 'number', 'integer', 'boolean', 'null'],
|
|
291
|
+
},
|
|
292
|
+
properties: {
|
|
293
|
+
type: 'object',
|
|
294
|
+
additionalProperties: true,
|
|
295
|
+
},
|
|
296
|
+
required: {
|
|
297
|
+
type: 'array',
|
|
298
|
+
items: { type: 'string' },
|
|
299
|
+
},
|
|
300
|
+
items: {
|
|
301
|
+
type: 'object',
|
|
302
|
+
additionalProperties: true,
|
|
303
|
+
},
|
|
304
|
+
},
|
|
305
|
+
required: ['type'],
|
|
306
|
+
additionalProperties: true,
|
|
307
|
+
};
|
|
308
|
+
exports.workflow = {
|
|
309
|
+
type: 'object',
|
|
310
|
+
properties: {
|
|
311
|
+
workflowId: { type: 'string' },
|
|
312
|
+
summary: { type: 'string' },
|
|
313
|
+
description: { type: 'string' },
|
|
314
|
+
parameters: parameters,
|
|
315
|
+
dependsOn: { type: 'array', items: { type: 'string' } },
|
|
316
|
+
inputs: JSONSchema,
|
|
317
|
+
outputs: {
|
|
318
|
+
type: 'object',
|
|
319
|
+
additionalProperties: {
|
|
320
|
+
type: 'string',
|
|
321
|
+
},
|
|
322
|
+
},
|
|
323
|
+
steps: steps,
|
|
324
|
+
successActions: {
|
|
325
|
+
type: 'array',
|
|
326
|
+
items: onSuccessObject,
|
|
327
|
+
},
|
|
328
|
+
failureActions: {
|
|
329
|
+
type: 'array',
|
|
330
|
+
items: onFailureObject,
|
|
331
|
+
},
|
|
332
|
+
},
|
|
333
|
+
additionalProperties: false,
|
|
334
|
+
required: ['workflowId', 'steps'],
|
|
335
|
+
};
|
|
336
|
+
const workflows = {
|
|
337
|
+
type: 'array',
|
|
338
|
+
items: exports.workflow,
|
|
339
|
+
};
|
|
340
|
+
exports.arazzoSchema = {
|
|
341
|
+
type: 'object',
|
|
342
|
+
properties: {
|
|
343
|
+
arazzo: { type: 'string', enum: ['1.0.0'] },
|
|
344
|
+
info: exports.infoObject,
|
|
345
|
+
sourceDescriptions: sourceDescriptionsSchema,
|
|
346
|
+
'x-parameters': parameters,
|
|
347
|
+
workflows: workflows,
|
|
348
|
+
components: {
|
|
349
|
+
type: 'object',
|
|
350
|
+
properties: {
|
|
351
|
+
inputs: {
|
|
352
|
+
type: 'object',
|
|
353
|
+
additionalProperties: {
|
|
354
|
+
type: 'object',
|
|
355
|
+
additionalProperties: true,
|
|
356
|
+
properties: {
|
|
357
|
+
type: {
|
|
358
|
+
type: 'string',
|
|
359
|
+
},
|
|
360
|
+
properties: {
|
|
361
|
+
type: 'object',
|
|
362
|
+
additionalProperties: true,
|
|
363
|
+
},
|
|
364
|
+
},
|
|
365
|
+
required: ['type'],
|
|
366
|
+
},
|
|
367
|
+
},
|
|
368
|
+
parameters: {
|
|
369
|
+
type: 'object',
|
|
370
|
+
additionalProperties: exports.parameter,
|
|
371
|
+
},
|
|
372
|
+
successActions: {
|
|
373
|
+
type: 'object',
|
|
374
|
+
additionalProperties: onSuccessObject,
|
|
375
|
+
},
|
|
376
|
+
failureActions: {
|
|
377
|
+
type: 'object',
|
|
378
|
+
additionalProperties: onFailureObject,
|
|
379
|
+
},
|
|
380
|
+
},
|
|
381
|
+
},
|
|
382
|
+
},
|
|
383
|
+
additionalProperties: false,
|
|
384
|
+
required: ['arazzo', 'info', 'sourceDescriptions', 'workflows'],
|
|
385
|
+
};
|
|
386
|
+
exports.ArazzoTypes = (0, json_schema_adapter_1.getNodeTypesFromJSONSchema)(exports.ARAZZO_ROOT_TYPE, exports.arazzoSchema);
|
package/lib/types/asyncapi.js
CHANGED
|
@@ -308,11 +308,8 @@ const MessageExample = {
|
|
|
308
308
|
const Schema = {
|
|
309
309
|
properties: {
|
|
310
310
|
$id: { type: 'string' },
|
|
311
|
-
id: { type: 'string' },
|
|
312
311
|
$schema: { type: 'string' },
|
|
313
312
|
definitions: 'NamedSchemas',
|
|
314
|
-
$defs: 'NamedSchemas',
|
|
315
|
-
$vocabulary: { type: 'string' },
|
|
316
313
|
externalDocs: 'ExternalDocs',
|
|
317
314
|
discriminator: 'Discriminator',
|
|
318
315
|
myArbitraryKeyword: { type: 'boolean' },
|
|
@@ -333,17 +330,14 @@ const Schema = {
|
|
|
333
330
|
required: { type: 'array', items: { type: 'string' } },
|
|
334
331
|
enum: { type: 'array' },
|
|
335
332
|
type: (value) => {
|
|
336
|
-
|
|
337
|
-
|
|
333
|
+
return Array.isArray(value)
|
|
334
|
+
? {
|
|
338
335
|
type: 'array',
|
|
339
336
|
items: { enum: ['object', 'array', 'string', 'number', 'integer', 'boolean', 'null'] },
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
else {
|
|
343
|
-
return {
|
|
337
|
+
}
|
|
338
|
+
: {
|
|
344
339
|
enum: ['object', 'array', 'string', 'number', 'integer', 'boolean', 'null'],
|
|
345
340
|
};
|
|
346
|
-
}
|
|
347
341
|
},
|
|
348
342
|
allOf: (0, _1.listOf)('Schema'),
|
|
349
343
|
anyOf: (0, _1.listOf)('Schema'),
|
|
@@ -352,38 +346,12 @@ const Schema = {
|
|
|
352
346
|
if: 'Schema',
|
|
353
347
|
then: 'Schema',
|
|
354
348
|
else: 'Schema',
|
|
355
|
-
dependentSchemas: (0, _1.listOf)('Schema'),
|
|
356
|
-
prefixItems: (0, _1.listOf)('Schema'),
|
|
357
349
|
contains: 'Schema',
|
|
358
|
-
minContains: { type: 'integer', minimum: 0 },
|
|
359
|
-
maxContains: { type: 'integer', minimum: 0 },
|
|
360
350
|
patternProperties: { type: 'object' },
|
|
361
351
|
propertyNames: 'Schema',
|
|
362
|
-
unevaluatedItems: (value) => {
|
|
363
|
-
if (typeof value === 'boolean') {
|
|
364
|
-
return { type: 'boolean' };
|
|
365
|
-
}
|
|
366
|
-
else {
|
|
367
|
-
return 'Schema';
|
|
368
|
-
}
|
|
369
|
-
},
|
|
370
|
-
unevaluatedProperties: (value) => {
|
|
371
|
-
if (typeof value === 'boolean') {
|
|
372
|
-
return { type: 'boolean' };
|
|
373
|
-
}
|
|
374
|
-
else {
|
|
375
|
-
return 'Schema';
|
|
376
|
-
}
|
|
377
|
-
},
|
|
378
|
-
summary: { type: 'string' },
|
|
379
352
|
properties: 'SchemaProperties',
|
|
380
353
|
items: (value) => {
|
|
381
|
-
|
|
382
|
-
return { type: 'boolean' };
|
|
383
|
-
}
|
|
384
|
-
else {
|
|
385
|
-
return 'Schema';
|
|
386
|
-
}
|
|
354
|
+
return Array.isArray(value) ? (0, _1.listOf)('Schema') : 'Schema';
|
|
387
355
|
},
|
|
388
356
|
additionalProperties: (value) => {
|
|
389
357
|
return typeof value === 'boolean' ? { type: 'boolean' } : 'Schema';
|
|
@@ -395,22 +363,21 @@ const Schema = {
|
|
|
395
363
|
default: null,
|
|
396
364
|
readOnly: { type: 'boolean' },
|
|
397
365
|
writeOnly: { type: 'boolean' },
|
|
398
|
-
// xml: 'Xml',
|
|
399
366
|
examples: { type: 'array' },
|
|
400
367
|
example: { isExample: true },
|
|
401
368
|
deprecated: { type: 'boolean' },
|
|
402
369
|
const: null,
|
|
403
370
|
$comment: { type: 'string' },
|
|
404
|
-
|
|
371
|
+
additionalItems: (value) => {
|
|
372
|
+
return typeof value === 'boolean' ? { type: 'boolean' } : 'Schema';
|
|
373
|
+
},
|
|
374
|
+
dependencies: 'Dependencies',
|
|
405
375
|
},
|
|
406
376
|
};
|
|
407
377
|
const SchemaProperties = {
|
|
408
378
|
properties: {},
|
|
409
379
|
additionalProperties: (value) => {
|
|
410
|
-
|
|
411
|
-
return { type: 'boolean' };
|
|
412
|
-
}
|
|
413
|
-
return 'Schema';
|
|
380
|
+
return typeof value === 'boolean' ? { type: 'boolean' } : 'Schema';
|
|
414
381
|
},
|
|
415
382
|
};
|
|
416
383
|
const DiscriminatorMapping = {
|
|
@@ -552,6 +519,12 @@ const SecurityScheme = {
|
|
|
552
519
|
},
|
|
553
520
|
extensionsPrefix: 'x-',
|
|
554
521
|
};
|
|
522
|
+
const Dependencies = {
|
|
523
|
+
properties: {},
|
|
524
|
+
additionalProperties: (value) => {
|
|
525
|
+
return Array.isArray(value) ? { type: 'array', items: { type: 'string' } } : 'Schema';
|
|
526
|
+
},
|
|
527
|
+
};
|
|
555
528
|
// --- Per-protocol node types
|
|
556
529
|
// http
|
|
557
530
|
const HttpChannelBinding = {
|
|
@@ -1025,4 +998,5 @@ exports.AsyncApi2Types = {
|
|
|
1025
998
|
MessageTrait,
|
|
1026
999
|
MessageTraitList: (0, _1.listOf)('MessageTrait'),
|
|
1027
1000
|
CorrelationId,
|
|
1001
|
+
Dependencies,
|
|
1028
1002
|
};
|
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' };
|
package/lib/types/oas3_1.js
CHANGED
|
@@ -128,13 +128,13 @@ const Schema = {
|
|
|
128
128
|
if: 'Schema',
|
|
129
129
|
then: 'Schema',
|
|
130
130
|
else: 'Schema',
|
|
131
|
-
dependentSchemas: (0, _1.
|
|
131
|
+
dependentSchemas: (0, _1.mapOf)('Schema'),
|
|
132
132
|
dependentRequired: 'DependentRequired',
|
|
133
133
|
prefixItems: (0, _1.listOf)('Schema'),
|
|
134
134
|
contains: 'Schema',
|
|
135
135
|
minContains: { type: 'integer', minimum: 0 },
|
|
136
136
|
maxContains: { type: 'integer', minimum: 0 },
|
|
137
|
-
patternProperties:
|
|
137
|
+
patternProperties: 'SchemaProperties',
|
|
138
138
|
propertyNames: 'Schema',
|
|
139
139
|
unevaluatedItems: (value) => {
|
|
140
140
|
if (typeof value === '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
|
|
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
|
|
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 = [
|
|
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,30 @@
|
|
|
1
|
+
import type { FromSchema } from 'json-schema-to-ts';
|
|
2
|
+
import type { arazzoSchema, parameter, operationMethod, expectSchema, sourceDescriptionSchema, infoObject, requestBody, replacement, inherit, criteriaObject, step, workflow } from '../types/arazzo';
|
|
3
|
+
export type ArazzoDefinition = FromSchema<typeof arazzoSchema>;
|
|
4
|
+
export type OperationMethod = FromSchema<typeof operationMethod>;
|
|
5
|
+
export type ResponseContext = {
|
|
6
|
+
statusCode: number;
|
|
7
|
+
body: any;
|
|
8
|
+
headers: Headers;
|
|
9
|
+
mimeType: string;
|
|
10
|
+
} & Record<string, any>;
|
|
11
|
+
export type Expect = FromSchema<typeof expectSchema>;
|
|
12
|
+
export type SourceDescription = FromSchema<typeof sourceDescriptionSchema>;
|
|
13
|
+
export type Parameter = FromSchema<typeof parameter>;
|
|
14
|
+
export type InfoObject = FromSchema<typeof infoObject>;
|
|
15
|
+
export type RequestBody = FromSchema<typeof requestBody>;
|
|
16
|
+
export type Replacement = FromSchema<typeof replacement>;
|
|
17
|
+
export type Inherit = FromSchema<typeof inherit>;
|
|
18
|
+
export type CriteriaObject = FromSchema<typeof criteriaObject>;
|
|
19
|
+
export type VerboseLog = {
|
|
20
|
+
method: OperationMethod;
|
|
21
|
+
path: string;
|
|
22
|
+
host: string;
|
|
23
|
+
body?: any;
|
|
24
|
+
headerParams?: Record<string, string>;
|
|
25
|
+
statusCode?: number;
|
|
26
|
+
};
|
|
27
|
+
export type Step = FromSchema<typeof step>;
|
|
28
|
+
export type Workflow = FromSchema<typeof workflow> & {
|
|
29
|
+
steps: Step[];
|
|
30
|
+
};
|