@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
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Channel } from '../../typings/asyncapi3';
|
|
2
|
+
import { Async3Rule } from '../../visitors';
|
|
3
|
+
import { UserContext } from '../../walk';
|
|
4
|
+
|
|
5
|
+
export const ChannelsKebabCase: Async3Rule = () => {
|
|
6
|
+
return {
|
|
7
|
+
Channel(channel: Channel, { report }: UserContext) {
|
|
8
|
+
const segments = (channel.address || '')
|
|
9
|
+
.split(/[/.:]/) // split on / or : as likely channel namespacers
|
|
10
|
+
.filter((s) => s !== ''); // filter out empty segments
|
|
11
|
+
if (!segments.every((segment) => /^{.+}$/.test(segment) || /^[a-z0-9-.]+$/.test(segment))) {
|
|
12
|
+
report({
|
|
13
|
+
message: `\`${channel.address}\` does not use kebab-case.`,
|
|
14
|
+
location: { reportOnKey: true },
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Async3Rule } from '../../visitors';
|
|
2
|
+
import { Assertions } from '../common/assertions';
|
|
3
|
+
import { Spec } from '../common/spec';
|
|
4
|
+
import { InfoContact } from '../common/info-contact';
|
|
5
|
+
import { OperationOperationId } from '../common/operation-operationId';
|
|
6
|
+
import { TagDescription } from '../common/tag-description';
|
|
7
|
+
import { TagsAlphabetical } from '../common/tags-alphabetical';
|
|
8
|
+
import { ChannelsKebabCase } from './channels-kebab-case';
|
|
9
|
+
import { NoChannelTrailingSlash } from './no-channel-trailing-slash';
|
|
10
|
+
import type { Async3RuleSet } from '../../oas-types';
|
|
11
|
+
|
|
12
|
+
export const rules: Async3RuleSet<'built-in'> = {
|
|
13
|
+
spec: Spec as Async3Rule,
|
|
14
|
+
assertions: Assertions as Async3Rule,
|
|
15
|
+
'info-contact': InfoContact as Async3Rule,
|
|
16
|
+
'operation-operationId': OperationOperationId as Async3Rule,
|
|
17
|
+
'channels-kebab-case': ChannelsKebabCase,
|
|
18
|
+
'no-channel-trailing-slash': NoChannelTrailingSlash,
|
|
19
|
+
'tag-description': TagDescription as Async3Rule,
|
|
20
|
+
'tags-alphabetical': TagsAlphabetical as Async3Rule,
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const preprocessors = {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Async3Rule } from '../../visitors';
|
|
2
|
+
import { UserContext } from '../../walk';
|
|
3
|
+
import { Channel } from '../../typings/asyncapi3';
|
|
4
|
+
|
|
5
|
+
export const NoChannelTrailingSlash: Async3Rule = () => {
|
|
6
|
+
return {
|
|
7
|
+
Channel(channel: Channel, { report, location }: UserContext) {
|
|
8
|
+
if ((channel.address as string).endsWith('/') && channel.address !== '/') {
|
|
9
|
+
report({
|
|
10
|
+
message: `\`${channel.address}\` should not have a trailing slash.`,
|
|
11
|
+
location: location.key(),
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
};
|
|
@@ -1,9 +1,17 @@
|
|
|
1
|
-
import { asserts
|
|
1
|
+
import { asserts } from './asserts';
|
|
2
2
|
import { buildSubjectVisitor, buildVisitorObject } from './utils';
|
|
3
|
-
import { Oas2Visitor, Oas3Visitor } from '../../../visitors';
|
|
4
|
-
import { RuleSeverity } from '../../../config';
|
|
5
3
|
import { isString } from '../../../utils';
|
|
6
4
|
|
|
5
|
+
import type { AssertionFn } from './asserts';
|
|
6
|
+
import type {
|
|
7
|
+
ArazzoVisitor,
|
|
8
|
+
Async2Visitor,
|
|
9
|
+
Async3Visitor,
|
|
10
|
+
Oas2Visitor,
|
|
11
|
+
Oas3Visitor,
|
|
12
|
+
} from '../../../visitors';
|
|
13
|
+
import type { RuleSeverity } from '../../../config';
|
|
14
|
+
|
|
7
15
|
export type AssertionLocators = {
|
|
8
16
|
filterInParentKeys?: (string | number)[];
|
|
9
17
|
filterOutParentKeys?: (string | number)[];
|
|
@@ -28,7 +36,8 @@ export type RawAssertion = AssertionDefinition & {
|
|
|
28
36
|
export type Assertion = RawAssertion & { assertionId: string };
|
|
29
37
|
|
|
30
38
|
export const Assertions = (opts: Record<string, Assertion>) => {
|
|
31
|
-
const visitors: (Oas2Visitor | Oas3Visitor)[] =
|
|
39
|
+
const visitors: (Oas2Visitor | Oas3Visitor | Async2Visitor | Async3Visitor | ArazzoVisitor)[] =
|
|
40
|
+
[];
|
|
32
41
|
|
|
33
42
|
// As 'Assertions' has an array of asserts,
|
|
34
43
|
// that array spreads into an 'opts' object on init rules phase here
|
package/src/rules/common/spec.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { Oas3Rule, Oas2Rule, Async2Rule, ArazzoRule } from '../../visitors';
|
|
1
|
+
import type { Oas3Rule, Oas2Rule, Async2Rule, Async3Rule, ArazzoRule } from '../../visitors';
|
|
2
2
|
import { isNamedType, SpecExtension } from '../../types';
|
|
3
3
|
import { oasTypeOf, matchesJsonSchemaType, getSuggest, validateSchemaEnumType } from '../utils';
|
|
4
4
|
import { isRef } from '../../ref-utils';
|
|
5
5
|
import { isPlainObject } from '../../utils';
|
|
6
6
|
import { UserContext } from '../../walk';
|
|
7
7
|
|
|
8
|
-
export const Spec: Oas3Rule | Oas2Rule | Async2Rule | ArazzoRule = () => {
|
|
8
|
+
export const Spec: Oas3Rule | Oas2Rule | Async2Rule | Async3Rule | ArazzoRule = () => {
|
|
9
9
|
return {
|
|
10
10
|
any(
|
|
11
11
|
node: any,
|
package/src/rules/oas2/index.ts
CHANGED
|
@@ -86,10 +86,10 @@ export const rules: Oas2RuleSet<'built-in'> = {
|
|
|
86
86
|
'path-segment-plural': PathSegmentPlural as Oas2Rule,
|
|
87
87
|
'response-contains-header': ResponseContainsHeader as Oas2Rule,
|
|
88
88
|
'response-contains-property': ResponseContainsProperty as Oas2Rule,
|
|
89
|
-
'scalar-property-missing-example': ScalarPropertyMissingExample,
|
|
90
|
-
'required-string-property-missing-min-length': RequiredStringPropertyMissingMinLength,
|
|
91
|
-
'spec-strict-refs': SpecStrictRefs,
|
|
92
|
-
'no-required-schema-properties-undefined': NoRequiredSchemaPropertiesUndefined,
|
|
89
|
+
'scalar-property-missing-example': ScalarPropertyMissingExample as Oas2Rule,
|
|
90
|
+
'required-string-property-missing-min-length': RequiredStringPropertyMissingMinLength as Oas2Rule,
|
|
91
|
+
'spec-strict-refs': SpecStrictRefs as Oas2Rule,
|
|
92
|
+
'no-required-schema-properties-undefined': NoRequiredSchemaPropertiesUndefined as Oas2Rule,
|
|
93
93
|
};
|
|
94
94
|
|
|
95
95
|
export const preprocessors = {};
|
package/src/rules/oas3/index.ts
CHANGED
|
@@ -55,63 +55,65 @@ import { ComponentNameUnique } from './component-name-unique';
|
|
|
55
55
|
import { ArrayParameterSerialization } from './array-parameter-serialization';
|
|
56
56
|
import { NoRequiredSchemaPropertiesUndefined } from '../common/no-required-schema-properties-undefined';
|
|
57
57
|
|
|
58
|
+
import type { Oas3Rule } from '../../visitors';
|
|
59
|
+
|
|
58
60
|
export const rules: Oas3RuleSet<'built-in'> = {
|
|
59
|
-
spec: Spec,
|
|
60
|
-
'info-contact': InfoContact,
|
|
61
|
-
'info-license': InfoLicense,
|
|
62
|
-
'info-license-url': InfoLicenseUrl,
|
|
63
|
-
'operation-2xx-response': Operation2xxResponse,
|
|
64
|
-
'operation-4xx-response': Operation4xxResponse,
|
|
61
|
+
spec: Spec as Oas3Rule,
|
|
62
|
+
'info-contact': InfoContact as Oas3Rule,
|
|
63
|
+
'info-license': InfoLicense as Oas3Rule,
|
|
64
|
+
'info-license-url': InfoLicenseUrl as Oas3Rule,
|
|
65
|
+
'operation-2xx-response': Operation2xxResponse as Oas3Rule,
|
|
66
|
+
'operation-4xx-response': Operation4xxResponse as Oas3Rule,
|
|
65
67
|
'operation-4xx-problem-details-rfc7807': Operation4xxProblemDetailsRfc7807,
|
|
66
|
-
assertions: Assertions,
|
|
67
|
-
'operation-operationId-unique': OperationIdUnique,
|
|
68
|
-
'operation-parameters-unique': OperationParametersUnique,
|
|
69
|
-
'operation-tag-defined': OperationTagDefined,
|
|
68
|
+
assertions: Assertions as Oas3Rule,
|
|
69
|
+
'operation-operationId-unique': OperationIdUnique as Oas3Rule,
|
|
70
|
+
'operation-parameters-unique': OperationParametersUnique as Oas3Rule,
|
|
71
|
+
'operation-tag-defined': OperationTagDefined as Oas3Rule,
|
|
70
72
|
'no-example-value-and-externalValue': NoExampleValueAndExternalValue,
|
|
71
|
-
'no-enum-type-mismatch': NoEnumTypeMismatch,
|
|
72
|
-
'no-path-trailing-slash': NoPathTrailingSlash,
|
|
73
|
+
'no-enum-type-mismatch': NoEnumTypeMismatch as Oas3Rule,
|
|
74
|
+
'no-path-trailing-slash': NoPathTrailingSlash as Oas3Rule,
|
|
73
75
|
'no-empty-servers': NoEmptyServers,
|
|
74
|
-
'path-declaration-must-exist': PathDeclarationMustExist,
|
|
75
|
-
'operation-operationId-url-safe': OperationIdUrlSafe,
|
|
76
|
-
'operation-operationId': OperationOperationId,
|
|
77
|
-
'operation-summary': OperationSummary,
|
|
78
|
-
'tags-alphabetical': TagsAlphabetical,
|
|
76
|
+
'path-declaration-must-exist': PathDeclarationMustExist as Oas3Rule,
|
|
77
|
+
'operation-operationId-url-safe': OperationIdUrlSafe as Oas3Rule,
|
|
78
|
+
'operation-operationId': OperationOperationId as Oas3Rule,
|
|
79
|
+
'operation-summary': OperationSummary as Oas3Rule,
|
|
80
|
+
'tags-alphabetical': TagsAlphabetical as Oas3Rule,
|
|
79
81
|
'no-server-example.com': NoServerExample,
|
|
80
82
|
'no-server-trailing-slash': NoServerTrailingSlash,
|
|
81
|
-
'tag-description': TagDescription,
|
|
82
|
-
'operation-description': OperationDescription,
|
|
83
|
+
'tag-description': TagDescription as Oas3Rule,
|
|
84
|
+
'operation-description': OperationDescription as Oas3Rule,
|
|
83
85
|
'no-unused-components': NoUnusedComponents,
|
|
84
|
-
'path-not-include-query': PathNotIncludeQuery,
|
|
85
|
-
'path-parameters-defined': PathParamsDefined,
|
|
86
|
-
'path-params-defined': PathParamsDefined,
|
|
87
|
-
'parameter-description': ParameterDescription,
|
|
88
|
-
'operation-singular-tag': OperationSingularTag,
|
|
89
|
-
'security-defined': SecurityDefined,
|
|
86
|
+
'path-not-include-query': PathNotIncludeQuery as Oas3Rule,
|
|
87
|
+
'path-parameters-defined': PathParamsDefined as Oas3Rule,
|
|
88
|
+
'path-params-defined': PathParamsDefined as Oas3Rule,
|
|
89
|
+
'parameter-description': ParameterDescription as Oas3Rule,
|
|
90
|
+
'operation-singular-tag': OperationSingularTag as Oas3Rule,
|
|
91
|
+
'security-defined': SecurityDefined as Oas3Rule,
|
|
90
92
|
'no-unresolved-refs': NoUnresolvedRefs,
|
|
91
|
-
'paths-kebab-case': PathsKebabCase,
|
|
93
|
+
'paths-kebab-case': PathsKebabCase as Oas3Rule,
|
|
92
94
|
'boolean-parameter-prefixes': BooleanParameterPrefixes,
|
|
93
|
-
'path-http-verbs-order': PathHttpVerbsOrder,
|
|
95
|
+
'path-http-verbs-order': PathHttpVerbsOrder as Oas3Rule,
|
|
94
96
|
'no-invalid-media-type-examples': ValidContentExamples,
|
|
95
|
-
'no-identical-paths': NoIdenticalPaths,
|
|
96
|
-
'no-ambiguous-paths': NoAmbiguousPaths,
|
|
97
|
+
'no-identical-paths': NoIdenticalPaths as Oas3Rule,
|
|
98
|
+
'no-ambiguous-paths': NoAmbiguousPaths as Oas3Rule,
|
|
97
99
|
'no-undefined-server-variable': NoUndefinedServerVariable,
|
|
98
100
|
'no-server-variables-empty-enum': NoServerVariablesEmptyEnum,
|
|
99
|
-
'no-http-verbs-in-paths': NoHttpVerbsInPaths,
|
|
100
|
-
'path-excludes-patterns': PathExcludesPatterns,
|
|
101
|
+
'no-http-verbs-in-paths': NoHttpVerbsInPaths as Oas3Rule,
|
|
102
|
+
'path-excludes-patterns': PathExcludesPatterns as Oas3Rule,
|
|
101
103
|
'request-mime-type': RequestMimeType,
|
|
102
104
|
'response-mime-type': ResponseMimeType,
|
|
103
|
-
'path-segment-plural': PathSegmentPlural,
|
|
105
|
+
'path-segment-plural': PathSegmentPlural as Oas3Rule,
|
|
104
106
|
'no-invalid-schema-examples': NoInvalidSchemaExamples,
|
|
105
107
|
'no-invalid-parameter-examples': NoInvalidParameterExamples,
|
|
106
|
-
'response-contains-header': ResponseContainsHeader,
|
|
108
|
+
'response-contains-header': ResponseContainsHeader as Oas3Rule,
|
|
107
109
|
'response-contains-property': ResponseContainsProperty,
|
|
108
|
-
'scalar-property-missing-example': ScalarPropertyMissingExample,
|
|
110
|
+
'scalar-property-missing-example': ScalarPropertyMissingExample as Oas3Rule,
|
|
109
111
|
'spec-components-invalid-map-name': SpecComponentsInvalidMapName,
|
|
110
112
|
'required-string-property-missing-min-length': RequiredStringPropertyMissingMinLength,
|
|
111
|
-
'spec-strict-refs': SpecStrictRefs,
|
|
112
|
-
'component-name-unique': ComponentNameUnique,
|
|
113
|
+
'spec-strict-refs': SpecStrictRefs as Oas3Rule,
|
|
114
|
+
'component-name-unique': ComponentNameUnique as Oas3Rule,
|
|
113
115
|
'array-parameter-serialization': ArrayParameterSerialization,
|
|
114
|
-
'no-required-schema-properties-undefined': NoRequiredSchemaPropertiesUndefined,
|
|
116
|
+
'no-required-schema-properties-undefined': NoRequiredSchemaPropertiesUndefined as Oas3Rule,
|
|
115
117
|
};
|
|
116
118
|
|
|
117
119
|
export const preprocessors = {};
|
|
@@ -61,7 +61,7 @@ const ChannelBindings: NodeType = {
|
|
|
61
61
|
additionalProperties: { type: 'object' },
|
|
62
62
|
};
|
|
63
63
|
|
|
64
|
-
const Tag: NodeType = {
|
|
64
|
+
export const Tag: NodeType = {
|
|
65
65
|
properties: {
|
|
66
66
|
name: { type: 'string' },
|
|
67
67
|
description: { type: 'string' },
|
|
@@ -70,7 +70,7 @@ const Tag: NodeType = {
|
|
|
70
70
|
required: ['name'],
|
|
71
71
|
};
|
|
72
72
|
|
|
73
|
-
const ExternalDocs: NodeType = {
|
|
73
|
+
export const ExternalDocs: NodeType = {
|
|
74
74
|
properties: {
|
|
75
75
|
description: { type: 'string' },
|
|
76
76
|
url: { type: 'string' },
|
|
@@ -126,13 +126,13 @@ const Server: NodeType = {
|
|
|
126
126
|
required: ['url', 'protocol'],
|
|
127
127
|
};
|
|
128
128
|
|
|
129
|
-
const ServerMap: NodeType = {
|
|
129
|
+
export const ServerMap: NodeType = {
|
|
130
130
|
properties: {},
|
|
131
131
|
additionalProperties: (_value: any, key: string) =>
|
|
132
132
|
key.match(/^[A-Za-z0-9_\-]+$/) ? 'Server' : undefined,
|
|
133
133
|
};
|
|
134
134
|
|
|
135
|
-
const ServerVariable: NodeType = {
|
|
135
|
+
export const ServerVariable: NodeType = {
|
|
136
136
|
properties: {
|
|
137
137
|
enum: {
|
|
138
138
|
type: 'array',
|
|
@@ -160,7 +160,7 @@ const Info: NodeType = {
|
|
|
160
160
|
required: ['title', 'version'],
|
|
161
161
|
};
|
|
162
162
|
|
|
163
|
-
const Contact: NodeType = {
|
|
163
|
+
export const Contact: NodeType = {
|
|
164
164
|
properties: {
|
|
165
165
|
name: { type: 'string' },
|
|
166
166
|
url: { type: 'string' },
|
|
@@ -168,7 +168,7 @@ const Contact: NodeType = {
|
|
|
168
168
|
},
|
|
169
169
|
};
|
|
170
170
|
|
|
171
|
-
const License: NodeType = {
|
|
171
|
+
export const License: NodeType = {
|
|
172
172
|
properties: {
|
|
173
173
|
name: { type: 'string' },
|
|
174
174
|
url: { type: 'string' },
|
|
@@ -184,7 +184,7 @@ const Parameter: NodeType = {
|
|
|
184
184
|
},
|
|
185
185
|
};
|
|
186
186
|
|
|
187
|
-
const CorrelationId: NodeType = {
|
|
187
|
+
export const CorrelationId: NodeType = {
|
|
188
188
|
properties: {
|
|
189
189
|
description: { type: 'string' },
|
|
190
190
|
location: { type: 'string' },
|
|
@@ -208,7 +208,7 @@ const Message: NodeType = {
|
|
|
208
208
|
tags: 'TagList',
|
|
209
209
|
externalDocs: 'ExternalDocs',
|
|
210
210
|
bindings: 'MessageBindings',
|
|
211
|
-
|
|
211
|
+
examples: 'MessageExampleList',
|
|
212
212
|
traits: 'MessageTraitList',
|
|
213
213
|
},
|
|
214
214
|
additionalProperties: {},
|
|
@@ -301,7 +301,7 @@ const MessageTrait: NodeType = {
|
|
|
301
301
|
tags: 'TagList',
|
|
302
302
|
externalDocs: 'ExternalDocs',
|
|
303
303
|
bindings: 'MessageBindings',
|
|
304
|
-
|
|
304
|
+
examples: 'MessageExampleList',
|
|
305
305
|
},
|
|
306
306
|
additionalProperties: {},
|
|
307
307
|
};
|
|
@@ -322,7 +322,7 @@ const Operation: NodeType = {
|
|
|
322
322
|
required: [],
|
|
323
323
|
};
|
|
324
324
|
|
|
325
|
-
const MessageExample: NodeType = {
|
|
325
|
+
export const MessageExample: NodeType = {
|
|
326
326
|
properties: {
|
|
327
327
|
payload: { isExample: true },
|
|
328
328
|
summary: { type: 'string' },
|
|
@@ -331,7 +331,7 @@ const MessageExample: NodeType = {
|
|
|
331
331
|
},
|
|
332
332
|
};
|
|
333
333
|
|
|
334
|
-
const Schema: NodeType = {
|
|
334
|
+
export const Schema: NodeType = {
|
|
335
335
|
properties: {
|
|
336
336
|
$id: { type: 'string' },
|
|
337
337
|
$schema: { type: 'string' },
|
|
@@ -401,14 +401,14 @@ const Schema: NodeType = {
|
|
|
401
401
|
},
|
|
402
402
|
};
|
|
403
403
|
|
|
404
|
-
const SchemaProperties: NodeType = {
|
|
404
|
+
export const SchemaProperties: NodeType = {
|
|
405
405
|
properties: {},
|
|
406
406
|
additionalProperties: (value: any) => {
|
|
407
407
|
return typeof value === 'boolean' ? { type: 'boolean' } : 'Schema';
|
|
408
408
|
},
|
|
409
409
|
};
|
|
410
410
|
|
|
411
|
-
const DiscriminatorMapping: NodeType = {
|
|
411
|
+
export const DiscriminatorMapping: NodeType = {
|
|
412
412
|
properties: {},
|
|
413
413
|
additionalProperties: (value: any) => {
|
|
414
414
|
if (isMappingRef(value)) {
|
|
@@ -419,7 +419,7 @@ const DiscriminatorMapping: NodeType = {
|
|
|
419
419
|
},
|
|
420
420
|
};
|
|
421
421
|
|
|
422
|
-
const Discriminator: NodeType = {
|
|
422
|
+
export const Discriminator: NodeType = {
|
|
423
423
|
properties: {
|
|
424
424
|
propertyName: { type: 'string' },
|
|
425
425
|
mapping: 'DiscriminatorMapping',
|
|
@@ -435,7 +435,6 @@ const Components: NodeType = {
|
|
|
435
435
|
correlationIds: 'NamedCorrelationIds',
|
|
436
436
|
messageTraits: 'NamedMessageTraits',
|
|
437
437
|
operationTraits: 'NamedOperationTraits',
|
|
438
|
-
streamHeaders: 'NamedStreamHeaders',
|
|
439
438
|
securitySchemes: 'NamedSecuritySchemes',
|
|
440
439
|
servers: 'ServerMap',
|
|
441
440
|
serverVariables: 'ServerVariablesMap',
|
|
@@ -484,7 +483,7 @@ const AuthorizationCode: NodeType = {
|
|
|
484
483
|
required: ['authorizationUrl', 'tokenUrl', 'scopes'],
|
|
485
484
|
};
|
|
486
485
|
|
|
487
|
-
const SecuritySchemeFlows: NodeType = {
|
|
486
|
+
export const SecuritySchemeFlows: NodeType = {
|
|
488
487
|
properties: {
|
|
489
488
|
implicit: 'ImplicitFlow',
|
|
490
489
|
password: 'PasswordFlow',
|
|
@@ -555,7 +554,7 @@ const SecurityScheme: NodeType = {
|
|
|
555
554
|
extensionsPrefix: 'x-',
|
|
556
555
|
};
|
|
557
556
|
|
|
558
|
-
const Dependencies: NodeType = {
|
|
557
|
+
export const Dependencies: NodeType = {
|
|
559
558
|
properties: {},
|
|
560
559
|
additionalProperties: (value: any) => {
|
|
561
560
|
return Array.isArray(value) ? { type: 'array', items: { type: 'string' } } : 'Schema';
|
|
@@ -987,22 +986,7 @@ OperationBindings.properties.mercure = MercureOperationBinding;
|
|
|
987
986
|
// pulsar
|
|
988
987
|
|
|
989
988
|
// --- End per-protocol node types
|
|
990
|
-
|
|
991
|
-
export const AsyncApi2Types: Record<string, NodeType> = {
|
|
992
|
-
Root,
|
|
993
|
-
Tag,
|
|
994
|
-
TagList: listOf('Tag'),
|
|
995
|
-
ServerMap,
|
|
996
|
-
ExternalDocs,
|
|
997
|
-
Server,
|
|
998
|
-
ServerVariable,
|
|
999
|
-
ServerVariablesMap: mapOf('ServerVariable'),
|
|
1000
|
-
SecurityRequirement,
|
|
1001
|
-
SecurityRequirementList: listOf('SecurityRequirement'),
|
|
1002
|
-
Info,
|
|
1003
|
-
Contact,
|
|
1004
|
-
License,
|
|
1005
|
-
|
|
989
|
+
export const AsyncApi2Bindings: Record<string, NodeType> = {
|
|
1006
990
|
HttpServerBinding,
|
|
1007
991
|
HttpChannelBinding,
|
|
1008
992
|
HttpMessageBinding,
|
|
@@ -1078,6 +1062,25 @@ export const AsyncApi2Types: Record<string, NodeType> = {
|
|
|
1078
1062
|
|
|
1079
1063
|
ServerBindings,
|
|
1080
1064
|
ChannelBindings,
|
|
1065
|
+
MessageBindings,
|
|
1066
|
+
OperationBindings,
|
|
1067
|
+
};
|
|
1068
|
+
|
|
1069
|
+
export const AsyncApi2Types: Record<string, NodeType> = {
|
|
1070
|
+
...AsyncApi2Bindings,
|
|
1071
|
+
Root,
|
|
1072
|
+
Tag,
|
|
1073
|
+
TagList: listOf('Tag'),
|
|
1074
|
+
ServerMap,
|
|
1075
|
+
ExternalDocs,
|
|
1076
|
+
Server,
|
|
1077
|
+
ServerVariable,
|
|
1078
|
+
ServerVariablesMap: mapOf('ServerVariable'),
|
|
1079
|
+
SecurityRequirement,
|
|
1080
|
+
SecurityRequirementList: listOf('SecurityRequirement'),
|
|
1081
|
+
Info,
|
|
1082
|
+
Contact,
|
|
1083
|
+
License,
|
|
1081
1084
|
ChannelMap,
|
|
1082
1085
|
Channel,
|
|
1083
1086
|
Parameter,
|
|
@@ -1096,7 +1099,6 @@ export const AsyncApi2Types: Record<string, NodeType> = {
|
|
|
1096
1099
|
NamedParameters: mapOf('Parameter'),
|
|
1097
1100
|
NamedSecuritySchemes: mapOf('SecurityScheme'),
|
|
1098
1101
|
NamedCorrelationIds: mapOf('CorrelationId'),
|
|
1099
|
-
NamedStreamHeaders: mapOf('StreamHeader'),
|
|
1100
1102
|
ImplicitFlow,
|
|
1101
1103
|
PasswordFlow,
|
|
1102
1104
|
ClientCredentials,
|
|
@@ -1110,6 +1112,7 @@ export const AsyncApi2Types: Record<string, NodeType> = {
|
|
|
1110
1112
|
OperationTraitList: listOf('OperationTrait'),
|
|
1111
1113
|
MessageTrait,
|
|
1112
1114
|
MessageTraitList: listOf('MessageTrait'),
|
|
1115
|
+
MessageExampleList: listOf('MessageExample'),
|
|
1113
1116
|
CorrelationId,
|
|
1114
1117
|
Dependencies,
|
|
1115
1118
|
};
|