@redocly/openapi-core 1.18.1 → 1.19.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 (139) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/lib/benchmark/benches/lint-with-many-rules.bench.js +2 -2
  3. package/lib/benchmark/benches/lint-with-nested-rule.bench.js +2 -2
  4. package/lib/benchmark/benches/lint-with-no-rules.bench.js +2 -2
  5. package/lib/benchmark/benches/lint-with-top-level-rule-report.bench.js +2 -2
  6. package/lib/benchmark/benches/lint-with-top-level-rule.bench.js +2 -2
  7. package/lib/benchmark/benches/recommended-oas3.bench.js +2 -2
  8. package/lib/benchmark/benches/resolve-with-no-external.bench.js +2 -2
  9. package/lib/benchmark/utils.js +7 -4
  10. package/lib/bundle.d.ts +2 -2
  11. package/lib/bundle.js +127 -120
  12. package/lib/config/all.js +9 -0
  13. package/lib/config/builtIn.js +7 -1
  14. package/lib/config/config-resolvers.js +179 -138
  15. package/lib/config/config.d.ts +2 -2
  16. package/lib/config/config.js +53 -34
  17. package/lib/config/load.js +105 -117
  18. package/lib/config/minimal.js +9 -0
  19. package/lib/config/recommended-strict.js +9 -0
  20. package/lib/config/recommended.js +9 -0
  21. package/lib/config/rules.d.ts +3 -3
  22. package/lib/config/rules.js +1 -2
  23. package/lib/config/types.d.ts +9 -3
  24. package/lib/config/utils.js +70 -49
  25. package/lib/decorators/async3/index.d.ts +1 -0
  26. package/lib/decorators/async3/index.js +4 -0
  27. package/lib/decorators/common/filters/filter-helper.js +2 -3
  28. package/lib/decorators/common/filters/filter-in.js +1 -1
  29. package/lib/decorators/common/filters/filter-out.js +1 -1
  30. package/lib/decorators/common/info-override.js +1 -12
  31. package/lib/decorators/common/media-type-examples-override.js +8 -2
  32. package/lib/decorators/common/remove-x-internal.js +4 -5
  33. package/lib/decorators/oas2/remove-unused-components.js +1 -2
  34. package/lib/decorators/oas3/remove-unused-components.js +1 -2
  35. package/lib/env.d.ts +0 -1
  36. package/lib/env.js +1 -1
  37. package/lib/format/codeframes.js +10 -8
  38. package/lib/format/format.js +23 -15
  39. package/lib/index.d.ts +2 -1
  40. package/lib/index.js +6 -4
  41. package/lib/js-yaml/index.js +1 -1
  42. package/lib/lint.d.ts +2 -0
  43. package/lib/lint.js +92 -99
  44. package/lib/oas-types.d.ts +9 -5
  45. package/lib/oas-types.js +22 -12
  46. package/lib/redocly/domains.js +6 -6
  47. package/lib/redocly/index.js +60 -73
  48. package/lib/redocly/registry-api.js +64 -82
  49. package/lib/ref-utils.js +13 -13
  50. package/lib/resolve.js +186 -205
  51. package/lib/rules/ajv.js +10 -8
  52. package/lib/rules/async3/channels-kebab-case.d.ts +2 -0
  53. package/lib/rules/async3/channels-kebab-case.js +19 -0
  54. package/lib/rules/async3/index.d.ts +3 -0
  55. package/lib/rules/async3/index.js +22 -0
  56. package/lib/rules/async3/no-channel-trailing-slash.d.ts +2 -0
  57. package/lib/rules/async3/no-channel-trailing-slash.js +16 -0
  58. package/lib/rules/common/assertions/asserts.js +5 -5
  59. package/lib/rules/common/assertions/index.d.ts +5 -4
  60. package/lib/rules/common/assertions/utils.js +43 -28
  61. package/lib/rules/common/no-invalid-parameter-examples.js +1 -2
  62. package/lib/rules/common/no-invalid-schema-examples.js +1 -2
  63. package/lib/rules/common/no-required-schema-properties-undefined.js +1 -2
  64. package/lib/rules/common/operation-tag-defined.js +1 -2
  65. package/lib/rules/common/path-http-verbs-order.js +1 -1
  66. package/lib/rules/common/required-string-property-missing-min-length.js +2 -2
  67. package/lib/rules/common/response-contains-header.js +2 -2
  68. package/lib/rules/common/security-defined.js +3 -7
  69. package/lib/rules/common/spec.d.ts +2 -2
  70. package/lib/rules/common/spec.js +6 -7
  71. package/lib/rules/no-unresolved-refs.js +3 -4
  72. package/lib/rules/oas2/response-contains-property.js +1 -2
  73. package/lib/rules/oas3/array-parameter-serialization.js +1 -2
  74. package/lib/rules/oas3/component-name-unique.js +2 -4
  75. package/lib/rules/oas3/no-invalid-media-type-examples.js +1 -2
  76. package/lib/rules/oas3/no-server-variables-empty-enum.js +1 -2
  77. package/lib/rules/oas3/no-undefined-server-variable.js +2 -3
  78. package/lib/rules/oas3/no-unused-components.js +1 -2
  79. package/lib/rules/oas3/response-contains-property.js +1 -2
  80. package/lib/rules/utils.js +14 -12
  81. package/lib/types/asyncapi2.d.ts +17 -0
  82. package/lib/types/{asyncapi.js → asyncapi2.js} +56 -52
  83. package/lib/types/asyncapi3.d.ts +2 -0
  84. package/lib/types/asyncapi3.js +347 -0
  85. package/lib/types/index.js +19 -10
  86. package/lib/types/json-schema-adapter.js +4 -18
  87. package/lib/types/oas2.js +6 -6
  88. package/lib/types/oas3.js +10 -10
  89. package/lib/types/oas3_1.js +14 -8
  90. package/lib/types/redocly-yaml.d.ts +3 -1
  91. package/lib/types/redocly-yaml.js +131 -35
  92. package/lib/typings/asyncapi3.d.ts +53 -0
  93. package/lib/typings/asyncapi3.js +2 -0
  94. package/lib/utils.d.ts +4 -3
  95. package/lib/utils.js +55 -72
  96. package/lib/visitors.d.ts +11 -0
  97. package/lib/visitors.js +21 -8
  98. package/lib/walk.js +30 -23
  99. package/package.json +2 -2
  100. package/src/__tests__/bundle.test.ts +142 -0
  101. package/src/bundle.ts +17 -3
  102. package/src/config/__tests__/__snapshots__/config-resolvers.test.ts.snap +22 -0
  103. package/src/config/__tests__/__snapshots__/config.test.ts.snap +24 -0
  104. package/src/config/__tests__/config.test.ts +11 -0
  105. package/src/config/all.ts +9 -0
  106. package/src/config/builtIn.ts +6 -0
  107. package/src/config/config-resolvers.ts +15 -2
  108. package/src/config/config.ts +24 -5
  109. package/src/config/minimal.ts +9 -0
  110. package/src/config/recommended-strict.ts +9 -0
  111. package/src/config/recommended.ts +9 -0
  112. package/src/config/rules.ts +12 -4
  113. package/src/config/types.ts +15 -2
  114. package/src/config/utils.ts +15 -0
  115. package/src/decorators/async3/index.ts +1 -0
  116. package/src/decorators/common/remove-x-internal.ts +2 -2
  117. package/src/index.ts +2 -1
  118. package/src/lint.ts +26 -3
  119. package/src/oas-types.ts +31 -13
  120. package/src/rules/arazzo/index.ts +1 -1
  121. package/src/rules/async2/index.ts +5 -5
  122. package/src/rules/async3/__tests__/channels-kebab-case.test.ts +141 -0
  123. package/src/rules/async3/__tests__/no-channel-trailing-slash.test.ts +96 -0
  124. package/src/rules/async3/channels-kebab-case.ts +19 -0
  125. package/src/rules/async3/index.ts +23 -0
  126. package/src/rules/async3/no-channel-trailing-slash.ts +16 -0
  127. package/src/rules/common/assertions/index.ts +13 -4
  128. package/src/rules/common/spec.ts +2 -2
  129. package/src/rules/oas2/index.ts +4 -4
  130. package/src/rules/oas3/index.ts +39 -37
  131. package/src/types/{asyncapi.ts → asyncapi2.ts} +37 -34
  132. package/src/types/asyncapi3.ts +381 -0
  133. package/src/types/oas3_1.ts +2 -1
  134. package/src/types/redocly-yaml.ts +14 -0
  135. package/src/typings/asyncapi3.ts +61 -0
  136. package/src/utils.ts +5 -3
  137. package/src/visitors.ts +18 -0
  138. package/tsconfig.tsbuildinfo +1 -1
  139. package/lib/types/asyncapi.d.ts +0 -2
