@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.
- package/CHANGELOG.md +10 -0
- package/lib/benchmark/benches/lint-with-many-rules.bench.js +2 -2
- package/lib/benchmark/benches/lint-with-nested-rule.bench.js +2 -2
- package/lib/benchmark/benches/lint-with-no-rules.bench.js +2 -2
- package/lib/benchmark/benches/lint-with-top-level-rule-report.bench.js +2 -2
- package/lib/benchmark/benches/lint-with-top-level-rule.bench.js +2 -2
- package/lib/benchmark/benches/recommended-oas3.bench.js +2 -2
- package/lib/benchmark/benches/resolve-with-no-external.bench.js +2 -2
- package/lib/benchmark/utils.js +7 -4
- package/lib/bundle.d.ts +2 -2
- package/lib/bundle.js +127 -120
- package/lib/config/all.js +9 -0
- package/lib/config/builtIn.js +7 -1
- package/lib/config/config-resolvers.js +179 -138
- package/lib/config/config.d.ts +2 -2
- package/lib/config/config.js +53 -34
- package/lib/config/load.js +105 -117
- package/lib/config/minimal.js +9 -0
- package/lib/config/recommended-strict.js +9 -0
- package/lib/config/recommended.js +9 -0
- package/lib/config/rules.d.ts +3 -3
- package/lib/config/rules.js +1 -2
- package/lib/config/types.d.ts +9 -3
- package/lib/config/utils.js +70 -49
- package/lib/decorators/async3/index.d.ts +1 -0
- package/lib/decorators/async3/index.js +4 -0
- package/lib/decorators/common/filters/filter-helper.js +2 -3
- package/lib/decorators/common/filters/filter-in.js +1 -1
- package/lib/decorators/common/filters/filter-out.js +1 -1
- package/lib/decorators/common/info-override.js +1 -12
- package/lib/decorators/common/media-type-examples-override.js +8 -2
- package/lib/decorators/common/remove-x-internal.js +4 -5
- package/lib/decorators/oas2/remove-unused-components.js +1 -2
- package/lib/decorators/oas3/remove-unused-components.js +1 -2
- package/lib/env.d.ts +0 -1
- package/lib/env.js +1 -1
- package/lib/format/codeframes.js +10 -8
- package/lib/format/format.js +23 -15
- package/lib/index.d.ts +2 -1
- package/lib/index.js +6 -4
- package/lib/js-yaml/index.js +1 -1
- package/lib/lint.d.ts +2 -0
- package/lib/lint.js +92 -99
- package/lib/oas-types.d.ts +9 -5
- package/lib/oas-types.js +22 -12
- package/lib/redocly/domains.js +6 -6
- package/lib/redocly/index.js +60 -73
- package/lib/redocly/registry-api.js +64 -82
- package/lib/ref-utils.js +13 -13
- package/lib/resolve.js +186 -205
- package/lib/rules/ajv.js +10 -8
- package/lib/rules/async3/channels-kebab-case.d.ts +2 -0
- package/lib/rules/async3/channels-kebab-case.js +19 -0
- package/lib/rules/async3/index.d.ts +3 -0
- package/lib/rules/async3/index.js +22 -0
- package/lib/rules/async3/no-channel-trailing-slash.d.ts +2 -0
- package/lib/rules/async3/no-channel-trailing-slash.js +16 -0
- package/lib/rules/common/assertions/asserts.js +5 -5
- package/lib/rules/common/assertions/index.d.ts +5 -4
- package/lib/rules/common/assertions/utils.js +43 -28
- package/lib/rules/common/no-invalid-parameter-examples.js +1 -2
- package/lib/rules/common/no-invalid-schema-examples.js +1 -2
- package/lib/rules/common/no-required-schema-properties-undefined.js +1 -2
- package/lib/rules/common/operation-tag-defined.js +1 -2
- package/lib/rules/common/path-http-verbs-order.js +1 -1
- package/lib/rules/common/required-string-property-missing-min-length.js +2 -2
- package/lib/rules/common/response-contains-header.js +2 -2
- package/lib/rules/common/security-defined.js +3 -7
- package/lib/rules/common/spec.d.ts +2 -2
- package/lib/rules/common/spec.js +6 -7
- package/lib/rules/no-unresolved-refs.js +3 -4
- package/lib/rules/oas2/response-contains-property.js +1 -2
- package/lib/rules/oas3/array-parameter-serialization.js +1 -2
- package/lib/rules/oas3/component-name-unique.js +2 -4
- package/lib/rules/oas3/no-invalid-media-type-examples.js +1 -2
- package/lib/rules/oas3/no-server-variables-empty-enum.js +1 -2
- package/lib/rules/oas3/no-undefined-server-variable.js +2 -3
- package/lib/rules/oas3/no-unused-components.js +1 -2
- package/lib/rules/oas3/response-contains-property.js +1 -2
- package/lib/rules/utils.js +14 -12
- package/lib/types/asyncapi2.d.ts +17 -0
- package/lib/types/{asyncapi.js → asyncapi2.js} +56 -52
- package/lib/types/asyncapi3.d.ts +2 -0
- package/lib/types/asyncapi3.js +347 -0
- package/lib/types/index.js +19 -10
- package/lib/types/json-schema-adapter.js +4 -18
- package/lib/types/oas2.js +6 -6
- package/lib/types/oas3.js +10 -10
- package/lib/types/oas3_1.js +14 -8
- package/lib/types/redocly-yaml.d.ts +3 -1
- package/lib/types/redocly-yaml.js +131 -35
- package/lib/typings/asyncapi3.d.ts +53 -0
- package/lib/typings/asyncapi3.js +2 -0
- package/lib/utils.d.ts +4 -3
- package/lib/utils.js +55 -72
- package/lib/visitors.d.ts +11 -0
- package/lib/visitors.js +21 -8
- package/lib/walk.js +30 -23
- package/package.json +2 -2
- package/src/__tests__/bundle.test.ts +142 -0
- package/src/bundle.ts +17 -3
- package/src/config/__tests__/__snapshots__/config-resolvers.test.ts.snap +22 -0
- package/src/config/__tests__/__snapshots__/config.test.ts.snap +24 -0
- package/src/config/__tests__/config.test.ts +11 -0
- package/src/config/all.ts +9 -0
- package/src/config/builtIn.ts +6 -0
- package/src/config/config-resolvers.ts +15 -2
- package/src/config/config.ts +24 -5
- package/src/config/minimal.ts +9 -0
- package/src/config/recommended-strict.ts +9 -0
- package/src/config/recommended.ts +9 -0
- package/src/config/rules.ts +12 -4
- package/src/config/types.ts +15 -2
- package/src/config/utils.ts +15 -0
- package/src/decorators/async3/index.ts +1 -0
- package/src/decorators/common/remove-x-internal.ts +2 -2
- package/src/index.ts +2 -1
- package/src/lint.ts +26 -3
- package/src/oas-types.ts +31 -13
- package/src/rules/arazzo/index.ts +1 -1
- package/src/rules/async2/index.ts +5 -5
- package/src/rules/async3/__tests__/channels-kebab-case.test.ts +141 -0
- package/src/rules/async3/__tests__/no-channel-trailing-slash.test.ts +96 -0
- package/src/rules/async3/channels-kebab-case.ts +19 -0
- package/src/rules/async3/index.ts +23 -0
- package/src/rules/async3/no-channel-trailing-slash.ts +16 -0
- package/src/rules/common/assertions/index.ts +13 -4
- package/src/rules/common/spec.ts +2 -2
- package/src/rules/oas2/index.ts +4 -4
- package/src/rules/oas3/index.ts +39 -37
- package/src/types/{asyncapi.ts → asyncapi2.ts} +37 -34
- package/src/types/asyncapi3.ts +381 -0
- package/src/types/oas3_1.ts +2 -1
- package/src/types/redocly-yaml.ts +14 -0
- package/src/typings/asyncapi3.ts +61 -0
- package/src/utils.ts +5 -3
- package/src/visitors.ts +18 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/lib/types/asyncapi.d.ts +0 -2
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AsyncApi2Types = void 0;
|
|
3
|
+
exports.AsyncApi2Types = exports.AsyncApi2Bindings = exports.Dependencies = exports.SecuritySchemeFlows = exports.Discriminator = exports.DiscriminatorMapping = exports.SchemaProperties = exports.Schema = exports.MessageExample = exports.CorrelationId = exports.License = exports.Contact = exports.ServerVariable = exports.ServerMap = exports.ExternalDocs = exports.Tag = void 0;
|
|
4
4
|
const _1 = require(".");
|
|
5
5
|
const ref_utils_1 = require("../ref-utils");
|
|
6
6
|
const Root = {
|
|
7
7
|
properties: {
|
|
8
|
-
asyncapi: null,
|
|
8
|
+
asyncapi: null, // TODO: validate semver format and supported version
|
|
9
9
|
info: 'Info',
|
|
10
10
|
id: { type: 'string' },
|
|
11
11
|
servers: 'ServerMap',
|
|
@@ -59,7 +59,7 @@ const ChannelBindings = {
|
|
|
59
59
|
},
|
|
60
60
|
additionalProperties: { type: 'object' },
|
|
61
61
|
};
|
|
62
|
-
|
|
62
|
+
exports.Tag = {
|
|
63
63
|
properties: {
|
|
64
64
|
name: { type: 'string' },
|
|
65
65
|
description: { type: 'string' },
|
|
@@ -67,7 +67,7 @@ const Tag = {
|
|
|
67
67
|
},
|
|
68
68
|
required: ['name'],
|
|
69
69
|
};
|
|
70
|
-
|
|
70
|
+
exports.ExternalDocs = {
|
|
71
71
|
properties: {
|
|
72
72
|
description: { type: 'string' },
|
|
73
73
|
url: { type: 'string' },
|
|
@@ -119,11 +119,11 @@ const Server = {
|
|
|
119
119
|
},
|
|
120
120
|
required: ['url', 'protocol'],
|
|
121
121
|
};
|
|
122
|
-
|
|
122
|
+
exports.ServerMap = {
|
|
123
123
|
properties: {},
|
|
124
124
|
additionalProperties: (_value, key) => key.match(/^[A-Za-z0-9_\-]+$/) ? 'Server' : undefined,
|
|
125
125
|
};
|
|
126
|
-
|
|
126
|
+
exports.ServerVariable = {
|
|
127
127
|
properties: {
|
|
128
128
|
enum: {
|
|
129
129
|
type: 'array',
|
|
@@ -149,14 +149,14 @@ const Info = {
|
|
|
149
149
|
},
|
|
150
150
|
required: ['title', 'version'],
|
|
151
151
|
};
|
|
152
|
-
|
|
152
|
+
exports.Contact = {
|
|
153
153
|
properties: {
|
|
154
154
|
name: { type: 'string' },
|
|
155
155
|
url: { type: 'string' },
|
|
156
156
|
email: { type: 'string' },
|
|
157
157
|
},
|
|
158
158
|
};
|
|
159
|
-
|
|
159
|
+
exports.License = {
|
|
160
160
|
properties: {
|
|
161
161
|
name: { type: 'string' },
|
|
162
162
|
url: { type: 'string' },
|
|
@@ -170,7 +170,7 @@ const Parameter = {
|
|
|
170
170
|
location: { type: 'string' },
|
|
171
171
|
},
|
|
172
172
|
};
|
|
173
|
-
|
|
173
|
+
exports.CorrelationId = {
|
|
174
174
|
properties: {
|
|
175
175
|
description: { type: 'string' },
|
|
176
176
|
location: { type: 'string' },
|
|
@@ -181,9 +181,9 @@ const Message = {
|
|
|
181
181
|
properties: {
|
|
182
182
|
messageId: { type: 'string' },
|
|
183
183
|
headers: 'Schema',
|
|
184
|
-
payload: 'Schema',
|
|
184
|
+
payload: 'Schema', // TODO: strictly this does not cover all cases
|
|
185
185
|
correlationId: 'CorrelationId',
|
|
186
|
-
schemaFormat: { type: 'string' },
|
|
186
|
+
schemaFormat: { type: 'string' }, // TODO: support official list of schema formats and custom values
|
|
187
187
|
contentType: { type: 'string' },
|
|
188
188
|
name: { type: 'string' },
|
|
189
189
|
title: { type: 'string' },
|
|
@@ -192,7 +192,7 @@ const Message = {
|
|
|
192
192
|
tags: 'TagList',
|
|
193
193
|
externalDocs: 'ExternalDocs',
|
|
194
194
|
bindings: 'MessageBindings',
|
|
195
|
-
|
|
195
|
+
examples: 'MessageExampleList',
|
|
196
196
|
traits: 'MessageTraitList',
|
|
197
197
|
},
|
|
198
198
|
additionalProperties: {},
|
|
@@ -279,7 +279,7 @@ const MessageTrait = {
|
|
|
279
279
|
tags: 'TagList',
|
|
280
280
|
externalDocs: 'ExternalDocs',
|
|
281
281
|
bindings: 'MessageBindings',
|
|
282
|
-
|
|
282
|
+
examples: 'MessageExampleList',
|
|
283
283
|
},
|
|
284
284
|
additionalProperties: {},
|
|
285
285
|
};
|
|
@@ -297,7 +297,7 @@ const Operation = {
|
|
|
297
297
|
},
|
|
298
298
|
required: [],
|
|
299
299
|
};
|
|
300
|
-
|
|
300
|
+
exports.MessageExample = {
|
|
301
301
|
properties: {
|
|
302
302
|
payload: { isExample: true },
|
|
303
303
|
summary: { type: 'string' },
|
|
@@ -305,7 +305,7 @@ const MessageExample = {
|
|
|
305
305
|
headers: { type: 'object' },
|
|
306
306
|
},
|
|
307
307
|
};
|
|
308
|
-
|
|
308
|
+
exports.Schema = {
|
|
309
309
|
properties: {
|
|
310
310
|
$id: { type: 'string' },
|
|
311
311
|
$schema: { type: 'string' },
|
|
@@ -374,13 +374,13 @@ const Schema = {
|
|
|
374
374
|
dependencies: 'Dependencies',
|
|
375
375
|
},
|
|
376
376
|
};
|
|
377
|
-
|
|
377
|
+
exports.SchemaProperties = {
|
|
378
378
|
properties: {},
|
|
379
379
|
additionalProperties: (value) => {
|
|
380
380
|
return typeof value === 'boolean' ? { type: 'boolean' } : 'Schema';
|
|
381
381
|
},
|
|
382
382
|
};
|
|
383
|
-
|
|
383
|
+
exports.DiscriminatorMapping = {
|
|
384
384
|
properties: {},
|
|
385
385
|
additionalProperties: (value) => {
|
|
386
386
|
if ((0, ref_utils_1.isMappingRef)(value)) {
|
|
@@ -391,7 +391,7 @@ const DiscriminatorMapping = {
|
|
|
391
391
|
}
|
|
392
392
|
},
|
|
393
393
|
};
|
|
394
|
-
|
|
394
|
+
exports.Discriminator = {
|
|
395
395
|
properties: {
|
|
396
396
|
propertyName: { type: 'string' },
|
|
397
397
|
mapping: 'DiscriminatorMapping',
|
|
@@ -406,7 +406,6 @@ const Components = {
|
|
|
406
406
|
correlationIds: 'NamedCorrelationIds',
|
|
407
407
|
messageTraits: 'NamedMessageTraits',
|
|
408
408
|
operationTraits: 'NamedOperationTraits',
|
|
409
|
-
streamHeaders: 'NamedStreamHeaders',
|
|
410
409
|
securitySchemes: 'NamedSecuritySchemes',
|
|
411
410
|
servers: 'ServerMap',
|
|
412
411
|
serverVariables: 'ServerVariablesMap',
|
|
@@ -420,7 +419,7 @@ const Components = {
|
|
|
420
419
|
const ImplicitFlow = {
|
|
421
420
|
properties: {
|
|
422
421
|
refreshUrl: { type: 'string' },
|
|
423
|
-
scopes: { type: 'object', additionalProperties: { type: 'string' } },
|
|
422
|
+
scopes: { type: 'object', additionalProperties: { type: 'string' } }, // TODO: validate scopes
|
|
424
423
|
authorizationUrl: { type: 'string' },
|
|
425
424
|
},
|
|
426
425
|
required: ['authorizationUrl', 'scopes'],
|
|
@@ -428,7 +427,7 @@ const ImplicitFlow = {
|
|
|
428
427
|
const PasswordFlow = {
|
|
429
428
|
properties: {
|
|
430
429
|
refreshUrl: { type: 'string' },
|
|
431
|
-
scopes: { type: 'object', additionalProperties: { type: 'string' } },
|
|
430
|
+
scopes: { type: 'object', additionalProperties: { type: 'string' } }, // TODO: validate scopes
|
|
432
431
|
tokenUrl: { type: 'string' },
|
|
433
432
|
},
|
|
434
433
|
required: ['tokenUrl', 'scopes'],
|
|
@@ -436,7 +435,7 @@ const PasswordFlow = {
|
|
|
436
435
|
const ClientCredentials = {
|
|
437
436
|
properties: {
|
|
438
437
|
refreshUrl: { type: 'string' },
|
|
439
|
-
scopes: { type: 'object', additionalProperties: { type: 'string' } },
|
|
438
|
+
scopes: { type: 'object', additionalProperties: { type: 'string' } }, // TODO: validate scopes
|
|
440
439
|
tokenUrl: { type: 'string' },
|
|
441
440
|
},
|
|
442
441
|
required: ['tokenUrl', 'scopes'],
|
|
@@ -445,12 +444,12 @@ const AuthorizationCode = {
|
|
|
445
444
|
properties: {
|
|
446
445
|
refreshUrl: { type: 'string' },
|
|
447
446
|
authorizationUrl: { type: 'string' },
|
|
448
|
-
scopes: { type: 'object', additionalProperties: { type: 'string' } },
|
|
447
|
+
scopes: { type: 'object', additionalProperties: { type: 'string' } }, // TODO: validate scopes
|
|
449
448
|
tokenUrl: { type: 'string' },
|
|
450
449
|
},
|
|
451
450
|
required: ['authorizationUrl', 'tokenUrl', 'scopes'],
|
|
452
451
|
};
|
|
453
|
-
|
|
452
|
+
exports.SecuritySchemeFlows = {
|
|
454
453
|
properties: {
|
|
455
454
|
implicit: 'ImplicitFlow',
|
|
456
455
|
password: 'PasswordFlow',
|
|
@@ -486,7 +485,7 @@ const SecurityScheme = {
|
|
|
486
485
|
openIdConnectUrl: { type: 'string' },
|
|
487
486
|
},
|
|
488
487
|
required(value) {
|
|
489
|
-
switch (value
|
|
488
|
+
switch (value?.type) {
|
|
490
489
|
case 'apiKey':
|
|
491
490
|
return ['type', 'in'];
|
|
492
491
|
case 'httpApiKey':
|
|
@@ -502,7 +501,7 @@ const SecurityScheme = {
|
|
|
502
501
|
}
|
|
503
502
|
},
|
|
504
503
|
allowed(value) {
|
|
505
|
-
switch (value
|
|
504
|
+
switch (value?.type) {
|
|
506
505
|
case 'apiKey':
|
|
507
506
|
return ['type', 'in', 'description'];
|
|
508
507
|
case 'httpApiKey':
|
|
@@ -519,7 +518,7 @@ const SecurityScheme = {
|
|
|
519
518
|
},
|
|
520
519
|
extensionsPrefix: 'x-',
|
|
521
520
|
};
|
|
522
|
-
|
|
521
|
+
exports.Dependencies = {
|
|
523
522
|
properties: {},
|
|
524
523
|
additionalProperties: (value) => {
|
|
525
524
|
return Array.isArray(value) ? { type: 'array', items: { type: 'string' } } : 'Schema';
|
|
@@ -602,7 +601,7 @@ const KafkaServerBinding = {
|
|
|
602
601
|
ServerBindings.properties.kafka = KafkaServerBinding;
|
|
603
602
|
const KafkaMessageBinding = {
|
|
604
603
|
properties: {
|
|
605
|
-
key: 'Schema',
|
|
604
|
+
key: 'Schema', // TODO: add avro support
|
|
606
605
|
schemaIdLocation: { type: 'string' },
|
|
607
606
|
schemaIdPayloadEncoding: { type: 'string' },
|
|
608
607
|
schemaLookupStrategy: { type: 'string' },
|
|
@@ -666,7 +665,7 @@ const AmqpOperationBinding = {
|
|
|
666
665
|
userId: { type: 'string' },
|
|
667
666
|
cc: { type: 'array', items: { type: 'string' } },
|
|
668
667
|
priority: { type: 'integer' },
|
|
669
|
-
deliveryMode: { type: 'integer' },
|
|
668
|
+
deliveryMode: { type: 'integer' }, // TODO: enum: [1, 2]
|
|
670
669
|
mandatory: { type: 'boolean' },
|
|
671
670
|
bcc: { type: 'array', items: { type: 'string' } },
|
|
672
671
|
replyTo: { type: 'string' },
|
|
@@ -890,20 +889,7 @@ OperationBindings.properties.mercure = MercureOperationBinding;
|
|
|
890
889
|
// googlepubsub
|
|
891
890
|
// pulsar
|
|
892
891
|
// --- End per-protocol node types
|
|
893
|
-
exports.
|
|
894
|
-
Root,
|
|
895
|
-
Tag,
|
|
896
|
-
TagList: (0, _1.listOf)('Tag'),
|
|
897
|
-
ServerMap,
|
|
898
|
-
ExternalDocs,
|
|
899
|
-
Server,
|
|
900
|
-
ServerVariable,
|
|
901
|
-
ServerVariablesMap: (0, _1.mapOf)('ServerVariable'),
|
|
902
|
-
SecurityRequirement,
|
|
903
|
-
SecurityRequirementList: (0, _1.listOf)('SecurityRequirement'),
|
|
904
|
-
Info,
|
|
905
|
-
Contact,
|
|
906
|
-
License,
|
|
892
|
+
exports.AsyncApi2Bindings = {
|
|
907
893
|
HttpServerBinding,
|
|
908
894
|
HttpChannelBinding,
|
|
909
895
|
HttpMessageBinding,
|
|
@@ -965,16 +951,34 @@ exports.AsyncApi2Types = {
|
|
|
965
951
|
MercureOperationBinding,
|
|
966
952
|
ServerBindings,
|
|
967
953
|
ChannelBindings,
|
|
954
|
+
MessageBindings,
|
|
955
|
+
OperationBindings,
|
|
956
|
+
};
|
|
957
|
+
exports.AsyncApi2Types = {
|
|
958
|
+
...exports.AsyncApi2Bindings,
|
|
959
|
+
Root,
|
|
960
|
+
Tag: exports.Tag,
|
|
961
|
+
TagList: (0, _1.listOf)('Tag'),
|
|
962
|
+
ServerMap: exports.ServerMap,
|
|
963
|
+
ExternalDocs: exports.ExternalDocs,
|
|
964
|
+
Server,
|
|
965
|
+
ServerVariable: exports.ServerVariable,
|
|
966
|
+
ServerVariablesMap: (0, _1.mapOf)('ServerVariable'),
|
|
967
|
+
SecurityRequirement,
|
|
968
|
+
SecurityRequirementList: (0, _1.listOf)('SecurityRequirement'),
|
|
969
|
+
Info,
|
|
970
|
+
Contact: exports.Contact,
|
|
971
|
+
License: exports.License,
|
|
968
972
|
ChannelMap,
|
|
969
973
|
Channel,
|
|
970
974
|
Parameter,
|
|
971
975
|
ParametersMap: (0, _1.mapOf)('Parameter'),
|
|
972
976
|
Operation,
|
|
973
|
-
Schema,
|
|
974
|
-
MessageExample,
|
|
975
|
-
SchemaProperties,
|
|
976
|
-
DiscriminatorMapping,
|
|
977
|
-
Discriminator,
|
|
977
|
+
Schema: exports.Schema,
|
|
978
|
+
MessageExample: exports.MessageExample,
|
|
979
|
+
SchemaProperties: exports.SchemaProperties,
|
|
980
|
+
DiscriminatorMapping: exports.DiscriminatorMapping,
|
|
981
|
+
Discriminator: exports.Discriminator,
|
|
978
982
|
Components,
|
|
979
983
|
NamedSchemas: (0, _1.mapOf)('Schema'),
|
|
980
984
|
NamedMessages: (0, _1.mapOf)('Message'),
|
|
@@ -983,12 +987,11 @@ exports.AsyncApi2Types = {
|
|
|
983
987
|
NamedParameters: (0, _1.mapOf)('Parameter'),
|
|
984
988
|
NamedSecuritySchemes: (0, _1.mapOf)('SecurityScheme'),
|
|
985
989
|
NamedCorrelationIds: (0, _1.mapOf)('CorrelationId'),
|
|
986
|
-
NamedStreamHeaders: (0, _1.mapOf)('StreamHeader'),
|
|
987
990
|
ImplicitFlow,
|
|
988
991
|
PasswordFlow,
|
|
989
992
|
ClientCredentials,
|
|
990
993
|
AuthorizationCode,
|
|
991
|
-
SecuritySchemeFlows,
|
|
994
|
+
SecuritySchemeFlows: exports.SecuritySchemeFlows,
|
|
992
995
|
SecurityScheme,
|
|
993
996
|
Message,
|
|
994
997
|
MessageBindings,
|
|
@@ -997,6 +1000,7 @@ exports.AsyncApi2Types = {
|
|
|
997
1000
|
OperationTraitList: (0, _1.listOf)('OperationTrait'),
|
|
998
1001
|
MessageTrait,
|
|
999
1002
|
MessageTraitList: (0, _1.listOf)('MessageTrait'),
|
|
1000
|
-
|
|
1001
|
-
|
|
1003
|
+
MessageExampleList: (0, _1.listOf)('MessageExample'),
|
|
1004
|
+
CorrelationId: exports.CorrelationId,
|
|
1005
|
+
Dependencies: exports.Dependencies,
|
|
1002
1006
|
};
|
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AsyncApi3Types = void 0;
|
|
4
|
+
const _1 = require(".");
|
|
5
|
+
const asyncapi2_1 = require("./asyncapi2");
|
|
6
|
+
const Root = {
|
|
7
|
+
properties: {
|
|
8
|
+
asyncapi: { type: 'string', enum: ['3.0.0'] },
|
|
9
|
+
info: 'Info',
|
|
10
|
+
id: { type: 'string' },
|
|
11
|
+
servers: 'ServerMap',
|
|
12
|
+
channels: 'NamedChannels',
|
|
13
|
+
components: 'Components',
|
|
14
|
+
operations: 'NamedOperations',
|
|
15
|
+
defaultContentType: { type: 'string' },
|
|
16
|
+
},
|
|
17
|
+
required: ['asyncapi', 'info'],
|
|
18
|
+
};
|
|
19
|
+
const Channel = {
|
|
20
|
+
properties: {
|
|
21
|
+
address: { type: 'string' },
|
|
22
|
+
messages: 'NamedMessages',
|
|
23
|
+
title: { type: 'string' },
|
|
24
|
+
summary: { type: 'string' },
|
|
25
|
+
description: { type: 'string' },
|
|
26
|
+
servers: 'ServerList',
|
|
27
|
+
parameters: 'ParametersMap',
|
|
28
|
+
bindings: 'ChannelBindings',
|
|
29
|
+
tags: 'TagList',
|
|
30
|
+
externalDocs: 'ExternalDocs',
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
const Server = {
|
|
34
|
+
properties: {
|
|
35
|
+
host: { type: 'string' },
|
|
36
|
+
pathname: { type: 'string' },
|
|
37
|
+
protocol: { type: 'string' },
|
|
38
|
+
protocolVersion: { type: 'string' },
|
|
39
|
+
description: { type: 'string' },
|
|
40
|
+
variables: 'ServerVariablesMap',
|
|
41
|
+
security: 'SecuritySchemeList',
|
|
42
|
+
bindings: 'ServerBindings',
|
|
43
|
+
externalDocs: 'ExternalDocs',
|
|
44
|
+
tags: 'TagList',
|
|
45
|
+
},
|
|
46
|
+
required: ['host', 'protocol'],
|
|
47
|
+
};
|
|
48
|
+
const Info = {
|
|
49
|
+
properties: {
|
|
50
|
+
title: { type: 'string' },
|
|
51
|
+
version: { type: 'string' },
|
|
52
|
+
description: { type: 'string' },
|
|
53
|
+
termsOfService: { type: 'string' },
|
|
54
|
+
contact: 'Contact',
|
|
55
|
+
license: 'License',
|
|
56
|
+
tags: 'TagList',
|
|
57
|
+
externalDocs: 'ExternalDocs',
|
|
58
|
+
},
|
|
59
|
+
required: ['title', 'version'],
|
|
60
|
+
};
|
|
61
|
+
const Parameter = {
|
|
62
|
+
properties: {
|
|
63
|
+
description: { type: 'string' },
|
|
64
|
+
enum: { type: 'array', items: { type: 'string' } },
|
|
65
|
+
default: { type: 'string' },
|
|
66
|
+
examples: { type: 'array', items: { type: 'string' } },
|
|
67
|
+
location: { type: 'string' },
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
const Message = {
|
|
71
|
+
properties: {
|
|
72
|
+
headers: 'Schema',
|
|
73
|
+
payload: (value) => {
|
|
74
|
+
if (!!value && value?.['schemaFormat']) {
|
|
75
|
+
return {
|
|
76
|
+
properties: {
|
|
77
|
+
schema: 'Schema',
|
|
78
|
+
schemaFormat: { type: 'string' },
|
|
79
|
+
},
|
|
80
|
+
required: ['schema', 'schemaFormat'],
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
return 'Schema';
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
correlationId: 'CorrelationId',
|
|
88
|
+
contentType: { type: 'string' },
|
|
89
|
+
name: { type: 'string' },
|
|
90
|
+
title: { type: 'string' },
|
|
91
|
+
summary: { type: 'string' },
|
|
92
|
+
description: { type: 'string' },
|
|
93
|
+
tags: 'TagList',
|
|
94
|
+
externalDocs: 'ExternalDocs',
|
|
95
|
+
bindings: 'MessageBindings',
|
|
96
|
+
examples: 'MessageExampleList',
|
|
97
|
+
traits: 'MessageTraitList',
|
|
98
|
+
},
|
|
99
|
+
additionalProperties: {},
|
|
100
|
+
};
|
|
101
|
+
const OperationTrait = {
|
|
102
|
+
properties: {
|
|
103
|
+
tags: 'TagList',
|
|
104
|
+
title: { type: 'string' },
|
|
105
|
+
summary: { type: 'string' },
|
|
106
|
+
description: { type: 'string' },
|
|
107
|
+
externalDocs: 'ExternalDocs',
|
|
108
|
+
security: 'SecuritySchemeList',
|
|
109
|
+
bindings: 'OperationBindings',
|
|
110
|
+
},
|
|
111
|
+
required: [],
|
|
112
|
+
};
|
|
113
|
+
const MessageTrait = {
|
|
114
|
+
properties: {
|
|
115
|
+
headers: (value) => {
|
|
116
|
+
if (typeof value === 'function' || (typeof value === 'object' && !!value)) {
|
|
117
|
+
return {
|
|
118
|
+
properties: {
|
|
119
|
+
schema: 'Schema',
|
|
120
|
+
schemaFormat: { type: 'string' },
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
return 'Schema';
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
correlationId: 'CorrelationId',
|
|
129
|
+
contentType: { type: 'string' },
|
|
130
|
+
name: { type: 'string' },
|
|
131
|
+
title: { type: 'string' },
|
|
132
|
+
summary: { type: 'string' },
|
|
133
|
+
description: { type: 'string' },
|
|
134
|
+
tags: 'TagList',
|
|
135
|
+
externalDocs: 'ExternalDocs',
|
|
136
|
+
bindings: 'MessageBindings',
|
|
137
|
+
examples: 'MessageExampleList',
|
|
138
|
+
},
|
|
139
|
+
additionalProperties: {},
|
|
140
|
+
};
|
|
141
|
+
const Operation = {
|
|
142
|
+
properties: {
|
|
143
|
+
action: { type: 'string', enum: ['send', 'receive'] },
|
|
144
|
+
channel: 'Channel',
|
|
145
|
+
title: { type: 'string' },
|
|
146
|
+
tags: 'TagList',
|
|
147
|
+
summary: { type: 'string' },
|
|
148
|
+
description: { type: 'string' },
|
|
149
|
+
externalDocs: 'ExternalDocs',
|
|
150
|
+
operationId: { type: 'string' },
|
|
151
|
+
security: 'SecuritySchemeList',
|
|
152
|
+
bindings: 'OperationBindings',
|
|
153
|
+
traits: 'OperationTraitList',
|
|
154
|
+
messages: 'MessageList',
|
|
155
|
+
reply: 'OperationReply',
|
|
156
|
+
},
|
|
157
|
+
required: ['action', 'channel'],
|
|
158
|
+
};
|
|
159
|
+
const OperationReply = {
|
|
160
|
+
properties: {
|
|
161
|
+
channel: 'Channel',
|
|
162
|
+
messages: 'MessageList',
|
|
163
|
+
address: 'OperationReplyAddress',
|
|
164
|
+
},
|
|
165
|
+
};
|
|
166
|
+
const OperationReplyAddress = {
|
|
167
|
+
properties: {
|
|
168
|
+
location: { type: 'string' },
|
|
169
|
+
description: { type: 'string' },
|
|
170
|
+
},
|
|
171
|
+
required: ['location'],
|
|
172
|
+
};
|
|
173
|
+
const Components = {
|
|
174
|
+
properties: {
|
|
175
|
+
messages: 'NamedMessages',
|
|
176
|
+
parameters: 'NamedParameters',
|
|
177
|
+
schemas: 'NamedSchemas',
|
|
178
|
+
replies: 'NamedOperationReplies',
|
|
179
|
+
replyAddresses: 'NamedOperationRelyAddresses',
|
|
180
|
+
correlationIds: 'NamedCorrelationIds',
|
|
181
|
+
messageTraits: 'NamedMessageTraits',
|
|
182
|
+
operationTraits: 'NamedOperationTraits',
|
|
183
|
+
tags: 'NamedTags',
|
|
184
|
+
externalDocs: 'NamedExternalDocs',
|
|
185
|
+
securitySchemes: 'NamedSecuritySchemes',
|
|
186
|
+
servers: 'ServerMap',
|
|
187
|
+
serverVariables: 'ServerVariablesMap',
|
|
188
|
+
channels: 'NamedChannels',
|
|
189
|
+
operations: 'NamedOperations',
|
|
190
|
+
serverBindings: 'ServerBindings',
|
|
191
|
+
channelBindings: 'ChannelBindings',
|
|
192
|
+
operationBindings: 'OperationBindings',
|
|
193
|
+
messageBindings: 'MessageBindings',
|
|
194
|
+
},
|
|
195
|
+
};
|
|
196
|
+
const ImplicitFlow = {
|
|
197
|
+
properties: {
|
|
198
|
+
refreshUrl: { type: 'string' },
|
|
199
|
+
availableScopes: { type: 'object', additionalProperties: { type: 'string' } },
|
|
200
|
+
authorizationUrl: { type: 'string' },
|
|
201
|
+
},
|
|
202
|
+
required: ['authorizationUrl', 'availableScopes'],
|
|
203
|
+
};
|
|
204
|
+
const PasswordFlow = {
|
|
205
|
+
properties: {
|
|
206
|
+
refreshUrl: { type: 'string' },
|
|
207
|
+
availableScopes: { type: 'object', additionalProperties: { type: 'string' } },
|
|
208
|
+
tokenUrl: { type: 'string' },
|
|
209
|
+
},
|
|
210
|
+
required: ['tokenUrl', 'availableScopes'],
|
|
211
|
+
};
|
|
212
|
+
const ClientCredentials = {
|
|
213
|
+
properties: {
|
|
214
|
+
refreshUrl: { type: 'string' },
|
|
215
|
+
availableScopes: { type: 'object', additionalProperties: { type: 'string' } },
|
|
216
|
+
tokenUrl: { type: 'string' },
|
|
217
|
+
},
|
|
218
|
+
required: ['tokenUrl', 'availableScopes'],
|
|
219
|
+
};
|
|
220
|
+
const AuthorizationCode = {
|
|
221
|
+
properties: {
|
|
222
|
+
refreshUrl: { type: 'string' },
|
|
223
|
+
authorizationUrl: { type: 'string' },
|
|
224
|
+
availableScopes: { type: 'object', additionalProperties: { type: 'string' } },
|
|
225
|
+
tokenUrl: { type: 'string' },
|
|
226
|
+
},
|
|
227
|
+
required: ['authorizationUrl', 'tokenUrl', 'availableScopes'],
|
|
228
|
+
};
|
|
229
|
+
const SecurityScheme = {
|
|
230
|
+
properties: {
|
|
231
|
+
type: {
|
|
232
|
+
enum: [
|
|
233
|
+
'userPassword',
|
|
234
|
+
'apiKey',
|
|
235
|
+
'X509',
|
|
236
|
+
'symmetricEncryption',
|
|
237
|
+
'asymmetricEncryption',
|
|
238
|
+
'httpApiKey',
|
|
239
|
+
'http',
|
|
240
|
+
'oauth2',
|
|
241
|
+
'openIdConnect',
|
|
242
|
+
'plain',
|
|
243
|
+
'scramSha256',
|
|
244
|
+
'scramSha512',
|
|
245
|
+
'gssapi',
|
|
246
|
+
],
|
|
247
|
+
},
|
|
248
|
+
description: { type: 'string' },
|
|
249
|
+
name: { type: 'string' },
|
|
250
|
+
in: { type: 'string', enum: ['query', 'header', 'cookie', 'user', 'password'] },
|
|
251
|
+
scheme: { type: 'string' },
|
|
252
|
+
bearerFormat: { type: 'string' },
|
|
253
|
+
flows: 'SecuritySchemeFlows',
|
|
254
|
+
openIdConnectUrl: { type: 'string' },
|
|
255
|
+
scopes: { type: 'array', items: { type: 'string' } },
|
|
256
|
+
},
|
|
257
|
+
required(value) {
|
|
258
|
+
switch (value?.type) {
|
|
259
|
+
case 'apiKey':
|
|
260
|
+
return ['type', 'in'];
|
|
261
|
+
case 'httpApiKey':
|
|
262
|
+
return ['type', 'name', 'in'];
|
|
263
|
+
case 'http':
|
|
264
|
+
return ['type', 'scheme'];
|
|
265
|
+
case 'oauth2':
|
|
266
|
+
return ['type', 'flows'];
|
|
267
|
+
case 'openIdConnect':
|
|
268
|
+
return ['type', 'openIdConnectUrl'];
|
|
269
|
+
default:
|
|
270
|
+
return ['type'];
|
|
271
|
+
}
|
|
272
|
+
},
|
|
273
|
+
allowed(value) {
|
|
274
|
+
switch (value?.type) {
|
|
275
|
+
case 'apiKey':
|
|
276
|
+
return ['type', 'in', 'description'];
|
|
277
|
+
case 'httpApiKey':
|
|
278
|
+
return ['type', 'name', 'in', 'description'];
|
|
279
|
+
case 'http':
|
|
280
|
+
return ['type', 'scheme', 'bearerFormat', 'description'];
|
|
281
|
+
case 'oauth2':
|
|
282
|
+
return ['type', 'flows', 'description', 'scopes'];
|
|
283
|
+
case 'openIdConnect':
|
|
284
|
+
return ['type', 'openIdConnectUrl', 'description', 'scopes'];
|
|
285
|
+
default:
|
|
286
|
+
return ['type', 'description'];
|
|
287
|
+
}
|
|
288
|
+
},
|
|
289
|
+
extensionsPrefix: 'x-',
|
|
290
|
+
};
|
|
291
|
+
exports.AsyncApi3Types = {
|
|
292
|
+
// from asyncapi2
|
|
293
|
+
...asyncapi2_1.AsyncApi2Bindings,
|
|
294
|
+
CorrelationId: asyncapi2_1.CorrelationId,
|
|
295
|
+
SecuritySchemeFlows: asyncapi2_1.SecuritySchemeFlows,
|
|
296
|
+
ServerVariable: asyncapi2_1.ServerVariable,
|
|
297
|
+
Contact: asyncapi2_1.Contact,
|
|
298
|
+
License: asyncapi2_1.License,
|
|
299
|
+
MessageExample: asyncapi2_1.MessageExample,
|
|
300
|
+
Tag: asyncapi2_1.Tag,
|
|
301
|
+
Dependencies: asyncapi2_1.Dependencies,
|
|
302
|
+
Schema: asyncapi2_1.Schema,
|
|
303
|
+
Discriminator: asyncapi2_1.Discriminator,
|
|
304
|
+
DiscriminatorMapping: asyncapi2_1.DiscriminatorMapping,
|
|
305
|
+
SchemaProperties: asyncapi2_1.SchemaProperties,
|
|
306
|
+
ServerMap: asyncapi2_1.ServerMap,
|
|
307
|
+
ExternalDocs: asyncapi2_1.ExternalDocs,
|
|
308
|
+
Root,
|
|
309
|
+
Channel,
|
|
310
|
+
Parameter,
|
|
311
|
+
Info,
|
|
312
|
+
Server,
|
|
313
|
+
MessageTrait,
|
|
314
|
+
Operation,
|
|
315
|
+
OperationReply,
|
|
316
|
+
OperationReplyAddress,
|
|
317
|
+
Components,
|
|
318
|
+
ImplicitFlow,
|
|
319
|
+
PasswordFlow,
|
|
320
|
+
ClientCredentials,
|
|
321
|
+
AuthorizationCode,
|
|
322
|
+
SecurityScheme,
|
|
323
|
+
Message,
|
|
324
|
+
OperationTrait,
|
|
325
|
+
ServerVariablesMap: (0, _1.mapOf)('ServerVariable'),
|
|
326
|
+
NamedTags: (0, _1.mapOf)('Tag'),
|
|
327
|
+
NamedExternalDocs: (0, _1.mapOf)('ExternalDocs'),
|
|
328
|
+
NamedChannels: (0, _1.mapOf)('Channel'),
|
|
329
|
+
ParametersMap: (0, _1.mapOf)('Parameter'),
|
|
330
|
+
NamedOperations: (0, _1.mapOf)('Operation'),
|
|
331
|
+
NamedOperationReplies: (0, _1.mapOf)('OperationReply'),
|
|
332
|
+
NamedOperationRelyAddresses: (0, _1.mapOf)('OperationReplyAddress'),
|
|
333
|
+
NamedSchemas: (0, _1.mapOf)('Schema'),
|
|
334
|
+
NamedMessages: (0, _1.mapOf)('Message'),
|
|
335
|
+
NamedMessageTraits: (0, _1.mapOf)('MessageTrait'),
|
|
336
|
+
NamedOperationTraits: (0, _1.mapOf)('OperationTrait'),
|
|
337
|
+
NamedParameters: (0, _1.mapOf)('Parameter'),
|
|
338
|
+
NamedSecuritySchemes: (0, _1.mapOf)('SecurityScheme'),
|
|
339
|
+
NamedCorrelationIds: (0, _1.mapOf)('CorrelationId'),
|
|
340
|
+
ServerList: (0, _1.listOf)('Server'),
|
|
341
|
+
SecuritySchemeList: (0, _1.listOf)('SecurityScheme'),
|
|
342
|
+
MessageList: (0, _1.listOf)('Message'),
|
|
343
|
+
OperationTraitList: (0, _1.listOf)('OperationTrait'),
|
|
344
|
+
MessageTraitList: (0, _1.listOf)('MessageTrait'),
|
|
345
|
+
MessageExampleList: (0, _1.listOf)('MessageExample'),
|
|
346
|
+
TagList: (0, _1.listOf)('Tag'),
|
|
347
|
+
};
|