@redocly/openapi-core 1.17.1 → 1.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/lib/bundle.d.ts +1 -1
- package/lib/bundle.js +16 -2
- package/lib/config/all.js +6 -0
- package/lib/config/builtIn.js +10 -2
- package/lib/config/config-resolvers.js +15 -4
- package/lib/config/config.d.ts +2 -2
- package/lib/config/config.js +15 -0
- package/lib/config/load.d.ts +1 -2
- package/lib/config/minimal.js +8 -0
- package/lib/config/recommended-strict.js +8 -0
- package/lib/config/recommended.js +8 -0
- package/lib/config/types.d.ts +10 -4
- package/lib/config/utils.js +13 -1
- package/lib/decorators/arazzo/index.d.ts +1 -0
- package/lib/decorators/arazzo/index.js +4 -0
- package/lib/decorators/async2/index.d.ts +1 -0
- package/lib/decorators/async2/index.js +4 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +4 -2
- package/lib/oas-types.d.ts +13 -8
- package/lib/oas-types.js +10 -0
- package/lib/rules/arazzo/index.d.ts +3 -0
- package/lib/rules/arazzo/index.js +10 -0
- package/lib/rules/common/path-segment-plural.js +2 -1
- package/lib/rules/common/spec.d.ts +2 -2
- package/lib/types/arazzo.d.ts +2276 -0
- package/lib/types/arazzo.js +386 -0
- package/lib/types/asyncapi.js +17 -43
- package/lib/types/oas3.js +0 -8
- package/lib/types/oas3_1.js +2 -2
- package/lib/types/redocly-yaml.d.ts +4 -4
- package/lib/types/redocly-yaml.js +15 -5
- package/lib/typings/arazzo.d.ts +30 -0
- package/lib/typings/arazzo.js +2 -0
- package/lib/utils.d.ts +8 -4
- package/lib/utils.js +38 -7
- package/lib/visitors.d.ts +11 -0
- package/package.json +3 -2
- package/src/__tests__/lint.test.ts +0 -50
- package/src/bundle.ts +15 -3
- package/src/config/__tests__/__snapshots__/config-resolvers.test.ts.snap +20 -0
- package/src/config/__tests__/__snapshots__/config.test.ts.snap +3 -0
- package/src/config/__tests__/config.test.ts +6 -0
- package/src/config/all.ts +6 -0
- package/src/config/builtIn.ts +10 -2
- package/src/config/config-resolvers.ts +17 -3
- package/src/config/config.ts +17 -0
- package/src/config/load.ts +1 -2
- package/src/config/minimal.ts +8 -0
- package/src/config/recommended-strict.ts +8 -0
- package/src/config/recommended.ts +8 -0
- package/src/config/types.ts +15 -2
- package/src/config/utils.ts +15 -0
- package/src/decorators/arazzo/index.ts +1 -0
- package/src/decorators/async2/index.ts +1 -0
- package/src/index.ts +1 -0
- package/src/oas-types.ts +25 -4
- package/src/rules/arazzo/index.ts +11 -0
- package/src/rules/common/__tests__/spec.test.ts +47 -0
- package/src/rules/common/no-invalid-schema-examples.ts +3 -2
- package/src/rules/common/path-segment-plural.ts +3 -2
- package/src/rules/common/spec.ts +2 -2
- package/src/types/arazzo.ts +391 -0
- package/src/types/asyncapi.ts +22 -43
- package/src/types/oas3.ts +0 -7
- package/src/types/oas3_1.ts +2 -2
- package/src/types/redocly-yaml.ts +18 -8
- package/src/typings/arazzo.ts +44 -0
- package/src/utils.ts +41 -8
- package/src/visitors.ts +18 -0
- package/tsconfig.tsbuildinfo +1 -1
package/lib/utils.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { UserContext } from './walk';
|
|
2
|
-
import { HttpResolveConfig } from './config';
|
|
3
1
|
import { HttpsProxyAgent } from 'https-proxy-agent';
|
|
2
|
+
import type { HttpResolveConfig } from './config';
|
|
3
|
+
import type { UserContext } from './walk';
|
|
4
4
|
export { parseYaml, stringifyYaml } from './js-yaml';
|
|
5
5
|
export type StackFrame<T> = {
|
|
6
6
|
prev: StackFrame<T> | null;
|
|
@@ -28,7 +28,6 @@ export declare function omitObjectProps<T extends Record<string, unknown>>(objec
|
|
|
28
28
|
export declare function splitCamelCaseIntoWords(str: string): Set<string>;
|
|
29
29
|
export declare function validateMimeType({ type, value }: any, { report, location }: UserContext, allowedValues: string[]): void;
|
|
30
30
|
export declare function validateMimeTypeOAS3({ type, value }: any, { report, location }: UserContext, allowedValues: string[]): void;
|
|
31
|
-
export declare function isSingular(path: string): boolean;
|
|
32
31
|
export declare function readFileAsStringSync(filePath: string): string;
|
|
33
32
|
export declare function yamlAndJsonSyncReader<T>(filePath: string): T;
|
|
34
33
|
export declare function isPathParameter(pathSegment: string): boolean;
|
|
@@ -50,6 +49,11 @@ export declare function isTruthy<Truthy>(value: Truthy | Falsy): value is Truthy
|
|
|
50
49
|
export declare function identity<T>(value: T): T;
|
|
51
50
|
export declare function keysOf<T>(obj: T): (keyof T)[];
|
|
52
51
|
export declare function pickDefined<T extends Record<string, unknown>>(obj?: T): Record<string, unknown> | undefined;
|
|
53
|
-
export declare function nextTick():
|
|
52
|
+
export declare function nextTick(): Promise<unknown>;
|
|
54
53
|
export declare function pause(ms: number): Promise<void>;
|
|
55
54
|
export declare function getProxyAgent(): HttpsProxyAgent<string> | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* Checks if two objects are deeply equal.
|
|
57
|
+
* Borrowed the source code from https://github.com/lukeed/dequal.
|
|
58
|
+
*/
|
|
59
|
+
export declare function dequal(foo: any, bar: any): boolean;
|
package/lib/utils.js
CHANGED
|
@@ -9,12 +9,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.getProxyAgent = exports.pause = exports.nextTick = exports.pickDefined = exports.keysOf = exports.identity = exports.isTruthy = exports.showErrorForDeprecatedField = exports.showWarningForDeprecatedField = exports.doesYamlFileExist = exports.isCustomRuleId = exports.getMatchingStatusCodeRange = exports.assignExisting = exports.isNotString = exports.isString = exports.isNotEmptyObject = exports.slash = exports.isPathParameter = exports.yamlAndJsonSyncReader = exports.readFileAsStringSync = exports.
|
|
12
|
+
exports.dequal = exports.getProxyAgent = exports.pause = exports.nextTick = exports.pickDefined = exports.keysOf = exports.identity = exports.isTruthy = exports.showErrorForDeprecatedField = exports.showWarningForDeprecatedField = exports.doesYamlFileExist = exports.isCustomRuleId = exports.getMatchingStatusCodeRange = exports.assignExisting = exports.isNotString = exports.isString = exports.isNotEmptyObject = exports.slash = exports.isPathParameter = exports.yamlAndJsonSyncReader = exports.readFileAsStringSync = exports.validateMimeTypeOAS3 = exports.validateMimeType = exports.splitCamelCaseIntoWords = exports.omitObjectProps = exports.pickObjectProps = exports.readFileFromUrl = exports.isEmptyArray = exports.isEmptyObject = exports.isPlainObject = exports.isDefined = exports.loadYaml = exports.popStack = exports.pushStack = exports.stringifyYaml = exports.parseYaml = void 0;
|
|
13
13
|
const fs = require("fs");
|
|
14
14
|
const path_1 = require("path");
|
|
15
15
|
const minimatch = require("minimatch");
|
|
16
16
|
const node_fetch_1 = require("node-fetch");
|
|
17
|
-
const pluralize = require("pluralize");
|
|
18
17
|
const js_yaml_1 = require("./js-yaml");
|
|
19
18
|
const env_1 = require("./env");
|
|
20
19
|
const logger_1 = require("./logger");
|
|
@@ -132,10 +131,6 @@ function validateMimeTypeOAS3({ type, value }, { report, location }, allowedValu
|
|
|
132
131
|
}
|
|
133
132
|
}
|
|
134
133
|
exports.validateMimeTypeOAS3 = validateMimeTypeOAS3;
|
|
135
|
-
function isSingular(path) {
|
|
136
|
-
return pluralize.isSingular(path);
|
|
137
|
-
}
|
|
138
|
-
exports.isSingular = isSingular;
|
|
139
134
|
function readFileAsStringSync(filePath) {
|
|
140
135
|
return fs.readFileSync(filePath, 'utf-8');
|
|
141
136
|
}
|
|
@@ -233,7 +228,7 @@ function pickDefined(obj) {
|
|
|
233
228
|
}
|
|
234
229
|
exports.pickDefined = pickDefined;
|
|
235
230
|
function nextTick() {
|
|
236
|
-
new Promise((resolve) => {
|
|
231
|
+
return new Promise((resolve) => {
|
|
237
232
|
setTimeout(resolve);
|
|
238
233
|
});
|
|
239
234
|
}
|
|
@@ -252,3 +247,39 @@ function getProxyAgent() {
|
|
|
252
247
|
return proxy ? new https_proxy_agent_1.HttpsProxyAgent(proxy) : undefined;
|
|
253
248
|
}
|
|
254
249
|
exports.getProxyAgent = getProxyAgent;
|
|
250
|
+
/**
|
|
251
|
+
* Checks if two objects are deeply equal.
|
|
252
|
+
* Borrowed the source code from https://github.com/lukeed/dequal.
|
|
253
|
+
*/
|
|
254
|
+
function dequal(foo, bar) {
|
|
255
|
+
let ctor, len;
|
|
256
|
+
if (foo === bar)
|
|
257
|
+
return true;
|
|
258
|
+
if (foo && bar && (ctor = foo.constructor) === bar.constructor) {
|
|
259
|
+
if (ctor === Date)
|
|
260
|
+
return foo.getTime() === bar.getTime();
|
|
261
|
+
if (ctor === RegExp)
|
|
262
|
+
return foo.toString() === bar.toString();
|
|
263
|
+
if (ctor === Array) {
|
|
264
|
+
if ((len = foo.length) === bar.length) {
|
|
265
|
+
while (len-- && dequal(foo[len], bar[len]))
|
|
266
|
+
;
|
|
267
|
+
}
|
|
268
|
+
return len === -1;
|
|
269
|
+
}
|
|
270
|
+
if (!ctor || typeof foo === 'object') {
|
|
271
|
+
len = 0;
|
|
272
|
+
for (ctor in foo) {
|
|
273
|
+
if (Object.prototype.hasOwnProperty.call(foo, ctor) &&
|
|
274
|
+
++len &&
|
|
275
|
+
!Object.prototype.hasOwnProperty.call(bar, ctor))
|
|
276
|
+
return false;
|
|
277
|
+
if (!(ctor in bar) || !dequal(foo[ctor], bar[ctor]))
|
|
278
|
+
return false;
|
|
279
|
+
}
|
|
280
|
+
return Object.keys(bar).length === len;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
return foo !== foo && bar !== bar;
|
|
284
|
+
}
|
|
285
|
+
exports.dequal = dequal;
|
package/lib/visitors.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import type { Location } from './ref-utils';
|
|
|
5
5
|
import type { Oas3Definition, Oas3ExternalDocs, Oas3Info, Oas3Contact, Oas3Components, Oas3License, Oas3Schema, Oas3Header, Oas3Parameter, Oas3Operation, Oas3PathItem, Oas3ServerVariable, Oas3Server, Oas3MediaType, Oas3Response, Oas3Example, Oas3RequestBody, Oas3Tag, OasRef, Oas3SecurityScheme, Oas3SecurityRequirement, Oas3Encoding, Oas3Link, Oas3Xml, Oas3Discriminator, Oas3Callback } from './typings/openapi';
|
|
6
6
|
import type { Oas2Definition, Oas2Tag, Oas2ExternalDocs, Oas2SecurityRequirement, Oas2Info, Oas2Contact, Oas2License, Oas2PathItem, Oas2Operation, Oas2Header, Oas2Response, Oas2Schema, Oas2Xml, Oas2Parameter, Oas2SecurityScheme } from './typings/swagger';
|
|
7
7
|
import type { Async2Definition } from './typings/asyncapi';
|
|
8
|
+
import type { ArazzoDefinition } from './typings/arazzo';
|
|
8
9
|
export type SkipFunctionContext = Pick<UserContext, 'location' | 'rawNode' | 'resolve' | 'rawLocation'>;
|
|
9
10
|
export type VisitFunction<T> = (node: T, ctx: UserContext & {
|
|
10
11
|
ignoreNextVisitorsOnNode: () => void;
|
|
@@ -139,6 +140,9 @@ type Oas2FlatVisitor = {
|
|
|
139
140
|
type Async2FlatVisitor = {
|
|
140
141
|
Root?: VisitFunctionOrObject<Async2Definition>;
|
|
141
142
|
};
|
|
143
|
+
type ArazzoFlatVisitor = {
|
|
144
|
+
Root?: VisitFunctionOrObject<ArazzoDefinition>;
|
|
145
|
+
};
|
|
142
146
|
type Oas3NestedVisitor = {
|
|
143
147
|
[T in keyof Oas3FlatVisitor]: Oas3FlatVisitor[T] extends Function ? Oas3FlatVisitor[T] : Oas3FlatVisitor[T] & NestedVisitor<Oas3NestedVisitor>;
|
|
144
148
|
};
|
|
@@ -148,9 +152,13 @@ type Oas2NestedVisitor = {
|
|
|
148
152
|
type Async2NestedVisitor = {
|
|
149
153
|
[T in keyof Async2FlatVisitor]: Async2FlatVisitor[T] extends Function ? Async2FlatVisitor[T] : Async2FlatVisitor[T] & NestedVisitor<Async2NestedVisitor>;
|
|
150
154
|
};
|
|
155
|
+
type ArazzoNestedVisitor = {
|
|
156
|
+
[T in keyof ArazzoFlatVisitor]: ArazzoFlatVisitor[T] extends Function ? ArazzoFlatVisitor[T] : ArazzoFlatVisitor[T] & NestedVisitor<ArazzoNestedVisitor>;
|
|
157
|
+
};
|
|
151
158
|
export type Oas3Visitor = BaseVisitor & Oas3NestedVisitor & Record<string, VisitFunction<any> | NestedVisitObject<any, Oas3NestedVisitor>>;
|
|
152
159
|
export type Oas2Visitor = BaseVisitor & Oas2NestedVisitor & Record<string, VisitFunction<any> | NestedVisitObject<any, Oas2NestedVisitor>>;
|
|
153
160
|
export type Async2Visitor = BaseVisitor & Async2NestedVisitor & Record<string, VisitFunction<any> | NestedVisitObject<any, Async2NestedVisitor>>;
|
|
161
|
+
export type ArazzoVisitor = BaseVisitor & ArazzoNestedVisitor & Record<string, VisitFunction<any> | NestedVisitObject<any, ArazzoNestedVisitor>>;
|
|
154
162
|
export type NestedVisitor<T> = Exclude<T, 'any' | 'ref' | 'Root'>;
|
|
155
163
|
export type NormalizedOasVisitors<T extends BaseVisitor> = {
|
|
156
164
|
[V in keyof T]-?: {
|
|
@@ -170,12 +178,15 @@ export type NormalizedOasVisitors<T extends BaseVisitor> = {
|
|
|
170
178
|
export type Oas3Rule = (options: Record<string, any>) => Oas3Visitor | Oas3Visitor[];
|
|
171
179
|
export type Oas2Rule = (options: Record<string, any>) => Oas2Visitor | Oas2Visitor[];
|
|
172
180
|
export type Async2Rule = (options: Record<string, any>) => Async2Visitor | Async2Visitor[];
|
|
181
|
+
export type ArazzoRule = (options: Record<string, any>) => ArazzoVisitor | ArazzoVisitor[];
|
|
173
182
|
export type Oas3Preprocessor = (options: Record<string, any>) => Oas3Visitor;
|
|
174
183
|
export type Oas2Preprocessor = (options: Record<string, any>) => Oas2Visitor;
|
|
175
184
|
export type Async2Preprocessor = (options: Record<string, any>) => Async2Visitor;
|
|
185
|
+
export type ArazzoPreprocessor = (options: Record<string, any>) => ArazzoVisitor;
|
|
176
186
|
export type Oas3Decorator = (options: Record<string, any>) => Oas3Visitor;
|
|
177
187
|
export type Oas2Decorator = (options: Record<string, any>) => Oas2Visitor;
|
|
178
188
|
export type Async2Decorator = (options: Record<string, any>) => Async2Visitor;
|
|
189
|
+
export type ArazzoDecorator = (options: Record<string, any>) => ArazzoVisitor;
|
|
179
190
|
export type OasRule = Oas3Rule;
|
|
180
191
|
export type OasPreprocessor = Oas3Preprocessor;
|
|
181
192
|
export type OasDecorator = Oas3Decorator;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redocly/openapi-core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.18.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"engines": {
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@redocly/ajv": "^8.11.0",
|
|
39
|
-
"@redocly/config": "^0.
|
|
39
|
+
"@redocly/config": "^0.7.0",
|
|
40
40
|
"colorette": "^1.2.0",
|
|
41
41
|
"https-proxy-agent": "^7.0.4",
|
|
42
42
|
"js-levenshtein": "^1.1.6",
|
|
@@ -55,6 +55,7 @@
|
|
|
55
55
|
"@types/node": "^20.11.5",
|
|
56
56
|
"@types/node-fetch": "^2.5.7",
|
|
57
57
|
"@types/pluralize": "^0.0.29",
|
|
58
|
+
"json-schema-to-ts": "^3.1.0",
|
|
58
59
|
"typescript": "^5.2.2"
|
|
59
60
|
}
|
|
60
61
|
}
|
|
@@ -104,14 +104,6 @@ const testPortalConfig = parseYamlToDocument(
|
|
|
104
104
|
# configurationUrl: Must be reported as a missing required prop
|
|
105
105
|
clientSecret: '{{ process.env.secret }}'
|
|
106
106
|
|
|
107
|
-
basic:
|
|
108
|
-
type: BASIC
|
|
109
|
-
credentials:
|
|
110
|
-
- teams:
|
|
111
|
-
- 789 # Must be a string
|
|
112
|
-
- correct
|
|
113
|
-
# username: Must be reported as a missing required prop
|
|
114
|
-
|
|
115
107
|
sso:
|
|
116
108
|
- WRONG # Does not match allowed options
|
|
117
109
|
|
|
@@ -393,20 +385,6 @@ describe('lint', () => {
|
|
|
393
385
|
"severity": "error",
|
|
394
386
|
"suggest": [],
|
|
395
387
|
},
|
|
396
|
-
{
|
|
397
|
-
"from": undefined,
|
|
398
|
-
"location": [
|
|
399
|
-
{
|
|
400
|
-
"pointer": "#/theme/openapi/showConsole",
|
|
401
|
-
"reportOnKey": true,
|
|
402
|
-
"source": "",
|
|
403
|
-
},
|
|
404
|
-
],
|
|
405
|
-
"message": "Property \`showConsole\` is not expected here.",
|
|
406
|
-
"ruleId": "configuration spec",
|
|
407
|
-
"severity": "error",
|
|
408
|
-
"suggest": [],
|
|
409
|
-
},
|
|
410
388
|
{
|
|
411
389
|
"from": undefined,
|
|
412
390
|
"location": [
|
|
@@ -912,34 +890,6 @@ describe('lint', () => {
|
|
|
912
890
|
"severity": "error",
|
|
913
891
|
"suggest": [],
|
|
914
892
|
},
|
|
915
|
-
{
|
|
916
|
-
"from": undefined,
|
|
917
|
-
"location": [
|
|
918
|
-
{
|
|
919
|
-
"pointer": "#/ssoOnPrem/basic/credentials/0",
|
|
920
|
-
"reportOnKey": true,
|
|
921
|
-
"source": "",
|
|
922
|
-
},
|
|
923
|
-
],
|
|
924
|
-
"message": "The field \`username\` must be present on this level.",
|
|
925
|
-
"ruleId": "configuration spec",
|
|
926
|
-
"severity": "error",
|
|
927
|
-
"suggest": [],
|
|
928
|
-
},
|
|
929
|
-
{
|
|
930
|
-
"from": undefined,
|
|
931
|
-
"location": [
|
|
932
|
-
{
|
|
933
|
-
"pointer": "#/ssoOnPrem/basic/credentials/0/teams/0",
|
|
934
|
-
"reportOnKey": false,
|
|
935
|
-
"source": "",
|
|
936
|
-
},
|
|
937
|
-
],
|
|
938
|
-
"message": "Expected type \`string\` but got \`integer\`.",
|
|
939
|
-
"ruleId": "configuration spec",
|
|
940
|
-
"severity": "error",
|
|
941
|
-
"suggest": [],
|
|
942
|
-
},
|
|
943
893
|
{
|
|
944
894
|
"from": undefined,
|
|
945
895
|
"location": [
|
package/src/bundle.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import isEqual = require('lodash.isequal');
|
|
2
1
|
import { BaseResolver, resolveDocument, makeRefId, makeDocumentFromString } from './resolve';
|
|
3
2
|
import { normalizeVisitors } from './visitors';
|
|
4
3
|
import { normalizeTypes } from './types';
|
|
@@ -13,7 +12,7 @@ import {
|
|
|
13
12
|
import { isAbsoluteUrl, isRef, Location, refBaseName } from './ref-utils';
|
|
14
13
|
import { initRules } from './config/rules';
|
|
15
14
|
import { reportUnresolvedRef } from './rules/no-unresolved-refs';
|
|
16
|
-
import { isPlainObject, isTruthy } from './utils';
|
|
15
|
+
import { dequal, isPlainObject, isTruthy } from './utils';
|
|
17
16
|
import { isRedoclyRegistryURL } from './redocly/domains';
|
|
18
17
|
import { RemoveUnusedComponents as RemoveUnusedComponentsOas2 } from './decorators/oas2/remove-unused-components';
|
|
19
18
|
import { RemoveUnusedComponents as RemoveUnusedComponentsOas3 } from './decorators/oas3/remove-unused-components';
|
|
@@ -293,6 +292,15 @@ export function mapTypeToComponent(typeName: string, version: SpecMajorVersion)
|
|
|
293
292
|
default:
|
|
294
293
|
return null;
|
|
295
294
|
}
|
|
295
|
+
case SpecMajorVersion.Arazzo:
|
|
296
|
+
switch (typeName) {
|
|
297
|
+
case 'Root.x-parameters_items':
|
|
298
|
+
case 'Root.workflows_items.parameters_items':
|
|
299
|
+
case 'Root.workflows_items.steps_items.parameters_items':
|
|
300
|
+
return 'parameters';
|
|
301
|
+
default:
|
|
302
|
+
return null;
|
|
303
|
+
}
|
|
296
304
|
}
|
|
297
305
|
}
|
|
298
306
|
|
|
@@ -367,6 +375,10 @@ function makeBundleVisitor(
|
|
|
367
375
|
components = root.components = root.components || {};
|
|
368
376
|
} else if (version === SpecMajorVersion.OAS2) {
|
|
369
377
|
components = root;
|
|
378
|
+
} else if (version === SpecMajorVersion.Async2) {
|
|
379
|
+
components = root.components = root.components || {};
|
|
380
|
+
} else if (version === SpecMajorVersion.Arazzo) {
|
|
381
|
+
components = root.components = root.components || {};
|
|
370
382
|
}
|
|
371
383
|
},
|
|
372
384
|
},
|
|
@@ -433,7 +445,7 @@ function makeBundleVisitor(
|
|
|
433
445
|
return true;
|
|
434
446
|
}
|
|
435
447
|
|
|
436
|
-
return
|
|
448
|
+
return dequal(node, target.node);
|
|
437
449
|
}
|
|
438
450
|
|
|
439
451
|
function getComponentName(
|
|
@@ -2,11 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`resolveConfig should ignore minimal from the root and read local file 1`] = `
|
|
4
4
|
{
|
|
5
|
+
"arazzoDecorators": {},
|
|
6
|
+
"arazzoPreprocessors": {},
|
|
7
|
+
"arazzoRules": {
|
|
8
|
+
"spec": "error",
|
|
9
|
+
},
|
|
5
10
|
"async2Decorators": {},
|
|
6
11
|
"async2Preprocessors": {},
|
|
7
12
|
"async2Rules": {
|
|
8
13
|
"channels-kebab-case": "off",
|
|
14
|
+
"info-contact": "off",
|
|
9
15
|
"no-channel-trailing-slash": "off",
|
|
16
|
+
"operation-operationId": "warn",
|
|
17
|
+
"spec": "error",
|
|
18
|
+
"tag-description": "warn",
|
|
19
|
+
"tags-alphabetical": "off",
|
|
10
20
|
},
|
|
11
21
|
"decorators": {},
|
|
12
22
|
"doNotResolveExamples": undefined,
|
|
@@ -109,11 +119,21 @@ exports[`resolveConfig should ignore minimal from the root and read local file 1
|
|
|
109
119
|
|
|
110
120
|
exports[`resolveStyleguideConfig should resolve extends with local file config which contains path to nested config 1`] = `
|
|
111
121
|
{
|
|
122
|
+
"arazzoDecorators": {},
|
|
123
|
+
"arazzoPreprocessors": {},
|
|
124
|
+
"arazzoRules": {
|
|
125
|
+
"spec": "error",
|
|
126
|
+
},
|
|
112
127
|
"async2Decorators": {},
|
|
113
128
|
"async2Preprocessors": {},
|
|
114
129
|
"async2Rules": {
|
|
115
130
|
"channels-kebab-case": "off",
|
|
131
|
+
"info-contact": "off",
|
|
116
132
|
"no-channel-trailing-slash": "off",
|
|
133
|
+
"operation-operationId": "warn",
|
|
134
|
+
"spec": "error",
|
|
135
|
+
"tag-description": "warn",
|
|
136
|
+
"tags-alphabetical": "off",
|
|
117
137
|
},
|
|
118
138
|
"decorators": {},
|
|
119
139
|
"doNotResolveExamples": undefined,
|
|
@@ -6,6 +6,7 @@ StyleguideConfig {
|
|
|
6
6
|
"_usedVersions": Set {},
|
|
7
7
|
"configFile": undefined,
|
|
8
8
|
"decorators": {
|
|
9
|
+
"arazzo": {},
|
|
9
10
|
"async2": {
|
|
10
11
|
"oas2": {},
|
|
11
12
|
"oas3_0": {},
|
|
@@ -44,6 +45,7 @@ StyleguideConfig {
|
|
|
44
45
|
"pluginPaths": [],
|
|
45
46
|
"plugins": [],
|
|
46
47
|
"preprocessors": {
|
|
48
|
+
"arazzo": {},
|
|
47
49
|
"async2": {
|
|
48
50
|
"oas2": {},
|
|
49
51
|
"oas3_0": {},
|
|
@@ -107,6 +109,7 @@ StyleguideConfig {
|
|
|
107
109
|
},
|
|
108
110
|
"recommendedFallback": false,
|
|
109
111
|
"rules": {
|
|
112
|
+
"arazzo": {},
|
|
110
113
|
"async2": {
|
|
111
114
|
"oas2": {
|
|
112
115
|
"no-empty-servers": "error",
|
|
@@ -117,6 +117,7 @@ describe('getMergedConfig', () => {
|
|
|
117
117
|
"_usedVersions": Set {},
|
|
118
118
|
"configFile": "redocly.yaml",
|
|
119
119
|
"decorators": {
|
|
120
|
+
"arazzo": {},
|
|
120
121
|
"async2": {},
|
|
121
122
|
"oas2": {},
|
|
122
123
|
"oas3_0": {},
|
|
@@ -128,6 +129,7 @@ describe('getMergedConfig', () => {
|
|
|
128
129
|
"pluginPaths": [],
|
|
129
130
|
"plugins": [],
|
|
130
131
|
"preprocessors": {
|
|
132
|
+
"arazzo": {},
|
|
131
133
|
"async2": {},
|
|
132
134
|
"oas2": {},
|
|
133
135
|
"oas3_0": {},
|
|
@@ -142,6 +144,7 @@ describe('getMergedConfig', () => {
|
|
|
142
144
|
},
|
|
143
145
|
"recommendedFallback": false,
|
|
144
146
|
"rules": {
|
|
147
|
+
"arazzo": {},
|
|
145
148
|
"async2": {
|
|
146
149
|
"operation-summary": "warn",
|
|
147
150
|
},
|
|
@@ -222,6 +225,7 @@ describe('getMergedConfig', () => {
|
|
|
222
225
|
"_usedVersions": Set {},
|
|
223
226
|
"configFile": "redocly.yaml",
|
|
224
227
|
"decorators": {
|
|
228
|
+
"arazzo": {},
|
|
225
229
|
"async2": {},
|
|
226
230
|
"oas2": {},
|
|
227
231
|
"oas3_0": {},
|
|
@@ -233,6 +237,7 @@ describe('getMergedConfig', () => {
|
|
|
233
237
|
"pluginPaths": [],
|
|
234
238
|
"plugins": [],
|
|
235
239
|
"preprocessors": {
|
|
240
|
+
"arazzo": {},
|
|
236
241
|
"async2": {},
|
|
237
242
|
"oas2": {},
|
|
238
243
|
"oas3_0": {},
|
|
@@ -249,6 +254,7 @@ describe('getMergedConfig', () => {
|
|
|
249
254
|
},
|
|
250
255
|
"recommendedFallback": false,
|
|
251
256
|
"rules": {
|
|
257
|
+
"arazzo": {},
|
|
252
258
|
"async2": {
|
|
253
259
|
"no-empty-servers": "error",
|
|
254
260
|
"operation-summary": "error",
|
package/src/config/all.ts
CHANGED
|
@@ -106,9 +106,15 @@ const all: PluginStyleguideConfig<'built-in'> = {
|
|
|
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
|
|
|
114
120
|
export default all;
|
package/src/config/builtIn.ts
CHANGED
|
@@ -5,10 +5,15 @@ import minimal from './minimal';
|
|
|
5
5
|
import { rules as oas3Rules } from '../rules/oas3';
|
|
6
6
|
import { rules as oas2Rules } from '../rules/oas2';
|
|
7
7
|
import { rules as async2Rules } from '../rules/async2';
|
|
8
|
+
import { rules as arazzoRules } from '../rules/arazzo';
|
|
8
9
|
import { preprocessors as oas3Preprocessors } from '../rules/oas3';
|
|
9
10
|
import { preprocessors as oas2Preprocessors } from '../rules/oas2';
|
|
11
|
+
import { preprocessors as async2Preprocessors } from '../rules/async2';
|
|
12
|
+
import { preprocessors as arazzoPreprocessors } from '../rules/arazzo';
|
|
10
13
|
import { decorators as oas3Decorators } from '../decorators/oas3';
|
|
11
14
|
import { decorators as oas2Decorators } from '../decorators/oas2';
|
|
15
|
+
import { decorators as async2Decorators } from '../decorators/async2';
|
|
16
|
+
import { decorators as arazzoDecorators } from '../decorators/arazzo';
|
|
12
17
|
|
|
13
18
|
import type { CustomRulesConfig, StyleguideRawConfig, Plugin } from './types';
|
|
14
19
|
|
|
@@ -28,16 +33,19 @@ export const defaultPlugin: Plugin = {
|
|
|
28
33
|
oas3: oas3Rules,
|
|
29
34
|
oas2: oas2Rules,
|
|
30
35
|
async2: async2Rules,
|
|
36
|
+
arazzo: arazzoRules,
|
|
31
37
|
} as CustomRulesConfig,
|
|
32
38
|
preprocessors: {
|
|
33
39
|
oas3: oas3Preprocessors,
|
|
34
40
|
oas2: oas2Preprocessors,
|
|
35
|
-
async2:
|
|
41
|
+
async2: async2Preprocessors,
|
|
42
|
+
arazzo: arazzoPreprocessors,
|
|
36
43
|
},
|
|
37
44
|
decorators: {
|
|
38
45
|
oas3: oas3Decorators,
|
|
39
46
|
oas2: oas2Decorators,
|
|
40
|
-
async2:
|
|
47
|
+
async2: async2Decorators,
|
|
48
|
+
arazzo: arazzoDecorators,
|
|
41
49
|
},
|
|
42
50
|
configs: builtInConfigs,
|
|
43
51
|
};
|
|
@@ -180,7 +180,9 @@ export function resolvePlugins(
|
|
|
180
180
|
|
|
181
181
|
if (pluginModule.rules) {
|
|
182
182
|
if (!pluginModule.rules.oas3 && !pluginModule.rules.oas2 && !pluginModule.rules.async2) {
|
|
183
|
-
throw new Error(
|
|
183
|
+
throw new Error(
|
|
184
|
+
`Plugin rules must have \`oas3\`, \`oas2\`, \`async2\`, or \`arazzo\` rules "${p}.`
|
|
185
|
+
);
|
|
184
186
|
}
|
|
185
187
|
plugin.rules = {};
|
|
186
188
|
if (pluginModule.rules.oas3) {
|
|
@@ -192,12 +194,16 @@ export function resolvePlugins(
|
|
|
192
194
|
if (pluginModule.rules.async2) {
|
|
193
195
|
plugin.rules.async2 = prefixRules(pluginModule.rules.async2, id);
|
|
194
196
|
}
|
|
197
|
+
if (pluginModule.rules.arazzo) {
|
|
198
|
+
plugin.rules.arazzo = prefixRules(pluginModule.rules.arazzo, id);
|
|
199
|
+
}
|
|
195
200
|
}
|
|
196
201
|
if (pluginModule.preprocessors) {
|
|
197
202
|
if (
|
|
198
203
|
!pluginModule.preprocessors.oas3 &&
|
|
199
204
|
!pluginModule.preprocessors.oas2 &&
|
|
200
|
-
!pluginModule.preprocessors.async2
|
|
205
|
+
!pluginModule.preprocessors.async2 &&
|
|
206
|
+
!pluginModule.preprocessors.arazzo
|
|
201
207
|
) {
|
|
202
208
|
throw new Error(
|
|
203
209
|
`Plugin \`preprocessors\` must have \`oas3\`, \`oas2\` or \`async2\` preprocessors "${p}.`
|
|
@@ -213,13 +219,17 @@ export function resolvePlugins(
|
|
|
213
219
|
if (pluginModule.preprocessors.async2) {
|
|
214
220
|
plugin.preprocessors.async2 = prefixRules(pluginModule.preprocessors.async2, id);
|
|
215
221
|
}
|
|
222
|
+
if (pluginModule.preprocessors.arazzo) {
|
|
223
|
+
plugin.preprocessors.arazzo = prefixRules(pluginModule.preprocessors.arazzo, id);
|
|
224
|
+
}
|
|
216
225
|
}
|
|
217
226
|
|
|
218
227
|
if (pluginModule.decorators) {
|
|
219
228
|
if (
|
|
220
229
|
!pluginModule.decorators.oas3 &&
|
|
221
230
|
!pluginModule.decorators.oas2 &&
|
|
222
|
-
!pluginModule.decorators.async2
|
|
231
|
+
!pluginModule.decorators.async2 &&
|
|
232
|
+
!pluginModule.decorators.arazzo
|
|
223
233
|
) {
|
|
224
234
|
throw new Error(
|
|
225
235
|
`Plugin \`decorators\` must have \`oas3\`, \`oas2\` or \`async2\` decorators "${p}.`
|
|
@@ -235,6 +245,9 @@ export function resolvePlugins(
|
|
|
235
245
|
if (pluginModule.decorators.async2) {
|
|
236
246
|
plugin.decorators.async2 = prefixRules(pluginModule.decorators.async2, id);
|
|
237
247
|
}
|
|
248
|
+
if (pluginModule.decorators.arazzo) {
|
|
249
|
+
plugin.decorators.arazzo = prefixRules(pluginModule.decorators.arazzo, id);
|
|
250
|
+
}
|
|
238
251
|
}
|
|
239
252
|
|
|
240
253
|
if (pluginModule.assertions) {
|
|
@@ -419,6 +432,7 @@ function getMergedRawStyleguideConfig(
|
|
|
419
432
|
oas2Rules: { ...rootStyleguideConfig?.oas2Rules, ...apiStyleguideConfig?.oas2Rules },
|
|
420
433
|
oas3_0Rules: { ...rootStyleguideConfig?.oas3_0Rules, ...apiStyleguideConfig?.oas3_0Rules },
|
|
421
434
|
oas3_1Rules: { ...rootStyleguideConfig?.oas3_1Rules, ...apiStyleguideConfig?.oas3_1Rules },
|
|
435
|
+
arazzoRules: { ...rootStyleguideConfig?.arazzoRules, ...apiStyleguideConfig?.arazzoRules },
|
|
422
436
|
preprocessors: {
|
|
423
437
|
...rootStyleguideConfig?.preprocessors,
|
|
424
438
|
...apiStyleguideConfig?.preprocessors,
|
package/src/config/config.ts
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
Oas2RuleSet,
|
|
10
10
|
Oas3RuleSet,
|
|
11
11
|
Async2RuleSet,
|
|
12
|
+
ArazzoRuleSet,
|
|
12
13
|
} from '../oas-types';
|
|
13
14
|
import { isBrowser } from '../env';
|
|
14
15
|
|
|
@@ -71,6 +72,7 @@ export class StyleguideConfig {
|
|
|
71
72
|
[SpecVersion.OAS3_0]: { ...rawConfig.rules, ...rawConfig.oas3_0Rules },
|
|
72
73
|
[SpecVersion.OAS3_1]: { ...rawConfig.rules, ...rawConfig.oas3_1Rules },
|
|
73
74
|
[SpecVersion.Async2]: { ...rawConfig.rules, ...rawConfig.async2Rules },
|
|
75
|
+
[SpecVersion.Arazzo]: { ...rawConfig.arazzoRules },
|
|
74
76
|
};
|
|
75
77
|
|
|
76
78
|
this.preprocessors = {
|
|
@@ -78,6 +80,7 @@ export class StyleguideConfig {
|
|
|
78
80
|
[SpecVersion.OAS3_0]: { ...rawConfig.preprocessors, ...rawConfig.oas3_0Preprocessors },
|
|
79
81
|
[SpecVersion.OAS3_1]: { ...rawConfig.preprocessors, ...rawConfig.oas3_1Preprocessors },
|
|
80
82
|
[SpecVersion.Async2]: { ...rawConfig.preprocessors, ...rawConfig.async2Preprocessors },
|
|
83
|
+
[SpecVersion.Arazzo]: { ...rawConfig.arazzoPreprocessors },
|
|
81
84
|
};
|
|
82
85
|
|
|
83
86
|
this.decorators = {
|
|
@@ -85,6 +88,7 @@ export class StyleguideConfig {
|
|
|
85
88
|
[SpecVersion.OAS3_0]: { ...rawConfig.decorators, ...rawConfig.oas3_0Decorators },
|
|
86
89
|
[SpecVersion.OAS3_1]: { ...rawConfig.decorators, ...rawConfig.oas3_1Decorators },
|
|
87
90
|
[SpecVersion.Async2]: { ...rawConfig.decorators, ...rawConfig.async2Decorators },
|
|
91
|
+
[SpecVersion.Arazzo]: { ...rawConfig.arazzoDecorators },
|
|
88
92
|
};
|
|
89
93
|
|
|
90
94
|
this.extendPaths = rawConfig.extendPaths || [];
|
|
@@ -178,6 +182,10 @@ export class StyleguideConfig {
|
|
|
178
182
|
if (!plugin.typeExtension.async2) continue;
|
|
179
183
|
extendedTypes = plugin.typeExtension.async2(extendedTypes, version);
|
|
180
184
|
break;
|
|
185
|
+
case SpecVersion.Arazzo:
|
|
186
|
+
if (!plugin.typeExtension.arazzo) continue;
|
|
187
|
+
extendedTypes = plugin.typeExtension.arazzo(extendedTypes, version);
|
|
188
|
+
break;
|
|
181
189
|
default:
|
|
182
190
|
throw new Error('Not implemented');
|
|
183
191
|
}
|
|
@@ -277,6 +285,15 @@ export class StyleguideConfig {
|
|
|
277
285
|
(p) => p.decorators?.async2 && asyncApiRules.push(p.decorators.async2)
|
|
278
286
|
);
|
|
279
287
|
return asyncApiRules;
|
|
288
|
+
case SpecMajorVersion.Arazzo:
|
|
289
|
+
// eslint-disable-next-line no-case-declarations
|
|
290
|
+
const arazzoRules: ArazzoRuleSet[] = []; // default ruleset
|
|
291
|
+
this.plugins.forEach(
|
|
292
|
+
(p) => p.preprocessors?.arazzo && arazzoRules.push(p.preprocessors.arazzo)
|
|
293
|
+
);
|
|
294
|
+
this.plugins.forEach((p) => p.rules?.arazzo && arazzoRules.push(p.rules.arazzo));
|
|
295
|
+
this.plugins.forEach((p) => p.decorators?.arazzo && arazzoRules.push(p.decorators.arazzo));
|
|
296
|
+
return arazzoRules;
|
|
280
297
|
}
|
|
281
298
|
}
|
|
282
299
|
|
package/src/config/load.ts
CHANGED
|
@@ -10,10 +10,9 @@ import { bundleConfig } from '../bundle';
|
|
|
10
10
|
import { BaseResolver } from '../resolve';
|
|
11
11
|
import { isBrowser } from '../env';
|
|
12
12
|
|
|
13
|
-
import type { Document } from '../resolve';
|
|
13
|
+
import type { Document, ResolvedRefMap } from '../resolve';
|
|
14
14
|
import type { RegionalToken, RegionalTokenWithValidity } from '../redocly/redocly-client-types';
|
|
15
15
|
import type { RawConfig, RawUniversalConfig, Region } from './types';
|
|
16
|
-
import type { ResolvedRefMap } from '../resolve';
|
|
17
16
|
import { DOMAINS } from '../redocly/domains';
|
|
18
17
|
|
|
19
18
|
async function addConfigMetadata({
|
package/src/config/minimal.ts
CHANGED
|
@@ -88,9 +88,17 @@ const minimal: PluginStyleguideConfig<'built-in'> = {
|
|
|
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
|
|
|
96
104
|
export default minimal;
|
|
@@ -88,9 +88,17 @@ const recommendedStrict: PluginStyleguideConfig<'built-in'> = {
|
|
|
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
|
|
|
96
104
|
export default recommendedStrict;
|
|
@@ -88,9 +88,17 @@ const recommended: PluginStyleguideConfig<'built-in'> = {
|
|
|
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
|
|
|
96
104
|
export default recommended;
|