@@ -0,0 +1,381 @@
1
+ import { NodeType, listOf, mapOf } from '.';
2
+ import {
3
+ AsyncApi2Bindings,
4
+ Schema,
5
+ Dependencies,
6
+ Discriminator,
7
+ DiscriminatorMapping,
8
+ SchemaProperties,
9
+ CorrelationId,
10
+ Tag,
11
+ ServerMap,
12
+ ExternalDocs,
13
+ SecuritySchemeFlows,
14
+ ServerVariable,
15
+ Contact,
16
+ License,
17
+ MessageExample,
18
+ } from './asyncapi2';
19
+
20
+ const Root: NodeType = {
21
+ properties: {
22
+ asyncapi: { type: 'string', enum: ['3.0.0'] },
23
+ info: 'Info',
24
+ id: { type: 'string' },
25
+ servers: 'ServerMap',
26
+ channels: 'NamedChannels',
27
+ components: 'Components',
28
+ operations: 'NamedOperations',
29
+ defaultContentType: { type: 'string' },
30
+ },
31
+ required: ['asyncapi', 'info'],
32
+ };
33
+
34
+ const Channel: NodeType = {
35
+ properties: {
36
+ address: { type: 'string' },
37
+ messages: 'NamedMessages',
38
+ title: { type: 'string' },
39
+ summary: { type: 'string' },
40
+ description: { type: 'string' },
41
+ servers: 'ServerList',
42
+ parameters: 'ParametersMap',
43
+ bindings: 'ChannelBindings',
44
+ tags: 'TagList',
45
+ externalDocs: 'ExternalDocs',
46
+ },
47
+ };
48
+
49
+ const Server: NodeType = {
50
+ properties: {
51
+ host: { type: 'string' },
52
+ pathname: { type: 'string' },
53
+ protocol: { type: 'string' },
54
+ protocolVersion: { type: 'string' },
55
+ description: { type: 'string' },
56
+ variables: 'ServerVariablesMap',
57
+ security: 'SecuritySchemeList',
58
+ bindings: 'ServerBindings',
59
+ externalDocs: 'ExternalDocs',
60
+ tags: 'TagList',
61
+ },
62
+ required: ['host', 'protocol'],
63
+ };
64
+
65
+ const Info: NodeType = {
66
+ properties: {
67
+ title: { type: 'string' },
68
+ version: { type: 'string' },
69
+ description: { type: 'string' },
70
+ termsOfService: { type: 'string' },
71
+ contact: 'Contact',
72
+ license: 'License',
73
+ tags: 'TagList',
74
+ externalDocs: 'ExternalDocs',
75
+ },
76
+ required: ['title', 'version'],
77
+ };
78
+
79
+ const Parameter: NodeType = {
80
+ properties: {
81
+ description: { type: 'string' },
82
+ enum: { type: 'array', items: { type: 'string' } },
83
+ default: { type: 'string' },
84
+ examples: { type: 'array', items: { type: 'string' } },
85
+ location: { type: 'string' },
86
+ },
87
+ };
88
+
89
+ const Message: NodeType = {
90
+ properties: {
91
+ headers: 'Schema',
92
+ payload: (value: Record<string, unknown>) => {
93
+ if (!!value && value?.['schemaFormat']) {
94
+ return {
95
+ properties: {
96
+ schema: 'Schema',
97
+ schemaFormat: { type: 'string' },
98
+ },
99
+ required: ['schema', 'schemaFormat'],
100
+ };
101
+ } else {
102
+ return 'Schema';
103
+ }
104
+ },
105
+ correlationId: 'CorrelationId',
106
+
107
+ contentType: { type: 'string' },
108
+ name: { type: 'string' },
109
+ title: { type: 'string' },
110
+ summary: { type: 'string' },
111
+ description: { type: 'string' },
112
+ tags: 'TagList',
113
+ externalDocs: 'ExternalDocs',
114
+ bindings: 'MessageBindings',
115
+ examples: 'MessageExampleList',
116
+ traits: 'MessageTraitList',
117
+ },
118
+ additionalProperties: {},
119
+ };
120
+
121
+ const OperationTrait: NodeType = {
122
+ properties: {
123
+ tags: 'TagList',
124
+ title: { type: 'string' },
125
+ summary: { type: 'string' },
126
+ description: { type: 'string' },
127
+ externalDocs: 'ExternalDocs',
128
+ security: 'SecuritySchemeList',
129
+
130
+ bindings: 'OperationBindings',
131
+ },
132
+ required: [],
133
+ };
134
+
135
+ const MessageTrait: NodeType = {
136
+ properties: {
137
+ headers: (value: unknown) => {
138
+ if (typeof value === 'function' || (typeof value === 'object' && !!value)) {
139
+ return {
140
+ properties: {
141
+ schema: 'Schema',
142
+ schemaFormat: { type: 'string' },
143
+ },
144
+ };
145
+ } else {
146
+ return 'Schema';
147
+ }
148
+ },
149
+ correlationId: 'CorrelationId',
150
+
151
+ contentType: { type: 'string' },
152
+ name: { type: 'string' },
153
+ title: { type: 'string' },
154
+ summary: { type: 'string' },
155
+ description: { type: 'string' },
156
+ tags: 'TagList',
157
+ externalDocs: 'ExternalDocs',
158
+ bindings: 'MessageBindings',
159
+ examples: 'MessageExampleList',
160
+ },
161
+ additionalProperties: {},
162
+ };
163
+
164
+ const Operation: NodeType = {
165
+ properties: {
166
+ action: { type: 'string', enum: ['send', 'receive'] },
167
+ channel: 'Channel',
168
+ title: { type: 'string' },
169
+ tags: 'TagList',
170
+ summary: { type: 'string' },
171
+ description: { type: 'string' },
172
+ externalDocs: 'ExternalDocs',
173
+ operationId: { type: 'string' },
174
+ security: 'SecuritySchemeList',
175
+
176
+ bindings: 'OperationBindings',
177
+ traits: 'OperationTraitList',
178
+ messages: 'MessageList',
179
+ reply: 'OperationReply',
180
+ },
181
+ required: ['action', 'channel'],
182
+ };
183
+
184
+ const OperationReply: NodeType = {
185
+ properties: {
186
+ channel: 'Channel',
187
+ messages: 'MessageList',
188
+ address: 'OperationReplyAddress',
189
+ },
190
+ };
191
+
192
+ const OperationReplyAddress: NodeType = {
193
+ properties: {
194
+ location: { type: 'string' },
195
+ description: { type: 'string' },
196
+ },
197
+ required: ['location'],
198
+ };
199
+
200
+ const Components: NodeType = {
201
+ properties: {
202
+ messages: 'NamedMessages',
203
+ parameters: 'NamedParameters',
204
+ schemas: 'NamedSchemas',
205
+ replies: 'NamedOperationReplies',
206
+ replyAddresses: 'NamedOperationRelyAddresses',
207
+ correlationIds: 'NamedCorrelationIds',
208
+ messageTraits: 'NamedMessageTraits',
209
+ operationTraits: 'NamedOperationTraits',
210
+ tags: 'NamedTags',
211
+ externalDocs: 'NamedExternalDocs',
212
+ securitySchemes: 'NamedSecuritySchemes',
213
+ servers: 'ServerMap',
214
+ serverVariables: 'ServerVariablesMap',
215
+ channels: 'NamedChannels',
216
+ operations: 'NamedOperations',
217
+ serverBindings: 'ServerBindings',
218
+ channelBindings: 'ChannelBindings',
219
+ operationBindings: 'OperationBindings',
220
+ messageBindings: 'MessageBindings',
221
+ },
222
+ };
223
+
224
+ const ImplicitFlow: NodeType = {
225
+ properties: {
226
+ refreshUrl: { type: 'string' },
227
+ availableScopes: { type: 'object', additionalProperties: { type: 'string' } },
228
+ authorizationUrl: { type: 'string' },
229
+ },
230
+ required: ['authorizationUrl', 'availableScopes'],
231
+ };
232
+
233
+ const PasswordFlow: NodeType = {
234
+ properties: {
235
+ refreshUrl: { type: 'string' },
236
+ availableScopes: { type: 'object', additionalProperties: { type: 'string' } },
237
+ tokenUrl: { type: 'string' },
238
+ },
239
+ required: ['tokenUrl', 'availableScopes'],
240
+ };
241
+
242
+ const ClientCredentials: NodeType = {
243
+ properties: {
244
+ refreshUrl: { type: 'string' },
245
+ availableScopes: { type: 'object', additionalProperties: { type: 'string' } },
246
+ tokenUrl: { type: 'string' },
247
+ },
248
+ required: ['tokenUrl', 'availableScopes'],
249
+ };
250
+
251
+ const AuthorizationCode: NodeType = {
252
+ properties: {
253
+ refreshUrl: { type: 'string' },
254
+ authorizationUrl: { type: 'string' },
255
+ availableScopes: { type: 'object', additionalProperties: { type: 'string' } },
256
+ tokenUrl: { type: 'string' },
257
+ },
258
+ required: ['authorizationUrl', 'tokenUrl', 'availableScopes'],
259
+ };
260
+
261
+ const SecurityScheme: NodeType = {
262
+ properties: {
263
+ type: {
264
+ enum: [
265
+ 'userPassword',
266
+ 'apiKey',
267
+ 'X509',
268
+ 'symmetricEncryption',
269
+ 'asymmetricEncryption',
270
+ 'httpApiKey',
271
+ 'http',
272
+ 'oauth2',
273
+ 'openIdConnect',
274
+ 'plain',
275
+ 'scramSha256',
276
+ 'scramSha512',
277
+ 'gssapi',
278
+ ],
279
+ },
280
+ description: { type: 'string' },
281
+ name: { type: 'string' },
282
+ in: { type: 'string', enum: ['query', 'header', 'cookie', 'user', 'password'] },
283
+ scheme: { type: 'string' },
284
+ bearerFormat: { type: 'string' },
285
+ flows: 'SecuritySchemeFlows',
286
+ openIdConnectUrl: { type: 'string' },
287
+ scopes: { type: 'array', items: { type: 'string' } },
288
+ },
289
+ required(value) {
290
+ switch (value?.type) {
291
+ case 'apiKey':
292
+ return ['type', 'in'];
293
+ case 'httpApiKey':
294
+ return ['type', 'name', 'in'];
295
+ case 'http':
296
+ return ['type', 'scheme'];
297
+ case 'oauth2':
298
+ return ['type', 'flows'];
299
+ case 'openIdConnect':
300
+ return ['type', 'openIdConnectUrl'];
301
+ default:
302
+ return ['type'];
303
+ }
304
+ },
305
+ allowed(value) {
306
+ switch (value?.type) {
307
+ case 'apiKey':
308
+ return ['type', 'in', 'description'];
309
+ case 'httpApiKey':
310
+ return ['type', 'name', 'in', 'description'];
311
+ case 'http':
312
+ return ['type', 'scheme', 'bearerFormat', 'description'];
313
+ case 'oauth2':
314
+ return ['type', 'flows', 'description', 'scopes'];
315
+ case 'openIdConnect':
316
+ return ['type', 'openIdConnectUrl', 'description', 'scopes'];
317
+ default:
318
+ return ['type', 'description'];
319
+ }
320
+ },
321
+ extensionsPrefix: 'x-',
322
+ };
323
+
324
+ export const AsyncApi3Types: Record<string, NodeType> = {
325
+ // from asyncapi2
326
+ ...AsyncApi2Bindings,
327
+ CorrelationId,
328
+ SecuritySchemeFlows,
329
+ ServerVariable,
330
+ Contact,
331
+ License,
332
+ MessageExample,
333
+ Tag,
334
+ Dependencies,
335
+ Schema,
336
+ Discriminator,
337
+ DiscriminatorMapping,
338
+ SchemaProperties,
339
+ ServerMap,
340
+ ExternalDocs,
341
+ Root,
342
+
343
+ Channel,
344
+ Parameter,
345
+ Info,
346
+ Server,
347
+ MessageTrait,
348
+ Operation,
349
+ OperationReply,
350
+ OperationReplyAddress,
351
+ Components,
352
+ ImplicitFlow,
353
+ PasswordFlow,
354
+ ClientCredentials,
355
+ AuthorizationCode,
356
+ SecurityScheme,
357
+ Message,
358
+ OperationTrait,
359
+ ServerVariablesMap: mapOf('ServerVariable'),
360
+ NamedTags: mapOf('Tag'),
361
+ NamedExternalDocs: mapOf('ExternalDocs'),
362
+ NamedChannels: mapOf('Channel'),
363
+ ParametersMap: mapOf('Parameter'),
364
+ NamedOperations: mapOf('Operation'),
365
+ NamedOperationReplies: mapOf('OperationReply'),
366
+ NamedOperationRelyAddresses: mapOf('OperationReplyAddress'),
367
+ NamedSchemas: mapOf('Schema'),
368
+ NamedMessages: mapOf('Message'),
369
+ NamedMessageTraits: mapOf('MessageTrait'),
370
+ NamedOperationTraits: mapOf('OperationTrait'),
371
+ NamedParameters: mapOf('Parameter'),
372
+ NamedSecuritySchemes: mapOf('SecurityScheme'),
373
+ NamedCorrelationIds: mapOf('CorrelationId'),
374
+ ServerList: listOf('Server'),
375
+ SecuritySchemeList: listOf('SecurityScheme'),
376
+ MessageList: listOf('Message'),
377
+ OperationTraitList: listOf('OperationTrait'),
378
+ MessageTraitList: listOf('MessageTrait'),
379
+ MessageExampleList: listOf('MessageExample'),
380
+ TagList: listOf('Tag'),
381
+ };
@@ -139,7 +139,7 @@ const Schema: NodeType = {
139
139
  contains: 'Schema',
140
140
  minContains: { type: 'integer', minimum: 0 },
141
141
  maxContains: { type: 'integer', minimum: 0 },
142
- patternProperties: 'SchemaProperties',
142
+ patternProperties: 'PatternProperties',
143
143
  propertyNames: 'Schema',
144
144
  unevaluatedItems: (value: unknown) => {
145
145
  if (typeof value === 'boolean') {
@@ -278,6 +278,7 @@ export const Oas3_1Types: Record<Oas3_1NodeType, NodeType> = {
278
278
  Root,
279
279
  Schema,
280
280
  SchemaProperties,
281
+ PatternProperties: SchemaProperties,
281
282
  License,
282
283
  Components,
283
284
  NamedPathItems: mapOf('PathItem'),
@@ -92,8 +92,20 @@ const builtInAsync2Rules = [
92
92
  'no-channel-trailing-slash',
93
93
  ] as const;
94
94
 
95
+ const builtInAsync3Rules = [
96
+ 'spec',
97
+ 'info-contact',
98
+ 'operation-operationId',
99
+ 'tag-description',
100
+ 'tags-alphabetical',
101
+ 'channels-kebab-case',
102
+ 'no-channel-trailing-slash',
103
+ ] as const;
104
+
95
105
  export type BuiltInAsync2RuleId = typeof builtInAsync2Rules[number];
96
106
 
107
+ export type BuiltInAsync3RuleId = typeof builtInAsync3Rules[number];
108
+
97
109
  const builtInArazzoRules = ['spec'] as const;
98
110
 
99
111
  export type BuiltInArazzoRuleId = typeof builtInArazzoRules[number];
@@ -103,6 +115,7 @@ const builtInRules = [
103
115
  ...builtInOAS2Rules,
104
116
  ...builtInOAS3Rules,
105
117
  ...builtInAsync2Rules,
118
+ ...builtInAsync3Rules,
106
119
  ...builtInArazzoRules,
107
120
  ] as const;
108
121
 
@@ -221,6 +234,7 @@ const oas3_1NodeTypesList = [
221
234
  'Root',
222
235
  'Schema',
223
236
  'SchemaProperties',
237
+ 'PatternProperties',
224
238
  'Info',
225
239
  'License',
226
240
  'Components',
@@ -0,0 +1,61 @@
1
+ export interface Async3Definition {
2
+ asyncapi: string;
3
+ servers?: Record<string, any>;
4
+ info: Async3Info;
5
+ channels?: Record<string, Channel>;
6
+ components?: Record<string, any>;
7
+ operations?: Record<string, any>;
8
+ defaultContentType?: string;
9
+ }
10
+
11
+ export interface Async3Info {
12
+ title: string;
13
+ version: string;
14
+
15
+ description?: string;
16
+ termsOfService?: string;
17
+ contact?: Async3Contact;
18
+ license?: Async3License;
19
+ tags?: Tag[];
20
+ externalDocs?: ExternalDoc;
21
+ }
22
+
23
+ export interface Async3Contact {
24
+ name?: string;
25
+ url?: string;
26
+ email?: string;
27
+ }
28
+
29
+ export interface Async3License {
30
+ name: string;
31
+ url?: string;
32
+ }
33
+
34
+ export interface Tag {
35
+ name: string;
36
+ description?: string;
37
+ externalDocs?: ExternalDoc;
38
+ }
39
+
40
+ export interface ExternalDoc {
41
+ url: string;
42
+ description?: string;
43
+ }
44
+
45
+ export interface Channel {
46
+ address?: string | null;
47
+ messages?: Record<string, any>;
48
+ title?: string;
49
+ summary?: string;
50
+ description?: string;
51
+ servers?: Record<string, any>[];
52
+ parameters?: Record<string, any>;
53
+ tags?: Record<string, any>;
54
+ externalDocs?: ExternalDocumentation;
55
+ bindings?: Record<string, any>;
56
+ }
57
+
58
+ export interface ExternalDocumentation {
59
+ url: string;
60
+ description?: string;
61
+ }
package/src/utils.ts CHANGED
@@ -38,15 +38,15 @@ export function isDefined<T>(x: T | undefined): x is T {
38
38
  return x !== undefined;
39
39
  }
40
40
 
41
- export function isPlainObject(value: any): value is Record<string, unknown> {
41
+ export function isPlainObject(value: unknown): value is Record<string, unknown> {
42
42
  return value !== null && typeof value === 'object' && !Array.isArray(value);
43
43
  }
44
44
 
45
- export function isEmptyObject(value: any): value is Record<string, unknown> {
45
+ export function isEmptyObject(value: unknown): value is Record<string, unknown> {
46
46
  return isPlainObject(value) && Object.keys(value).length === 0;
47
47
  }
48
48
 
49
- export function isEmptyArray(value: any) {
49
+ export function isEmptyArray(value: unknown) {
50
50
  return Array.isArray(value) && value.length === 0;
51
51
  }
52
52
 
@@ -317,3 +317,5 @@ export function dequal(foo: any, bar: any): boolean {
317
317
 
318
318
  return foo !== foo && bar !== bar;
319
319
  }
320
+
321
+ export type CollectFn = (value: unknown) => void;
package/src/visitors.ts CHANGED
@@ -50,6 +50,7 @@ import type {
50
50
  Oas2SecurityScheme,
51
51
  } from './typings/swagger';
52
52
  import type { Async2Definition } from './typings/asyncapi';
53
+ import type { Async3Definition } from './typings/asyncapi3';
53
54
  import type { ArazzoDefinition } from './typings/arazzo';
54
55
 
55
56
  export type SkipFunctionContext = Pick<
@@ -213,6 +214,10 @@ type Async2FlatVisitor = {
213
214
  Root?: VisitFunctionOrObject<Async2Definition>;
214
215
  };
215
216
 
217
+ type Async3FlatVisitor = {
218
+ Root?: VisitFunctionOrObject<Async3Definition>;
219
+ };
220
+
216
221
  type ArazzoFlatVisitor = {
217
222
  Root?: VisitFunctionOrObject<ArazzoDefinition>;
218
223
  };
@@ -249,6 +254,12 @@ type Async2NestedVisitor = {
249
254
  : Async2FlatVisitor[T] & NestedVisitor<Async2NestedVisitor>;
250
255
  };
251
256
 
257
+ type Async3NestedVisitor = {
258
+ [T in keyof Async3FlatVisitor]: Async3FlatVisitor[T] extends Function
259
+ ? Async3FlatVisitor[T]
260
+ : Async3FlatVisitor[T] & NestedVisitor<Async3NestedVisitor>;
261
+ };
262
+
252
263
  type ArazzoNestedVisitor = {
253
264
  [T in keyof ArazzoFlatVisitor]: ArazzoFlatVisitor[T] extends Function
254
265
  ? ArazzoFlatVisitor[T]
@@ -267,6 +278,10 @@ export type Async2Visitor = BaseVisitor &
267
278
  Async2NestedVisitor &
268
279
  Record<string, VisitFunction<any> | NestedVisitObject<any, Async2NestedVisitor>>;
269
280
 
281
+ export type Async3Visitor = BaseVisitor &
282
+ Async3NestedVisitor &
283
+ Record<string, VisitFunction<any> | NestedVisitObject<any, Async3NestedVisitor>>;
284
+
270
285
  export type ArazzoVisitor = BaseVisitor &
271
286
  ArazzoNestedVisitor &
272
287
  Record<string, VisitFunction<any> | NestedVisitObject<any, ArazzoNestedVisitor>>;
@@ -293,14 +308,17 @@ export type NormalizedOasVisitors<T extends BaseVisitor> = {
293
308
  export type Oas3Rule = (options: Record<string, any>) => Oas3Visitor | Oas3Visitor[];
294
309
  export type Oas2Rule = (options: Record<string, any>) => Oas2Visitor | Oas2Visitor[];
295
310
  export type Async2Rule = (options: Record<string, any>) => Async2Visitor | Async2Visitor[];
311
+ export type Async3Rule = (options: Record<string, any>) => Async3Visitor | Async3Visitor[];
296
312
  export type ArazzoRule = (options: Record<string, any>) => ArazzoVisitor | ArazzoVisitor[];
297
313
  export type Oas3Preprocessor = (options: Record<string, any>) => Oas3Visitor;
298
314
  export type Oas2Preprocessor = (options: Record<string, any>) => Oas2Visitor;
299
315
  export type Async2Preprocessor = (options: Record<string, any>) => Async2Visitor;
316
+ export type Async3Preprocessor = (options: Record<string, any>) => Async3Visitor;
300
317
  export type ArazzoPreprocessor = (options: Record<string, any>) => ArazzoVisitor;
301
318
  export type Oas3Decorator = (options: Record<string, any>) => Oas3Visitor;
302
319
  export type Oas2Decorator = (options: Record<string, any>) => Oas2Visitor;
303
320
  export type Async2Decorator = (options: Record<string, any>) => Async2Visitor;
321
+ export type Async3Decorator = (options: Record<string, any>) => Async3Visitor;
304
322
  export type ArazzoDecorator = (options: Record<string, any>) => ArazzoVisitor;
305
323
 
306
324
  // alias for the latest version supported