@redocly/openapi-core 1.0.0-beta.112 → 1.0.0-beta.113
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/lib/config/config-resolvers.js +3 -6
- package/lib/config/config.d.ts +4 -10
- package/lib/config/config.js +1 -1
- package/lib/config/load.js +6 -6
- package/lib/config/rules.d.ts +6 -3
- package/lib/config/rules.js +3 -2
- package/lib/config/types.d.ts +3 -0
- package/lib/ref-utils.d.ts +1 -0
- package/lib/ref-utils.js +5 -1
- package/lib/resolve.js +19 -0
- package/lib/rules/common/spec.js +6 -0
- package/lib/rules/utils.js +3 -0
- package/lib/types/oas2.js +11 -7
- package/lib/types/oas3.js +15 -10
- package/lib/types/oas3_1.js +1 -0
- package/lib/types/redocly-yaml.js +5 -0
- package/lib/utils.d.ts +1 -0
- package/lib/utils.js +7 -1
- package/package.json +1 -1
- package/src/__tests__/bundle.test.ts +46 -0
- package/src/benchmark/benches/rebilly.yaml +36 -28
- package/src/config/__tests__/config-resolvers.test.ts +1 -2
- package/src/config/__tests__/fixtures/load-redocly.yaml +0 -2
- package/src/config/__tests__/fixtures/resolve-config/local-config-with-custom-function.yaml +0 -1
- package/src/config/__tests__/fixtures/resolve-config/local-config-with-wrong-custom-function.yaml +0 -1
- package/src/config/config-resolvers.ts +2 -12
- package/src/config/config.ts +6 -5
- package/src/config/load.ts +12 -5
- package/src/config/rules.ts +11 -3
- package/src/config/types.ts +2 -0
- package/src/ref-utils.ts +4 -0
- package/src/resolve.ts +25 -3
- package/src/rules/common/__tests__/spec.test.ts +170 -0
- package/src/rules/common/spec.ts +7 -0
- package/src/rules/oas3/__tests__/no-invalid-media-type-examples.test.ts +32 -0
- package/src/rules/utils.ts +4 -0
- package/src/types/oas2.ts +11 -7
- package/src/types/oas3.ts +15 -10
- package/src/types/oas3_1.ts +1 -0
- package/src/types/redocly-yaml.ts +5 -0
- package/src/utils.ts +6 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -33,22 +33,19 @@ const config_1 = require("./config");
|
|
|
33
33
|
const logger_1 = require("../logger");
|
|
34
34
|
const asserts_1 = require("../rules/common/assertions/asserts");
|
|
35
35
|
function resolveConfig(rawConfig, configPath) {
|
|
36
|
-
var _a, _b
|
|
36
|
+
var _a, _b;
|
|
37
37
|
return __awaiter(this, void 0, void 0, function* () {
|
|
38
38
|
if ((_b = (_a = rawConfig.styleguide) === null || _a === void 0 ? void 0 : _a.extends) === null || _b === void 0 ? void 0 : _b.some(utils_3.isNotString)) {
|
|
39
39
|
throw new Error(`Error configuration format not detected in extends value must contain strings`);
|
|
40
40
|
}
|
|
41
41
|
const resolver = new resolve_1.BaseResolver(utils_2.getResolveConfig(rawConfig.resolve));
|
|
42
|
-
const configExtends = (_d = (_c = rawConfig === null || rawConfig === void 0 ? void 0 : rawConfig.styleguide) === null || _c === void 0 ? void 0 : _c.extends) !== null && _d !== void 0 ? _d : ['recommended'];
|
|
43
|
-
const recommendedFallback = !((_e = rawConfig === null || rawConfig === void 0 ? void 0 : rawConfig.styleguide) === null || _e === void 0 ? void 0 : _e.extends);
|
|
44
|
-
const styleguideConfig = Object.assign(Object.assign({}, rawConfig === null || rawConfig === void 0 ? void 0 : rawConfig.styleguide), { extends: configExtends, recommendedFallback });
|
|
45
42
|
const apis = yield resolveApis({
|
|
46
|
-
rawConfig
|
|
43
|
+
rawConfig,
|
|
47
44
|
configPath,
|
|
48
45
|
resolver,
|
|
49
46
|
});
|
|
50
47
|
const styleguide = yield resolveStyleguideConfig({
|
|
51
|
-
styleguideConfig,
|
|
48
|
+
styleguideConfig: rawConfig.styleguide,
|
|
52
49
|
configPath,
|
|
53
50
|
resolver,
|
|
54
51
|
});
|
package/lib/config/config.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { NormalizedProblem } from '../walk';
|
|
2
2
|
import { OasVersion, OasMajorVersion, Oas2RuleSet, Oas3RuleSet } from '../oas-types';
|
|
3
3
|
import type { NodeType } from '../types';
|
|
4
|
-
import type { DecoratorConfig, Plugin, PreprocessorConfig, Region, ResolveConfig, ResolvedApi, ResolvedConfig, ResolvedStyleguideConfig, RuleConfig } from './types';
|
|
4
|
+
import type { DecoratorConfig, Plugin, PreprocessorConfig, Region, ResolveConfig, ResolvedApi, ResolvedConfig, ResolvedStyleguideConfig, RuleConfig, RuleSettings } from './types';
|
|
5
5
|
export declare const IGNORE_FILE = ".redocly.lint-ignore.yaml";
|
|
6
6
|
export declare const DEFAULT_REGION = "us";
|
|
7
7
|
export declare const DOMAINS: {
|
|
@@ -29,15 +29,9 @@ export declare class StyleguideConfig {
|
|
|
29
29
|
addIgnore(problem: NormalizedProblem): void;
|
|
30
30
|
addProblemToIgnore(problem: NormalizedProblem): NormalizedProblem;
|
|
31
31
|
extendTypes(types: Record<string, NodeType>, version: OasVersion): Record<string, NodeType>;
|
|
32
|
-
getRuleSettings(ruleId: string, oasVersion: OasVersion):
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
getPreprocessorSettings(ruleId: string, oasVersion: OasVersion): {
|
|
36
|
-
severity: string;
|
|
37
|
-
};
|
|
38
|
-
getDecoratorSettings(ruleId: string, oasVersion: OasVersion): {
|
|
39
|
-
severity: string;
|
|
40
|
-
};
|
|
32
|
+
getRuleSettings(ruleId: string, oasVersion: OasVersion): RuleSettings;
|
|
33
|
+
getPreprocessorSettings(ruleId: string, oasVersion: OasVersion): RuleSettings;
|
|
34
|
+
getDecoratorSettings(ruleId: string, oasVersion: OasVersion): RuleSettings;
|
|
41
35
|
getUnusedRules(): {
|
|
42
36
|
rules: string[];
|
|
43
37
|
preprocessors: string[];
|
package/lib/config/config.js
CHANGED
|
@@ -34,7 +34,7 @@ function getIgnoreFilePath(configFile) {
|
|
|
34
34
|
: path.join(configFile, exports.IGNORE_FILE);
|
|
35
35
|
}
|
|
36
36
|
else {
|
|
37
|
-
return
|
|
37
|
+
return env_1.isBrowser ? undefined : path.join(process.cwd(), exports.IGNORE_FILE);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
exports.DOMAINS = getDomains();
|
package/lib/config/load.js
CHANGED
|
@@ -18,7 +18,7 @@ const js_yaml_1 = require("../js-yaml");
|
|
|
18
18
|
const config_1 = require("./config");
|
|
19
19
|
const utils_2 = require("./utils");
|
|
20
20
|
const config_resolvers_1 = require("./config-resolvers");
|
|
21
|
-
function addConfigMetadata({ rawConfig, customExtends, configPath, tokens, }) {
|
|
21
|
+
function addConfigMetadata({ rawConfig, customExtends, configPath, tokens, files, region, }) {
|
|
22
22
|
var _a;
|
|
23
23
|
return __awaiter(this, void 0, void 0, function* () {
|
|
24
24
|
if (customExtends !== undefined) {
|
|
@@ -26,8 +26,7 @@ function addConfigMetadata({ rawConfig, customExtends, configPath, tokens, }) {
|
|
|
26
26
|
rawConfig.styleguide.extends = customExtends;
|
|
27
27
|
}
|
|
28
28
|
else if (utils_1.isEmptyObject(rawConfig)) {
|
|
29
|
-
|
|
30
|
-
// rawConfig.styleguide = { extends: ['recommended'], recommendedFallback: true };
|
|
29
|
+
rawConfig.styleguide = { extends: ['recommended'], recommendedFallback: true };
|
|
31
30
|
}
|
|
32
31
|
if (tokens === null || tokens === void 0 ? void 0 : tokens.length) {
|
|
33
32
|
if (!rawConfig.resolve)
|
|
@@ -56,14 +55,13 @@ function addConfigMetadata({ rawConfig, customExtends, configPath, tokens, }) {
|
|
|
56
55
|
: []));
|
|
57
56
|
}
|
|
58
57
|
}
|
|
59
|
-
return config_resolvers_1.resolveConfig(rawConfig, configPath);
|
|
58
|
+
return config_resolvers_1.resolveConfig(Object.assign(Object.assign({}, rawConfig), { files: files !== null && files !== void 0 ? files : rawConfig.files, region: region !== null && region !== void 0 ? region : rawConfig.region }), configPath);
|
|
60
59
|
});
|
|
61
60
|
}
|
|
62
61
|
function loadConfig(options = {}) {
|
|
63
62
|
return __awaiter(this, void 0, void 0, function* () {
|
|
64
63
|
const { configPath = findConfig(), customExtends, processRawConfig, files, region } = options;
|
|
65
|
-
const
|
|
66
|
-
const rawConfig = Object.assign(Object.assign({}, config), { files: files !== null && files !== void 0 ? files : config.files, region: region !== null && region !== void 0 ? region : config.region });
|
|
64
|
+
const rawConfig = yield getConfig(configPath, processRawConfig);
|
|
67
65
|
const redoclyClient = new redocly_1.RedoclyClient();
|
|
68
66
|
const tokens = yield redoclyClient.getTokens();
|
|
69
67
|
return addConfigMetadata({
|
|
@@ -71,6 +69,8 @@ function loadConfig(options = {}) {
|
|
|
71
69
|
customExtends,
|
|
72
70
|
configPath,
|
|
73
71
|
tokens,
|
|
72
|
+
files,
|
|
73
|
+
region,
|
|
74
74
|
});
|
|
75
75
|
});
|
|
76
76
|
}
|
package/lib/config/rules.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { RuleSet, OasVersion } from '../oas-types';
|
|
2
2
|
import { StyleguideConfig } from './config';
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import type { ProblemSeverity } from '../walk';
|
|
4
|
+
declare type InitializedRule = {
|
|
5
|
+
severity: ProblemSeverity;
|
|
5
6
|
ruleId: string;
|
|
6
7
|
visitor: any;
|
|
7
|
-
}
|
|
8
|
+
};
|
|
9
|
+
export declare function initRules<T extends Function, P extends RuleSet<T>>(rules: P[], config: StyleguideConfig, type: 'rules' | 'preprocessors' | 'decorators', oasVersion: OasVersion): InitializedRule[];
|
|
10
|
+
export {};
|
package/lib/config/rules.js
CHANGED
|
@@ -14,16 +14,17 @@ function initRules(rules, config, type, oasVersion) {
|
|
|
14
14
|
if (ruleSettings.severity === 'off') {
|
|
15
15
|
return undefined;
|
|
16
16
|
}
|
|
17
|
+
const severity = ruleSettings.severity;
|
|
17
18
|
const visitors = rule(ruleSettings);
|
|
18
19
|
if (Array.isArray(visitors)) {
|
|
19
20
|
return visitors.map((visitor) => ({
|
|
20
|
-
severity
|
|
21
|
+
severity,
|
|
21
22
|
ruleId,
|
|
22
23
|
visitor: visitor,
|
|
23
24
|
}));
|
|
24
25
|
}
|
|
25
26
|
return {
|
|
26
|
-
severity
|
|
27
|
+
severity,
|
|
27
28
|
ruleId,
|
|
28
29
|
visitor: visitors, // note: actually it is only one visitor object
|
|
29
30
|
};
|
package/lib/config/types.d.ts
CHANGED
|
@@ -3,6 +3,9 @@ import type { Oas3PreprocessorsSet, OasMajorVersion, Oas3DecoratorsSet, Oas2Rule
|
|
|
3
3
|
import type { NodeType } from '../types';
|
|
4
4
|
import { Location } from '../ref-utils';
|
|
5
5
|
export declare type RuleSeverity = ProblemSeverity | 'off';
|
|
6
|
+
export declare type RuleSettings = {
|
|
7
|
+
severity: RuleSeverity;
|
|
8
|
+
};
|
|
6
9
|
export declare type PreprocessorSeverity = RuleSeverity | 'on';
|
|
7
10
|
export declare type RuleConfig = RuleSeverity | ({
|
|
8
11
|
severity?: ProblemSeverity;
|
package/lib/ref-utils.d.ts
CHANGED
|
@@ -23,3 +23,4 @@ export declare function pointerBaseName(pointer: string): string;
|
|
|
23
23
|
export declare function refBaseName(ref: string): string;
|
|
24
24
|
export declare function isAbsoluteUrl(ref: string): boolean;
|
|
25
25
|
export declare function isMappingRef(mapping: string): boolean;
|
|
26
|
+
export declare function isAnchor(ref: string): boolean;
|
package/lib/ref-utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isMappingRef = exports.isAbsoluteUrl = exports.refBaseName = exports.pointerBaseName = exports.parsePointer = exports.parseRef = exports.escapePointer = exports.unescapePointer = exports.Location = exports.isRef = exports.joinPointer = void 0;
|
|
3
|
+
exports.isAnchor = exports.isMappingRef = exports.isAbsoluteUrl = exports.refBaseName = exports.pointerBaseName = exports.parsePointer = exports.parseRef = exports.escapePointer = exports.unescapePointer = exports.Location = exports.isRef = exports.joinPointer = void 0;
|
|
4
4
|
const utils_1 = require("./utils");
|
|
5
5
|
function joinPointer(base, key) {
|
|
6
6
|
if (base === '')
|
|
@@ -74,3 +74,7 @@ function isMappingRef(mapping) {
|
|
|
74
74
|
mapping.indexOf('/') > -1);
|
|
75
75
|
}
|
|
76
76
|
exports.isMappingRef = isMappingRef;
|
|
77
|
+
function isAnchor(ref) {
|
|
78
|
+
return /^#[A-Za-z][A-Za-z0-9\-_:.]*$/.test(ref);
|
|
79
|
+
}
|
|
80
|
+
exports.isAnchor = isAnchor;
|
package/lib/resolve.js
CHANGED
|
@@ -186,6 +186,7 @@ function resolveDocument(opts) {
|
|
|
186
186
|
return resolvedRefMap;
|
|
187
187
|
function resolveRefsInParallel(rootNode, rootNodeDocument, rootNodePointer, type) {
|
|
188
188
|
const rootNodeDocAbsoluteRef = rootNodeDocument.source.absoluteRef;
|
|
189
|
+
const anchorRefsMap = new Map();
|
|
189
190
|
walk(rootNode, type, rootNodeDocAbsoluteRef + rootNodePointer);
|
|
190
191
|
function walk(node, type, nodeAbsoluteRef) {
|
|
191
192
|
if (typeof node !== 'object' || node === null) {
|
|
@@ -196,6 +197,10 @@ function resolveDocument(opts) {
|
|
|
196
197
|
return;
|
|
197
198
|
}
|
|
198
199
|
seedNodes.add(nodeId);
|
|
200
|
+
const [_, anchor] = Object.entries(node).find(([key]) => key === '$anchor') || [];
|
|
201
|
+
if (anchor) {
|
|
202
|
+
anchorRefsMap.set(`#${anchor}`, node);
|
|
203
|
+
}
|
|
199
204
|
if (Array.isArray(node)) {
|
|
200
205
|
const itemsType = type.items;
|
|
201
206
|
// we continue resolving unknown types, but stop early on known scalars
|
|
@@ -245,6 +250,20 @@ function resolveDocument(opts) {
|
|
|
245
250
|
if (hasRef(refStack.prev, ref)) {
|
|
246
251
|
throw new Error('Self-referencing circular pointer');
|
|
247
252
|
}
|
|
253
|
+
if (ref_utils_1.isAnchor(ref.$ref)) {
|
|
254
|
+
// Wait for all anchors in the document to be collected firstly.
|
|
255
|
+
yield utils_1.nextTick();
|
|
256
|
+
const resolvedRef = {
|
|
257
|
+
resolved: true,
|
|
258
|
+
isRemote: false,
|
|
259
|
+
node: anchorRefsMap.get(ref.$ref),
|
|
260
|
+
document,
|
|
261
|
+
nodePointer: ref.$ref,
|
|
262
|
+
};
|
|
263
|
+
const refId = makeRefId(document.source.absoluteRef, ref.$ref);
|
|
264
|
+
resolvedRefMap.set(refId, resolvedRef);
|
|
265
|
+
return resolvedRef;
|
|
266
|
+
}
|
|
248
267
|
const { uri, pointer } = ref_utils_1.parseRef(ref.$ref);
|
|
249
268
|
const isRemote = uri !== null;
|
|
250
269
|
let targetDoc;
|
package/lib/rules/common/spec.js
CHANGED
|
@@ -142,6 +142,12 @@ const OasSpec = () => {
|
|
|
142
142
|
});
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
|
+
if (propName === 'nullable' && !node.type) {
|
|
146
|
+
report({
|
|
147
|
+
message: 'The `type` field must be defined when the `nullable` field is used.',
|
|
148
|
+
location: location.child([propName]),
|
|
149
|
+
});
|
|
150
|
+
}
|
|
145
151
|
}
|
|
146
152
|
},
|
|
147
153
|
};
|
package/lib/rules/utils.js
CHANGED
|
@@ -101,6 +101,9 @@ function validateExample(example, schema, dataLoc, { resolve, location, report }
|
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
catch (e) {
|
|
104
|
+
if (e.message === 'discriminator: requires oneOf or anyOf composite keyword') {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
104
107
|
report({
|
|
105
108
|
message: `Example validation errored: ${e.message}.`,
|
|
106
109
|
location: location.child('schema'),
|
package/lib/types/oas2.js
CHANGED
|
@@ -17,8 +17,8 @@ const Root = {
|
|
|
17
17
|
parameters: 'NamedParameters',
|
|
18
18
|
responses: 'NamedResponses',
|
|
19
19
|
securityDefinitions: 'NamedSecuritySchemes',
|
|
20
|
-
security:
|
|
21
|
-
tags:
|
|
20
|
+
security: 'SecurityRequirementList',
|
|
21
|
+
tags: 'TagList',
|
|
22
22
|
externalDocs: 'ExternalDocs',
|
|
23
23
|
},
|
|
24
24
|
required: ['swagger', 'paths', 'info'],
|
|
@@ -55,7 +55,7 @@ const Paths = {
|
|
|
55
55
|
const PathItem = {
|
|
56
56
|
properties: {
|
|
57
57
|
$ref: { type: 'string' },
|
|
58
|
-
parameters:
|
|
58
|
+
parameters: 'ParameterList',
|
|
59
59
|
get: 'Operation',
|
|
60
60
|
put: 'Operation',
|
|
61
61
|
post: 'Operation',
|
|
@@ -74,13 +74,13 @@ const Operation = {
|
|
|
74
74
|
operationId: { type: 'string' },
|
|
75
75
|
consumes: { type: 'array', items: { type: 'string' } },
|
|
76
76
|
produces: { type: 'array', items: { type: 'string' } },
|
|
77
|
-
parameters:
|
|
77
|
+
parameters: 'ParameterList',
|
|
78
78
|
responses: 'Responses',
|
|
79
79
|
schemes: { type: 'array', items: { type: 'string' } },
|
|
80
80
|
deprecated: { type: 'boolean' },
|
|
81
|
-
security:
|
|
82
|
-
'x-codeSamples':
|
|
83
|
-
'x-code-samples':
|
|
81
|
+
security: 'SecurityRequirementList',
|
|
82
|
+
'x-codeSamples': 'XCodeSampleList',
|
|
83
|
+
'x-code-samples': 'XCodeSampleList',
|
|
84
84
|
'x-hideTryItPanel': { type: 'boolean' },
|
|
85
85
|
},
|
|
86
86
|
required: ['responses'],
|
|
@@ -354,8 +354,10 @@ const SecurityRequirement = {
|
|
|
354
354
|
exports.Oas2Types = {
|
|
355
355
|
Root,
|
|
356
356
|
Tag,
|
|
357
|
+
TagList: _1.listOf('Tag'),
|
|
357
358
|
ExternalDocs,
|
|
358
359
|
SecurityRequirement,
|
|
360
|
+
SecurityRequirementList: _1.listOf('SecurityRequirement'),
|
|
359
361
|
Info,
|
|
360
362
|
Contact,
|
|
361
363
|
License,
|
|
@@ -363,6 +365,7 @@ exports.Oas2Types = {
|
|
|
363
365
|
PathItem,
|
|
364
366
|
Parameter,
|
|
365
367
|
ParameterItems,
|
|
368
|
+
ParameterList: _1.listOf('Parameter'),
|
|
366
369
|
Operation,
|
|
367
370
|
Examples,
|
|
368
371
|
Header,
|
|
@@ -377,4 +380,5 @@ exports.Oas2Types = {
|
|
|
377
380
|
NamedSecuritySchemes: _1.mapOf('SecurityScheme'),
|
|
378
381
|
SecurityScheme,
|
|
379
382
|
XCodeSample,
|
|
383
|
+
XCodeSampleList: _1.listOf('XCodeSample'),
|
|
380
384
|
};
|
package/lib/types/oas3.js
CHANGED
|
@@ -8,9 +8,9 @@ const Root = {
|
|
|
8
8
|
properties: {
|
|
9
9
|
openapi: null,
|
|
10
10
|
info: 'Info',
|
|
11
|
-
servers:
|
|
12
|
-
security:
|
|
13
|
-
tags:
|
|
11
|
+
servers: 'ServerList',
|
|
12
|
+
security: 'SecurityRequirementList',
|
|
13
|
+
tags: 'TagList',
|
|
14
14
|
externalDocs: 'ExternalDocs',
|
|
15
15
|
paths: 'Paths',
|
|
16
16
|
components: 'Components',
|
|
@@ -92,8 +92,8 @@ const WebhooksMap = {
|
|
|
92
92
|
const PathItem = {
|
|
93
93
|
properties: {
|
|
94
94
|
$ref: { type: 'string' },
|
|
95
|
-
servers:
|
|
96
|
-
parameters:
|
|
95
|
+
servers: 'ServerList',
|
|
96
|
+
parameters: 'ParameterList',
|
|
97
97
|
summary: { type: 'string' },
|
|
98
98
|
description: { type: 'string' },
|
|
99
99
|
get: 'Operation',
|
|
@@ -137,15 +137,15 @@ const Operation = {
|
|
|
137
137
|
description: { type: 'string' },
|
|
138
138
|
externalDocs: 'ExternalDocs',
|
|
139
139
|
operationId: { type: 'string' },
|
|
140
|
-
parameters:
|
|
141
|
-
security:
|
|
142
|
-
servers:
|
|
140
|
+
parameters: 'ParameterList',
|
|
141
|
+
security: 'SecurityRequirementList',
|
|
142
|
+
servers: 'ServerList',
|
|
143
143
|
requestBody: 'RequestBody',
|
|
144
144
|
responses: 'Responses',
|
|
145
145
|
deprecated: { type: 'boolean' },
|
|
146
146
|
callbacks: 'CallbacksMap',
|
|
147
|
-
'x-codeSamples':
|
|
148
|
-
'x-code-samples':
|
|
147
|
+
'x-codeSamples': 'XCodeSampleList',
|
|
148
|
+
'x-code-samples': 'XCodeSampleList',
|
|
149
149
|
'x-hideTryItPanel': { type: 'boolean' },
|
|
150
150
|
},
|
|
151
151
|
required: ['responses'],
|
|
@@ -430,17 +430,21 @@ const SecurityScheme = {
|
|
|
430
430
|
exports.Oas3Types = {
|
|
431
431
|
Root,
|
|
432
432
|
Tag,
|
|
433
|
+
TagList: _1.listOf('Tag'),
|
|
433
434
|
ExternalDocs,
|
|
434
435
|
Server,
|
|
436
|
+
ServerList: _1.listOf('Server'),
|
|
435
437
|
ServerVariable,
|
|
436
438
|
ServerVariablesMap: _1.mapOf('ServerVariable'),
|
|
437
439
|
SecurityRequirement,
|
|
440
|
+
SecurityRequirementList: _1.listOf('SecurityRequirement'),
|
|
438
441
|
Info,
|
|
439
442
|
Contact,
|
|
440
443
|
License,
|
|
441
444
|
Paths,
|
|
442
445
|
PathItem,
|
|
443
446
|
Parameter,
|
|
447
|
+
ParameterList: _1.listOf('Parameter'),
|
|
444
448
|
Operation,
|
|
445
449
|
Callback: _1.mapOf('PathItem'),
|
|
446
450
|
CallbacksMap: _1.mapOf('Callback'),
|
|
@@ -479,5 +483,6 @@ exports.Oas3Types = {
|
|
|
479
483
|
OAuth2Flows,
|
|
480
484
|
SecurityScheme,
|
|
481
485
|
XCodeSample,
|
|
486
|
+
XCodeSampleList: _1.listOf('XCodeSample'),
|
|
482
487
|
WebhooksMap,
|
|
483
488
|
};
|
package/lib/types/oas3_1.js
CHANGED
|
@@ -59,17 +59,21 @@ const builtInRulesList = [
|
|
|
59
59
|
const nodeTypesList = [
|
|
60
60
|
'Root',
|
|
61
61
|
'Tag',
|
|
62
|
+
'TagList',
|
|
62
63
|
'ExternalDocs',
|
|
63
64
|
'Server',
|
|
65
|
+
'ServerList',
|
|
64
66
|
'ServerVariable',
|
|
65
67
|
'ServerVariablesMap',
|
|
66
68
|
'SecurityRequirement',
|
|
69
|
+
'SecurityRequirementList',
|
|
67
70
|
'Info',
|
|
68
71
|
'Contact',
|
|
69
72
|
'License',
|
|
70
73
|
'Paths',
|
|
71
74
|
'PathItem',
|
|
72
75
|
'Parameter',
|
|
76
|
+
'ParameterList',
|
|
73
77
|
'Operation',
|
|
74
78
|
'Callback',
|
|
75
79
|
'CallbacksMap',
|
|
@@ -108,6 +112,7 @@ const nodeTypesList = [
|
|
|
108
112
|
'OAuth2Flows',
|
|
109
113
|
'SecurityScheme',
|
|
110
114
|
'XCodeSample',
|
|
115
|
+
'XCodeSampleList',
|
|
111
116
|
'WebhooksMap',
|
|
112
117
|
];
|
|
113
118
|
const ConfigStyleguide = {
|
package/lib/utils.d.ts
CHANGED
|
@@ -48,3 +48,4 @@ export declare function isTruthy<Truthy>(value: Truthy | Falsy): value is Truthy
|
|
|
48
48
|
export declare function identity<T>(value: T): T;
|
|
49
49
|
export declare function keysOf<T>(obj: T): (keyof T)[];
|
|
50
50
|
export declare function pickDefined<T extends Record<string, unknown>>(obj?: T): Record<string, unknown> | undefined;
|
|
51
|
+
export declare function nextTick(): void;
|
package/lib/utils.js
CHANGED
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
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.readFileAsStringSync = exports.isSingular = 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;
|
|
12
|
+
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.readFileAsStringSync = exports.isSingular = 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");
|
|
@@ -223,3 +223,9 @@ function pickDefined(obj) {
|
|
|
223
223
|
return res;
|
|
224
224
|
}
|
|
225
225
|
exports.pickDefined = pickDefined;
|
|
226
|
+
function nextTick() {
|
|
227
|
+
new Promise((resolve) => {
|
|
228
|
+
setTimeout(resolve);
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
exports.nextTick = nextTick;
|
package/package.json
CHANGED
|
@@ -187,4 +187,50 @@ describe('bundle', () => {
|
|
|
187
187
|
expect(problems).toHaveLength(0);
|
|
188
188
|
expect(parsedMeta).toMatchSnapshot();
|
|
189
189
|
});
|
|
190
|
+
|
|
191
|
+
it('should bundle refs using $anchors', async () => {
|
|
192
|
+
const testDocument = parseYamlToDocument(
|
|
193
|
+
outdent`
|
|
194
|
+
openapi: 3.1.0
|
|
195
|
+
components:
|
|
196
|
+
schemas:
|
|
197
|
+
User:
|
|
198
|
+
type: object
|
|
199
|
+
properties:
|
|
200
|
+
profile:
|
|
201
|
+
$ref: '#user-profile'
|
|
202
|
+
UserProfile:
|
|
203
|
+
$anchor: user-profile
|
|
204
|
+
type: string
|
|
205
|
+
`,
|
|
206
|
+
''
|
|
207
|
+
);
|
|
208
|
+
|
|
209
|
+
const config = await makeConfig({});
|
|
210
|
+
|
|
211
|
+
const {
|
|
212
|
+
bundle: { parsed },
|
|
213
|
+
problems,
|
|
214
|
+
} = await bundleDocument({
|
|
215
|
+
document: testDocument,
|
|
216
|
+
config: config,
|
|
217
|
+
externalRefResolver: new BaseResolver(),
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
expect(problems).toHaveLength(0);
|
|
221
|
+
expect(parsed).toMatchInlineSnapshot(`
|
|
222
|
+
openapi: 3.1.0
|
|
223
|
+
components:
|
|
224
|
+
schemas:
|
|
225
|
+
User:
|
|
226
|
+
type: object
|
|
227
|
+
properties:
|
|
228
|
+
profile:
|
|
229
|
+
$ref: '#user-profile'
|
|
230
|
+
UserProfile:
|
|
231
|
+
$anchor: user-profile
|
|
232
|
+
type: string
|
|
233
|
+
|
|
234
|
+
`);
|
|
235
|
+
});
|
|
190
236
|
});
|
|
@@ -4238,10 +4238,11 @@ components:
|
|
|
4238
4238
|
type: integer
|
|
4239
4239
|
readOnly: true
|
|
4240
4240
|
dueReminderTime:
|
|
4241
|
-
description:
|
|
4241
|
+
description: Date and time at which a past due reminder event is triggered.
|
|
4242
4242
|
nullable: true
|
|
4243
|
-
|
|
4244
|
-
|
|
4243
|
+
type: string
|
|
4244
|
+
format: date-time
|
|
4245
|
+
readOnly: true
|
|
4245
4246
|
dueReminderNumber:
|
|
4246
4247
|
description: Number of past due reminder events triggered
|
|
4247
4248
|
type: integer
|
|
@@ -9524,10 +9525,11 @@ components:
|
|
|
9524
9525
|
allOf:
|
|
9525
9526
|
- $ref: '#/components/schemas/ServerTimestamp'
|
|
9526
9527
|
expirationReminderTime:
|
|
9527
|
-
description:
|
|
9528
|
+
description: Date and time at which an expiration reminder event is triggered.
|
|
9528
9529
|
nullable: true
|
|
9529
|
-
|
|
9530
|
-
|
|
9530
|
+
type: string
|
|
9531
|
+
format: date-time
|
|
9532
|
+
readOnly: true
|
|
9531
9533
|
expirationReminderNumber:
|
|
9532
9534
|
description: Number of expiration reminder events triggered
|
|
9533
9535
|
type: integer
|
|
@@ -10226,9 +10228,10 @@ components:
|
|
|
10226
10228
|
readOnly: true
|
|
10227
10229
|
reviewTime:
|
|
10228
10230
|
description: Date and time of manual review.
|
|
10231
|
+
type: string
|
|
10229
10232
|
nullable: true
|
|
10230
|
-
|
|
10231
|
-
|
|
10233
|
+
format: date-time
|
|
10234
|
+
readOnly: true
|
|
10232
10235
|
documentMatches:
|
|
10233
10236
|
$ref: '#/components/schemas/KycDocumentMatches'
|
|
10234
10237
|
_links:
|
|
@@ -10587,19 +10590,22 @@ components:
|
|
|
10587
10590
|
deliveryAddress:
|
|
10588
10591
|
description: Delivery address
|
|
10589
10592
|
nullable: true
|
|
10593
|
+
type: object
|
|
10590
10594
|
allOf:
|
|
10591
10595
|
- $ref: '#/components/schemas/ContactObject'
|
|
10592
10596
|
billingAddress:
|
|
10593
10597
|
description: Billing address
|
|
10594
10598
|
nullable: true
|
|
10599
|
+
type: object
|
|
10595
10600
|
allOf:
|
|
10596
10601
|
- $ref: '#/components/schemas/ContactObject'
|
|
10597
10602
|
riskMetadata:
|
|
10598
10603
|
nullable: true
|
|
10604
|
+
type: object
|
|
10599
10605
|
example: null
|
|
10600
|
-
description:
|
|
10601
|
-
Risk metadata.
|
|
10602
|
-
metadata captured when creating the payment token.
|
|
10606
|
+
description: |-
|
|
10607
|
+
Risk metadata.
|
|
10608
|
+
If null, the value would coalesce to the risk metadata captured when creating the payment token.
|
|
10603
10609
|
allOf:
|
|
10604
10610
|
- $ref: '#/components/schemas/RiskMetadata'
|
|
10605
10611
|
activationTime:
|
|
@@ -10842,18 +10848,16 @@ components:
|
|
|
10842
10848
|
type: string
|
|
10843
10849
|
format: date-time
|
|
10844
10850
|
invoiceTimeShift:
|
|
10845
|
-
description:
|
|
10846
|
-
You can shift issue time and due time of invoices for this
|
|
10847
|
-
subscription.
|
|
10851
|
+
description: |-
|
|
10852
|
+
You can shift issue time and due time of invoices for this subscription.
|
|
10848
10853
|
|
|
10849
|
-
This setting overrides plan settings.
|
|
10850
|
-
`null`.
|
|
10851
|
-
|
|
10852
|
-
To use multiple plans in one subscription they all must have the
|
|
10853
|
-
same billing period,
|
|
10854
|
+
This setting overrides plan settings.
|
|
10855
|
+
To use plan settings, set `null`.
|
|
10854
10856
|
|
|
10857
|
+
To use multiple plans in one subscription they all must have the same billing period,
|
|
10855
10858
|
this property allows to subscribe to different plans.
|
|
10856
10859
|
nullable: true
|
|
10860
|
+
type: object
|
|
10857
10861
|
example: null
|
|
10858
10862
|
allOf:
|
|
10859
10863
|
- $ref: '#/components/schemas/InvoiceTimeShift'
|
|
@@ -10898,19 +10902,21 @@ components:
|
|
|
10898
10902
|
type: integer
|
|
10899
10903
|
readOnly: true
|
|
10900
10904
|
renewalReminderTime:
|
|
10901
|
-
description: Time renewal reminder event will be triggered
|
|
10905
|
+
description: Time renewal reminder event will be triggered.
|
|
10902
10906
|
nullable: true
|
|
10903
|
-
|
|
10904
|
-
|
|
10907
|
+
type: string
|
|
10908
|
+
format: date-time
|
|
10909
|
+
readOnly: true
|
|
10905
10910
|
renewalReminderNumber:
|
|
10906
10911
|
description: Number of renewal reminder events triggered
|
|
10907
10912
|
type: integer
|
|
10908
10913
|
readOnly: true
|
|
10909
10914
|
trialReminderTime:
|
|
10910
|
-
description: Time renewal reminder event will be triggered
|
|
10915
|
+
description: Time renewal reminder event will be triggered.
|
|
10911
10916
|
nullable: true
|
|
10912
|
-
|
|
10913
|
-
|
|
10917
|
+
type: string
|
|
10918
|
+
format: date-time
|
|
10919
|
+
readOnly: true
|
|
10914
10920
|
trialReminderNumber:
|
|
10915
10921
|
description: Number of renewal reminder events triggered
|
|
10916
10922
|
type: integer
|
|
@@ -11807,10 +11813,12 @@ components:
|
|
|
11807
11813
|
paymentInstrument:
|
|
11808
11814
|
$ref: '#/components/schemas/PaymentInstrument'
|
|
11809
11815
|
billingAddress:
|
|
11810
|
-
description:
|
|
11811
|
-
Billing
|
|
11812
|
-
|
|
11816
|
+
description: |-
|
|
11817
|
+
Billing address.
|
|
11818
|
+
If not supplied, the billing address associated
|
|
11819
|
+
with the payment instrument is used, and then customer.
|
|
11813
11820
|
nullable: true
|
|
11821
|
+
type: object
|
|
11814
11822
|
allOf:
|
|
11815
11823
|
- $ref: '#/components/schemas/ContactObject'
|
|
11816
11824
|
requestId:
|