@redocly/openapi-core 1.0.0-beta.104 → 1.0.0-beta.107
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/README.md +4 -4
- package/__tests__/utils.ts +8 -6
- package/lib/benchmark/benches/recommended-oas3.bench.js +1 -1
- package/lib/benchmark/utils.d.ts +2 -2
- package/lib/benchmark/utils.js +2 -2
- package/lib/bundle.d.ts +2 -2
- package/lib/bundle.js +2 -2
- package/lib/config/all.d.ts +2 -2
- package/lib/config/all.js +1 -1
- package/lib/config/builtIn.d.ts +2 -2
- package/lib/config/builtIn.js +2 -2
- package/lib/config/config-resolvers.d.ts +5 -5
- package/lib/config/config-resolvers.js +39 -36
- package/lib/config/config.d.ts +6 -5
- package/lib/config/config.js +27 -20
- package/lib/config/load.js +6 -7
- package/lib/config/minimal.d.ts +2 -2
- package/lib/config/minimal.js +3 -2
- package/lib/config/recommended.d.ts +2 -2
- package/lib/config/recommended.js +3 -2
- package/lib/config/rules.d.ts +2 -2
- package/lib/config/rules.js +1 -1
- package/lib/config/types.d.ts +23 -19
- package/lib/config/utils.d.ts +5 -5
- package/lib/config/utils.js +43 -26
- package/lib/decorators/common/remove-x-internal.js +2 -2
- package/lib/format/format.js +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.js +3 -2
- package/lib/js-yaml/index.js +1 -6
- package/lib/lint.d.ts +2 -2
- package/lib/lint.js +16 -6
- package/lib/redocly/registry-api.d.ts +1 -1
- package/lib/redocly/registry-api.js +2 -2
- package/lib/rules/ajv.d.ts +1 -1
- package/lib/rules/ajv.js +6 -6
- package/lib/rules/common/info-license-url.d.ts +1 -1
- package/lib/rules/common/info-license-url.js +5 -10
- package/lib/rules/common/info-license.d.ts +2 -0
- package/lib/rules/common/info-license.js +17 -0
- package/lib/rules/common/no-enum-type-mismatch.js +1 -3
- package/lib/rules/common/no-invalid-parameter-examples.js +3 -3
- package/lib/rules/common/no-invalid-schema-examples.js +3 -3
- package/lib/rules/common/operation-operationId.js +1 -1
- package/lib/rules/common/path-not-include-query.js +1 -1
- package/lib/rules/common/paths-kebab-case.js +4 -1
- package/lib/rules/common/spec.js +1 -1
- package/lib/rules/oas2/index.js +4 -4
- package/lib/rules/oas2/remove-unused-components.js +3 -3
- package/lib/rules/oas3/index.js +4 -4
- package/lib/rules/oas3/no-empty-servers.js +1 -1
- package/lib/rules/oas3/no-invalid-media-type-examples.js +2 -2
- package/lib/rules/oas3/remove-unused-components.js +2 -2
- package/lib/rules/other/stats.js +43 -14
- package/lib/rules/utils.d.ts +3 -2
- package/lib/rules/utils.js +19 -4
- package/lib/types/index.d.ts +2 -2
- package/lib/types/redocly-yaml.js +8 -7
- package/lib/utils.d.ts +5 -2
- package/lib/utils.js +20 -2
- package/lib/walk.d.ts +2 -1
- package/lib/walk.js +6 -3
- package/package.json +2 -2
- package/src/__tests__/__snapshots__/bundle.test.ts.snap +141 -0
- package/src/__tests__/bundle.test.ts +68 -34
- package/src/__tests__/codeframes.test.ts +13 -14
- package/src/__tests__/fixtures/.redocly.lint-ignore.yaml +5 -0
- package/src/__tests__/js-yaml.test.ts +6 -4
- package/src/__tests__/lint.test.ts +127 -12
- package/src/__tests__/login.test.ts +2 -2
- package/src/__tests__/normalizeVisitors.test.ts +4 -4
- package/src/__tests__/ref-utils.test.ts +13 -13
- package/src/__tests__/resolve-http.test.ts +1 -1
- package/src/__tests__/resolve.test.ts +14 -11
- package/src/__tests__/utils.test.ts +42 -1
- package/src/__tests__/walk.test.ts +48 -56
- package/src/benchmark/benches/lint-with-many-rules.bench.ts +1 -1
- package/src/benchmark/benches/lint-with-nested-rule.bench.ts +1 -1
- package/src/benchmark/benches/lint-with-no-rules.bench.ts +1 -1
- package/src/benchmark/benches/lint-with-top-level-rule-report.bench.ts +1 -1
- package/src/benchmark/benches/lint-with-top-level-rule.bench.ts +1 -1
- package/src/benchmark/benches/recommended-oas3.bench.ts +3 -3
- package/src/benchmark/benches/resolve-with-no-external.bench.ts +1 -1
- package/src/benchmark/benchmark.js +9 -5
- package/src/benchmark/utils.ts +5 -5
- package/src/bundle.ts +18 -17
- package/src/config/__tests__/__snapshots__/config-resolvers.test.ts.snap +3 -1
- package/src/config/__tests__/config-resolvers.test.ts +123 -121
- package/src/config/__tests__/config.test.ts +76 -76
- package/src/config/__tests__/fixtures/resolve-config/api/plugin.js +4 -2
- package/src/config/__tests__/fixtures/resolve-config/plugin.js +4 -1
- package/src/config/__tests__/load.test.ts +2 -2
- package/src/config/__tests__/resolve-plugins.test.ts +3 -3
- package/src/config/__tests__/utils.test.ts +83 -0
- package/src/config/all.ts +3 -4
- package/src/config/builtIn.ts +5 -5
- package/src/config/config-resolvers.ts +122 -83
- package/src/config/config.ts +36 -32
- package/src/config/load.ts +13 -16
- package/src/config/minimal.ts +5 -4
- package/src/config/recommended.ts +5 -4
- package/src/config/rules.ts +6 -6
- package/src/config/types.ts +28 -19
- package/src/config/utils.ts +74 -54
- package/src/decorators/__tests__/filter-out.test.ts +8 -4
- package/src/decorators/__tests__/remove-x-internal.test.ts +5 -5
- package/src/decorators/common/filters/filter-helper.ts +1 -1
- package/src/decorators/common/info-description-override.ts +1 -1
- package/src/decorators/common/operation-description-override.ts +1 -1
- package/src/decorators/common/remove-x-internal.ts +4 -4
- package/src/decorators/common/tag-description-override.ts +1 -1
- package/src/format/codeframes.ts +4 -4
- package/src/format/format.ts +10 -10
- package/src/index.ts +3 -4
- package/src/js-yaml/index.ts +3 -8
- package/src/lint.ts +22 -18
- package/src/oas-types.ts +1 -6
- package/src/redocly/__tests__/redocly-client.test.ts +25 -19
- package/src/redocly/index.ts +6 -4
- package/src/redocly/registry-api.ts +6 -6
- package/src/ref-utils.ts +2 -2
- package/src/resolve.ts +7 -4
- package/src/rules/__tests__/no-unresolved-refs.test.ts +4 -4
- package/src/rules/__tests__/utils.test.ts +160 -0
- package/src/rules/ajv.ts +7 -8
- package/src/rules/common/__tests__/info-description.test.ts +3 -3
- package/src/rules/common/__tests__/info-license.test.ts +2 -2
- package/src/rules/common/__tests__/license-url.test.ts +2 -2
- package/src/rules/common/__tests__/no-ambiguous-paths.test.ts +1 -1
- package/src/rules/common/__tests__/no-enum-type-mismatch.test.ts +8 -8
- package/src/rules/common/__tests__/no-identical-paths.test.ts +1 -1
- package/src/rules/common/__tests__/no-path-trailing-slash.test.ts +3 -3
- package/src/rules/common/__tests__/operation-2xx-response.test.ts +3 -3
- package/src/rules/common/__tests__/operation-4xx-response.test.ts +3 -3
- package/src/rules/common/__tests__/operation-operationId-unique.test.ts +2 -2
- package/src/rules/common/__tests__/operation-operationId-url-safe.test.ts +1 -1
- package/src/rules/common/__tests__/operation-parameters-unique.test.ts +4 -4
- package/src/rules/common/__tests__/operation-security-defined.test.ts +2 -2
- package/src/rules/common/__tests__/operation-singular-tag.test.ts +2 -2
- package/src/rules/common/__tests__/path-http-verbs-order.test.ts +2 -2
- package/src/rules/common/__tests__/path-not-include-query.test.ts +2 -2
- package/src/rules/common/__tests__/path-params-defined.test.ts +3 -3
- package/src/rules/common/__tests__/paths-kebab-case.test.ts +15 -15
- package/src/rules/common/__tests__/scalar-property-missing-example.test.ts +8 -8
- package/src/rules/common/__tests__/spec.test.ts +2 -2
- package/src/rules/common/__tests__/tag-description.test.ts +2 -2
- package/src/rules/common/__tests__/tags-alphabetical.test.ts +2 -2
- package/src/rules/common/assertions/__tests__/asserts.test.ts +513 -130
- package/src/rules/common/assertions/index.ts +6 -6
- package/src/rules/common/info-license-url.ts +4 -9
- package/src/rules/common/info-license.ts +15 -0
- package/src/rules/common/no-ambiguous-paths.ts +1 -1
- package/src/rules/common/no-enum-type-mismatch.ts +12 -9
- package/src/rules/common/no-invalid-parameter-examples.ts +4 -4
- package/src/rules/common/no-invalid-schema-examples.ts +4 -4
- package/src/rules/common/operation-operationId.ts +1 -1
- package/src/rules/common/operation-parameters-unique.ts +2 -2
- package/src/rules/common/path-not-include-query.ts +1 -1
- package/src/rules/common/path-params-defined.ts +1 -1
- package/src/rules/common/paths-kebab-case.ts +4 -1
- package/src/rules/common/scalar-property-missing-example.ts +1 -1
- package/src/rules/common/spec.ts +10 -7
- package/src/rules/no-unresolved-refs.ts +1 -1
- package/src/rules/oas2/__tests__/boolean-parameter-prefixes.test.ts +3 -3
- package/src/rules/oas2/__tests__/spec/info.test.ts +12 -12
- package/src/rules/oas2/__tests__/spec/operation.test.ts +4 -4
- package/src/rules/oas2/__tests__/spec/paths.test.ts +10 -10
- package/src/rules/oas2/__tests__/spec/referenceableScalars.test.ts +6 -2
- package/src/rules/oas2/__tests__/spec/utils.ts +6 -6
- package/src/rules/oas2/index.ts +3 -3
- package/src/rules/oas2/remove-unused-components.ts +13 -8
- package/src/rules/oas3/__tests__/boolean-parameter-prefixes.test.ts +3 -3
- package/src/rules/oas3/__tests__/no-example-value-and-externalValue.test.ts +2 -2
- package/src/rules/oas3/__tests__/no-invalid-media-type-examples.test.ts +13 -13
- package/src/rules/oas3/__tests__/no-server-example.com.test.ts +2 -2
- package/src/rules/oas3/__tests__/no-server-trailing-slash.test.ts +3 -3
- package/src/rules/oas3/__tests__/no-unused-components.test.ts +1 -1
- package/src/rules/oas3/__tests__/spec/callbacks.test.ts +1 -1
- package/src/rules/oas3/__tests__/spec/info.test.ts +12 -12
- package/src/rules/oas3/__tests__/spec/operation.test.ts +8 -8
- package/src/rules/oas3/__tests__/spec/paths.test.ts +10 -10
- package/src/rules/oas3/__tests__/spec/referenceableScalars.test.ts +12 -12
- package/src/rules/oas3/__tests__/spec/servers.test.ts +15 -15
- package/src/rules/oas3/__tests__/spec/spec.test.ts +6 -6
- package/src/rules/oas3/__tests__/spec/utils.ts +6 -6
- package/src/rules/oas3/index.ts +3 -3
- package/src/rules/oas3/no-empty-servers.ts +1 -1
- package/src/rules/oas3/no-invalid-media-type-examples.ts +14 -6
- package/src/rules/oas3/no-servers-empty-enum.ts +9 -10
- package/src/rules/oas3/remove-unused-components.ts +18 -7
- package/src/rules/other/stats.ts +46 -17
- package/src/rules/utils.ts +19 -3
- package/src/types/index.ts +5 -5
- package/src/types/redocly-yaml.ts +8 -7
- package/src/typings/common.ts +9 -1
- package/src/typings/openapi.ts +1 -1
- package/src/utils.ts +31 -8
- package/src/visitors.ts +4 -4
- package/src/walk.ts +15 -11
- package/tsconfig.tsbuildinfo +1 -1
- package/lib/rules/common/license-url.d.ts +0 -2
- package/lib/rules/common/license-url.js +0 -12
- package/src/rules/common/license-url.ts +0 -10
package/lib/config/types.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export declare type PreprocessorConfig = PreprocessorSeverity | ({
|
|
|
10
10
|
severity?: ProblemSeverity;
|
|
11
11
|
} & Record<string, any>);
|
|
12
12
|
export declare type DecoratorConfig = PreprocessorConfig;
|
|
13
|
-
export declare type
|
|
13
|
+
export declare type StyleguideRawConfig = {
|
|
14
14
|
plugins?: (string | Plugin)[];
|
|
15
15
|
extends?: string[];
|
|
16
16
|
doNotResolveExamples?: boolean;
|
|
@@ -28,7 +28,8 @@ export declare type LintRawConfig = {
|
|
|
28
28
|
oas3_0Decorators?: Record<string, DecoratorConfig>;
|
|
29
29
|
oas3_1Decorators?: Record<string, DecoratorConfig>;
|
|
30
30
|
};
|
|
31
|
-
export declare type
|
|
31
|
+
export declare type ApiStyleguideRawConfig = Omit<StyleguideRawConfig, 'plugins'>;
|
|
32
|
+
export declare type ResolvedStyleguideConfig = PluginStyleguideConfig & {
|
|
32
33
|
plugins?: Plugin[];
|
|
33
34
|
recommendedFallback?: boolean;
|
|
34
35
|
extends?: void | never;
|
|
@@ -51,13 +52,13 @@ export declare type CustomRulesConfig = {
|
|
|
51
52
|
};
|
|
52
53
|
export declare type Plugin = {
|
|
53
54
|
id: string;
|
|
54
|
-
configs?: Record<string,
|
|
55
|
+
configs?: Record<string, PluginStyleguideConfig>;
|
|
55
56
|
rules?: CustomRulesConfig;
|
|
56
57
|
preprocessors?: PreprocessorsConfig;
|
|
57
58
|
decorators?: DecoratorsConfig;
|
|
58
59
|
typeExtension?: TypeExtensionsConfig;
|
|
59
60
|
};
|
|
60
|
-
export declare type
|
|
61
|
+
export declare type PluginStyleguideConfig = Omit<StyleguideRawConfig, 'plugins' | 'extends'>;
|
|
61
62
|
export declare type ResolveHeader = {
|
|
62
63
|
name: string;
|
|
63
64
|
envVariable?: undefined;
|
|
@@ -83,33 +84,36 @@ export declare type Region = 'us' | 'eu';
|
|
|
83
84
|
export declare type AccessTokens = {
|
|
84
85
|
[region in Region]?: string;
|
|
85
86
|
};
|
|
86
|
-
export declare type
|
|
87
|
+
export declare type DeprecatedInRawConfig = {
|
|
87
88
|
apiDefinitions?: Record<string, string>;
|
|
88
|
-
lint?:
|
|
89
|
-
resolve?: RawResolveConfig;
|
|
90
|
-
region?: Region;
|
|
89
|
+
lint?: StyleguideRawConfig;
|
|
91
90
|
referenceDocs?: Record<string, any>;
|
|
91
|
+
apis?: Record<string, Api & DeprecatedInApi>;
|
|
92
92
|
};
|
|
93
93
|
export declare type Api = {
|
|
94
94
|
root: string;
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
95
|
+
styleguide?: ApiStyleguideRawConfig;
|
|
96
|
+
} & FeaturesConfig;
|
|
97
|
+
export declare type DeprecatedInApi = {
|
|
98
|
+
lint?: ApiStyleguideRawConfig;
|
|
98
99
|
};
|
|
99
|
-
export declare type ResolvedApi = Omit<Api, '
|
|
100
|
-
|
|
100
|
+
export declare type ResolvedApi = Omit<Api, 'styleguide'> & {
|
|
101
|
+
styleguide: ResolvedStyleguideConfig;
|
|
101
102
|
};
|
|
102
103
|
export declare type RawConfig = {
|
|
103
104
|
apis?: Record<string, Api>;
|
|
104
|
-
|
|
105
|
+
styleguide?: StyleguideRawConfig;
|
|
105
106
|
resolve?: RawResolveConfig;
|
|
106
107
|
region?: Region;
|
|
107
|
-
'features.openapi'?: Record<string, any>;
|
|
108
|
-
'features.mockServer'?: Record<string, any>;
|
|
109
108
|
organization?: string;
|
|
110
|
-
};
|
|
111
|
-
export declare type ResolvedConfig = Omit<RawConfig, '
|
|
112
|
-
lint: ResolvedLintConfig;
|
|
109
|
+
} & FeaturesConfig;
|
|
110
|
+
export declare type ResolvedConfig = Omit<RawConfig, 'apis' | 'styleguide'> & {
|
|
113
111
|
apis: Record<string, ResolvedApi>;
|
|
112
|
+
styleguide: ResolvedStyleguideConfig;
|
|
113
|
+
};
|
|
114
|
+
declare type FeaturesConfig = {
|
|
115
|
+
'features.openapi'?: Record<string, any>;
|
|
116
|
+
'features.mockServer'?: Record<string, any>;
|
|
114
117
|
};
|
|
115
118
|
export declare type RulesFields = 'rules' | 'oas2Rules' | 'oas3_0Rules' | 'oas3_1Rules' | 'preprocessors' | 'oas2Preprocessors' | 'oas3_0Preprocessors' | 'oas3_1Preprocessors' | 'decorators' | 'oas2Decorators' | 'oas3_0Decorators' | 'oas3_1Decorators';
|
|
119
|
+
export {};
|
package/lib/config/utils.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Config } from './config';
|
|
2
|
-
import type { Api,
|
|
2
|
+
import type { Api, DeprecatedInRawConfig, Plugin, RawConfig, RawResolveConfig, ResolveConfig, ResolvedStyleguideConfig, RulesFields } from './types';
|
|
3
3
|
export declare function parsePresetName(presetName: string): {
|
|
4
4
|
pluginId: string;
|
|
5
5
|
configName: string;
|
|
6
6
|
};
|
|
7
|
-
export declare function transformApiDefinitionsToApis(apiDefinitions?:
|
|
7
|
+
export declare function transformApiDefinitionsToApis(apiDefinitions?: DeprecatedInRawConfig['apiDefinitions']): Record<string, Api> | undefined;
|
|
8
8
|
export declare function prefixRules<T extends Record<string, any>>(rules: T, prefix: string): any;
|
|
9
|
-
export declare function mergeExtends(rulesConfList:
|
|
10
|
-
export declare function getMergedConfig(config: Config,
|
|
11
|
-
export declare function transformConfig(rawConfig:
|
|
9
|
+
export declare function mergeExtends(rulesConfList: ResolvedStyleguideConfig[]): Omit<ResolvedStyleguideConfig, RulesFields> & Required<Pick<ResolvedStyleguideConfig, RulesFields>>;
|
|
10
|
+
export declare function getMergedConfig(config: Config, apiName?: string): Config;
|
|
11
|
+
export declare function transformConfig(rawConfig: DeprecatedInRawConfig & RawConfig): RawConfig;
|
|
12
12
|
export declare function getResolveConfig(resolve?: RawResolveConfig): ResolveConfig;
|
|
13
13
|
export declare function getUniquePlugins(plugins: Plugin[]): Plugin[];
|
package/lib/config/utils.js
CHANGED
|
@@ -25,14 +25,26 @@ function parsePresetName(presetName) {
|
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
exports.parsePresetName = parsePresetName;
|
|
28
|
-
function transformApiDefinitionsToApis(apiDefinitions
|
|
29
|
-
|
|
28
|
+
function transformApiDefinitionsToApis(apiDefinitions) {
|
|
29
|
+
if (!apiDefinitions)
|
|
30
|
+
return undefined;
|
|
31
|
+
const apis = {};
|
|
30
32
|
for (const [apiName, apiPath] of Object.entries(apiDefinitions)) {
|
|
31
33
|
apis[apiName] = { root: apiPath };
|
|
32
34
|
}
|
|
33
35
|
return apis;
|
|
34
36
|
}
|
|
35
37
|
exports.transformApiDefinitionsToApis = transformApiDefinitionsToApis;
|
|
38
|
+
function transformApis(legacyApis) {
|
|
39
|
+
if (!legacyApis)
|
|
40
|
+
return undefined;
|
|
41
|
+
const apis = {};
|
|
42
|
+
for (let _a of Object.entries(legacyApis)) {
|
|
43
|
+
const [apiName, _b] = _a, { lint } = _b, apiContent = __rest(_b, ["lint"]);
|
|
44
|
+
apis[apiName] = Object.assign({ styleguide: lint }, apiContent);
|
|
45
|
+
}
|
|
46
|
+
return apis;
|
|
47
|
+
}
|
|
36
48
|
function prefixRules(rules, prefix) {
|
|
37
49
|
if (!prefix)
|
|
38
50
|
return rules;
|
|
@@ -63,7 +75,7 @@ function mergeExtends(rulesConfList) {
|
|
|
63
75
|
};
|
|
64
76
|
for (let rulesConf of rulesConfList) {
|
|
65
77
|
if (rulesConf.extends) {
|
|
66
|
-
throw new Error(
|
|
78
|
+
throw new Error(`'extends' is not supported in shared configs yet: ${JSON.stringify(rulesConf, null, 2)}.`);
|
|
67
79
|
}
|
|
68
80
|
Object.assign(result.rules, rulesConf.rules);
|
|
69
81
|
Object.assign(result.oas2Rules, rulesConf.oas2Rules);
|
|
@@ -93,44 +105,49 @@ function mergeExtends(rulesConfList) {
|
|
|
93
105
|
return result;
|
|
94
106
|
}
|
|
95
107
|
exports.mergeExtends = mergeExtends;
|
|
96
|
-
function getMergedConfig(config,
|
|
108
|
+
function getMergedConfig(config, apiName) {
|
|
97
109
|
var _a, _b, _c, _d, _e, _f;
|
|
98
110
|
const extendPaths = [
|
|
99
|
-
...Object.values(config.apis).map((api) => { var _a; return (_a = api === null || api === void 0 ? void 0 : api.
|
|
100
|
-
(_b = (_a = config.rawConfig) === null || _a === void 0 ? void 0 : _a.
|
|
111
|
+
...Object.values(config.apis).map((api) => { var _a; return (_a = api === null || api === void 0 ? void 0 : api.styleguide) === null || _a === void 0 ? void 0 : _a.extendPaths; }),
|
|
112
|
+
(_b = (_a = config.rawConfig) === null || _a === void 0 ? void 0 : _a.styleguide) === null || _b === void 0 ? void 0 : _b.extendPaths,
|
|
101
113
|
]
|
|
102
114
|
.flat()
|
|
103
115
|
.filter(Boolean);
|
|
104
116
|
const pluginPaths = [
|
|
105
|
-
...Object.values(config.apis).map((api) => { var _a; return (_a = api === null || api === void 0 ? void 0 : api.
|
|
106
|
-
(_d = (_c = config.rawConfig) === null || _c === void 0 ? void 0 : _c.
|
|
117
|
+
...Object.values(config.apis).map((api) => { var _a; return (_a = api === null || api === void 0 ? void 0 : api.styleguide) === null || _a === void 0 ? void 0 : _a.pluginPaths; }),
|
|
118
|
+
(_d = (_c = config.rawConfig) === null || _c === void 0 ? void 0 : _c.styleguide) === null || _d === void 0 ? void 0 : _d.pluginPaths,
|
|
107
119
|
]
|
|
108
120
|
.flat()
|
|
109
121
|
.filter(Boolean);
|
|
110
|
-
return
|
|
111
|
-
? new config_1.Config(Object.assign(Object.assign({}, config.rawConfig), {
|
|
112
|
-
? config.apis[
|
|
113
|
-
: config.rawConfig.
|
|
114
|
-
pluginPaths }), 'features.openapi': Object.assign(Object.assign({}, config['features.openapi']), (_e = config.apis[
|
|
122
|
+
return apiName
|
|
123
|
+
? new config_1.Config(Object.assign(Object.assign({}, config.rawConfig), { styleguide: Object.assign(Object.assign({}, (config.apis[apiName]
|
|
124
|
+
? config.apis[apiName].styleguide
|
|
125
|
+
: config.rawConfig.styleguide)), { extendPaths,
|
|
126
|
+
pluginPaths }), 'features.openapi': Object.assign(Object.assign({}, config['features.openapi']), (_e = config.apis[apiName]) === null || _e === void 0 ? void 0 : _e['features.openapi']), 'features.mockServer': Object.assign(Object.assign({}, config['features.mockServer']), (_f = config.apis[apiName]) === null || _f === void 0 ? void 0 : _f['features.mockServer']) }), config.configFile)
|
|
115
127
|
: config;
|
|
116
128
|
}
|
|
117
129
|
exports.getMergedConfig = getMergedConfig;
|
|
118
|
-
function
|
|
119
|
-
|
|
120
|
-
|
|
130
|
+
function checkForDeprecatedFields(deprecatedField, updatedField, rawConfig) {
|
|
131
|
+
const isDeprecatedFieldInApis = rawConfig.apis &&
|
|
132
|
+
Object.values(rawConfig.apis).some((api) => api[deprecatedField]);
|
|
133
|
+
if (rawConfig[deprecatedField] && rawConfig[updatedField]) {
|
|
134
|
+
utils_1.showErrorForDeprecatedField(deprecatedField, updatedField);
|
|
121
135
|
}
|
|
122
|
-
if (rawConfig[
|
|
123
|
-
|
|
124
|
-
throw new Error("Do not use 'referenceDocs' field. Use 'features.openapi' instead.\n");
|
|
136
|
+
if (rawConfig[deprecatedField] || isDeprecatedFieldInApis) {
|
|
137
|
+
utils_1.showWarningForDeprecatedField(deprecatedField, updatedField);
|
|
125
138
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
139
|
+
}
|
|
140
|
+
function transformConfig(rawConfig) {
|
|
141
|
+
const migratedFields = [
|
|
142
|
+
['apiDefinitions', 'apis'],
|
|
143
|
+
['referenceDocs', 'features.openapi'],
|
|
144
|
+
['lint', 'styleguide'], // TODO: update docs
|
|
145
|
+
];
|
|
146
|
+
for (const [deprecatedField, updatedField] of migratedFields) {
|
|
147
|
+
checkForDeprecatedFields(deprecatedField, updatedField, rawConfig);
|
|
132
148
|
}
|
|
133
|
-
|
|
149
|
+
const { apis, apiDefinitions, referenceDocs, lint } = rawConfig, rest = __rest(rawConfig, ["apis", "apiDefinitions", "referenceDocs", "lint"]);
|
|
150
|
+
return Object.assign({ 'features.openapi': referenceDocs, apis: transformApis(apis) || transformApiDefinitionsToApis(apiDefinitions), styleguide: lint }, rest);
|
|
134
151
|
}
|
|
135
152
|
exports.transformConfig = transformConfig;
|
|
136
153
|
function getResolveConfig(resolve) {
|
package/lib/format/format.js
CHANGED
|
@@ -167,7 +167,7 @@ function formatProblems(problems, opts) {
|
|
|
167
167
|
function formatStylish(problem, locationPad, ruleIdPad) {
|
|
168
168
|
const color = COLORS[problem.severity];
|
|
169
169
|
if (!SEVERITY_NAMES[problem.severity]) {
|
|
170
|
-
return 'Error not found severity. Please check your config file. Allowed values:
|
|
170
|
+
return 'Error not found severity. Please check your config file. Allowed values: `warn,error,off`';
|
|
171
171
|
}
|
|
172
172
|
const severityName = color(SEVERITY_NAMES[problem.severity].toLowerCase().padEnd(7));
|
|
173
173
|
const { start } = problem.location[0];
|
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { BundleOutputFormat, readFileFromUrl, slash } from './utils';
|
|
1
|
+
export { BundleOutputFormat, readFileFromUrl, slash, doesYamlFileExist } from './utils';
|
|
2
2
|
export { Oas3_1Types } from './types/oas3_1';
|
|
3
3
|
export { Oas3Types } from './types/oas3';
|
|
4
4
|
export { Oas2Types } from './types/oas2';
|
|
@@ -8,7 +8,7 @@ export { Oas2Definition } from './typings/swagger';
|
|
|
8
8
|
export { StatsAccumulator, StatsName } from './typings/common';
|
|
9
9
|
export { normalizeTypes } from './types';
|
|
10
10
|
export { Stats } from './rules/other/stats';
|
|
11
|
-
export { Config,
|
|
11
|
+
export { Config, StyleguideConfig, RawConfig, IGNORE_FILE, Region, getMergedConfig, transformConfig, loadConfig, getConfig, findConfig, CONFIG_FILE_NAMES, RuleSeverity, } from './config';
|
|
12
12
|
export { RedoclyClient, isRedoclyRegistryURL } from './redocly';
|
|
13
13
|
export { Source, BaseResolver, Document, resolveDocument, ResolveError, YamlParseError, makeDocumentFromString, } from './resolve';
|
|
14
14
|
export { parseYaml, stringifyYaml } from './js-yaml';
|
package/lib/index.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mapTypeToComponent = exports.bundleDocument = exports.bundle = exports.lintConfig = exports.lintFromString = exports.lintDocument = exports.validate = exports.lint = exports.getTotals = exports.formatProblems = exports.getLineColLocation = exports.getAstNodeByPointer = exports.walkDocument = exports.normalizeVisitors = exports.OasVersion = exports.openAPIMajor = exports.OasMajorVersion = exports.detectOpenAPI = exports.isRef = exports.unescapePointer = exports.stringifyYaml = exports.parseYaml = exports.makeDocumentFromString = exports.YamlParseError = exports.ResolveError = exports.resolveDocument = exports.BaseResolver = exports.Source = exports.isRedoclyRegistryURL = exports.RedoclyClient = exports.CONFIG_FILE_NAMES = exports.findConfig = exports.getConfig = exports.loadConfig = exports.transformConfig = exports.getMergedConfig = exports.IGNORE_FILE = exports.
|
|
3
|
+
exports.mapTypeToComponent = exports.bundleDocument = exports.bundle = exports.lintConfig = exports.lintFromString = exports.lintDocument = exports.validate = exports.lint = exports.getTotals = exports.formatProblems = exports.getLineColLocation = exports.getAstNodeByPointer = exports.walkDocument = exports.normalizeVisitors = exports.OasVersion = exports.openAPIMajor = exports.OasMajorVersion = exports.detectOpenAPI = exports.isRef = exports.unescapePointer = exports.stringifyYaml = exports.parseYaml = exports.makeDocumentFromString = exports.YamlParseError = exports.ResolveError = exports.resolveDocument = exports.BaseResolver = exports.Source = exports.isRedoclyRegistryURL = exports.RedoclyClient = 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.Oas2Types = exports.Oas3Types = exports.Oas3_1Types = exports.doesYamlFileExist = exports.slash = exports.readFileFromUrl = void 0;
|
|
4
4
|
var utils_1 = require("./utils");
|
|
5
5
|
Object.defineProperty(exports, "readFileFromUrl", { enumerable: true, get: function () { return utils_1.readFileFromUrl; } });
|
|
6
6
|
Object.defineProperty(exports, "slash", { enumerable: true, get: function () { return utils_1.slash; } });
|
|
7
|
+
Object.defineProperty(exports, "doesYamlFileExist", { enumerable: true, get: function () { return utils_1.doesYamlFileExist; } });
|
|
7
8
|
var oas3_1_1 = require("./types/oas3_1");
|
|
8
9
|
Object.defineProperty(exports, "Oas3_1Types", { enumerable: true, get: function () { return oas3_1_1.Oas3_1Types; } });
|
|
9
10
|
var oas3_1 = require("./types/oas3");
|
|
@@ -18,7 +19,7 @@ var stats_1 = require("./rules/other/stats");
|
|
|
18
19
|
Object.defineProperty(exports, "Stats", { enumerable: true, get: function () { return stats_1.Stats; } });
|
|
19
20
|
var config_1 = require("./config");
|
|
20
21
|
Object.defineProperty(exports, "Config", { enumerable: true, get: function () { return config_1.Config; } });
|
|
21
|
-
Object.defineProperty(exports, "
|
|
22
|
+
Object.defineProperty(exports, "StyleguideConfig", { enumerable: true, get: function () { return config_1.StyleguideConfig; } });
|
|
22
23
|
Object.defineProperty(exports, "IGNORE_FILE", { enumerable: true, get: function () { return config_1.IGNORE_FILE; } });
|
|
23
24
|
Object.defineProperty(exports, "getMergedConfig", { enumerable: true, get: function () { return config_1.getMergedConfig; } });
|
|
24
25
|
Object.defineProperty(exports, "transformConfig", { enumerable: true, get: function () { return config_1.transformConfig; } });
|
package/lib/js-yaml/index.js
CHANGED
|
@@ -6,12 +6,7 @@ exports.stringifyYaml = exports.parseYaml = void 0;
|
|
|
6
6
|
const js_yaml_1 = require("js-yaml");
|
|
7
7
|
const DEFAULT_SCHEMA_WITHOUT_TIMESTAMP = js_yaml_1.JSON_SCHEMA.extend({
|
|
8
8
|
implicit: [js_yaml_1.types.merge],
|
|
9
|
-
explicit: [
|
|
10
|
-
js_yaml_1.types.binary,
|
|
11
|
-
js_yaml_1.types.omap,
|
|
12
|
-
js_yaml_1.types.pairs,
|
|
13
|
-
js_yaml_1.types.set,
|
|
14
|
-
],
|
|
9
|
+
explicit: [js_yaml_1.types.binary, js_yaml_1.types.omap, js_yaml_1.types.pairs, js_yaml_1.types.set],
|
|
15
10
|
});
|
|
16
11
|
const parseYaml = (str, opts) => js_yaml_1.load(str, Object.assign({ schema: DEFAULT_SCHEMA_WITHOUT_TIMESTAMP }, opts));
|
|
17
12
|
exports.parseYaml = parseYaml;
|
package/lib/lint.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BaseResolver, Document } from './resolve';
|
|
2
2
|
import { NodeType } from './types';
|
|
3
3
|
import { ProblemSeverity } from './walk';
|
|
4
|
-
import {
|
|
4
|
+
import { StyleguideConfig, Config } from './config';
|
|
5
5
|
export declare function lint(opts: {
|
|
6
6
|
ref: string;
|
|
7
7
|
config: Config;
|
|
@@ -15,7 +15,7 @@ export declare function lintFromString(opts: {
|
|
|
15
15
|
}): Promise<import("./walk").NormalizedProblem[]>;
|
|
16
16
|
export declare function lintDocument(opts: {
|
|
17
17
|
document: Document;
|
|
18
|
-
config:
|
|
18
|
+
config: StyleguideConfig;
|
|
19
19
|
customTypes?: Record<string, NodeType>;
|
|
20
20
|
externalRefResolver: BaseResolver;
|
|
21
21
|
}): Promise<import("./walk").NormalizedProblem[]>;
|
package/lib/lint.js
CHANGED
|
@@ -26,7 +26,7 @@ function lint(opts) {
|
|
|
26
26
|
return __awaiter(this, void 0, void 0, function* () {
|
|
27
27
|
const { ref, externalRefResolver = new resolve_1.BaseResolver(opts.config.resolve) } = opts;
|
|
28
28
|
const document = (yield externalRefResolver.resolveDocument(null, ref, true));
|
|
29
|
-
return lintDocument(Object.assign(Object.assign({ document }, opts), { externalRefResolver, config: opts.config.
|
|
29
|
+
return lintDocument(Object.assign(Object.assign({ document }, opts), { externalRefResolver, config: opts.config.styleguide }));
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
32
|
exports.lint = lint;
|
|
@@ -34,7 +34,7 @@ function lintFromString(opts) {
|
|
|
34
34
|
return __awaiter(this, void 0, void 0, function* () {
|
|
35
35
|
const { source, absoluteRef, externalRefResolver = new resolve_1.BaseResolver(opts.config.resolve) } = opts;
|
|
36
36
|
const document = resolve_1.makeDocumentFromString(source, absoluteRef || '/');
|
|
37
|
-
return lintDocument(Object.assign(Object.assign({ document }, opts), { externalRefResolver, config: opts.config.
|
|
37
|
+
return lintDocument(Object.assign(Object.assign({ document }, opts), { externalRefResolver, config: opts.config.styleguide }));
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
40
|
exports.lintFromString = lintFromString;
|
|
@@ -45,7 +45,11 @@ function lintDocument(opts) {
|
|
|
45
45
|
const oasVersion = oas_types_1.detectOpenAPI(document.parsed);
|
|
46
46
|
const oasMajorVersion = oas_types_1.openAPIMajor(oasVersion);
|
|
47
47
|
const rules = config.getRulesForOasVersion(oasMajorVersion);
|
|
48
|
-
const types = types_1.normalizeTypes(config.extendTypes((customTypes !== null && customTypes !== void 0 ? customTypes : oasMajorVersion === oas_types_1.OasMajorVersion.Version3)
|
|
48
|
+
const types = types_1.normalizeTypes(config.extendTypes((customTypes !== null && customTypes !== void 0 ? customTypes : oasMajorVersion === oas_types_1.OasMajorVersion.Version3)
|
|
49
|
+
? oasVersion === oas_types_1.OasVersion.Version3_1
|
|
50
|
+
? oas3_1_1.Oas3_1Types
|
|
51
|
+
: oas3_1.Oas3Types
|
|
52
|
+
: oas2_1.Oas2Types, oasVersion), config);
|
|
49
53
|
const ctx = {
|
|
50
54
|
problems: [],
|
|
51
55
|
oasVersion: oasVersion,
|
|
@@ -57,7 +61,7 @@ function lintDocument(opts) {
|
|
|
57
61
|
const resolvedRefMap = yield resolve_1.resolveDocument({
|
|
58
62
|
rootDocument: document,
|
|
59
63
|
rootType: types.DefinitionRoot,
|
|
60
|
-
externalRefResolver
|
|
64
|
+
externalRefResolver,
|
|
61
65
|
});
|
|
62
66
|
walk_1.walkDocument({
|
|
63
67
|
document,
|
|
@@ -79,12 +83,18 @@ function lintConfig(opts) {
|
|
|
79
83
|
visitorsData: {},
|
|
80
84
|
};
|
|
81
85
|
const plugins = config_1.resolvePlugins([config_1.defaultPlugin]);
|
|
82
|
-
const config = new config_1.
|
|
86
|
+
const config = new config_1.StyleguideConfig({
|
|
83
87
|
plugins,
|
|
84
88
|
rules: { spec: 'error' },
|
|
85
89
|
});
|
|
86
90
|
const types = types_1.normalizeTypes(redocly_yaml_1.ConfigTypes, config);
|
|
87
|
-
const rules = [
|
|
91
|
+
const rules = [
|
|
92
|
+
{
|
|
93
|
+
severity: severity || 'error',
|
|
94
|
+
ruleId: 'configuration spec',
|
|
95
|
+
visitor: spec_1.OasSpec({ severity: 'error' }),
|
|
96
|
+
},
|
|
97
|
+
];
|
|
88
98
|
const normalizedVisitors = visitors_1.normalizeVisitors(rules, types);
|
|
89
99
|
walk_1.walkDocument({
|
|
90
100
|
document,
|
|
@@ -13,5 +13,5 @@ export declare class RegistryApi {
|
|
|
13
13
|
organizations: string[];
|
|
14
14
|
}>;
|
|
15
15
|
prepareFileUpload({ organizationId, name, version, filesHash, filename, isUpsert, }: RegistryApiTypes.PrepareFileuploadParams): Promise<RegistryApiTypes.PrepareFileuploadOKResponse>;
|
|
16
|
-
pushApi({ organizationId, name, version, rootFilePath, filePaths, branch, isUpsert, isPublic, batchId, batchSize }: RegistryApiTypes.PushApiParams): Promise<void>;
|
|
16
|
+
pushApi({ organizationId, name, version, rootFilePath, filePaths, branch, isUpsert, isPublic, batchId, batchSize, }: RegistryApiTypes.PushApiParams): Promise<void>;
|
|
17
17
|
}
|
|
@@ -80,7 +80,7 @@ class RegistryApi {
|
|
|
80
80
|
throw new Error('Could not prepare file upload');
|
|
81
81
|
});
|
|
82
82
|
}
|
|
83
|
-
pushApi({ organizationId, name, version, rootFilePath, filePaths, branch, isUpsert, isPublic, batchId, batchSize }) {
|
|
83
|
+
pushApi({ organizationId, name, version, rootFilePath, filePaths, branch, isUpsert, isPublic, batchId, batchSize, }) {
|
|
84
84
|
return __awaiter(this, void 0, void 0, function* () {
|
|
85
85
|
const response = yield this.request(`/${organizationId}/${name}/${version}`, {
|
|
86
86
|
method: 'PUT',
|
|
@@ -95,7 +95,7 @@ class RegistryApi {
|
|
|
95
95
|
isUpsert,
|
|
96
96
|
isPublic,
|
|
97
97
|
batchId,
|
|
98
|
-
batchSize
|
|
98
|
+
batchSize,
|
|
99
99
|
}),
|
|
100
100
|
}, this.region);
|
|
101
101
|
if (response.ok) {
|
package/lib/rules/ajv.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { ErrorObject } from '@redocly/ajv';
|
|
|
2
2
|
import { Location } from '../ref-utils';
|
|
3
3
|
import { ResolveFn } from '../walk';
|
|
4
4
|
export declare function releaseAjvInstance(): void;
|
|
5
|
-
export declare function validateJsonSchema(data: any, schema: any, schemaLoc: Location, instancePath: string, resolve: ResolveFn,
|
|
5
|
+
export declare function validateJsonSchema(data: any, schema: any, schemaLoc: Location, instancePath: string, resolve: ResolveFn, allowAdditionalProperties: boolean): {
|
|
6
6
|
valid: boolean;
|
|
7
7
|
errors: (ErrorObject & {
|
|
8
8
|
suggest?: string[];
|
package/lib/rules/ajv.js
CHANGED
|
@@ -8,7 +8,7 @@ function releaseAjvInstance() {
|
|
|
8
8
|
ajvInstance = null;
|
|
9
9
|
}
|
|
10
10
|
exports.releaseAjvInstance = releaseAjvInstance;
|
|
11
|
-
function getAjv(resolve,
|
|
11
|
+
function getAjv(resolve, allowAdditionalProperties) {
|
|
12
12
|
if (!ajvInstance) {
|
|
13
13
|
ajvInstance = new ajv_1.default({
|
|
14
14
|
schemaId: '$id',
|
|
@@ -20,7 +20,7 @@ function getAjv(resolve, disallowAdditionalProperties) {
|
|
|
20
20
|
discriminator: true,
|
|
21
21
|
allowUnionTypes: true,
|
|
22
22
|
validateFormats: false,
|
|
23
|
-
defaultAdditionalProperties:
|
|
23
|
+
defaultAdditionalProperties: allowAdditionalProperties,
|
|
24
24
|
loadSchemaSync(base, $ref) {
|
|
25
25
|
const resolvedRef = resolve({ $ref }, base.split('#')[0]);
|
|
26
26
|
if (!resolvedRef || !resolvedRef.location)
|
|
@@ -32,15 +32,15 @@ function getAjv(resolve, disallowAdditionalProperties) {
|
|
|
32
32
|
}
|
|
33
33
|
return ajvInstance;
|
|
34
34
|
}
|
|
35
|
-
function getAjvValidator(schema, loc, resolve,
|
|
36
|
-
const ajv = getAjv(resolve,
|
|
35
|
+
function getAjvValidator(schema, loc, resolve, allowAdditionalProperties) {
|
|
36
|
+
const ajv = getAjv(resolve, allowAdditionalProperties);
|
|
37
37
|
if (!ajv.getSchema(loc.absolutePointer)) {
|
|
38
38
|
ajv.addSchema(Object.assign({ $id: loc.absolutePointer }, schema), loc.absolutePointer);
|
|
39
39
|
}
|
|
40
40
|
return ajv.getSchema(loc.absolutePointer);
|
|
41
41
|
}
|
|
42
|
-
function validateJsonSchema(data, schema, schemaLoc, instancePath, resolve,
|
|
43
|
-
const validate = getAjvValidator(schema, schemaLoc, resolve,
|
|
42
|
+
function validateJsonSchema(data, schema, schemaLoc, instancePath, resolve, allowAdditionalProperties) {
|
|
43
|
+
const validate = getAjvValidator(schema, schemaLoc, resolve, allowAdditionalProperties);
|
|
44
44
|
if (!validate)
|
|
45
45
|
return { valid: true, errors: [] }; // unresolved refs are reported
|
|
46
46
|
const valid = validate(data, {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Oas3Rule, Oas2Rule } from '../../visitors';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const InfoLicenseUrl: Oas3Rule | Oas2Rule;
|
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.InfoLicenseUrl = void 0;
|
|
4
4
|
const utils_1 = require("../utils");
|
|
5
|
-
const
|
|
5
|
+
const InfoLicenseUrl = () => {
|
|
6
6
|
return {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
report({
|
|
10
|
-
message: utils_1.missingRequiredField('Info', 'license'),
|
|
11
|
-
location: { reportOnKey: true }
|
|
12
|
-
});
|
|
13
|
-
}
|
|
7
|
+
License(license, ctx) {
|
|
8
|
+
utils_1.validateDefinedAndNonEmpty('url', license, ctx);
|
|
14
9
|
},
|
|
15
10
|
};
|
|
16
11
|
};
|
|
17
|
-
exports.
|
|
12
|
+
exports.InfoLicenseUrl = InfoLicenseUrl;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InfoLicense = void 0;
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
const InfoLicense = () => {
|
|
6
|
+
return {
|
|
7
|
+
Info(info, { report }) {
|
|
8
|
+
if (!info.license) {
|
|
9
|
+
report({
|
|
10
|
+
message: utils_1.missingRequiredField('Info', 'license'),
|
|
11
|
+
location: { reportOnKey: true },
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
exports.InfoLicense = InfoLicense;
|
|
@@ -28,14 +28,12 @@ const NoEnumTypeMismatch = () => {
|
|
|
28
28
|
if (mismatchedResults[enumValue].length !== schema.type.length)
|
|
29
29
|
delete mismatchedResults[enumValue];
|
|
30
30
|
}
|
|
31
|
-
;
|
|
32
31
|
for (const mismatchedKey of Object.keys(mismatchedResults)) {
|
|
33
32
|
report({
|
|
34
|
-
message: `Enum value \`${mismatchedKey}\` must be of
|
|
33
|
+
message: `Enum value \`${mismatchedKey}\` must be of allowed types: \`${schema.type}\`.`,
|
|
35
34
|
location: location.child(['enum', schema.enum.indexOf(mismatchedKey)]),
|
|
36
35
|
});
|
|
37
36
|
}
|
|
38
|
-
;
|
|
39
37
|
}
|
|
40
38
|
},
|
|
41
39
|
};
|
|
@@ -4,17 +4,17 @@ exports.NoInvalidParameterExamples = void 0;
|
|
|
4
4
|
const utils_1 = require("../utils");
|
|
5
5
|
const NoInvalidParameterExamples = (opts) => {
|
|
6
6
|
var _a;
|
|
7
|
-
const
|
|
7
|
+
const allowAdditionalProperties = (_a = utils_1.getAdditionalPropertiesOption(opts)) !== null && _a !== void 0 ? _a : false;
|
|
8
8
|
return {
|
|
9
9
|
Parameter: {
|
|
10
10
|
leave(parameter, ctx) {
|
|
11
11
|
if (parameter.example) {
|
|
12
|
-
utils_1.validateExample(parameter.example, parameter.schema, ctx.location.child('example'), ctx,
|
|
12
|
+
utils_1.validateExample(parameter.example, parameter.schema, ctx.location.child('example'), ctx, allowAdditionalProperties);
|
|
13
13
|
}
|
|
14
14
|
if (parameter.examples) {
|
|
15
15
|
for (const [key, example] of Object.entries(parameter.examples)) {
|
|
16
16
|
if ('value' in example) {
|
|
17
|
-
utils_1.validateExample(example.value, parameter.schema, ctx.location.child(['examples', key]), ctx,
|
|
17
|
+
utils_1.validateExample(example.value, parameter.schema, ctx.location.child(['examples', key]), ctx, true);
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
}
|
|
@@ -4,17 +4,17 @@ exports.NoInvalidSchemaExamples = void 0;
|
|
|
4
4
|
const utils_1 = require("../utils");
|
|
5
5
|
const NoInvalidSchemaExamples = (opts) => {
|
|
6
6
|
var _a;
|
|
7
|
-
const
|
|
7
|
+
const allowAdditionalProperties = (_a = utils_1.getAdditionalPropertiesOption(opts)) !== null && _a !== void 0 ? _a : false;
|
|
8
8
|
return {
|
|
9
9
|
Schema: {
|
|
10
10
|
leave(schema, ctx) {
|
|
11
11
|
if (schema.examples) {
|
|
12
12
|
for (const example of schema.examples) {
|
|
13
|
-
utils_1.validateExample(example, schema, ctx.location.child(['examples', schema.examples.indexOf(example)]), ctx,
|
|
13
|
+
utils_1.validateExample(example, schema, ctx.location.child(['examples', schema.examples.indexOf(example)]), ctx, allowAdditionalProperties);
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
if (schema.example) {
|
|
17
|
-
utils_1.validateExample(schema.example, schema, ctx.location.child('example'), ctx,
|
|
17
|
+
utils_1.validateExample(schema.example, schema, ctx.location.child('example'), ctx, true);
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
},
|
|
@@ -4,7 +4,10 @@ exports.PathsKebabCase = void 0;
|
|
|
4
4
|
const PathsKebabCase = () => {
|
|
5
5
|
return {
|
|
6
6
|
PathItem(_path, { report, key }) {
|
|
7
|
-
const segments = key
|
|
7
|
+
const segments = key
|
|
8
|
+
.substr(1)
|
|
9
|
+
.split('/')
|
|
10
|
+
.filter((s) => s !== ''); // filter out empty segments
|
|
8
11
|
if (!segments.every((segment) => /^{.+}$/.test(segment) || /^[a-z0-9-.]+$/.test(segment))) {
|
|
9
12
|
report({
|
|
10
13
|
message: `\`${key}\` does not use kebab-case.`,
|