@redocly/openapi-core 1.17.1 → 1.18.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/bundle.d.ts +1 -1
- package/lib/bundle.js +15 -0
- 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/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 +12 -7
- 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/spec.d.ts +2 -2
- package/lib/types/arazzo.d.ts +1050 -0
- package/lib/types/arazzo.js +381 -0
- package/lib/types/oas3.js +0 -8
- package/lib/types/redocly-yaml.d.ts +4 -4
- package/lib/types/redocly-yaml.js +15 -5
- package/lib/typings/arazzo.d.ts +3 -0
- package/lib/typings/arazzo.js +2 -0
- package/lib/visitors.d.ts +11 -0
- package/package.json +2 -1
- package/src/bundle.ts +13 -0
- 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/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/spec.ts +2 -2
- package/src/types/arazzo.ts +386 -0
- package/src/types/oas3.ts +0 -7
- package/src/types/redocly-yaml.ts +18 -8
- package/src/typings/arazzo.ts +4 -0
- package/src/visitors.ts +18 -0
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @redocly/openapi-core
|
|
2
2
|
|
|
3
|
+
## 1.18.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Added support for Arazzo description linting.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Removed `additionalItems` from OAS 3.0.x typings. This keyword is not supported by the specification.
|
|
12
|
+
|
|
3
13
|
## 1.17.1
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
package/lib/bundle.d.ts
CHANGED
|
@@ -47,4 +47,4 @@ export declare function bundleDocument(opts: {
|
|
|
47
47
|
removeUnusedComponents?: boolean;
|
|
48
48
|
keepUrlRefs?: boolean;
|
|
49
49
|
}): Promise<BundleResult>;
|
|
50
|
-
export declare function mapTypeToComponent(typeName: string, version: SpecMajorVersion): "definitions" | "
|
|
50
|
+
export declare function mapTypeToComponent(typeName: string, version: SpecMajorVersion): "definitions" | "parameters" | "examples" | "headers" | "schemas" | "responses" | "requestBodies" | "securitySchemes" | "links" | "callbacks" | null;
|
package/lib/bundle.js
CHANGED
|
@@ -201,6 +201,15 @@ function mapTypeToComponent(typeName, version) {
|
|
|
201
201
|
default:
|
|
202
202
|
return null;
|
|
203
203
|
}
|
|
204
|
+
case oas_types_1.SpecMajorVersion.Arazzo:
|
|
205
|
+
switch (typeName) {
|
|
206
|
+
case 'Root.x-parameters_items':
|
|
207
|
+
case 'Root.workflows_items.parameters_items':
|
|
208
|
+
case 'Root.workflows_items.steps_items.parameters_items':
|
|
209
|
+
return 'parameters';
|
|
210
|
+
default:
|
|
211
|
+
return null;
|
|
212
|
+
}
|
|
204
213
|
}
|
|
205
214
|
}
|
|
206
215
|
exports.mapTypeToComponent = mapTypeToComponent;
|
|
@@ -265,6 +274,12 @@ function makeBundleVisitor(version, dereference, skipRedoclyRegistryRefs, rootDo
|
|
|
265
274
|
else if (version === oas_types_1.SpecMajorVersion.OAS2) {
|
|
266
275
|
components = root;
|
|
267
276
|
}
|
|
277
|
+
else if (version === oas_types_1.SpecMajorVersion.Async2) {
|
|
278
|
+
components = root.components = root.components || {};
|
|
279
|
+
}
|
|
280
|
+
else if (version === oas_types_1.SpecMajorVersion.Arazzo) {
|
|
281
|
+
components = root.components = root.components || {};
|
|
282
|
+
}
|
|
268
283
|
},
|
|
269
284
|
},
|
|
270
285
|
};
|
package/lib/config/all.js
CHANGED
|
@@ -106,8 +106,14 @@ const all = {
|
|
|
106
106
|
'array-parameter-serialization': 'error',
|
|
107
107
|
},
|
|
108
108
|
async2Rules: {
|
|
109
|
+
spec: 'error',
|
|
110
|
+
'info-contact': 'error',
|
|
111
|
+
'operation-operationId': 'error',
|
|
112
|
+
'tag-description': 'error',
|
|
113
|
+
'tags-alphabetical': 'error',
|
|
109
114
|
'channels-kebab-case': 'error',
|
|
110
115
|
'no-channel-trailing-slash': 'error',
|
|
111
116
|
},
|
|
117
|
+
arazzoRules: { spec: 'error' },
|
|
112
118
|
};
|
|
113
119
|
exports.default = all;
|
package/lib/config/builtIn.js
CHANGED
|
@@ -8,10 +8,15 @@ const minimal_1 = require("./minimal");
|
|
|
8
8
|
const oas3_1 = require("../rules/oas3");
|
|
9
9
|
const oas2_1 = require("../rules/oas2");
|
|
10
10
|
const async2_1 = require("../rules/async2");
|
|
11
|
+
const arazzo_1 = require("../rules/arazzo");
|
|
11
12
|
const oas3_2 = require("../rules/oas3");
|
|
12
13
|
const oas2_2 = require("../rules/oas2");
|
|
14
|
+
const async2_2 = require("../rules/async2");
|
|
15
|
+
const arazzo_2 = require("../rules/arazzo");
|
|
13
16
|
const oas3_3 = require("../decorators/oas3");
|
|
14
17
|
const oas2_3 = require("../decorators/oas2");
|
|
18
|
+
const async2_3 = require("../decorators/async2");
|
|
19
|
+
const arazzo_3 = require("../decorators/arazzo");
|
|
15
20
|
exports.builtInConfigs = {
|
|
16
21
|
recommended: recommended_1.default,
|
|
17
22
|
'recommended-strict': recommended_strict_1.default,
|
|
@@ -27,16 +32,19 @@ exports.defaultPlugin = {
|
|
|
27
32
|
oas3: oas3_1.rules,
|
|
28
33
|
oas2: oas2_1.rules,
|
|
29
34
|
async2: async2_1.rules,
|
|
35
|
+
arazzo: arazzo_1.rules,
|
|
30
36
|
},
|
|
31
37
|
preprocessors: {
|
|
32
38
|
oas3: oas3_2.preprocessors,
|
|
33
39
|
oas2: oas2_2.preprocessors,
|
|
34
|
-
async2:
|
|
40
|
+
async2: async2_2.preprocessors,
|
|
41
|
+
arazzo: arazzo_2.preprocessors,
|
|
35
42
|
},
|
|
36
43
|
decorators: {
|
|
37
44
|
oas3: oas3_3.decorators,
|
|
38
45
|
oas2: oas2_3.decorators,
|
|
39
|
-
async2:
|
|
46
|
+
async2: async2_3.decorators,
|
|
47
|
+
arazzo: arazzo_3.decorators,
|
|
40
48
|
},
|
|
41
49
|
configs: exports.builtInConfigs,
|
|
42
50
|
};
|
|
@@ -127,7 +127,7 @@ function resolvePlugins(plugins, configPath = '') {
|
|
|
127
127
|
const plugin = Object.assign(Object.assign({ id }, (pluginModule.configs ? { configs: pluginModule.configs } : {})), (pluginModule.typeExtension ? { typeExtension: pluginModule.typeExtension } : {}));
|
|
128
128
|
if (pluginModule.rules) {
|
|
129
129
|
if (!pluginModule.rules.oas3 && !pluginModule.rules.oas2 && !pluginModule.rules.async2) {
|
|
130
|
-
throw new Error(`Plugin rules must have \`oas3\`, \`oas2\` or \`
|
|
130
|
+
throw new Error(`Plugin rules must have \`oas3\`, \`oas2\`, \`async2\`, or \`arazzo\` rules "${p}.`);
|
|
131
131
|
}
|
|
132
132
|
plugin.rules = {};
|
|
133
133
|
if (pluginModule.rules.oas3) {
|
|
@@ -139,11 +139,15 @@ function resolvePlugins(plugins, configPath = '') {
|
|
|
139
139
|
if (pluginModule.rules.async2) {
|
|
140
140
|
plugin.rules.async2 = (0, utils_2.prefixRules)(pluginModule.rules.async2, id);
|
|
141
141
|
}
|
|
142
|
+
if (pluginModule.rules.arazzo) {
|
|
143
|
+
plugin.rules.arazzo = (0, utils_2.prefixRules)(pluginModule.rules.arazzo, id);
|
|
144
|
+
}
|
|
142
145
|
}
|
|
143
146
|
if (pluginModule.preprocessors) {
|
|
144
147
|
if (!pluginModule.preprocessors.oas3 &&
|
|
145
148
|
!pluginModule.preprocessors.oas2 &&
|
|
146
|
-
!pluginModule.preprocessors.async2
|
|
149
|
+
!pluginModule.preprocessors.async2 &&
|
|
150
|
+
!pluginModule.preprocessors.arazzo) {
|
|
147
151
|
throw new Error(`Plugin \`preprocessors\` must have \`oas3\`, \`oas2\` or \`async2\` preprocessors "${p}.`);
|
|
148
152
|
}
|
|
149
153
|
plugin.preprocessors = {};
|
|
@@ -156,11 +160,15 @@ function resolvePlugins(plugins, configPath = '') {
|
|
|
156
160
|
if (pluginModule.preprocessors.async2) {
|
|
157
161
|
plugin.preprocessors.async2 = (0, utils_2.prefixRules)(pluginModule.preprocessors.async2, id);
|
|
158
162
|
}
|
|
163
|
+
if (pluginModule.preprocessors.arazzo) {
|
|
164
|
+
plugin.preprocessors.arazzo = (0, utils_2.prefixRules)(pluginModule.preprocessors.arazzo, id);
|
|
165
|
+
}
|
|
159
166
|
}
|
|
160
167
|
if (pluginModule.decorators) {
|
|
161
168
|
if (!pluginModule.decorators.oas3 &&
|
|
162
169
|
!pluginModule.decorators.oas2 &&
|
|
163
|
-
!pluginModule.decorators.async2
|
|
170
|
+
!pluginModule.decorators.async2 &&
|
|
171
|
+
!pluginModule.decorators.arazzo) {
|
|
164
172
|
throw new Error(`Plugin \`decorators\` must have \`oas3\`, \`oas2\` or \`async2\` decorators "${p}.`);
|
|
165
173
|
}
|
|
166
174
|
plugin.decorators = {};
|
|
@@ -173,6 +181,9 @@ function resolvePlugins(plugins, configPath = '') {
|
|
|
173
181
|
if (pluginModule.decorators.async2) {
|
|
174
182
|
plugin.decorators.async2 = (0, utils_2.prefixRules)(pluginModule.decorators.async2, id);
|
|
175
183
|
}
|
|
184
|
+
if (pluginModule.decorators.arazzo) {
|
|
185
|
+
plugin.decorators.arazzo = (0, utils_2.prefixRules)(pluginModule.decorators.arazzo, id);
|
|
186
|
+
}
|
|
176
187
|
}
|
|
177
188
|
if (pluginModule.assertions) {
|
|
178
189
|
plugin.assertions = pluginModule.assertions;
|
|
@@ -276,7 +287,7 @@ function loadExtendStyleguideConfig(filePath, resolver) {
|
|
|
276
287
|
});
|
|
277
288
|
}
|
|
278
289
|
function getMergedRawStyleguideConfig(rootStyleguideConfig, apiStyleguideConfig) {
|
|
279
|
-
const resultLint = Object.assign(Object.assign(Object.assign({}, rootStyleguideConfig), (0, utils_1.pickDefined)(apiStyleguideConfig)), { rules: Object.assign(Object.assign({}, rootStyleguideConfig === null || rootStyleguideConfig === void 0 ? void 0 : rootStyleguideConfig.rules), apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.rules), oas2Rules: Object.assign(Object.assign({}, rootStyleguideConfig === null || rootStyleguideConfig === void 0 ? void 0 : rootStyleguideConfig.oas2Rules), apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.oas2Rules), oas3_0Rules: Object.assign(Object.assign({}, rootStyleguideConfig === null || rootStyleguideConfig === void 0 ? void 0 : rootStyleguideConfig.oas3_0Rules), apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.oas3_0Rules), oas3_1Rules: Object.assign(Object.assign({}, rootStyleguideConfig === null || rootStyleguideConfig === void 0 ? void 0 : rootStyleguideConfig.oas3_1Rules), apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.oas3_1Rules), preprocessors: Object.assign(Object.assign({}, rootStyleguideConfig === null || rootStyleguideConfig === void 0 ? void 0 : rootStyleguideConfig.preprocessors), apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.preprocessors), oas2Preprocessors: Object.assign(Object.assign({}, rootStyleguideConfig === null || rootStyleguideConfig === void 0 ? void 0 : rootStyleguideConfig.oas2Preprocessors), apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.oas2Preprocessors), oas3_0Preprocessors: Object.assign(Object.assign({}, rootStyleguideConfig === null || rootStyleguideConfig === void 0 ? void 0 : rootStyleguideConfig.oas3_0Preprocessors), apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.oas3_0Preprocessors), oas3_1Preprocessors: Object.assign(Object.assign({}, rootStyleguideConfig === null || rootStyleguideConfig === void 0 ? void 0 : rootStyleguideConfig.oas3_1Preprocessors), apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.oas3_1Preprocessors), decorators: Object.assign(Object.assign({}, rootStyleguideConfig === null || rootStyleguideConfig === void 0 ? void 0 : rootStyleguideConfig.decorators), apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.decorators), oas2Decorators: Object.assign(Object.assign({}, rootStyleguideConfig === null || rootStyleguideConfig === void 0 ? void 0 : rootStyleguideConfig.oas2Decorators), apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.oas2Decorators), oas3_0Decorators: Object.assign(Object.assign({}, rootStyleguideConfig === null || rootStyleguideConfig === void 0 ? void 0 : rootStyleguideConfig.oas3_0Decorators), apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.oas3_0Decorators), oas3_1Decorators: Object.assign(Object.assign({}, rootStyleguideConfig === null || rootStyleguideConfig === void 0 ? void 0 : rootStyleguideConfig.oas3_1Decorators), apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.oas3_1Decorators), recommendedFallback: (apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.extends)
|
|
290
|
+
const resultLint = Object.assign(Object.assign(Object.assign({}, rootStyleguideConfig), (0, utils_1.pickDefined)(apiStyleguideConfig)), { rules: Object.assign(Object.assign({}, rootStyleguideConfig === null || rootStyleguideConfig === void 0 ? void 0 : rootStyleguideConfig.rules), apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.rules), oas2Rules: Object.assign(Object.assign({}, rootStyleguideConfig === null || rootStyleguideConfig === void 0 ? void 0 : rootStyleguideConfig.oas2Rules), apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.oas2Rules), oas3_0Rules: Object.assign(Object.assign({}, rootStyleguideConfig === null || rootStyleguideConfig === void 0 ? void 0 : rootStyleguideConfig.oas3_0Rules), apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.oas3_0Rules), oas3_1Rules: Object.assign(Object.assign({}, rootStyleguideConfig === null || rootStyleguideConfig === void 0 ? void 0 : rootStyleguideConfig.oas3_1Rules), apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.oas3_1Rules), arazzoRules: Object.assign(Object.assign({}, rootStyleguideConfig === null || rootStyleguideConfig === void 0 ? void 0 : rootStyleguideConfig.arazzoRules), apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.arazzoRules), preprocessors: Object.assign(Object.assign({}, rootStyleguideConfig === null || rootStyleguideConfig === void 0 ? void 0 : rootStyleguideConfig.preprocessors), apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.preprocessors), oas2Preprocessors: Object.assign(Object.assign({}, rootStyleguideConfig === null || rootStyleguideConfig === void 0 ? void 0 : rootStyleguideConfig.oas2Preprocessors), apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.oas2Preprocessors), oas3_0Preprocessors: Object.assign(Object.assign({}, rootStyleguideConfig === null || rootStyleguideConfig === void 0 ? void 0 : rootStyleguideConfig.oas3_0Preprocessors), apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.oas3_0Preprocessors), oas3_1Preprocessors: Object.assign(Object.assign({}, rootStyleguideConfig === null || rootStyleguideConfig === void 0 ? void 0 : rootStyleguideConfig.oas3_1Preprocessors), apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.oas3_1Preprocessors), decorators: Object.assign(Object.assign({}, rootStyleguideConfig === null || rootStyleguideConfig === void 0 ? void 0 : rootStyleguideConfig.decorators), apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.decorators), oas2Decorators: Object.assign(Object.assign({}, rootStyleguideConfig === null || rootStyleguideConfig === void 0 ? void 0 : rootStyleguideConfig.oas2Decorators), apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.oas2Decorators), oas3_0Decorators: Object.assign(Object.assign({}, rootStyleguideConfig === null || rootStyleguideConfig === void 0 ? void 0 : rootStyleguideConfig.oas3_0Decorators), apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.oas3_0Decorators), oas3_1Decorators: Object.assign(Object.assign({}, rootStyleguideConfig === null || rootStyleguideConfig === void 0 ? void 0 : rootStyleguideConfig.oas3_1Decorators), apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.oas3_1Decorators), recommendedFallback: (apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.extends)
|
|
280
291
|
? false
|
|
281
292
|
: rootStyleguideConfig.recommendedFallback });
|
|
282
293
|
return resultLint;
|
package/lib/config/config.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NormalizedProblem } from '../walk';
|
|
2
|
-
import { SpecVersion, SpecMajorVersion, Oas2RuleSet, Oas3RuleSet, Async2RuleSet } from '../oas-types';
|
|
2
|
+
import { SpecVersion, SpecMajorVersion, Oas2RuleSet, Oas3RuleSet, Async2RuleSet, ArazzoRuleSet } from '../oas-types';
|
|
3
3
|
import type { NodeType } from '../types';
|
|
4
4
|
import type { DecoratorConfig, Plugin, PreprocessorConfig, Region, ResolveConfig, ResolvedApi, ResolvedConfig, ResolvedStyleguideConfig, RuleConfig, RuleSettings, Telemetry, ThemeRawConfig } from './types';
|
|
5
5
|
export declare const IGNORE_FILE = ".redocly.lint-ignore.yaml";
|
|
@@ -31,7 +31,7 @@ export declare class StyleguideConfig {
|
|
|
31
31
|
preprocessors: string[];
|
|
32
32
|
decorators: string[];
|
|
33
33
|
};
|
|
34
|
-
getRulesForOasVersion(version: SpecMajorVersion): Oas3RuleSet[] | Oas2RuleSet[] | Async2RuleSet[];
|
|
34
|
+
getRulesForOasVersion(version: SpecMajorVersion): Oas3RuleSet[] | Oas2RuleSet[] | Async2RuleSet[] | ArazzoRuleSet[];
|
|
35
35
|
skipRules(rules?: string[]): void;
|
|
36
36
|
skipPreprocessors(preprocessors?: string[]): void;
|
|
37
37
|
skipDecorators(decorators?: string[]): void;
|
package/lib/config/config.js
CHANGED
|
@@ -37,18 +37,21 @@ class StyleguideConfig {
|
|
|
37
37
|
[oas_types_1.SpecVersion.OAS3_0]: Object.assign(Object.assign({}, rawConfig.rules), rawConfig.oas3_0Rules),
|
|
38
38
|
[oas_types_1.SpecVersion.OAS3_1]: Object.assign(Object.assign({}, rawConfig.rules), rawConfig.oas3_1Rules),
|
|
39
39
|
[oas_types_1.SpecVersion.Async2]: Object.assign(Object.assign({}, rawConfig.rules), rawConfig.async2Rules),
|
|
40
|
+
[oas_types_1.SpecVersion.Arazzo]: Object.assign({}, rawConfig.arazzoRules),
|
|
40
41
|
};
|
|
41
42
|
this.preprocessors = {
|
|
42
43
|
[oas_types_1.SpecVersion.OAS2]: Object.assign(Object.assign({}, rawConfig.preprocessors), rawConfig.oas2Preprocessors),
|
|
43
44
|
[oas_types_1.SpecVersion.OAS3_0]: Object.assign(Object.assign({}, rawConfig.preprocessors), rawConfig.oas3_0Preprocessors),
|
|
44
45
|
[oas_types_1.SpecVersion.OAS3_1]: Object.assign(Object.assign({}, rawConfig.preprocessors), rawConfig.oas3_1Preprocessors),
|
|
45
46
|
[oas_types_1.SpecVersion.Async2]: Object.assign(Object.assign({}, rawConfig.preprocessors), rawConfig.async2Preprocessors),
|
|
47
|
+
[oas_types_1.SpecVersion.Arazzo]: Object.assign({}, rawConfig.arazzoPreprocessors),
|
|
46
48
|
};
|
|
47
49
|
this.decorators = {
|
|
48
50
|
[oas_types_1.SpecVersion.OAS2]: Object.assign(Object.assign({}, rawConfig.decorators), rawConfig.oas2Decorators),
|
|
49
51
|
[oas_types_1.SpecVersion.OAS3_0]: Object.assign(Object.assign({}, rawConfig.decorators), rawConfig.oas3_0Decorators),
|
|
50
52
|
[oas_types_1.SpecVersion.OAS3_1]: Object.assign(Object.assign({}, rawConfig.decorators), rawConfig.oas3_1Decorators),
|
|
51
53
|
[oas_types_1.SpecVersion.Async2]: Object.assign(Object.assign({}, rawConfig.decorators), rawConfig.async2Decorators),
|
|
54
|
+
[oas_types_1.SpecVersion.Arazzo]: Object.assign({}, rawConfig.arazzoDecorators),
|
|
52
55
|
};
|
|
53
56
|
this.extendPaths = rawConfig.extendPaths || [];
|
|
54
57
|
this.pluginPaths = rawConfig.pluginPaths || [];
|
|
@@ -125,6 +128,11 @@ class StyleguideConfig {
|
|
|
125
128
|
continue;
|
|
126
129
|
extendedTypes = plugin.typeExtension.async2(extendedTypes, version);
|
|
127
130
|
break;
|
|
131
|
+
case oas_types_1.SpecVersion.Arazzo:
|
|
132
|
+
if (!plugin.typeExtension.arazzo)
|
|
133
|
+
continue;
|
|
134
|
+
extendedTypes = plugin.typeExtension.arazzo(extendedTypes, version);
|
|
135
|
+
break;
|
|
128
136
|
default:
|
|
129
137
|
throw new Error('Not implemented');
|
|
130
138
|
}
|
|
@@ -209,6 +217,13 @@ class StyleguideConfig {
|
|
|
209
217
|
this.plugins.forEach((p) => { var _a; return ((_a = p.rules) === null || _a === void 0 ? void 0 : _a.async2) && asyncApiRules.push(p.rules.async2); });
|
|
210
218
|
this.plugins.forEach((p) => { var _a; return ((_a = p.decorators) === null || _a === void 0 ? void 0 : _a.async2) && asyncApiRules.push(p.decorators.async2); });
|
|
211
219
|
return asyncApiRules;
|
|
220
|
+
case oas_types_1.SpecMajorVersion.Arazzo:
|
|
221
|
+
// eslint-disable-next-line no-case-declarations
|
|
222
|
+
const arazzoRules = []; // default ruleset
|
|
223
|
+
this.plugins.forEach((p) => { var _a; return ((_a = p.preprocessors) === null || _a === void 0 ? void 0 : _a.arazzo) && arazzoRules.push(p.preprocessors.arazzo); });
|
|
224
|
+
this.plugins.forEach((p) => { var _a; return ((_a = p.rules) === null || _a === void 0 ? void 0 : _a.arazzo) && arazzoRules.push(p.rules.arazzo); });
|
|
225
|
+
this.plugins.forEach((p) => { var _a; return ((_a = p.decorators) === null || _a === void 0 ? void 0 : _a.arazzo) && arazzoRules.push(p.decorators.arazzo); });
|
|
226
|
+
return arazzoRules;
|
|
212
227
|
}
|
|
213
228
|
}
|
|
214
229
|
skipRules(rules) {
|
package/lib/config/minimal.js
CHANGED
|
@@ -88,8 +88,16 @@ const minimal = {
|
|
|
88
88
|
'array-parameter-serialization': 'off',
|
|
89
89
|
},
|
|
90
90
|
async2Rules: {
|
|
91
|
+
spec: 'error',
|
|
92
|
+
'info-contact': 'off',
|
|
93
|
+
'operation-operationId': 'warn',
|
|
94
|
+
'tag-description': 'warn',
|
|
95
|
+
'tags-alphabetical': 'off',
|
|
91
96
|
'channels-kebab-case': 'off',
|
|
92
97
|
'no-channel-trailing-slash': 'off',
|
|
93
98
|
},
|
|
99
|
+
arazzoRules: {
|
|
100
|
+
spec: 'error',
|
|
101
|
+
},
|
|
94
102
|
};
|
|
95
103
|
exports.default = minimal;
|
|
@@ -88,8 +88,16 @@ const recommendedStrict = {
|
|
|
88
88
|
'array-parameter-serialization': 'off',
|
|
89
89
|
},
|
|
90
90
|
async2Rules: {
|
|
91
|
+
spec: 'error',
|
|
92
|
+
'info-contact': 'off',
|
|
93
|
+
'operation-operationId': 'error',
|
|
94
|
+
'tag-description': 'error',
|
|
95
|
+
'tags-alphabetical': 'off',
|
|
91
96
|
'channels-kebab-case': 'off',
|
|
92
97
|
'no-channel-trailing-slash': 'off',
|
|
93
98
|
},
|
|
99
|
+
arazzoRules: {
|
|
100
|
+
spec: 'error',
|
|
101
|
+
},
|
|
94
102
|
};
|
|
95
103
|
exports.default = recommendedStrict;
|
|
@@ -88,8 +88,16 @@ const recommended = {
|
|
|
88
88
|
'array-parameter-serialization': 'off',
|
|
89
89
|
},
|
|
90
90
|
async2Rules: {
|
|
91
|
+
spec: 'error',
|
|
92
|
+
'info-contact': 'off',
|
|
93
|
+
'operation-operationId': 'warn',
|
|
94
|
+
'tag-description': 'warn',
|
|
95
|
+
'tags-alphabetical': 'off',
|
|
91
96
|
'channels-kebab-case': 'off',
|
|
92
97
|
'no-channel-trailing-slash': 'off',
|
|
93
98
|
},
|
|
99
|
+
arazzoRules: {
|
|
100
|
+
spec: 'error',
|
|
101
|
+
},
|
|
94
102
|
};
|
|
95
103
|
exports.default = recommended;
|
package/lib/config/types.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { ProblemSeverity, UserContext } from '../walk';
|
|
2
|
-
import type { Oas3PreprocessorsSet, SpecMajorVersion, Oas3DecoratorsSet, Oas2RuleSet, Oas2PreprocessorsSet, Oas2DecoratorsSet, Oas3RuleSet, SpecVersion, Async2PreprocessorsSet, Async2DecoratorsSet, Async2RuleSet, RuleMap } from '../oas-types';
|
|
2
|
+
import type { Oas3PreprocessorsSet, SpecMajorVersion, Oas3DecoratorsSet, Oas2RuleSet, Oas2PreprocessorsSet, Oas2DecoratorsSet, Oas3RuleSet, SpecVersion, Async2PreprocessorsSet, Async2DecoratorsSet, Async2RuleSet, ArazzoRuleSet, ArazzoPreprocessorsSet, ArazzoDecoratorsSet, RuleMap } from '../oas-types';
|
|
3
3
|
import type { NodeType } from '../types';
|
|
4
4
|
import { Location } from '../ref-utils';
|
|
5
5
|
import type { SkipFunctionContext } from '../visitors';
|
|
6
|
-
import { BuiltInAsync2RuleId, BuiltInCommonOASRuleId,
|
|
6
|
+
import { BuiltInAsync2RuleId, BuiltInCommonOASRuleId, BuiltInOAS2RuleId, BuiltInOAS3RuleId, BuiltInArazzoRuleId } from '../types/redocly-yaml';
|
|
7
7
|
export type RuleSeverity = ProblemSeverity | 'off';
|
|
8
8
|
export type RuleSettings = {
|
|
9
9
|
severity: RuleSeverity;
|
|
@@ -21,21 +21,24 @@ export type StyleguideRawConfig<T = undefined> = {
|
|
|
21
21
|
extends?: string[];
|
|
22
22
|
doNotResolveExamples?: boolean;
|
|
23
23
|
recommendedFallback?: boolean;
|
|
24
|
-
rules?: RuleMap<
|
|
24
|
+
rules?: RuleMap<BuiltInCommonOASRuleId, RuleConfig, T>;
|
|
25
25
|
oas2Rules?: RuleMap<BuiltInOAS2RuleId, RuleConfig, T>;
|
|
26
26
|
oas3_0Rules?: RuleMap<BuiltInOAS3RuleId, RuleConfig, T>;
|
|
27
27
|
oas3_1Rules?: RuleMap<BuiltInOAS3RuleId, RuleConfig, T>;
|
|
28
28
|
async2Rules?: RuleMap<BuiltInAsync2RuleId, RuleConfig, T>;
|
|
29
|
+
arazzoRules?: RuleMap<BuiltInArazzoRuleId, RuleConfig, T>;
|
|
29
30
|
preprocessors?: Record<string, PreprocessorConfig>;
|
|
30
31
|
oas2Preprocessors?: Record<string, PreprocessorConfig>;
|
|
31
32
|
oas3_0Preprocessors?: Record<string, PreprocessorConfig>;
|
|
32
33
|
oas3_1Preprocessors?: Record<string, PreprocessorConfig>;
|
|
33
34
|
async2Preprocessors?: Record<string, PreprocessorConfig>;
|
|
35
|
+
arazzoPreprocessors?: Record<string, PreprocessorConfig>;
|
|
34
36
|
decorators?: Record<string, DecoratorConfig>;
|
|
35
37
|
oas2Decorators?: Record<string, DecoratorConfig>;
|
|
36
38
|
oas3_0Decorators?: Record<string, DecoratorConfig>;
|
|
37
39
|
oas3_1Decorators?: Record<string, DecoratorConfig>;
|
|
38
40
|
async2Decorators?: Record<string, DecoratorConfig>;
|
|
41
|
+
arazzoDecorators?: Record<string, DecoratorConfig>;
|
|
39
42
|
};
|
|
40
43
|
export type ApiStyleguideRawConfig = Omit<StyleguideRawConfig, 'plugins'>;
|
|
41
44
|
export type ResolvedStyleguideConfig = PluginStyleguideConfig & {
|
|
@@ -49,11 +52,13 @@ export type PreprocessorsConfig = {
|
|
|
49
52
|
oas3?: Oas3PreprocessorsSet;
|
|
50
53
|
oas2?: Oas2PreprocessorsSet;
|
|
51
54
|
async2?: Async2PreprocessorsSet;
|
|
55
|
+
arazzo?: ArazzoPreprocessorsSet;
|
|
52
56
|
};
|
|
53
57
|
export type DecoratorsConfig = {
|
|
54
58
|
oas3?: Oas3DecoratorsSet;
|
|
55
59
|
oas2?: Oas2DecoratorsSet;
|
|
56
60
|
async2?: Async2DecoratorsSet;
|
|
61
|
+
arazzo?: ArazzoDecoratorsSet;
|
|
57
62
|
};
|
|
58
63
|
export type TypesExtensionFn = (types: Record<string, NodeType>, oasVersion: SpecVersion) => Record<string, NodeType>;
|
|
59
64
|
export type TypeExtensionsConfig = Partial<Record<SpecMajorVersion, TypesExtensionFn>>;
|
|
@@ -61,6 +66,7 @@ export type CustomRulesConfig = {
|
|
|
61
66
|
oas3?: Oas3RuleSet;
|
|
62
67
|
oas2?: Oas2RuleSet;
|
|
63
68
|
async2?: Async2RuleSet;
|
|
69
|
+
arazzo?: ArazzoRuleSet;
|
|
64
70
|
};
|
|
65
71
|
export type AssertionContext = Partial<UserContext> & SkipFunctionContext & {
|
|
66
72
|
node: any;
|
|
@@ -156,5 +162,5 @@ export type ThemeRawConfig = {
|
|
|
156
162
|
openapi?: Record<string, any>;
|
|
157
163
|
mockServer?: Record<string, any>;
|
|
158
164
|
};
|
|
159
|
-
export type RulesFields = 'rules' | 'oas2Rules' | 'oas3_0Rules' | 'oas3_1Rules' | 'async2Rules' | 'preprocessors' | 'oas2Preprocessors' | 'oas3_0Preprocessors' | 'oas3_1Preprocessors' | 'async2Preprocessors' | 'decorators' | 'oas2Decorators' | 'oas3_0Decorators' | 'oas3_1Decorators' | 'async2Decorators';
|
|
165
|
+
export type RulesFields = 'rules' | 'oas2Rules' | 'oas3_0Rules' | 'oas3_1Rules' | 'async2Rules' | 'arazzoRules' | 'preprocessors' | 'oas2Preprocessors' | 'oas3_0Preprocessors' | 'oas3_1Preprocessors' | 'async2Preprocessors' | 'arazzoPreprocessors' | 'decorators' | 'oas2Decorators' | 'oas3_0Decorators' | 'oas3_1Decorators' | 'arazzoDecorators' | 'async2Decorators';
|
|
160
166
|
export {};
|
package/lib/config/utils.js
CHANGED
|
@@ -37,7 +37,7 @@ function transformApiDefinitionsToApis(apiDefinitions) {
|
|
|
37
37
|
exports.transformApiDefinitionsToApis = transformApiDefinitionsToApis;
|
|
38
38
|
function extractFlatConfig(_a) {
|
|
39
39
|
var _b;
|
|
40
|
-
var { plugins, extends: _extends, rules, oas2Rules, oas3_0Rules, oas3_1Rules, async2Rules, preprocessors, oas2Preprocessors, oas3_0Preprocessors, oas3_1Preprocessors, async2Preprocessors, decorators, oas2Decorators, oas3_0Decorators, oas3_1Decorators, async2Decorators } = _a, rawConfigRest = __rest(_a, ["plugins", "extends", "rules", "oas2Rules", "oas3_0Rules", "oas3_1Rules", "async2Rules", "preprocessors", "oas2Preprocessors", "oas3_0Preprocessors", "oas3_1Preprocessors", "async2Preprocessors", "decorators", "oas2Decorators", "oas3_0Decorators", "oas3_1Decorators", "async2Decorators"]);
|
|
40
|
+
var { plugins, extends: _extends, rules, oas2Rules, oas3_0Rules, oas3_1Rules, async2Rules, arazzoRules, preprocessors, oas2Preprocessors, oas3_0Preprocessors, oas3_1Preprocessors, async2Preprocessors, arazzoPreprocessors, decorators, oas2Decorators, oas3_0Decorators, oas3_1Decorators, async2Decorators, arazzoDecorators } = _a, rawConfigRest = __rest(_a, ["plugins", "extends", "rules", "oas2Rules", "oas3_0Rules", "oas3_1Rules", "async2Rules", "arazzoRules", "preprocessors", "oas2Preprocessors", "oas3_0Preprocessors", "oas3_1Preprocessors", "async2Preprocessors", "arazzoPreprocessors", "decorators", "oas2Decorators", "oas3_0Decorators", "oas3_1Decorators", "async2Decorators", "arazzoDecorators"]);
|
|
41
41
|
const styleguideConfig = {
|
|
42
42
|
plugins,
|
|
43
43
|
extends: _extends,
|
|
@@ -46,16 +46,19 @@ function extractFlatConfig(_a) {
|
|
|
46
46
|
oas3_0Rules,
|
|
47
47
|
oas3_1Rules,
|
|
48
48
|
async2Rules,
|
|
49
|
+
arazzoRules,
|
|
49
50
|
preprocessors,
|
|
50
51
|
oas2Preprocessors,
|
|
51
52
|
oas3_0Preprocessors,
|
|
52
53
|
oas3_1Preprocessors,
|
|
53
54
|
async2Preprocessors,
|
|
55
|
+
arazzoPreprocessors,
|
|
54
56
|
decorators,
|
|
55
57
|
oas2Decorators,
|
|
56
58
|
oas3_0Decorators,
|
|
57
59
|
oas3_1Decorators,
|
|
58
60
|
async2Decorators,
|
|
61
|
+
arazzoDecorators,
|
|
59
62
|
doNotResolveExamples: (_b = rawConfigRest.resolve) === null || _b === void 0 ? void 0 : _b.doNotResolveExamples,
|
|
60
63
|
};
|
|
61
64
|
if ((rawConfigRest.lint && rawConfigRest.styleguide) ||
|
|
@@ -98,16 +101,19 @@ function mergeExtends(rulesConfList) {
|
|
|
98
101
|
oas3_0Rules: {},
|
|
99
102
|
oas3_1Rules: {},
|
|
100
103
|
async2Rules: {},
|
|
104
|
+
arazzoRules: {},
|
|
101
105
|
preprocessors: {},
|
|
102
106
|
oas2Preprocessors: {},
|
|
103
107
|
oas3_0Preprocessors: {},
|
|
104
108
|
oas3_1Preprocessors: {},
|
|
105
109
|
async2Preprocessors: {},
|
|
110
|
+
arazzoPreprocessors: {},
|
|
106
111
|
decorators: {},
|
|
107
112
|
oas2Decorators: {},
|
|
108
113
|
oas3_0Decorators: {},
|
|
109
114
|
oas3_1Decorators: {},
|
|
110
115
|
async2Decorators: {},
|
|
116
|
+
arazzoDecorators: {},
|
|
111
117
|
plugins: [],
|
|
112
118
|
pluginPaths: [],
|
|
113
119
|
extendPaths: [],
|
|
@@ -125,6 +131,8 @@ function mergeExtends(rulesConfList) {
|
|
|
125
131
|
(0, utils_1.assignExisting)(result.oas3_1Rules, rulesConf.rules || {});
|
|
126
132
|
Object.assign(result.async2Rules, rulesConf.async2Rules);
|
|
127
133
|
(0, utils_1.assignExisting)(result.async2Rules, rulesConf.rules || {});
|
|
134
|
+
Object.assign(result.arazzoRules, rulesConf.arazzoRules);
|
|
135
|
+
(0, utils_1.assignExisting)(result.arazzoRules, rulesConf.rules || {});
|
|
128
136
|
Object.assign(result.preprocessors, rulesConf.preprocessors);
|
|
129
137
|
Object.assign(result.oas2Preprocessors, rulesConf.oas2Preprocessors);
|
|
130
138
|
(0, utils_1.assignExisting)(result.oas2Preprocessors, rulesConf.preprocessors || {});
|
|
@@ -134,6 +142,8 @@ function mergeExtends(rulesConfList) {
|
|
|
134
142
|
(0, utils_1.assignExisting)(result.oas3_1Preprocessors, rulesConf.preprocessors || {});
|
|
135
143
|
Object.assign(result.async2Preprocessors, rulesConf.async2Preprocessors);
|
|
136
144
|
(0, utils_1.assignExisting)(result.async2Preprocessors, rulesConf.preprocessors || {});
|
|
145
|
+
Object.assign(result.arazzoPreprocessors, rulesConf.arazzoPreprocessors);
|
|
146
|
+
(0, utils_1.assignExisting)(result.arazzoPreprocessors, rulesConf.preprocessors || {});
|
|
137
147
|
Object.assign(result.decorators, rulesConf.decorators);
|
|
138
148
|
Object.assign(result.oas2Decorators, rulesConf.oas2Decorators);
|
|
139
149
|
(0, utils_1.assignExisting)(result.oas2Decorators, rulesConf.decorators || {});
|
|
@@ -143,6 +153,8 @@ function mergeExtends(rulesConfList) {
|
|
|
143
153
|
(0, utils_1.assignExisting)(result.oas3_1Decorators, rulesConf.decorators || {});
|
|
144
154
|
Object.assign(result.async2Decorators, rulesConf.async2Decorators);
|
|
145
155
|
(0, utils_1.assignExisting)(result.async2Decorators, rulesConf.decorators || {});
|
|
156
|
+
Object.assign(result.arazzoDecorators, rulesConf.arazzoDecorators);
|
|
157
|
+
(0, utils_1.assignExisting)(result.arazzoDecorators, rulesConf.decorators || {});
|
|
146
158
|
result.plugins.push(...(rulesConf.plugins || []));
|
|
147
159
|
result.pluginPaths.push(...(rulesConf.pluginPaths || []));
|
|
148
160
|
result.extendPaths.push(...new Set(rulesConf.extendPaths));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const decorators: {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const decorators: {};
|
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { BundleOutputFormat, readFileFromUrl, slash, doesYamlFileExist, isTruthy, getProxyAgent, pause, } from './utils';
|
|
2
2
|
export { Oas3_1Types } from './types/oas3_1';
|
|
3
|
+
export { ArazzoTypes } from './types/arazzo';
|
|
3
4
|
export { Oas3Types } from './types/oas3';
|
|
4
5
|
export { Oas2Types } from './types/oas2';
|
|
5
6
|
export { AsyncApi2Types } from './types/asyncapi';
|
package/lib/index.js
CHANGED
|
@@ -14,8 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.
|
|
18
|
-
exports.bundleFromString = exports.mapTypeToComponent = exports.bundleDocument = exports.bundle = exports.lintConfig = void 0;
|
|
17
|
+
exports.lintDocument = exports.validate = exports.lint = exports.getTotals = exports.formatProblems = exports.getLineColLocation = exports.getAstNodeByPointer = exports.walkDocument = exports.normalizeVisitors = exports.getTypes = exports.detectSpec = exports.SpecVersion = exports.getMajorSpecVersion = exports.SpecMajorVersion = exports.isAbsoluteUrl = exports.isRef = exports.unescapePointer = exports.stringifyYaml = exports.parseYaml = exports.makeDocumentFromString = exports.YamlParseError = exports.ResolveError = exports.resolveDocument = exports.BaseResolver = exports.Source = exports.RedoclyClient = exports.createConfig = exports.CONFIG_FILE_NAMES = exports.findConfig = exports.getConfig = exports.loadConfig = exports.transformConfig = exports.getMergedConfig = exports.IGNORE_FILE = exports.StyleguideConfig = exports.Config = exports.Stats = exports.normalizeTypes = exports.ConfigTypes = exports.AsyncApi2Types = exports.Oas2Types = exports.Oas3Types = exports.ArazzoTypes = exports.Oas3_1Types = exports.pause = exports.getProxyAgent = exports.isTruthy = exports.doesYamlFileExist = exports.slash = exports.readFileFromUrl = void 0;
|
|
18
|
+
exports.bundleFromString = exports.mapTypeToComponent = exports.bundleDocument = exports.bundle = exports.lintConfig = exports.lintFromString = void 0;
|
|
19
19
|
var utils_1 = require("./utils");
|
|
20
20
|
Object.defineProperty(exports, "readFileFromUrl", { enumerable: true, get: function () { return utils_1.readFileFromUrl; } });
|
|
21
21
|
Object.defineProperty(exports, "slash", { enumerable: true, get: function () { return utils_1.slash; } });
|
|
@@ -25,6 +25,8 @@ Object.defineProperty(exports, "getProxyAgent", { enumerable: true, get: functio
|
|
|
25
25
|
Object.defineProperty(exports, "pause", { enumerable: true, get: function () { return utils_1.pause; } });
|
|
26
26
|
var oas3_1_1 = require("./types/oas3_1");
|
|
27
27
|
Object.defineProperty(exports, "Oas3_1Types", { enumerable: true, get: function () { return oas3_1_1.Oas3_1Types; } });
|
|
28
|
+
var arazzo_1 = require("./types/arazzo");
|
|
29
|
+
Object.defineProperty(exports, "ArazzoTypes", { enumerable: true, get: function () { return arazzo_1.ArazzoTypes; } });
|
|
28
30
|
var oas3_1 = require("./types/oas3");
|
|
29
31
|
Object.defineProperty(exports, "Oas3Types", { enumerable: true, get: function () { return oas3_1.Oas3Types; } });
|
|
30
32
|
var oas2_1 = require("./types/oas2");
|
package/lib/oas-types.d.ts
CHANGED
|
@@ -1,27 +1,32 @@
|
|
|
1
|
-
import { Oas3Rule, Oas3Preprocessor, Oas2Rule, Oas2Preprocessor, Async2Preprocessor, Async2Rule } from './visitors';
|
|
2
|
-
import { BuiltInAsync2RuleId, BuiltInCommonOASRuleId,
|
|
1
|
+
import { Oas3Rule, Oas3Preprocessor, Oas2Rule, Oas2Preprocessor, Async2Preprocessor, Async2Rule, ArazzoPreprocessor, ArazzoRule } from './visitors';
|
|
2
|
+
import { BuiltInAsync2RuleId, BuiltInCommonOASRuleId, BuiltInArazzoRuleId, BuiltInOAS2RuleId, BuiltInOAS3RuleId } from './types/redocly-yaml';
|
|
3
3
|
export type RuleSet<T> = Record<string, T>;
|
|
4
4
|
export declare enum SpecVersion {
|
|
5
5
|
OAS2 = "oas2",
|
|
6
6
|
OAS3_0 = "oas3_0",
|
|
7
7
|
OAS3_1 = "oas3_1",
|
|
8
|
-
Async2 = "async2"
|
|
8
|
+
Async2 = "async2",
|
|
9
|
+
Arazzo = "arazzo"
|
|
9
10
|
}
|
|
10
11
|
export declare enum SpecMajorVersion {
|
|
11
12
|
OAS2 = "oas2",
|
|
12
13
|
OAS3 = "oas3",
|
|
13
|
-
Async2 = "async2"
|
|
14
|
+
Async2 = "async2",
|
|
15
|
+
Arazzo = "arazzo"
|
|
14
16
|
}
|
|
15
17
|
export type RuleMap<Key extends string, RuleConfig, T> = Record<T extends 'built-in' ? Key : string, RuleConfig>;
|
|
16
|
-
export type Oas3RuleSet<T = undefined> = RuleMap<
|
|
17
|
-
export type Oas2RuleSet<T = undefined> = RuleMap<
|
|
18
|
-
export type Async2RuleSet<T = undefined> = RuleMap<
|
|
18
|
+
export type Oas3RuleSet<T = undefined> = RuleMap<BuiltInCommonOASRuleId | BuiltInOAS3RuleId | 'assertions', Oas3Rule, T>;
|
|
19
|
+
export type Oas2RuleSet<T = undefined> = RuleMap<BuiltInCommonOASRuleId | BuiltInOAS2RuleId | 'assertions', Oas2Rule, T>;
|
|
20
|
+
export type Async2RuleSet<T = undefined> = RuleMap<BuiltInAsync2RuleId | 'assertions', Async2Rule, T>;
|
|
21
|
+
export type ArazzoRuleSet<T = undefined> = RuleMap<BuiltInArazzoRuleId | 'assertions', ArazzoRule, T>;
|
|
19
22
|
export type Oas3PreprocessorsSet = Record<string, Oas3Preprocessor>;
|
|
20
23
|
export type Oas2PreprocessorsSet = Record<string, Oas2Preprocessor>;
|
|
21
24
|
export type Async2PreprocessorsSet = Record<string, Async2Preprocessor>;
|
|
25
|
+
export type ArazzoPreprocessorsSet = Record<string, ArazzoPreprocessor>;
|
|
22
26
|
export type Oas3DecoratorsSet = Record<string, Oas3Preprocessor>;
|
|
23
27
|
export type Oas2DecoratorsSet = Record<string, Oas2Preprocessor>;
|
|
24
28
|
export type Async2DecoratorsSet = Record<string, Async2Preprocessor>;
|
|
29
|
+
export type ArazzoDecoratorsSet = Record<string, ArazzoPreprocessor>;
|
|
25
30
|
export declare function detectSpec(root: any): SpecVersion;
|
|
26
31
|
export declare function getMajorSpecVersion(version: SpecVersion): SpecMajorVersion;
|
|
27
32
|
export declare function getTypes(spec: SpecVersion): Record<string, import("./types").NodeType> | Record<"Root" | "Tag" | "ExternalDocs" | "SecurityRequirement" | "Info" | "Contact" | "License" | "Paths" | "PathItem" | "Parameter" | "Operation" | "Example" | "Header" | "Responses" | "Response" | "Schema" | "Xml" | "SchemaProperties" | "NamedSchemas" | "NamedResponses" | "NamedParameters" | "NamedSecuritySchemes" | "SecurityScheme" | "Examples" | "ExamplesMap" | "TagList" | "SecurityRequirementList" | "ParameterList" | "ParameterItems" | "TagGroup" | "TagGroups" | "EnumDescriptions" | "Logo" | "XCodeSample" | "XCodeSampleList" | "XServer" | "XServerList", import("./types").NodeType> | Record<"Root" | "Tag" | "ExternalDocs" | "Server" | "ServerVariable" | "SecurityRequirement" | "Info" | "Contact" | "License" | "Paths" | "PathItem" | "Callback" | "CallbacksMap" | "Parameter" | "Operation" | "RequestBody" | "MediaTypesMap" | "MediaType" | "Example" | "Encoding" | "Header" | "Responses" | "Response" | "Link" | "Schema" | "Xml" | "SchemaProperties" | "DiscriminatorMapping" | "Discriminator" | "Components" | "NamedSchemas" | "NamedResponses" | "NamedParameters" | "NamedExamples" | "NamedRequestBodies" | "NamedHeaders" | "NamedSecuritySchemes" | "NamedLinks" | "NamedCallbacks" | "ImplicitFlow" | "PasswordFlow" | "ClientCredentials" | "AuthorizationCode" | "OAuth2Flows" | "SecurityScheme" | "ServerVariablesMap" | "ExamplesMap" | "EncodingMap" | "HeadersMap" | "LinksMap" | "WebhooksMap" | "TagList" | "SecurityRequirementList" | "ParameterList" | "TagGroup" | "TagGroups" | "EnumDescriptions" | "Logo" | "XCodeSample" | "XCodeSampleList" | "ServerList" | "XUsePkce", import("./types").NodeType> | Record<"Root" | "Info" | "License" | "Operation" | "Schema" | "SchemaProperties" | "Components" | "SecurityScheme" | "NamedPathItems" | "DependentRequired", import("./types").NodeType>;
|
package/lib/oas-types.js
CHANGED
|
@@ -5,24 +5,28 @@ const oas2_1 = require("./types/oas2");
|
|
|
5
5
|
const oas3_1 = require("./types/oas3");
|
|
6
6
|
const oas3_1_1 = require("./types/oas3_1");
|
|
7
7
|
const asyncapi_1 = require("./types/asyncapi");
|
|
8
|
+
const arazzo_1 = require("./types/arazzo");
|
|
8
9
|
var SpecVersion;
|
|
9
10
|
(function (SpecVersion) {
|
|
10
11
|
SpecVersion["OAS2"] = "oas2";
|
|
11
12
|
SpecVersion["OAS3_0"] = "oas3_0";
|
|
12
13
|
SpecVersion["OAS3_1"] = "oas3_1";
|
|
13
14
|
SpecVersion["Async2"] = "async2";
|
|
15
|
+
SpecVersion["Arazzo"] = "arazzo";
|
|
14
16
|
})(SpecVersion || (exports.SpecVersion = SpecVersion = {}));
|
|
15
17
|
var SpecMajorVersion;
|
|
16
18
|
(function (SpecMajorVersion) {
|
|
17
19
|
SpecMajorVersion["OAS2"] = "oas2";
|
|
18
20
|
SpecMajorVersion["OAS3"] = "oas3";
|
|
19
21
|
SpecMajorVersion["Async2"] = "async2";
|
|
22
|
+
SpecMajorVersion["Arazzo"] = "arazzo";
|
|
20
23
|
})(SpecMajorVersion || (exports.SpecMajorVersion = SpecMajorVersion = {}));
|
|
21
24
|
const typesMap = {
|
|
22
25
|
[SpecVersion.OAS2]: oas2_1.Oas2Types,
|
|
23
26
|
[SpecVersion.OAS3_0]: oas3_1.Oas3Types,
|
|
24
27
|
[SpecVersion.OAS3_1]: oas3_1_1.Oas3_1Types,
|
|
25
28
|
[SpecVersion.Async2]: asyncapi_1.AsyncApi2Types,
|
|
29
|
+
[SpecVersion.Arazzo]: arazzo_1.ArazzoTypes,
|
|
26
30
|
};
|
|
27
31
|
function detectSpec(root) {
|
|
28
32
|
if (typeof root !== 'object') {
|
|
@@ -50,6 +54,9 @@ function detectSpec(root) {
|
|
|
50
54
|
if (root.asyncapi) {
|
|
51
55
|
throw new Error(`Unsupported AsyncAPI version: ${root.asyncapi}`);
|
|
52
56
|
}
|
|
57
|
+
if (root.arazzo && root.arazzo.startsWith('1.')) {
|
|
58
|
+
return SpecVersion.Arazzo;
|
|
59
|
+
}
|
|
53
60
|
throw new Error(`Unsupported specification`);
|
|
54
61
|
}
|
|
55
62
|
exports.detectSpec = detectSpec;
|
|
@@ -60,6 +67,9 @@ function getMajorSpecVersion(version) {
|
|
|
60
67
|
else if (version === SpecVersion.Async2) {
|
|
61
68
|
return SpecMajorVersion.Async2;
|
|
62
69
|
}
|
|
70
|
+
else if (version === SpecVersion.Arazzo) {
|
|
71
|
+
return SpecMajorVersion.Arazzo;
|
|
72
|
+
}
|
|
63
73
|
else {
|
|
64
74
|
return SpecMajorVersion.OAS3;
|
|
65
75
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.preprocessors = exports.rules = void 0;
|
|
4
|
+
const spec_1 = require("../common/spec");
|
|
5
|
+
const assertions_1 = require("../common/assertions");
|
|
6
|
+
exports.rules = {
|
|
7
|
+
spec: spec_1.Spec,
|
|
8
|
+
assertions: assertions_1.Assertions,
|
|
9
|
+
};
|
|
10
|
+
exports.preprocessors = {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { Oas3Rule, Oas2Rule, Async2Rule } from '../../visitors';
|
|
2
|
-
export declare const Spec: Oas3Rule | Oas2Rule | Async2Rule;
|
|
1
|
+
import type { Oas3Rule, Oas2Rule, Async2Rule, ArazzoRule } from '../../visitors';
|
|
2
|
+
export declare const Spec: Oas3Rule | Oas2Rule | Async2Rule | ArazzoRule;
|