@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,391 @@
|
|
|
1
|
+
import type { NodeType } from '.';
|
|
2
|
+
|
|
3
|
+
import { getNodeTypesFromJSONSchema } from './json-schema-adapter';
|
|
4
|
+
|
|
5
|
+
export const ARAZZO_ROOT_TYPE = 'Root';
|
|
6
|
+
|
|
7
|
+
export const operationMethod = {
|
|
8
|
+
type: 'string',
|
|
9
|
+
enum: ['get', 'post', 'put', 'delete', 'patch'],
|
|
10
|
+
} as const;
|
|
11
|
+
export const expectSchema = {
|
|
12
|
+
type: 'object',
|
|
13
|
+
properties: {
|
|
14
|
+
statusCode: { type: 'number' },
|
|
15
|
+
mimeType: { type: 'string' },
|
|
16
|
+
body: {},
|
|
17
|
+
schema: {
|
|
18
|
+
type: 'object',
|
|
19
|
+
additionalProperties: true,
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
additionalProperties: false,
|
|
23
|
+
oneOf: [
|
|
24
|
+
{ required: ['statusCode'] },
|
|
25
|
+
{ required: ['mimeType'] },
|
|
26
|
+
{ required: ['body'] },
|
|
27
|
+
{ required: ['schema'] },
|
|
28
|
+
],
|
|
29
|
+
} as const;
|
|
30
|
+
const openAPISourceDescriptionSchema = {
|
|
31
|
+
type: 'object',
|
|
32
|
+
properties: {
|
|
33
|
+
name: { type: 'string' },
|
|
34
|
+
type: { type: 'string', enum: ['openapi'] },
|
|
35
|
+
url: { type: 'string' },
|
|
36
|
+
'x-serverUrl': { type: 'string' },
|
|
37
|
+
},
|
|
38
|
+
additionalProperties: false,
|
|
39
|
+
required: ['name', 'type', 'url'],
|
|
40
|
+
} as const;
|
|
41
|
+
const noneSourceDescriptionSchema = {
|
|
42
|
+
type: 'object',
|
|
43
|
+
properties: {
|
|
44
|
+
name: { type: 'string' },
|
|
45
|
+
type: { type: 'string', enum: ['none'] },
|
|
46
|
+
'x-serverUrl': { type: 'string' },
|
|
47
|
+
},
|
|
48
|
+
additionalProperties: false,
|
|
49
|
+
required: ['name', 'type', 'x-serverUrl'],
|
|
50
|
+
} as const;
|
|
51
|
+
const arazzoSourceDescriptionSchema = {
|
|
52
|
+
type: 'object',
|
|
53
|
+
properties: {
|
|
54
|
+
name: { type: 'string' },
|
|
55
|
+
type: { type: 'string', enum: ['arazzo'] },
|
|
56
|
+
url: { type: 'string' },
|
|
57
|
+
},
|
|
58
|
+
additionalProperties: false,
|
|
59
|
+
required: ['name', 'type', 'url'],
|
|
60
|
+
} as const;
|
|
61
|
+
export const sourceDescriptionSchema = {
|
|
62
|
+
type: 'object',
|
|
63
|
+
oneOf: [
|
|
64
|
+
openAPISourceDescriptionSchema,
|
|
65
|
+
noneSourceDescriptionSchema,
|
|
66
|
+
arazzoSourceDescriptionSchema,
|
|
67
|
+
],
|
|
68
|
+
} as const;
|
|
69
|
+
const sourceDescriptionsSchema = {
|
|
70
|
+
type: 'array',
|
|
71
|
+
items: sourceDescriptionSchema,
|
|
72
|
+
} as const;
|
|
73
|
+
const extendedOperation = {
|
|
74
|
+
type: 'object',
|
|
75
|
+
properties: {
|
|
76
|
+
path: { type: 'string' },
|
|
77
|
+
method: operationMethod,
|
|
78
|
+
sourceDescriptionName: { type: 'string' },
|
|
79
|
+
serverUrl: { type: 'string' },
|
|
80
|
+
},
|
|
81
|
+
additionalProperties: false,
|
|
82
|
+
required: ['path', 'method'],
|
|
83
|
+
} as const;
|
|
84
|
+
export const parameter = {
|
|
85
|
+
type: 'object',
|
|
86
|
+
oneOf: [
|
|
87
|
+
{
|
|
88
|
+
type: 'object',
|
|
89
|
+
properties: {
|
|
90
|
+
in: { type: 'string', enum: ['header', 'query', 'path', 'cookie', 'body'] },
|
|
91
|
+
name: { type: 'string' },
|
|
92
|
+
value: {
|
|
93
|
+
oneOf: [{ type: 'string' }, { type: 'number' }, { type: 'boolean' }],
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
required: ['name', 'value'],
|
|
97
|
+
additionalProperties: false,
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
type: 'object',
|
|
101
|
+
properties: {
|
|
102
|
+
reference: { type: 'string' },
|
|
103
|
+
value: {
|
|
104
|
+
oneOf: [{ type: 'string' }, { type: 'number' }, { type: 'boolean' }],
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
required: ['reference'],
|
|
108
|
+
additionalProperties: false,
|
|
109
|
+
},
|
|
110
|
+
],
|
|
111
|
+
} as const;
|
|
112
|
+
const parameters = {
|
|
113
|
+
type: 'array',
|
|
114
|
+
items: parameter,
|
|
115
|
+
} as const;
|
|
116
|
+
export const infoObject = {
|
|
117
|
+
type: 'object',
|
|
118
|
+
properties: {
|
|
119
|
+
title: { type: 'string' },
|
|
120
|
+
description: { type: 'string' },
|
|
121
|
+
summary: { type: 'string' },
|
|
122
|
+
version: { type: 'string' },
|
|
123
|
+
},
|
|
124
|
+
additionalProperties: false,
|
|
125
|
+
required: ['title', 'version'],
|
|
126
|
+
} as const;
|
|
127
|
+
export const replacement = {
|
|
128
|
+
type: 'object',
|
|
129
|
+
properties: {
|
|
130
|
+
target: { type: 'string' },
|
|
131
|
+
value: {
|
|
132
|
+
oneOf: [
|
|
133
|
+
{ type: 'string' },
|
|
134
|
+
{ type: 'object' },
|
|
135
|
+
{ type: 'array' },
|
|
136
|
+
{ type: 'number' },
|
|
137
|
+
{ type: 'boolean' },
|
|
138
|
+
],
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
} as const;
|
|
142
|
+
export const requestBody = {
|
|
143
|
+
type: 'object',
|
|
144
|
+
properties: {
|
|
145
|
+
contentType: { type: 'string' },
|
|
146
|
+
payload: {
|
|
147
|
+
oneOf: [
|
|
148
|
+
{ type: 'string' },
|
|
149
|
+
{ type: 'object', additionalProperties: true },
|
|
150
|
+
{ type: 'array' },
|
|
151
|
+
{ type: 'number' },
|
|
152
|
+
{ type: 'boolean' },
|
|
153
|
+
],
|
|
154
|
+
},
|
|
155
|
+
encoding: { type: 'string' },
|
|
156
|
+
replacements: {
|
|
157
|
+
type: 'array',
|
|
158
|
+
items: replacement,
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
additionalProperties: false,
|
|
162
|
+
required: ['payload'],
|
|
163
|
+
} as const;
|
|
164
|
+
export const criteriaObject = {
|
|
165
|
+
type: 'object',
|
|
166
|
+
properties: {
|
|
167
|
+
condition: { type: 'string' },
|
|
168
|
+
context: { type: 'string' },
|
|
169
|
+
type: {
|
|
170
|
+
oneOf: [
|
|
171
|
+
{ type: 'string', enum: ['regex', 'jsonpath', 'simple', 'xpath'] },
|
|
172
|
+
{
|
|
173
|
+
type: 'object',
|
|
174
|
+
properties: {
|
|
175
|
+
type: { type: 'string', enum: ['jsonpath'] },
|
|
176
|
+
version: { type: 'string', enum: ['draft-goessner-dispatch-jsonpath-00'] },
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
type: 'object',
|
|
181
|
+
properties: {
|
|
182
|
+
type: { type: 'string', enum: ['xpath'] },
|
|
183
|
+
version: { type: 'string', enum: ['xpath-30', 'xpath-20', 'xpath-10'] },
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
],
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
required: ['condition'],
|
|
190
|
+
additionalProperties: false,
|
|
191
|
+
} as const;
|
|
192
|
+
const criteriaObjects = {
|
|
193
|
+
type: 'array',
|
|
194
|
+
items: criteriaObject,
|
|
195
|
+
} as const;
|
|
196
|
+
export const inherit = {
|
|
197
|
+
type: 'string',
|
|
198
|
+
enum: ['auto', 'none'],
|
|
199
|
+
} as const;
|
|
200
|
+
const onSuccessObject = {
|
|
201
|
+
type: 'object',
|
|
202
|
+
properties: {
|
|
203
|
+
name: { type: 'string' },
|
|
204
|
+
type: { type: 'string', enum: ['goto', 'end'] },
|
|
205
|
+
stepId: { type: 'string' },
|
|
206
|
+
workflowId: { type: 'string' },
|
|
207
|
+
criteria: criteriaObjects,
|
|
208
|
+
},
|
|
209
|
+
additionalProperties: false,
|
|
210
|
+
required: ['type', 'name'],
|
|
211
|
+
} as const;
|
|
212
|
+
const onSuccessList = {
|
|
213
|
+
type: 'array',
|
|
214
|
+
items: onSuccessObject,
|
|
215
|
+
} as const;
|
|
216
|
+
const onFailureObject = {
|
|
217
|
+
type: 'object',
|
|
218
|
+
properties: {
|
|
219
|
+
name: { type: 'string' },
|
|
220
|
+
type: { type: 'string', enum: ['goto', 'retry', 'end'] },
|
|
221
|
+
workflowId: { type: 'string' },
|
|
222
|
+
stepId: { type: 'string' },
|
|
223
|
+
retryAfter: { type: 'number' },
|
|
224
|
+
retryLimit: { type: 'number' },
|
|
225
|
+
criteria: criteriaObjects,
|
|
226
|
+
},
|
|
227
|
+
additionalProperties: false,
|
|
228
|
+
required: ['type', 'name'],
|
|
229
|
+
} as const;
|
|
230
|
+
const onFailureList = {
|
|
231
|
+
type: 'array',
|
|
232
|
+
items: onFailureObject,
|
|
233
|
+
} as const;
|
|
234
|
+
export const step = {
|
|
235
|
+
type: 'object',
|
|
236
|
+
properties: {
|
|
237
|
+
stepId: { type: 'string' },
|
|
238
|
+
description: { type: 'string' },
|
|
239
|
+
operationId: { type: 'string' },
|
|
240
|
+
operationPath: { type: 'string' },
|
|
241
|
+
workflowId: { type: 'string' },
|
|
242
|
+
parameters: parameters,
|
|
243
|
+
successCriteria: criteriaObjects,
|
|
244
|
+
onSuccess: onSuccessList,
|
|
245
|
+
onFailure: onFailureList,
|
|
246
|
+
outputs: {
|
|
247
|
+
type: 'object',
|
|
248
|
+
additionalProperties: {
|
|
249
|
+
oneOf: [
|
|
250
|
+
{
|
|
251
|
+
type: 'string',
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
type: 'object',
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
type: 'array',
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
type: 'boolean',
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
type: 'number',
|
|
264
|
+
},
|
|
265
|
+
],
|
|
266
|
+
},
|
|
267
|
+
},
|
|
268
|
+
'x-inherit': inherit,
|
|
269
|
+
'x-expect': expectSchema,
|
|
270
|
+
'x-assert': { type: 'string' },
|
|
271
|
+
'x-operation': extendedOperation,
|
|
272
|
+
requestBody: requestBody,
|
|
273
|
+
},
|
|
274
|
+
required: ['stepId'],
|
|
275
|
+
oneOf: [
|
|
276
|
+
{ required: ['x-operation'] },
|
|
277
|
+
{ required: ['operationId'] },
|
|
278
|
+
{ required: ['operationPath'] },
|
|
279
|
+
{ required: ['workflowId'] },
|
|
280
|
+
],
|
|
281
|
+
} as const;
|
|
282
|
+
const steps = {
|
|
283
|
+
type: 'array',
|
|
284
|
+
items: step,
|
|
285
|
+
} as const;
|
|
286
|
+
const JSONSchema = {
|
|
287
|
+
type: 'object',
|
|
288
|
+
properties: {
|
|
289
|
+
type: {
|
|
290
|
+
type: 'string',
|
|
291
|
+
enum: ['object', 'array', 'string', 'number', 'integer', 'boolean', 'null'],
|
|
292
|
+
},
|
|
293
|
+
properties: {
|
|
294
|
+
type: 'object',
|
|
295
|
+
additionalProperties: true,
|
|
296
|
+
},
|
|
297
|
+
required: {
|
|
298
|
+
type: 'array',
|
|
299
|
+
items: { type: 'string' },
|
|
300
|
+
},
|
|
301
|
+
items: {
|
|
302
|
+
type: 'object',
|
|
303
|
+
additionalProperties: true,
|
|
304
|
+
},
|
|
305
|
+
},
|
|
306
|
+
required: ['type'],
|
|
307
|
+
additionalProperties: true,
|
|
308
|
+
} as const;
|
|
309
|
+
export const workflow = {
|
|
310
|
+
type: 'object',
|
|
311
|
+
properties: {
|
|
312
|
+
workflowId: { type: 'string' },
|
|
313
|
+
summary: { type: 'string' },
|
|
314
|
+
description: { type: 'string' },
|
|
315
|
+
parameters: parameters,
|
|
316
|
+
dependsOn: { type: 'array', items: { type: 'string' } },
|
|
317
|
+
inputs: JSONSchema,
|
|
318
|
+
outputs: {
|
|
319
|
+
type: 'object',
|
|
320
|
+
additionalProperties: {
|
|
321
|
+
type: 'string',
|
|
322
|
+
},
|
|
323
|
+
},
|
|
324
|
+
steps: steps,
|
|
325
|
+
successActions: {
|
|
326
|
+
type: 'array',
|
|
327
|
+
items: onSuccessObject,
|
|
328
|
+
},
|
|
329
|
+
failureActions: {
|
|
330
|
+
type: 'array',
|
|
331
|
+
items: onFailureObject,
|
|
332
|
+
},
|
|
333
|
+
},
|
|
334
|
+
additionalProperties: false,
|
|
335
|
+
required: ['workflowId', 'steps'],
|
|
336
|
+
} as const;
|
|
337
|
+
const workflows = {
|
|
338
|
+
type: 'array',
|
|
339
|
+
items: workflow,
|
|
340
|
+
} as const;
|
|
341
|
+
export const arazzoSchema = {
|
|
342
|
+
type: 'object',
|
|
343
|
+
properties: {
|
|
344
|
+
arazzo: { type: 'string', enum: ['1.0.0'] },
|
|
345
|
+
info: infoObject,
|
|
346
|
+
sourceDescriptions: sourceDescriptionsSchema,
|
|
347
|
+
'x-parameters': parameters,
|
|
348
|
+
workflows: workflows,
|
|
349
|
+
components: {
|
|
350
|
+
type: 'object',
|
|
351
|
+
properties: {
|
|
352
|
+
inputs: {
|
|
353
|
+
type: 'object',
|
|
354
|
+
additionalProperties: {
|
|
355
|
+
type: 'object',
|
|
356
|
+
additionalProperties: true,
|
|
357
|
+
properties: {
|
|
358
|
+
type: {
|
|
359
|
+
type: 'string',
|
|
360
|
+
},
|
|
361
|
+
properties: {
|
|
362
|
+
type: 'object',
|
|
363
|
+
additionalProperties: true,
|
|
364
|
+
},
|
|
365
|
+
},
|
|
366
|
+
required: ['type'],
|
|
367
|
+
},
|
|
368
|
+
},
|
|
369
|
+
parameters: {
|
|
370
|
+
type: 'object',
|
|
371
|
+
additionalProperties: parameter,
|
|
372
|
+
},
|
|
373
|
+
successActions: {
|
|
374
|
+
type: 'object',
|
|
375
|
+
additionalProperties: onSuccessObject,
|
|
376
|
+
},
|
|
377
|
+
failureActions: {
|
|
378
|
+
type: 'object',
|
|
379
|
+
additionalProperties: onFailureObject,
|
|
380
|
+
},
|
|
381
|
+
},
|
|
382
|
+
},
|
|
383
|
+
},
|
|
384
|
+
additionalProperties: false,
|
|
385
|
+
required: ['arazzo', 'info', 'sourceDescriptions', 'workflows'],
|
|
386
|
+
} as const;
|
|
387
|
+
|
|
388
|
+
export const ArazzoTypes: Record<string, NodeType> = getNodeTypesFromJSONSchema(
|
|
389
|
+
ARAZZO_ROOT_TYPE,
|
|
390
|
+
arazzoSchema
|
|
391
|
+
);
|
package/src/types/asyncapi.ts
CHANGED
|
@@ -334,11 +334,8 @@ const MessageExample: NodeType = {
|
|
|
334
334
|
const Schema: NodeType = {
|
|
335
335
|
properties: {
|
|
336
336
|
$id: { type: 'string' },
|
|
337
|
-
id: { type: 'string' },
|
|
338
337
|
$schema: { type: 'string' },
|
|
339
338
|
definitions: 'NamedSchemas',
|
|
340
|
-
$defs: 'NamedSchemas',
|
|
341
|
-
$vocabulary: { type: 'string' },
|
|
342
339
|
externalDocs: 'ExternalDocs',
|
|
343
340
|
discriminator: 'Discriminator',
|
|
344
341
|
myArbitraryKeyword: { type: 'boolean' },
|
|
@@ -359,16 +356,14 @@ const Schema: NodeType = {
|
|
|
359
356
|
required: { type: 'array', items: { type: 'string' } },
|
|
360
357
|
enum: { type: 'array' },
|
|
361
358
|
type: (value: any) => {
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
};
|
|
371
|
-
}
|
|
359
|
+
return Array.isArray(value)
|
|
360
|
+
? {
|
|
361
|
+
type: 'array',
|
|
362
|
+
items: { enum: ['object', 'array', 'string', 'number', 'integer', 'boolean', 'null'] },
|
|
363
|
+
}
|
|
364
|
+
: {
|
|
365
|
+
enum: ['object', 'array', 'string', 'number', 'integer', 'boolean', 'null'],
|
|
366
|
+
};
|
|
372
367
|
},
|
|
373
368
|
allOf: listOf('Schema'),
|
|
374
369
|
anyOf: listOf('Schema'),
|
|
@@ -377,35 +372,12 @@ const Schema: NodeType = {
|
|
|
377
372
|
if: 'Schema',
|
|
378
373
|
then: 'Schema',
|
|
379
374
|
else: 'Schema',
|
|
380
|
-
dependentSchemas: listOf('Schema'),
|
|
381
|
-
prefixItems: listOf('Schema'),
|
|
382
375
|
contains: 'Schema',
|
|
383
|
-
minContains: { type: 'integer', minimum: 0 },
|
|
384
|
-
maxContains: { type: 'integer', minimum: 0 },
|
|
385
376
|
patternProperties: { type: 'object' },
|
|
386
377
|
propertyNames: 'Schema',
|
|
387
|
-
unevaluatedItems: (value: unknown) => {
|
|
388
|
-
if (typeof value === 'boolean') {
|
|
389
|
-
return { type: 'boolean' };
|
|
390
|
-
} else {
|
|
391
|
-
return 'Schema';
|
|
392
|
-
}
|
|
393
|
-
},
|
|
394
|
-
unevaluatedProperties: (value: unknown) => {
|
|
395
|
-
if (typeof value === 'boolean') {
|
|
396
|
-
return { type: 'boolean' };
|
|
397
|
-
} else {
|
|
398
|
-
return 'Schema';
|
|
399
|
-
}
|
|
400
|
-
},
|
|
401
|
-
summary: { type: 'string' },
|
|
402
378
|
properties: 'SchemaProperties',
|
|
403
379
|
items: (value: any) => {
|
|
404
|
-
|
|
405
|
-
return { type: 'boolean' };
|
|
406
|
-
} else {
|
|
407
|
-
return 'Schema';
|
|
408
|
-
}
|
|
380
|
+
return Array.isArray(value) ? listOf('Schema') : 'Schema';
|
|
409
381
|
},
|
|
410
382
|
additionalProperties: (value: any) => {
|
|
411
383
|
return typeof value === 'boolean' ? { type: 'boolean' } : 'Schema';
|
|
@@ -417,23 +389,22 @@ const Schema: NodeType = {
|
|
|
417
389
|
default: null,
|
|
418
390
|
readOnly: { type: 'boolean' },
|
|
419
391
|
writeOnly: { type: 'boolean' },
|
|
420
|
-
// xml: 'Xml',
|
|
421
392
|
examples: { type: 'array' },
|
|
422
393
|
example: { isExample: true },
|
|
423
394
|
deprecated: { type: 'boolean' },
|
|
424
395
|
const: null,
|
|
425
396
|
$comment: { type: 'string' },
|
|
426
|
-
|
|
397
|
+
additionalItems: (value: any) => {
|
|
398
|
+
return typeof value === 'boolean' ? { type: 'boolean' } : 'Schema';
|
|
399
|
+
},
|
|
400
|
+
dependencies: 'Dependencies',
|
|
427
401
|
},
|
|
428
402
|
};
|
|
429
403
|
|
|
430
404
|
const SchemaProperties: NodeType = {
|
|
431
405
|
properties: {},
|
|
432
406
|
additionalProperties: (value: any) => {
|
|
433
|
-
|
|
434
|
-
return { type: 'boolean' };
|
|
435
|
-
}
|
|
436
|
-
return 'Schema';
|
|
407
|
+
return typeof value === 'boolean' ? { type: 'boolean' } : 'Schema';
|
|
437
408
|
},
|
|
438
409
|
};
|
|
439
410
|
|
|
@@ -584,6 +555,13 @@ const SecurityScheme: NodeType = {
|
|
|
584
555
|
extensionsPrefix: 'x-',
|
|
585
556
|
};
|
|
586
557
|
|
|
558
|
+
const Dependencies: NodeType = {
|
|
559
|
+
properties: {},
|
|
560
|
+
additionalProperties: (value: any) => {
|
|
561
|
+
return Array.isArray(value) ? { type: 'array', items: { type: 'string' } } : 'Schema';
|
|
562
|
+
},
|
|
563
|
+
};
|
|
564
|
+
|
|
587
565
|
// --- Per-protocol node types
|
|
588
566
|
|
|
589
567
|
// http
|
|
@@ -1133,4 +1111,5 @@ export const AsyncApi2Types: Record<string, NodeType> = {
|
|
|
1133
1111
|
MessageTrait,
|
|
1134
1112
|
MessageTraitList: listOf('MessageTrait'),
|
|
1135
1113
|
CorrelationId,
|
|
1114
|
+
Dependencies,
|
|
1136
1115
|
};
|
package/src/types/oas3.ts
CHANGED
|
@@ -346,13 +346,6 @@ const Schema: NodeType = {
|
|
|
346
346
|
return 'Schema';
|
|
347
347
|
}
|
|
348
348
|
},
|
|
349
|
-
additionalItems: (value: any) => {
|
|
350
|
-
if (typeof value === 'boolean') {
|
|
351
|
-
return { type: 'boolean' };
|
|
352
|
-
} else {
|
|
353
|
-
return 'Schema';
|
|
354
|
-
}
|
|
355
|
-
},
|
|
356
349
|
additionalProperties: (value: any) => {
|
|
357
350
|
if (typeof value === 'boolean') {
|
|
358
351
|
return { type: 'boolean' };
|
package/src/types/oas3_1.ts
CHANGED
|
@@ -133,13 +133,13 @@ const Schema: NodeType = {
|
|
|
133
133
|
if: 'Schema',
|
|
134
134
|
then: 'Schema',
|
|
135
135
|
else: 'Schema',
|
|
136
|
-
dependentSchemas:
|
|
136
|
+
dependentSchemas: mapOf('Schema'),
|
|
137
137
|
dependentRequired: 'DependentRequired',
|
|
138
138
|
prefixItems: listOf('Schema'),
|
|
139
139
|
contains: 'Schema',
|
|
140
140
|
minContains: { type: 'integer', minimum: 0 },
|
|
141
141
|
maxContains: { type: 'integer', minimum: 0 },
|
|
142
|
-
patternProperties:
|
|
142
|
+
patternProperties: 'SchemaProperties',
|
|
143
143
|
propertyNames: 'Schema',
|
|
144
144
|
unevaluatedItems: (value: unknown) => {
|
|
145
145
|
if (typeof value === 'boolean') {
|
|
@@ -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
|
|
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 = [
|
|
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];
|
|
@@ -238,16 +245,19 @@ const ConfigStyleguide: NodeType = {
|
|
|
238
245
|
oas3_0Rules: 'Rules',
|
|
239
246
|
oas3_1Rules: 'Rules',
|
|
240
247
|
async2Rules: 'Rules',
|
|
248
|
+
arazzoRules: 'Rules',
|
|
241
249
|
preprocessors: { type: 'object' },
|
|
242
250
|
oas2Preprocessors: { type: 'object' },
|
|
243
251
|
oas3_0Preprocessors: { type: 'object' },
|
|
244
252
|
oas3_1Preprocessors: { type: 'object' },
|
|
245
253
|
async2Preprocessors: { type: 'object' },
|
|
254
|
+
arazzoPreprocessors: { type: 'object' },
|
|
246
255
|
decorators: { type: 'object' },
|
|
247
256
|
oas2Decorators: { type: 'object' },
|
|
248
257
|
oas3_0Decorators: { type: 'object' },
|
|
249
258
|
oas3_1Decorators: { type: 'object' },
|
|
250
259
|
async2Decorators: { type: 'object' },
|
|
260
|
+
arazzoDecorators: { type: 'object' },
|
|
251
261
|
},
|
|
252
262
|
};
|
|
253
263
|
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { FromSchema } from 'json-schema-to-ts';
|
|
2
|
+
import type {
|
|
3
|
+
arazzoSchema,
|
|
4
|
+
parameter,
|
|
5
|
+
operationMethod,
|
|
6
|
+
expectSchema,
|
|
7
|
+
sourceDescriptionSchema,
|
|
8
|
+
infoObject,
|
|
9
|
+
requestBody,
|
|
10
|
+
replacement,
|
|
11
|
+
inherit,
|
|
12
|
+
criteriaObject,
|
|
13
|
+
step,
|
|
14
|
+
workflow,
|
|
15
|
+
} from '../types/arazzo';
|
|
16
|
+
|
|
17
|
+
export type ArazzoDefinition = FromSchema<typeof arazzoSchema>;
|
|
18
|
+
export type OperationMethod = FromSchema<typeof operationMethod>;
|
|
19
|
+
export type ResponseContext = {
|
|
20
|
+
statusCode: number;
|
|
21
|
+
body: any;
|
|
22
|
+
headers: Headers;
|
|
23
|
+
mimeType: string;
|
|
24
|
+
} & Record<string, any>;
|
|
25
|
+
export type Expect = FromSchema<typeof expectSchema>;
|
|
26
|
+
export type SourceDescription = FromSchema<typeof sourceDescriptionSchema>;
|
|
27
|
+
export type Parameter = FromSchema<typeof parameter>;
|
|
28
|
+
export type InfoObject = FromSchema<typeof infoObject>;
|
|
29
|
+
export type RequestBody = FromSchema<typeof requestBody>;
|
|
30
|
+
export type Replacement = FromSchema<typeof replacement>;
|
|
31
|
+
export type Inherit = FromSchema<typeof inherit>;
|
|
32
|
+
export type CriteriaObject = FromSchema<typeof criteriaObject>;
|
|
33
|
+
export type VerboseLog = {
|
|
34
|
+
method: OperationMethod;
|
|
35
|
+
path: string;
|
|
36
|
+
host: string;
|
|
37
|
+
body?: any;
|
|
38
|
+
headerParams?: Record<string, string>;
|
|
39
|
+
statusCode?: number;
|
|
40
|
+
};
|
|
41
|
+
export type Step = FromSchema<typeof step>;
|
|
42
|
+
export type Workflow = FromSchema<typeof workflow> & {
|
|
43
|
+
steps: Step[];
|
|
44
|
+
};
|