@redocly/openapi-core 1.0.0-beta.103 → 1.0.0-beta.106
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 +1 -1
- package/lib/config/recommended.d.ts +2 -2
- package/lib/config/recommended.js +1 -1
- 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/filters/filter-helper.js +1 -1
- 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 +1 -1
- 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/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/remove-unused-components.js +2 -2
- package/lib/rules/other/stats.js +43 -14
- package/lib/rules/utils.d.ts +1 -1
- package/lib/rules/utils.js +4 -1
- package/lib/types/index.d.ts +2 -2
- package/lib/types/redocly-yaml.js +9 -7
- package/lib/utils.d.ts +3 -2
- package/lib/utils.js +11 -2
- package/lib/walk.d.ts +2 -14
- package/lib/walk.js +19 -19
- package/package.json +3 -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 +1 -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 +3 -3
- package/src/config/recommended.ts +3 -3
- package/src/config/rules.ts +6 -6
- package/src/config/types.ts +28 -19
- package/src/config/utils.ts +70 -50
- package/src/decorators/__tests__/filter-out.test.ts +113 -5
- 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 +122 -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 +2 -2
- package/src/rules/common/no-invalid-schema-examples.ts +1 -1
- 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 +8 -8
- 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 +12 -4
- 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 +5 -3
- package/src/types/index.ts +5 -5
- package/src/types/redocly-yaml.ts +9 -7
- package/src/typings/common.ts +9 -1
- package/src/typings/openapi.ts +1 -1
- package/src/utils.ts +18 -8
- package/src/visitors.ts +4 -4
- package/src/walk.ts +23 -31
- 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/README.md
CHANGED
|
@@ -9,9 +9,9 @@ See https://github.com/Redocly/redocly-cli
|
|
|
9
9
|
```js
|
|
10
10
|
import { formatProblems, lint, loadConfig } from '@redocly/openapi-core';
|
|
11
11
|
|
|
12
|
-
const
|
|
12
|
+
const pathToApi = 'openapi.yaml';
|
|
13
13
|
const config = loadConfig('optional/path/to/.redocly.yaml');
|
|
14
|
-
const lintResults = await lint({ ref:
|
|
14
|
+
const lintResults = await lint({ ref: pathToApi, config });
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
### Bundle
|
|
@@ -19,7 +19,7 @@ const lintResults = await lint({ ref: pathToEntryPoint, config });
|
|
|
19
19
|
```js
|
|
20
20
|
import { formatProblems, bundle, loadConfig } from '@redocly/openapi-core';
|
|
21
21
|
|
|
22
|
-
const
|
|
22
|
+
const pathToApi = 'openapi.yaml';
|
|
23
23
|
const config = loadConfig('optional/path/to/.redocly.yaml');
|
|
24
|
-
const { bundle, problems } = await bundle({ ref:
|
|
24
|
+
const { bundle, problems } = await bundle({ ref: pathToApi, config });
|
|
25
25
|
```
|
package/__tests__/utils.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as path from 'path';
|
|
2
2
|
|
|
3
3
|
import { Document, Source, NormalizedProblem, parseYaml, stringifyYaml } from '../src';
|
|
4
|
-
import {
|
|
4
|
+
import { StyleguideConfig, resolveStyleguideConfig, resolvePlugins } from '../src/config';
|
|
5
5
|
import { Oas3RuleSet } from '../src/oas-types';
|
|
6
6
|
|
|
7
7
|
import type { RuleConfig, Plugin, DecoratorConfig } from '../src/config';
|
|
@@ -48,7 +48,7 @@ export const yamlSerializer = {
|
|
|
48
48
|
export function makeConfigForRuleset(
|
|
49
49
|
rules: Oas3RuleSet,
|
|
50
50
|
plugin?: Partial<Plugin>,
|
|
51
|
-
version: string = 'oas3'
|
|
51
|
+
version: string = 'oas3'
|
|
52
52
|
) {
|
|
53
53
|
const rulesConf: Record<string, RuleConfig> = {};
|
|
54
54
|
const ruleId = 'test';
|
|
@@ -63,7 +63,7 @@ export function makeConfigForRuleset(
|
|
|
63
63
|
},
|
|
64
64
|
]);
|
|
65
65
|
|
|
66
|
-
return new
|
|
66
|
+
return new StyleguideConfig({
|
|
67
67
|
plugins,
|
|
68
68
|
rules: rulesConf,
|
|
69
69
|
});
|
|
@@ -72,15 +72,17 @@ export function makeConfigForRuleset(
|
|
|
72
72
|
export async function makeConfig(
|
|
73
73
|
rules: Record<string, RuleConfig>,
|
|
74
74
|
decorators?: Record<string, DecoratorConfig>,
|
|
75
|
+
configPath?: string
|
|
75
76
|
) {
|
|
76
|
-
return new
|
|
77
|
-
await
|
|
78
|
-
|
|
77
|
+
return new StyleguideConfig(
|
|
78
|
+
await resolveStyleguideConfig({
|
|
79
|
+
styleguideConfig: {
|
|
79
80
|
plugins: [],
|
|
80
81
|
extends: [],
|
|
81
82
|
rules,
|
|
82
83
|
decorators,
|
|
83
84
|
},
|
|
84
85
|
}),
|
|
86
|
+
configPath
|
|
85
87
|
);
|
|
86
88
|
}
|
|
@@ -15,7 +15,7 @@ function measureAsync() {
|
|
|
15
15
|
return lint_1.lintDocument({
|
|
16
16
|
externalRefResolver: new resolve_1.BaseResolver(),
|
|
17
17
|
document: rebillyDocument,
|
|
18
|
-
config: new config_1.
|
|
18
|
+
config: new config_1.StyleguideConfig(config_1.resolvePreset('recommended', [config_1.defaultPlugin])),
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
21
|
exports.measureAsync = measureAsync;
|
package/lib/benchmark/utils.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Document } from '../resolve';
|
|
2
2
|
import { Oas3RuleSet } from '../oas-types';
|
|
3
|
-
import {
|
|
3
|
+
import { StyleguideConfig } from '../config';
|
|
4
4
|
import type { Plugin } from '../config/types';
|
|
5
5
|
export declare function parseYamlToDocument(body: string, absoluteRef?: string): Document;
|
|
6
|
-
export declare function makeConfigForRuleset(rules: Oas3RuleSet, plugin?: Partial<Plugin>):
|
|
6
|
+
export declare function makeConfigForRuleset(rules: Oas3RuleSet, plugin?: Partial<Plugin>): StyleguideConfig;
|
package/lib/benchmark/utils.js
CHANGED
|
@@ -25,7 +25,7 @@ function makeConfigForRuleset(rules, plugin) {
|
|
|
25
25
|
if (rules) {
|
|
26
26
|
extendConfigs.push({ rules });
|
|
27
27
|
}
|
|
28
|
-
const
|
|
29
|
-
return new config_1.
|
|
28
|
+
const styleguide = config_1.mergeExtends(extendConfigs);
|
|
29
|
+
return new config_1.StyleguideConfig(styleguide);
|
|
30
30
|
}
|
|
31
31
|
exports.makeConfigForRuleset = makeConfigForRuleset;
|
package/lib/bundle.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { BaseResolver, Document } from './resolve';
|
|
|
2
2
|
import { Oas3Rule } from './visitors';
|
|
3
3
|
import { NormalizedNodeType, NodeType } from './types';
|
|
4
4
|
import { OasMajorVersion } from './oas-types';
|
|
5
|
-
import type { Config,
|
|
5
|
+
import type { Config, StyleguideConfig } from './config';
|
|
6
6
|
export declare type Oas3RuleSet = Record<string, Oas3Rule>;
|
|
7
7
|
export declare enum OasVersion {
|
|
8
8
|
Version2 = "oas2",
|
|
@@ -29,7 +29,7 @@ export declare function bundle(opts: {
|
|
|
29
29
|
}>;
|
|
30
30
|
export declare function bundleDocument(opts: {
|
|
31
31
|
document: Document;
|
|
32
|
-
config:
|
|
32
|
+
config: StyleguideConfig;
|
|
33
33
|
customTypes?: Record<string, NodeType>;
|
|
34
34
|
externalRefResolver: BaseResolver;
|
|
35
35
|
dereference?: boolean;
|
package/lib/bundle.js
CHANGED
|
@@ -42,7 +42,7 @@ function bundle(opts) {
|
|
|
42
42
|
if (document instanceof Error) {
|
|
43
43
|
throw document;
|
|
44
44
|
}
|
|
45
|
-
return bundleDocument(Object.assign(Object.assign({ document }, opts), { config: opts.config.
|
|
45
|
+
return bundleDocument(Object.assign(Object.assign({ document }, opts), { config: opts.config.styleguide, externalRefResolver }));
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
48
|
exports.bundle = bundle;
|
|
@@ -71,7 +71,7 @@ function bundleDocument(opts) {
|
|
|
71
71
|
ruleId: 'remove-unused-components',
|
|
72
72
|
visitor: oasMajorVersion === oas_types_1.OasMajorVersion.Version2
|
|
73
73
|
? remove_unused_components_1.RemoveUnusedComponents({})
|
|
74
|
-
: remove_unused_components_2.RemoveUnusedComponents({})
|
|
74
|
+
: remove_unused_components_2.RemoveUnusedComponents({}),
|
|
75
75
|
});
|
|
76
76
|
}
|
|
77
77
|
const resolvedRefMap = yield resolve_1.resolveDocument({
|
package/lib/config/all.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
declare const _default:
|
|
1
|
+
import type { PluginStyleguideConfig } from './types';
|
|
2
|
+
declare const _default: PluginStyleguideConfig;
|
|
3
3
|
export default _default;
|
package/lib/config/all.js
CHANGED
|
@@ -19,7 +19,7 @@ exports.default = {
|
|
|
19
19
|
'operation-description': 'error',
|
|
20
20
|
'operation-2xx-response': 'error',
|
|
21
21
|
'operation-4xx-response': 'error',
|
|
22
|
-
|
|
22
|
+
assertions: 'error',
|
|
23
23
|
'operation-operationId': 'error',
|
|
24
24
|
'operation-summary': 'error',
|
|
25
25
|
'operation-operationId-unique': 'error',
|
package/lib/config/builtIn.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const builtInConfigs: Record<string,
|
|
1
|
+
import type { StyleguideRawConfig, Plugin } from './types';
|
|
2
|
+
export declare const builtInConfigs: Record<string, StyleguideRawConfig>;
|
|
3
3
|
export declare const defaultPlugin: Plugin;
|
package/lib/config/builtIn.js
CHANGED
|
@@ -15,8 +15,8 @@ exports.builtInConfigs = {
|
|
|
15
15
|
minimal: minimal_1.default,
|
|
16
16
|
all: all_1.default,
|
|
17
17
|
'redocly-registry': {
|
|
18
|
-
decorators: { 'registry-dependencies': 'on' }
|
|
19
|
-
}
|
|
18
|
+
decorators: { 'registry-dependencies': 'on' },
|
|
19
|
+
},
|
|
20
20
|
};
|
|
21
21
|
exports.defaultPlugin = {
|
|
22
22
|
id: '',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseResolver } from '../resolve';
|
|
2
|
-
import type {
|
|
2
|
+
import type { StyleguideRawConfig, Plugin, RawConfig, ResolvedApi, ResolvedStyleguideConfig } from './types';
|
|
3
3
|
import { Config } from './config';
|
|
4
4
|
export declare function resolveConfig(rawConfig: RawConfig, configPath?: string): Promise<Config>;
|
|
5
5
|
export declare function resolvePlugins(plugins: (string | Plugin)[] | null, configPath?: string): Plugin[];
|
|
@@ -8,9 +8,9 @@ export declare function resolveApis({ rawConfig, configPath, resolver, }: {
|
|
|
8
8
|
configPath?: string;
|
|
9
9
|
resolver?: BaseResolver;
|
|
10
10
|
}): Promise<Record<string, ResolvedApi>>;
|
|
11
|
-
export declare function
|
|
12
|
-
|
|
11
|
+
export declare function resolveStyleguideConfig(opts: {
|
|
12
|
+
styleguideConfig?: StyleguideRawConfig;
|
|
13
13
|
configPath?: string;
|
|
14
14
|
resolver?: BaseResolver;
|
|
15
|
-
}, parentConfigPaths?: string[], extendPaths?: string[]): Promise<
|
|
16
|
-
export declare function resolvePreset(presetName: string, plugins: Plugin[]):
|
|
15
|
+
}, parentConfigPaths?: string[], extendPaths?: string[]): Promise<ResolvedStyleguideConfig>;
|
|
16
|
+
export declare function resolvePreset(presetName: string, plugins: Plugin[]): ResolvedStyleguideConfig;
|
|
@@ -20,7 +20,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
20
20
|
return t;
|
|
21
21
|
};
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
-
exports.resolvePreset = exports.
|
|
23
|
+
exports.resolvePreset = exports.resolveStyleguideConfig = exports.resolveApis = exports.resolvePlugins = exports.resolveConfig = void 0;
|
|
24
24
|
const path = require("path");
|
|
25
25
|
const colorette_1 = require("colorette");
|
|
26
26
|
const ref_utils_1 = require("../ref-utils");
|
|
@@ -32,25 +32,25 @@ const config_1 = require("./config");
|
|
|
32
32
|
function resolveConfig(rawConfig, configPath) {
|
|
33
33
|
var _a, _b, _c, _d, _e;
|
|
34
34
|
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
-
if ((_b = (_a = rawConfig.
|
|
35
|
+
if ((_b = (_a = rawConfig.styleguide) === null || _a === void 0 ? void 0 : _a.extends) === null || _b === void 0 ? void 0 : _b.some(utils_2.isNotString)) {
|
|
36
36
|
throw new Error(`Error configuration format not detected in extends value must contain strings`);
|
|
37
37
|
}
|
|
38
38
|
const resolver = new resolve_1.BaseResolver(utils_1.getResolveConfig(rawConfig.resolve));
|
|
39
|
-
const configExtends = (_d = (_c = rawConfig === null || rawConfig === void 0 ? void 0 : rawConfig.
|
|
40
|
-
const recommendedFallback = !((_e = rawConfig === null || rawConfig === void 0 ? void 0 : rawConfig.
|
|
41
|
-
const
|
|
39
|
+
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'];
|
|
40
|
+
const recommendedFallback = !((_e = rawConfig === null || rawConfig === void 0 ? void 0 : rawConfig.styleguide) === null || _e === void 0 ? void 0 : _e.extends);
|
|
41
|
+
const styleguideConfig = Object.assign(Object.assign({}, rawConfig === null || rawConfig === void 0 ? void 0 : rawConfig.styleguide), { extends: configExtends, recommendedFallback });
|
|
42
42
|
const apis = yield resolveApis({
|
|
43
|
-
rawConfig: Object.assign(Object.assign({}, rawConfig), {
|
|
43
|
+
rawConfig: Object.assign(Object.assign({}, rawConfig), { styleguide: styleguideConfig }),
|
|
44
44
|
configPath,
|
|
45
45
|
resolver,
|
|
46
46
|
});
|
|
47
|
-
const
|
|
48
|
-
|
|
47
|
+
const styleguide = yield resolveStyleguideConfig({
|
|
48
|
+
styleguideConfig,
|
|
49
49
|
configPath,
|
|
50
50
|
resolver,
|
|
51
51
|
});
|
|
52
52
|
return new config_1.Config(Object.assign(Object.assign({}, rawConfig), { apis,
|
|
53
|
-
|
|
53
|
+
styleguide }), configPath);
|
|
54
54
|
});
|
|
55
55
|
}
|
|
56
56
|
exports.resolveConfig = resolveConfig;
|
|
@@ -123,36 +123,36 @@ exports.resolvePlugins = resolvePlugins;
|
|
|
123
123
|
function resolveApis({ rawConfig, configPath = '', resolver, }) {
|
|
124
124
|
var _a, _b;
|
|
125
125
|
return __awaiter(this, void 0, void 0, function* () {
|
|
126
|
-
const { apis = {},
|
|
126
|
+
const { apis = {}, styleguide: styleguideConfig = {} } = rawConfig;
|
|
127
127
|
let resolvedApis = {};
|
|
128
128
|
for (const [apiName, apiContent] of Object.entries(apis || {})) {
|
|
129
|
-
if ((_b = (_a = apiContent.
|
|
129
|
+
if ((_b = (_a = apiContent.styleguide) === null || _a === void 0 ? void 0 : _a.extends) === null || _b === void 0 ? void 0 : _b.some(utils_2.isNotString)) {
|
|
130
130
|
throw new Error(`Error configuration format not detected in extends value must contain strings`);
|
|
131
131
|
}
|
|
132
|
-
const
|
|
133
|
-
const
|
|
134
|
-
|
|
132
|
+
const rawStyleguideConfig = getMergedRawStyleguideConfig(styleguideConfig, apiContent.styleguide);
|
|
133
|
+
const resolvedApiConfig = yield resolveStyleguideConfig({
|
|
134
|
+
styleguideConfig: rawStyleguideConfig,
|
|
135
135
|
configPath,
|
|
136
136
|
resolver,
|
|
137
137
|
});
|
|
138
|
-
resolvedApis[apiName] = Object.assign(Object.assign({}, apiContent), {
|
|
138
|
+
resolvedApis[apiName] = Object.assign(Object.assign({}, apiContent), { styleguide: resolvedApiConfig });
|
|
139
139
|
}
|
|
140
140
|
return resolvedApis;
|
|
141
141
|
});
|
|
142
142
|
}
|
|
143
143
|
exports.resolveApis = resolveApis;
|
|
144
|
-
function
|
|
144
|
+
function resolveAndMergeNestedStyleguideConfig({ styleguideConfig, configPath = '', resolver = new resolve_1.BaseResolver(), }, parentConfigPaths = [], extendPaths = []) {
|
|
145
145
|
var _a, _b, _c;
|
|
146
146
|
return __awaiter(this, void 0, void 0, function* () {
|
|
147
147
|
if (parentConfigPaths.includes(configPath)) {
|
|
148
148
|
throw new Error(`Circular dependency in config file: "${configPath}"`);
|
|
149
149
|
}
|
|
150
|
-
const plugins = utils_1.getUniquePlugins(resolvePlugins([...((
|
|
151
|
-
const pluginPaths = (_a =
|
|
150
|
+
const plugins = utils_1.getUniquePlugins(resolvePlugins([...((styleguideConfig === null || styleguideConfig === void 0 ? void 0 : styleguideConfig.plugins) || []), builtIn_1.defaultPlugin], configPath));
|
|
151
|
+
const pluginPaths = (_a = styleguideConfig === null || styleguideConfig === void 0 ? void 0 : styleguideConfig.plugins) === null || _a === void 0 ? void 0 : _a.filter(utils_2.isString).map((p) => path.resolve(path.dirname(configPath), p));
|
|
152
152
|
const resolvedConfigPath = ref_utils_1.isAbsoluteUrl(configPath)
|
|
153
153
|
? configPath
|
|
154
154
|
: configPath && path.resolve(configPath);
|
|
155
|
-
const extendConfigs = yield Promise.all(((_b =
|
|
155
|
+
const extendConfigs = yield Promise.all(((_b = styleguideConfig === null || styleguideConfig === void 0 ? void 0 : styleguideConfig.extends) === null || _b === void 0 ? void 0 : _b.map((presetItem) => __awaiter(this, void 0, void 0, function* () {
|
|
156
156
|
if (!ref_utils_1.isAbsoluteUrl(presetItem) && !path.extname(presetItem)) {
|
|
157
157
|
return resolvePreset(presetItem, plugins);
|
|
158
158
|
}
|
|
@@ -161,27 +161,28 @@ function resolveAndMergeNestedLint({ lintConfig, configPath = '', resolver = new
|
|
|
161
161
|
: ref_utils_1.isAbsoluteUrl(configPath)
|
|
162
162
|
? new URL(presetItem, configPath).href
|
|
163
163
|
: path.resolve(path.dirname(configPath), presetItem);
|
|
164
|
-
const
|
|
165
|
-
return yield
|
|
166
|
-
|
|
164
|
+
const extendedStyleguideConfig = yield loadExtendStyleguideConfig(pathItem, resolver);
|
|
165
|
+
return yield resolveAndMergeNestedStyleguideConfig({
|
|
166
|
+
styleguideConfig: extendedStyleguideConfig,
|
|
167
167
|
configPath: pathItem,
|
|
168
168
|
resolver: resolver,
|
|
169
169
|
}, [...parentConfigPaths, resolvedConfigPath], extendPaths);
|
|
170
170
|
}))) || []);
|
|
171
171
|
const _d = utils_1.mergeExtends([
|
|
172
172
|
...extendConfigs,
|
|
173
|
-
Object.assign(Object.assign({},
|
|
174
|
-
]), { plugins: mergedPlugins = [] } = _d,
|
|
175
|
-
return Object.assign(Object.assign({},
|
|
173
|
+
Object.assign(Object.assign({}, styleguideConfig), { plugins, extends: undefined, extendPaths: [...parentConfigPaths, resolvedConfigPath], pluginPaths }),
|
|
174
|
+
]), { plugins: mergedPlugins = [] } = _d, styleguide = __rest(_d, ["plugins"]);
|
|
175
|
+
return Object.assign(Object.assign({}, styleguide), { extendPaths: (_c = styleguide.extendPaths) === null || _c === void 0 ? void 0 : _c.filter((path) => path && !ref_utils_1.isAbsoluteUrl(path)), plugins: utils_1.getUniquePlugins(mergedPlugins), recommendedFallback: styleguideConfig === null || styleguideConfig === void 0 ? void 0 : styleguideConfig.recommendedFallback, doNotResolveExamples: styleguideConfig === null || styleguideConfig === void 0 ? void 0 : styleguideConfig.doNotResolveExamples });
|
|
176
176
|
});
|
|
177
177
|
}
|
|
178
|
-
function
|
|
178
|
+
function resolveStyleguideConfig(opts, parentConfigPaths = [], extendPaths = []) {
|
|
179
179
|
return __awaiter(this, void 0, void 0, function* () {
|
|
180
|
-
const
|
|
181
|
-
return Object.assign(Object.assign({},
|
|
180
|
+
const resolvedStyleguideConfig = yield resolveAndMergeNestedStyleguideConfig(opts, parentConfigPaths, extendPaths);
|
|
181
|
+
return Object.assign(Object.assign({}, resolvedStyleguideConfig), { rules: resolvedStyleguideConfig.rules &&
|
|
182
|
+
groupStyleguideAssertionRules(resolvedStyleguideConfig.rules) });
|
|
182
183
|
});
|
|
183
184
|
}
|
|
184
|
-
exports.
|
|
185
|
+
exports.resolveStyleguideConfig = resolveStyleguideConfig;
|
|
185
186
|
function resolvePreset(presetName, plugins) {
|
|
186
187
|
var _a;
|
|
187
188
|
const { pluginId, configName } = utils_1.parsePresetName(presetName);
|
|
@@ -198,26 +199,28 @@ function resolvePreset(presetName, plugins) {
|
|
|
198
199
|
return preset;
|
|
199
200
|
}
|
|
200
201
|
exports.resolvePreset = resolvePreset;
|
|
201
|
-
function
|
|
202
|
+
function loadExtendStyleguideConfig(filePath, resolver) {
|
|
202
203
|
return __awaiter(this, void 0, void 0, function* () {
|
|
203
204
|
try {
|
|
204
205
|
const fileSource = yield resolver.loadExternalRef(filePath);
|
|
205
206
|
const rawConfig = utils_1.transformConfig(utils_2.parseYaml(fileSource.body));
|
|
206
|
-
if (!rawConfig.
|
|
207
|
-
throw new Error(`
|
|
207
|
+
if (!rawConfig.styleguide) {
|
|
208
|
+
throw new Error(`Styleguide configuration format not detected: "${filePath}"`);
|
|
208
209
|
}
|
|
209
|
-
return rawConfig.
|
|
210
|
+
return rawConfig.styleguide;
|
|
210
211
|
}
|
|
211
212
|
catch (error) {
|
|
212
213
|
throw new Error(`Failed to load "${filePath}": ${error.message}`);
|
|
213
214
|
}
|
|
214
215
|
});
|
|
215
216
|
}
|
|
216
|
-
function
|
|
217
|
-
const resultLint = Object.assign(Object.assign(Object.assign({},
|
|
217
|
+
function getMergedRawStyleguideConfig(rootStyleguideConfig, apiStyleguideConfig) {
|
|
218
|
+
const resultLint = Object.assign(Object.assign(Object.assign({}, rootStyleguideConfig), apiStyleguideConfig), { rules: Object.assign(Object.assign({}, rootStyleguideConfig === null || rootStyleguideConfig === void 0 ? void 0 : rootStyleguideConfig.rules), apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.rules), oas2Rules: Object.assign(Object.assign({}, rootStyleguideConfig === null || rootStyleguideConfig === void 0 ? void 0 : rootStyleguideConfig.oas2Rules), apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.oas2Rules), oas3_0Rules: Object.assign(Object.assign({}, rootStyleguideConfig === null || rootStyleguideConfig === void 0 ? void 0 : rootStyleguideConfig.oas3_0Rules), apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.oas3_0Rules), oas3_1Rules: Object.assign(Object.assign({}, rootStyleguideConfig === null || rootStyleguideConfig === void 0 ? void 0 : rootStyleguideConfig.oas3_1Rules), apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.oas3_1Rules), preprocessors: Object.assign(Object.assign({}, rootStyleguideConfig === null || rootStyleguideConfig === void 0 ? void 0 : rootStyleguideConfig.preprocessors), apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.preprocessors), oas2Preprocessors: Object.assign(Object.assign({}, rootStyleguideConfig === null || rootStyleguideConfig === void 0 ? void 0 : rootStyleguideConfig.oas2Preprocessors), apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.oas2Preprocessors), oas3_0Preprocessors: Object.assign(Object.assign({}, rootStyleguideConfig === null || rootStyleguideConfig === void 0 ? void 0 : rootStyleguideConfig.oas3_0Preprocessors), apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.oas3_0Preprocessors), oas3_1Preprocessors: Object.assign(Object.assign({}, rootStyleguideConfig === null || rootStyleguideConfig === void 0 ? void 0 : rootStyleguideConfig.oas3_1Preprocessors), apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.oas3_1Preprocessors), decorators: Object.assign(Object.assign({}, rootStyleguideConfig === null || rootStyleguideConfig === void 0 ? void 0 : rootStyleguideConfig.decorators), apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.decorators), oas2Decorators: Object.assign(Object.assign({}, rootStyleguideConfig === null || rootStyleguideConfig === void 0 ? void 0 : rootStyleguideConfig.oas2Decorators), apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.oas2Decorators), oas3_0Decorators: Object.assign(Object.assign({}, rootStyleguideConfig === null || rootStyleguideConfig === void 0 ? void 0 : rootStyleguideConfig.oas3_0Decorators), apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.oas3_0Decorators), oas3_1Decorators: Object.assign(Object.assign({}, rootStyleguideConfig === null || rootStyleguideConfig === void 0 ? void 0 : rootStyleguideConfig.oas3_1Decorators), apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.oas3_1Decorators), recommendedFallback: (apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.extends)
|
|
219
|
+
? false
|
|
220
|
+
: rootStyleguideConfig.recommendedFallback });
|
|
218
221
|
return resultLint;
|
|
219
222
|
}
|
|
220
|
-
function
|
|
223
|
+
function groupStyleguideAssertionRules(rules) {
|
|
221
224
|
if (!rules) {
|
|
222
225
|
return rules;
|
|
223
226
|
}
|
package/lib/config/config.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { NormalizedProblem } from '../walk';
|
|
3
3
|
import { OasVersion, OasMajorVersion, Oas2RuleSet, Oas3RuleSet } from '../oas-types';
|
|
4
4
|
import type { NodeType } from '../types';
|
|
5
|
-
import type { DecoratorConfig, Plugin, PreprocessorConfig, Region, ResolveConfig, ResolvedApi, ResolvedConfig,
|
|
5
|
+
import type { DecoratorConfig, Plugin, PreprocessorConfig, Region, ResolveConfig, ResolvedApi, ResolvedConfig, ResolvedStyleguideConfig, RuleConfig } from './types';
|
|
6
6
|
export declare const env: NodeJS.ProcessEnv;
|
|
7
7
|
export declare const IGNORE_FILE = ".redocly.lint-ignore.yaml";
|
|
8
8
|
export declare const DEFAULT_REGION = "us";
|
|
@@ -11,8 +11,8 @@ export declare const DOMAINS: {
|
|
|
11
11
|
eu: string;
|
|
12
12
|
};
|
|
13
13
|
export declare const AVAILABLE_REGIONS: Region[];
|
|
14
|
-
export declare class
|
|
15
|
-
rawConfig:
|
|
14
|
+
export declare class StyleguideConfig {
|
|
15
|
+
rawConfig: ResolvedStyleguideConfig;
|
|
16
16
|
configFile?: string | undefined;
|
|
17
17
|
plugins: Plugin[];
|
|
18
18
|
ignore: Record<string, Record<string, Set<string>>>;
|
|
@@ -25,7 +25,8 @@ export declare class LintConfig {
|
|
|
25
25
|
recommendedFallback: boolean;
|
|
26
26
|
extendPaths: string[];
|
|
27
27
|
pluginPaths: string[];
|
|
28
|
-
constructor(rawConfig:
|
|
28
|
+
constructor(rawConfig: ResolvedStyleguideConfig, configFile?: string | undefined);
|
|
29
|
+
resolveIgnore(ignoreFile?: string): void;
|
|
29
30
|
saveIgnore(): void;
|
|
30
31
|
addIgnore(problem: NormalizedProblem): void;
|
|
31
32
|
addProblemToIgnore(problem: NormalizedProblem): NormalizedProblem;
|
|
@@ -53,7 +54,7 @@ export declare class Config {
|
|
|
53
54
|
rawConfig: ResolvedConfig;
|
|
54
55
|
configFile?: string | undefined;
|
|
55
56
|
apis: Record<string, ResolvedApi>;
|
|
56
|
-
|
|
57
|
+
styleguide: StyleguideConfig;
|
|
57
58
|
resolve: ResolveConfig;
|
|
58
59
|
licenseKey?: string;
|
|
59
60
|
region?: Region;
|
package/lib/config/config.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Config = exports.
|
|
3
|
+
exports.Config = exports.StyleguideConfig = exports.AVAILABLE_REGIONS = exports.DOMAINS = exports.DEFAULT_REGION = exports.IGNORE_FILE = exports.env = void 0;
|
|
4
4
|
const fs = require("fs");
|
|
5
5
|
const path = require("path");
|
|
6
6
|
const js_yaml_1 = require("../js-yaml");
|
|
@@ -28,9 +28,19 @@ function getDomains() {
|
|
|
28
28
|
}
|
|
29
29
|
return domains;
|
|
30
30
|
}
|
|
31
|
+
function getIgnoreFilePath(configFile) {
|
|
32
|
+
if (configFile) {
|
|
33
|
+
return utils_1.doesYamlFileExist(configFile)
|
|
34
|
+
? path.join(path.dirname(configFile), exports.IGNORE_FILE)
|
|
35
|
+
: path.join(configFile, exports.IGNORE_FILE);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
return typeof process === 'undefined' ? undefined : path.join(process.cwd(), exports.IGNORE_FILE);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
31
41
|
exports.DOMAINS = getDomains();
|
|
32
42
|
exports.AVAILABLE_REGIONS = Object.keys(exports.DOMAINS);
|
|
33
|
-
class
|
|
43
|
+
class StyleguideConfig {
|
|
34
44
|
constructor(rawConfig, configFile) {
|
|
35
45
|
this.rawConfig = rawConfig;
|
|
36
46
|
this.configFile = configFile;
|
|
@@ -57,23 +67,20 @@ class LintConfig {
|
|
|
57
67
|
};
|
|
58
68
|
this.extendPaths = rawConfig.extendPaths || [];
|
|
59
69
|
this.pluginPaths = rawConfig.pluginPaths || [];
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
for (const
|
|
71
|
-
this.ignore[
|
|
72
|
-
for (const ruleId of Object.keys(this.ignore[fileName])) {
|
|
73
|
-
this.ignore[fileName][ruleId] = new Set(this.ignore[fileName][ruleId]);
|
|
74
|
-
}
|
|
75
|
-
delete this.ignore[fileName];
|
|
70
|
+
this.resolveIgnore(getIgnoreFilePath(configFile));
|
|
71
|
+
}
|
|
72
|
+
resolveIgnore(ignoreFile) {
|
|
73
|
+
if (!ignoreFile || !utils_1.doesYamlFileExist(ignoreFile))
|
|
74
|
+
return;
|
|
75
|
+
this.ignore =
|
|
76
|
+
js_yaml_1.parseYaml(fs.readFileSync(ignoreFile, 'utf-8')) || {};
|
|
77
|
+
// resolve ignore paths
|
|
78
|
+
for (const fileName of Object.keys(this.ignore)) {
|
|
79
|
+
this.ignore[path.resolve(path.dirname(ignoreFile), fileName)] = this.ignore[fileName];
|
|
80
|
+
for (const ruleId of Object.keys(this.ignore[fileName])) {
|
|
81
|
+
this.ignore[fileName][ruleId] = new Set(this.ignore[fileName][ruleId]);
|
|
76
82
|
}
|
|
83
|
+
delete this.ignore[fileName];
|
|
77
84
|
}
|
|
78
85
|
}
|
|
79
86
|
saveIgnore() {
|
|
@@ -227,13 +234,13 @@ class LintConfig {
|
|
|
227
234
|
}
|
|
228
235
|
}
|
|
229
236
|
}
|
|
230
|
-
exports.
|
|
237
|
+
exports.StyleguideConfig = StyleguideConfig;
|
|
231
238
|
class Config {
|
|
232
239
|
constructor(rawConfig, configFile) {
|
|
233
240
|
this.rawConfig = rawConfig;
|
|
234
241
|
this.configFile = configFile;
|
|
235
242
|
this.apis = rawConfig.apis || {};
|
|
236
|
-
this.
|
|
243
|
+
this.styleguide = new StyleguideConfig(rawConfig.styleguide || {}, configFile);
|
|
237
244
|
this['features.openapi'] = rawConfig['features.openapi'] || {};
|
|
238
245
|
this['features.mockServer'] = rawConfig['features.mockServer'] || {};
|
|
239
246
|
this.resolve = utils_2.getResolveConfig(rawConfig === null || rawConfig === void 0 ? void 0 : rawConfig.resolve);
|
package/lib/config/load.js
CHANGED
|
@@ -17,16 +17,16 @@ const utils_1 = require("../utils");
|
|
|
17
17
|
const config_1 = require("./config");
|
|
18
18
|
const utils_2 = require("./utils");
|
|
19
19
|
const config_resolvers_1 = require("./config-resolvers");
|
|
20
|
-
function addConfigMetadata({ rawConfig, customExtends, configPath }) {
|
|
20
|
+
function addConfigMetadata({ rawConfig, customExtends, configPath, }) {
|
|
21
21
|
var _a;
|
|
22
22
|
return __awaiter(this, void 0, void 0, function* () {
|
|
23
23
|
if (customExtends !== undefined) {
|
|
24
|
-
rawConfig.
|
|
25
|
-
rawConfig.
|
|
24
|
+
rawConfig.styleguide = rawConfig.styleguide || {};
|
|
25
|
+
rawConfig.styleguide.extends = customExtends;
|
|
26
26
|
}
|
|
27
27
|
else if (utils_1.isEmptyObject(rawConfig)) {
|
|
28
28
|
// TODO: check if we can add recommended here. add message here?
|
|
29
|
-
// rawConfig.
|
|
29
|
+
// rawConfig.styleguide = { extends: ['recommended'], recommendedFallback: true };
|
|
30
30
|
}
|
|
31
31
|
const redoclyClient = new redocly_1.RedoclyClient();
|
|
32
32
|
const tokens = yield redoclyClient.getTokens();
|
|
@@ -74,7 +74,6 @@ function loadConfig(configPath = findConfig(), customExtends, processRawConfig)
|
|
|
74
74
|
});
|
|
75
75
|
}
|
|
76
76
|
exports.loadConfig = loadConfig;
|
|
77
|
-
;
|
|
78
77
|
exports.CONFIG_FILE_NAMES = ['redocly.yaml', 'redocly.yml', '.redocly.yaml', '.redocly.yml'];
|
|
79
78
|
function findConfig(dir) {
|
|
80
79
|
if (!fs.hasOwnProperty('existsSync'))
|
|
@@ -92,10 +91,10 @@ function findConfig(dir) {
|
|
|
92
91
|
exports.findConfig = findConfig;
|
|
93
92
|
function getConfig(configPath = findConfig()) {
|
|
94
93
|
return __awaiter(this, void 0, void 0, function* () {
|
|
95
|
-
if (!configPath)
|
|
94
|
+
if (!configPath || !utils_1.doesYamlFileExist(configPath))
|
|
96
95
|
return {};
|
|
97
96
|
try {
|
|
98
|
-
const rawConfig = (
|
|
97
|
+
const rawConfig = (yield utils_1.loadYaml(configPath)) || {};
|
|
99
98
|
return utils_2.transformConfig(rawConfig);
|
|
100
99
|
}
|
|
101
100
|
catch (e) {
|
package/lib/config/minimal.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
declare const _default:
|
|
1
|
+
import type { PluginStyleguideConfig } from './types';
|
|
2
|
+
declare const _default: PluginStyleguideConfig;
|
|
3
3
|
export default _default;
|
package/lib/config/minimal.js
CHANGED
|
@@ -18,7 +18,7 @@ exports.default = {
|
|
|
18
18
|
'operation-description': 'off',
|
|
19
19
|
'operation-2xx-response': 'warn',
|
|
20
20
|
'operation-4xx-response': 'off',
|
|
21
|
-
|
|
21
|
+
assertions: 'warn',
|
|
22
22
|
'operation-operationId': 'warn',
|
|
23
23
|
'operation-summary': 'warn',
|
|
24
24
|
'operation-operationId-unique': 'warn',
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
declare const _default:
|
|
1
|
+
import type { PluginStyleguideConfig } from './types';
|
|
2
|
+
declare const _default: PluginStyleguideConfig;
|
|
3
3
|
export default _default;
|
|
@@ -17,7 +17,7 @@ exports.default = {
|
|
|
17
17
|
'path-parameters-defined': 'error',
|
|
18
18
|
'operation-description': 'off',
|
|
19
19
|
'operation-2xx-response': 'warn',
|
|
20
|
-
|
|
20
|
+
assertions: 'warn',
|
|
21
21
|
'operation-4xx-response': 'warn',
|
|
22
22
|
'operation-operationId': 'warn',
|
|
23
23
|
'operation-summary': 'error',
|
package/lib/config/rules.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RuleSet, OasVersion } from '../oas-types';
|
|
2
|
-
import {
|
|
3
|
-
export declare function initRules<T extends Function, P extends RuleSet<T>>(rules: P[], config:
|
|
2
|
+
import { StyleguideConfig } from './config';
|
|
3
|
+
export declare function initRules<T extends Function, P extends RuleSet<T>>(rules: P[], config: StyleguideConfig, type: 'rules' | 'preprocessors' | 'decorators', oasVersion: OasVersion): {
|
|
4
4
|
severity: import("./types").RuleSeverity;
|
|
5
5
|
ruleId: string;
|
|
6
6
|
visitor: any;
|
package/lib/config/rules.js
CHANGED
|
@@ -28,7 +28,7 @@ function initRules(rules, config, type, oasVersion) {
|
|
|
28
28
|
visitor: visitors, // note: actually it is only one visitor object
|
|
29
29
|
};
|
|
30
30
|
}))
|
|
31
|
-
.flatMap(visitor => visitor)
|
|
31
|
+
.flatMap((visitor) => visitor)
|
|
32
32
|
.filter(utils_1.notUndefined);
|
|
33
33
|
}
|
|
34
34
|
exports.initRules = initRules;
|