@redocly/openapi-core 1.2.1 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/lib/benchmark/benches/lint-with-many-rules.bench.js +4 -4
- package/lib/benchmark/benches/lint-with-nested-rule.bench.js +4 -4
- package/lib/benchmark/benches/lint-with-no-rules.bench.js +4 -4
- package/lib/benchmark/benches/lint-with-top-level-rule-report.bench.js +4 -4
- package/lib/benchmark/benches/lint-with-top-level-rule.bench.js +4 -4
- package/lib/benchmark/benches/recommended-oas3.bench.js +4 -4
- package/lib/benchmark/benches/resolve-with-no-external.bench.js +3 -3
- package/lib/benchmark/utils.js +3 -3
- package/lib/bundle.d.ts +4 -4
- package/lib/bundle.js +23 -23
- package/lib/config/all.d.ts +2 -2
- package/lib/config/all.js +44 -8
- package/lib/config/builtIn.js +2 -0
- package/lib/config/config-resolvers.js +25 -25
- package/lib/config/config.js +9 -9
- package/lib/config/index.js +5 -1
- package/lib/config/load.d.ts +1 -1
- package/lib/config/load.js +9 -6
- package/lib/config/minimal.d.ts +2 -2
- package/lib/config/minimal.js +34 -3
- package/lib/config/recommended-strict.d.ts +3 -0
- package/lib/config/recommended-strict.js +92 -0
- package/lib/config/recommended.d.ts +2 -2
- package/lib/config/recommended.js +34 -3
- package/lib/config/rules.d.ts +1 -1
- package/lib/config/types.d.ts +47 -46
- package/lib/config/types.js +2 -2
- package/lib/config/utils.d.ts +2 -0
- package/lib/config/utils.js +30 -15
- package/lib/decorators/common/filters/filter-helper.js +4 -4
- package/lib/decorators/common/filters/filter-in.js +2 -2
- package/lib/decorators/common/filters/filter-out.js +2 -2
- package/lib/decorators/common/info-description-override.js +1 -1
- package/lib/decorators/common/media-type-examples-override.js +3 -3
- package/lib/decorators/common/operation-description-override.js +1 -1
- package/lib/decorators/common/registry-dependencies.js +1 -1
- package/lib/decorators/common/remove-x-internal.js +4 -4
- package/lib/decorators/common/tag-description-override.js +1 -1
- package/lib/format/codeframes.d.ts +6 -6
- package/lib/format/format.d.ts +2 -2
- package/lib/format/format.js +12 -12
- package/lib/js-yaml/index.d.ts +2 -2
- package/lib/js-yaml/index.js +2 -2
- package/lib/lint.js +18 -18
- package/lib/oas-types.d.ts +12 -10
- package/lib/oas-types.js +2 -2
- package/lib/redocly/index.js +10 -10
- package/lib/redocly/registry-api.js +2 -2
- package/lib/resolve.d.ts +4 -4
- package/lib/resolve.js +18 -18
- package/lib/rules/ajv.js +1 -1
- package/lib/rules/async2/index.d.ts +2 -11
- package/lib/rules/common/assertions/asserts.d.ts +3 -3
- package/lib/rules/common/assertions/asserts.js +21 -21
- package/lib/rules/common/assertions/index.d.ts +4 -4
- package/lib/rules/common/assertions/index.js +3 -3
- package/lib/rules/common/assertions/utils.d.ts +4 -4
- package/lib/rules/common/assertions/utils.js +3 -3
- package/lib/rules/common/info-contact.js +1 -1
- package/lib/rules/common/info-license-url.js +1 -1
- package/lib/rules/common/info-license.js +1 -1
- package/lib/rules/common/no-enum-type-mismatch.js +3 -3
- package/lib/rules/common/no-http-verbs-in-paths.js +2 -2
- 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-2xx-response.js +2 -2
- package/lib/rules/common/operation-4xx-response.js +2 -2
- package/lib/rules/common/operation-description.js +1 -1
- package/lib/rules/common/operation-operationId.js +1 -1
- package/lib/rules/common/operation-summary.js +1 -1
- package/lib/rules/common/path-segment-plural.js +1 -1
- package/lib/rules/common/response-contains-header.js +2 -2
- package/lib/rules/common/spec-strict-refs.js +1 -1
- package/lib/rules/common/spec.js +11 -11
- package/lib/rules/common/tag-description.js +1 -1
- package/lib/rules/oas2/boolean-parameter-prefixes.d.ts +1 -1
- package/lib/rules/oas2/index.d.ts +2 -46
- package/lib/rules/oas2/remove-unused-components.js +1 -1
- package/lib/rules/oas2/request-mime-type.js +2 -2
- package/lib/rules/oas2/response-contains-property.js +2 -2
- package/lib/rules/oas2/response-mime-type.js +2 -2
- package/lib/rules/oas3/boolean-parameter-prefixes.d.ts +1 -1
- package/lib/rules/oas3/index.d.ts +1 -1
- package/lib/rules/oas3/index.js +1 -1
- package/lib/rules/oas3/no-invalid-media-type-examples.js +3 -3
- package/lib/rules/oas3/operation-4xx-problem-details-rfc7807.js +3 -3
- package/lib/rules/oas3/remove-unused-components.js +2 -2
- package/lib/rules/oas3/request-mime-type.js +3 -3
- package/lib/rules/oas3/response-contains-property.js +2 -2
- package/lib/rules/oas3/response-mime-type.js +3 -3
- package/lib/rules/utils.js +3 -3
- package/lib/types/asyncapi.js +21 -21
- package/lib/types/index.d.ts +8 -8
- package/lib/types/oas2.js +14 -14
- package/lib/types/oas3.js +27 -27
- package/lib/types/oas3_1.js +6 -6
- package/lib/types/redocly-yaml.d.ts +11 -0
- package/lib/types/redocly-yaml.js +71 -53
- package/lib/types/theme-config.js +1 -1
- package/lib/typings/common.d.ts +2 -2
- package/lib/typings/openapi.d.ts +6 -6
- package/lib/typings/swagger.d.ts +3 -3
- package/lib/utils.d.ts +5 -5
- package/lib/utils.js +3 -3
- package/lib/visitors.d.ts +40 -40
- package/lib/walk.d.ts +14 -15
- package/lib/walk.js +11 -11
- package/package.json +2 -2
- package/src/__tests__/lint.test.ts +40 -40
- package/src/__tests__/normalizeVisitors.test.ts +23 -5
- package/src/__tests__/ref-utils.test.ts +7 -7
- package/src/__tests__/resolve-http.test.ts +10 -10
- package/src/__tests__/resolve.test.ts +39 -39
- package/src/__tests__/walk.test.ts +48 -48
- package/src/config/__tests__/__snapshots__/config-resolvers.test.ts.snap +95 -32
- package/src/config/__tests__/__snapshots__/config.test.ts.snap +81 -81
- package/src/config/__tests__/config-resolvers.test.ts +30 -1
- package/src/config/__tests__/config.test.ts +88 -88
- package/src/config/__tests__/load.test.ts +12 -8
- package/src/config/__tests__/utils.test.ts +18 -18
- package/src/config/all.ts +46 -9
- package/src/config/builtIn.ts +2 -0
- package/src/config/load.ts +4 -1
- package/src/config/minimal.ts +36 -4
- package/src/config/recommended-strict.ts +93 -0
- package/src/config/recommended.ts +36 -4
- package/src/config/types.ts +22 -8
- package/src/config/utils.ts +17 -0
- package/src/decorators/common/media-type-examples-override.ts +2 -2
- package/src/lint.ts +3 -3
- package/src/oas-types.ts +26 -3
- package/src/rules/__tests__/no-unresolved-refs.test.ts +26 -26
- package/src/rules/async2/__tests__/channels-kebab-case.test.ts +12 -12
- package/src/rules/async2/__tests__/no-channel-trailing-slash.test.ts +7 -7
- package/src/rules/async2/index.ts +2 -1
- package/src/rules/common/__tests__/info-license.test.ts +6 -6
- package/src/rules/common/__tests__/license-url.test.ts +6 -6
- package/src/rules/common/__tests__/no-ambiguous-paths.test.ts +13 -13
- package/src/rules/common/__tests__/no-enum-type-mismatch.test.ts +18 -18
- package/src/rules/common/__tests__/no-identical-paths.test.ts +5 -5
- package/src/rules/common/__tests__/no-path-trailing-slash.test.ts +12 -12
- package/src/rules/common/__tests__/operation-2xx-response.test.ts +18 -18
- package/src/rules/common/__tests__/operation-4xx-response.test.ts +23 -23
- package/src/rules/common/__tests__/operation-operationId-unique.test.ts +6 -6
- package/src/rules/common/__tests__/operation-operationId-url-safe.test.ts +5 -5
- package/src/rules/common/__tests__/operation-parameters-unique.test.ts +16 -16
- package/src/rules/common/__tests__/operation-singular-tag.test.ts +6 -6
- package/src/rules/common/__tests__/path-http-verbs-order.test.ts +10 -10
- package/src/rules/common/__tests__/path-not-include-query.test.ts +6 -6
- package/src/rules/common/__tests__/path-params-defined.test.ts +21 -21
- package/src/rules/common/__tests__/paths-kebab-case.test.ts +11 -11
- package/src/rules/common/__tests__/scalar-property-missing-example.test.ts +18 -18
- package/src/rules/common/__tests__/security-defined.test.ts +21 -21
- package/src/rules/common/__tests__/spec-strict-refs.test.ts +9 -9
- package/src/rules/common/__tests__/spec.test.ts +102 -102
- package/src/rules/common/__tests__/tag-description.test.ts +6 -6
- package/src/rules/common/__tests__/tags-alphabetical.test.ts +12 -12
- package/src/rules/common/assertions/__tests__/index.test.ts +15 -15
- package/src/rules/common/assertions/__tests__/utils.test.ts +9 -9
- package/src/rules/oas2/__tests__/boolean-parameter-prefixes.test.ts +7 -7
- package/src/rules/oas2/__tests__/response-contains-header.test.ts +13 -13
- package/src/rules/oas2/__tests__/response-contains-property.test.ts +8 -8
- package/src/rules/oas2/__tests__/spec/info.test.ts +21 -21
- package/src/rules/oas2/__tests__/spec/operation.test.ts +4 -4
- package/src/rules/oas2/__tests__/spec/paths.test.ts +12 -12
- package/src/rules/oas2/__tests__/spec/referenceableScalars.test.ts +1 -1
- package/src/rules/oas2/index.ts +3 -1
- package/src/rules/oas3/__tests__/boolean-parameter-prefixes.test.ts +7 -7
- package/src/rules/oas3/__tests__/component-name-unique.test.ts +186 -186
- package/src/rules/oas3/__tests__/no-empty-enum-servers.com.test.ts +18 -18
- package/src/rules/oas3/__tests__/no-example-value-and-externalValue.test.ts +6 -6
- package/src/rules/oas3/__tests__/no-invalid-media-type-examples.test.ts +36 -36
- package/src/rules/oas3/__tests__/no-server-example.com.test.ts +11 -11
- package/src/rules/oas3/__tests__/no-server-trailing-slash.test.ts +7 -7
- package/src/rules/oas3/__tests__/no-unused-components.test.ts +31 -31
- package/src/rules/oas3/__tests__/operation-4xx-problem-details-rfc7807.test.ts +15 -15
- package/src/rules/oas3/__tests__/response-contains-header.test.ts +26 -26
- package/src/rules/oas3/__tests__/response-contains-property.test.ts +27 -27
- package/src/rules/oas3/__tests__/spec/callbacks.test.ts +1 -1
- package/src/rules/oas3/__tests__/spec/info.test.ts +21 -21
- package/src/rules/oas3/__tests__/spec/operation.test.ts +10 -10
- package/src/rules/oas3/__tests__/spec/paths.test.ts +13 -13
- package/src/rules/oas3/__tests__/spec/referenceableScalars.test.ts +2 -2
- package/src/rules/oas3/__tests__/spec/servers.test.ts +25 -25
- package/src/rules/oas3/__tests__/spec/spec.test.ts +56 -56
- package/src/rules/oas3/__tests__/spec-components-invalid-map-name.test.ts +28 -28
- package/src/rules/oas3/index.ts +3 -3
- package/src/types/redocly-yaml.ts +75 -40
- package/src/visitors.ts +3 -3
- package/src/walk.ts +23 -10
- package/tsconfig.tsbuildinfo +1 -1
package/src/config/all.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PluginStyleguideConfig } from './types';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
const all: PluginStyleguideConfig<'built-in'> = {
|
|
4
4
|
rules: {
|
|
5
5
|
'info-contact': 'error',
|
|
6
6
|
'info-license': 'error',
|
|
@@ -28,13 +28,24 @@ export default {
|
|
|
28
28
|
'operation-singular-tag': 'error',
|
|
29
29
|
'no-unresolved-refs': 'error',
|
|
30
30
|
'no-enum-type-mismatch': 'error',
|
|
31
|
-
'boolean-parameter-prefixes': 'error',
|
|
32
31
|
'paths-kebab-case': 'error',
|
|
33
32
|
'no-http-verbs-in-paths': 'error',
|
|
34
33
|
'path-excludes-patterns': {
|
|
35
34
|
severity: 'error',
|
|
36
35
|
patterns: [],
|
|
37
36
|
},
|
|
37
|
+
spec: 'error',
|
|
38
|
+
'no-invalid-schema-examples': 'error',
|
|
39
|
+
'no-invalid-parameter-examples': 'error',
|
|
40
|
+
'scalar-property-missing-example': 'error',
|
|
41
|
+
'spec-strict-refs': 'error',
|
|
42
|
+
'path-http-verbs-order': 'error',
|
|
43
|
+
'path-params-defined': 'error',
|
|
44
|
+
'required-string-property-missing-min-length': 'error',
|
|
45
|
+
'response-contains-header': 'error',
|
|
46
|
+
},
|
|
47
|
+
oas2Rules: {
|
|
48
|
+
'boolean-parameter-prefixes': 'error',
|
|
38
49
|
'request-mime-type': {
|
|
39
50
|
severity: 'error',
|
|
40
51
|
allowedValues: ['application/json'],
|
|
@@ -43,12 +54,7 @@ export default {
|
|
|
43
54
|
severity: 'error',
|
|
44
55
|
allowedValues: ['application/json'],
|
|
45
56
|
},
|
|
46
|
-
|
|
47
|
-
'no-invalid-schema-examples': 'error',
|
|
48
|
-
'no-invalid-parameter-examples': 'error',
|
|
49
|
-
'scalar-property-missing-example': 'error',
|
|
50
|
-
'spec-strict-refs': 'error',
|
|
51
|
-
'component-name-unique': 'error',
|
|
57
|
+
'response-contains-property': 'error',
|
|
52
58
|
},
|
|
53
59
|
oas3_0Rules: {
|
|
54
60
|
'no-invalid-media-type-examples': 'error',
|
|
@@ -60,8 +66,21 @@ export default {
|
|
|
60
66
|
'no-undefined-server-variable': 'error',
|
|
61
67
|
'no-server-variables-empty-enum': 'error',
|
|
62
68
|
'operation-4xx-problem-details-rfc7807': 'error',
|
|
69
|
+
'boolean-parameter-prefixes': 'error',
|
|
70
|
+
'request-mime-type': {
|
|
71
|
+
severity: 'error',
|
|
72
|
+
allowedValues: ['application/json'],
|
|
73
|
+
},
|
|
74
|
+
'response-mime-type': {
|
|
75
|
+
severity: 'error',
|
|
76
|
+
allowedValues: ['application/json'],
|
|
77
|
+
},
|
|
78
|
+
'component-name-unique': 'error',
|
|
79
|
+
'response-contains-property': 'error',
|
|
80
|
+
'spec-components-invalid-map-name': 'error',
|
|
63
81
|
},
|
|
64
82
|
oas3_1Rules: {
|
|
83
|
+
'no-invalid-media-type-examples': 'error',
|
|
65
84
|
'no-server-example.com': 'error',
|
|
66
85
|
'no-server-trailing-slash': 'error',
|
|
67
86
|
'no-empty-servers': 'error',
|
|
@@ -70,5 +89,23 @@ export default {
|
|
|
70
89
|
'no-undefined-server-variable': 'error',
|
|
71
90
|
'no-server-variables-empty-enum': 'error',
|
|
72
91
|
'operation-4xx-problem-details-rfc7807': 'error',
|
|
92
|
+
'boolean-parameter-prefixes': 'error',
|
|
93
|
+
'request-mime-type': {
|
|
94
|
+
severity: 'error',
|
|
95
|
+
allowedValues: ['application/json'],
|
|
96
|
+
},
|
|
97
|
+
'response-mime-type': {
|
|
98
|
+
severity: 'error',
|
|
99
|
+
allowedValues: ['application/json'],
|
|
100
|
+
},
|
|
101
|
+
'component-name-unique': 'error',
|
|
102
|
+
'response-contains-property': 'error',
|
|
103
|
+
'spec-components-invalid-map-name': 'error',
|
|
73
104
|
},
|
|
74
|
-
|
|
105
|
+
async2Rules: {
|
|
106
|
+
'channels-kebab-case': 'error',
|
|
107
|
+
'no-channel-trailing-slash': 'error',
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
export default all;
|
package/src/config/builtIn.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import recommended from './recommended';
|
|
2
|
+
import recommendedStrict from './recommended-strict';
|
|
2
3
|
import all from './all';
|
|
3
4
|
import minimal from './minimal';
|
|
4
5
|
import { rules as oas3Rules } from '../rules/oas3';
|
|
@@ -13,6 +14,7 @@ import type { CustomRulesConfig, StyleguideRawConfig, Plugin } from './types';
|
|
|
13
14
|
|
|
14
15
|
export const builtInConfigs: Record<string, StyleguideRawConfig> = {
|
|
15
16
|
recommended,
|
|
17
|
+
'recommended-strict': recommendedStrict,
|
|
16
18
|
minimal,
|
|
17
19
|
all,
|
|
18
20
|
'redocly-registry': {
|
package/src/config/load.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { RedoclyClient } from '../redocly';
|
|
|
4
4
|
import { isEmptyObject, loadYaml, doesYamlFileExist } from '../utils';
|
|
5
5
|
import { parseYaml } from '../js-yaml';
|
|
6
6
|
import { Config, DOMAINS } from './config';
|
|
7
|
-
import { transformConfig } from './utils';
|
|
7
|
+
import { ConfigValidationError, transformConfig } from './utils';
|
|
8
8
|
import { resolveConfig } from './config-resolvers';
|
|
9
9
|
|
|
10
10
|
import type {
|
|
@@ -128,6 +128,9 @@ export async function getConfig(
|
|
|
128
128
|
}
|
|
129
129
|
return transformConfig(rawConfig);
|
|
130
130
|
} catch (e) {
|
|
131
|
+
if (e instanceof ConfigValidationError) {
|
|
132
|
+
throw e;
|
|
133
|
+
}
|
|
131
134
|
throw new Error(`Error parsing config file at '${configPath}': ${e.message}`);
|
|
132
135
|
}
|
|
133
136
|
}
|
package/src/config/minimal.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PluginStyleguideConfig } from './types';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
const minimal: PluginStyleguideConfig<'built-in'> = {
|
|
4
4
|
rules: {
|
|
5
5
|
'info-contact': 'off',
|
|
6
6
|
'info-license': 'off',
|
|
@@ -27,11 +27,25 @@ export default {
|
|
|
27
27
|
'operation-singular-tag': 'off',
|
|
28
28
|
'no-unresolved-refs': 'error',
|
|
29
29
|
'no-enum-type-mismatch': 'warn',
|
|
30
|
-
'boolean-parameter-prefixes': 'off',
|
|
31
30
|
'paths-kebab-case': 'off',
|
|
32
31
|
spec: 'error',
|
|
33
32
|
'spec-strict-refs': 'off',
|
|
34
|
-
'
|
|
33
|
+
'no-http-verbs-in-paths': 'off',
|
|
34
|
+
'no-invalid-parameter-examples': 'off',
|
|
35
|
+
'no-invalid-schema-examples': 'off',
|
|
36
|
+
'path-excludes-patterns': 'off',
|
|
37
|
+
'path-http-verbs-order': 'off',
|
|
38
|
+
'path-params-defined': 'off',
|
|
39
|
+
'required-string-property-missing-min-length': 'off',
|
|
40
|
+
'response-contains-header': 'off',
|
|
41
|
+
'path-segment-plural': 'off',
|
|
42
|
+
'scalar-property-missing-example': 'off',
|
|
43
|
+
},
|
|
44
|
+
oas2Rules: {
|
|
45
|
+
'boolean-parameter-prefixes': 'off',
|
|
46
|
+
'request-mime-type': 'off',
|
|
47
|
+
'response-contains-property': 'off',
|
|
48
|
+
'response-mime-type': 'off',
|
|
35
49
|
},
|
|
36
50
|
oas3_0Rules: {
|
|
37
51
|
'no-invalid-media-type-examples': {
|
|
@@ -46,6 +60,12 @@ export default {
|
|
|
46
60
|
'no-undefined-server-variable': 'warn',
|
|
47
61
|
'no-server-variables-empty-enum': 'error',
|
|
48
62
|
'spec-components-invalid-map-name': 'warn',
|
|
63
|
+
'boolean-parameter-prefixes': 'off',
|
|
64
|
+
'component-name-unique': 'off',
|
|
65
|
+
'operation-4xx-problem-details-rfc7807': 'off',
|
|
66
|
+
'request-mime-type': 'off',
|
|
67
|
+
'response-contains-property': 'off',
|
|
68
|
+
'response-mime-type': 'off',
|
|
49
69
|
},
|
|
50
70
|
oas3_1Rules: {
|
|
51
71
|
'no-invalid-media-type-examples': 'warn',
|
|
@@ -57,5 +77,17 @@ export default {
|
|
|
57
77
|
'no-undefined-server-variable': 'warn',
|
|
58
78
|
'no-server-variables-empty-enum': 'error',
|
|
59
79
|
'spec-components-invalid-map-name': 'warn',
|
|
80
|
+
'boolean-parameter-prefixes': 'off',
|
|
81
|
+
'component-name-unique': 'off',
|
|
82
|
+
'operation-4xx-problem-details-rfc7807': 'off',
|
|
83
|
+
'request-mime-type': 'off',
|
|
84
|
+
'response-contains-property': 'off',
|
|
85
|
+
'response-mime-type': 'off',
|
|
60
86
|
},
|
|
61
|
-
|
|
87
|
+
async2Rules: {
|
|
88
|
+
'channels-kebab-case': 'off',
|
|
89
|
+
'no-channel-trailing-slash': 'off',
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export default minimal;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { PluginStyleguideConfig } from './types';
|
|
2
|
+
|
|
3
|
+
const recommendedStrict: PluginStyleguideConfig<'built-in'> = {
|
|
4
|
+
rules: {
|
|
5
|
+
'info-contact': 'off',
|
|
6
|
+
'info-license': 'error',
|
|
7
|
+
'info-license-url': 'error',
|
|
8
|
+
'tag-description': 'error',
|
|
9
|
+
'tags-alphabetical': 'off',
|
|
10
|
+
'parameter-description': 'off',
|
|
11
|
+
'no-path-trailing-slash': 'error',
|
|
12
|
+
'no-identical-paths': 'error',
|
|
13
|
+
'no-ambiguous-paths': 'error',
|
|
14
|
+
'path-declaration-must-exist': 'error',
|
|
15
|
+
'path-not-include-query': 'error',
|
|
16
|
+
'path-parameters-defined': 'error',
|
|
17
|
+
'operation-description': 'off',
|
|
18
|
+
'operation-2xx-response': 'error',
|
|
19
|
+
'operation-4xx-response': 'error',
|
|
20
|
+
'operation-operationId': 'error',
|
|
21
|
+
'operation-summary': 'error',
|
|
22
|
+
'operation-operationId-unique': 'error',
|
|
23
|
+
'operation-operationId-url-safe': 'error',
|
|
24
|
+
'operation-parameters-unique': 'error',
|
|
25
|
+
'operation-tag-defined': 'off',
|
|
26
|
+
'security-defined': 'error',
|
|
27
|
+
'operation-singular-tag': 'off',
|
|
28
|
+
'no-unresolved-refs': 'error',
|
|
29
|
+
'no-enum-type-mismatch': 'error',
|
|
30
|
+
'paths-kebab-case': 'off',
|
|
31
|
+
spec: 'error',
|
|
32
|
+
'spec-strict-refs': 'off',
|
|
33
|
+
'no-http-verbs-in-paths': 'off',
|
|
34
|
+
'no-invalid-parameter-examples': 'off',
|
|
35
|
+
'no-invalid-schema-examples': 'off',
|
|
36
|
+
'path-excludes-patterns': 'off',
|
|
37
|
+
'path-http-verbs-order': 'off',
|
|
38
|
+
'path-params-defined': 'off',
|
|
39
|
+
'path-segment-plural': 'off',
|
|
40
|
+
'required-string-property-missing-min-length': 'off',
|
|
41
|
+
'response-contains-header': 'off',
|
|
42
|
+
'scalar-property-missing-example': 'off',
|
|
43
|
+
},
|
|
44
|
+
oas2Rules: {
|
|
45
|
+
'boolean-parameter-prefixes': 'off',
|
|
46
|
+
'request-mime-type': 'off',
|
|
47
|
+
'response-contains-property': 'off',
|
|
48
|
+
'response-mime-type': 'off',
|
|
49
|
+
},
|
|
50
|
+
oas3_0Rules: {
|
|
51
|
+
'no-invalid-media-type-examples': {
|
|
52
|
+
severity: 'error',
|
|
53
|
+
allowAdditionalProperties: false,
|
|
54
|
+
},
|
|
55
|
+
'no-server-example.com': 'error',
|
|
56
|
+
'no-server-trailing-slash': 'error',
|
|
57
|
+
'no-empty-servers': 'error',
|
|
58
|
+
'no-example-value-and-externalValue': 'error',
|
|
59
|
+
'no-unused-components': 'error',
|
|
60
|
+
'no-undefined-server-variable': 'error',
|
|
61
|
+
'no-server-variables-empty-enum': 'error',
|
|
62
|
+
'spec-components-invalid-map-name': 'error',
|
|
63
|
+
'boolean-parameter-prefixes': 'off',
|
|
64
|
+
'component-name-unique': 'off',
|
|
65
|
+
'operation-4xx-problem-details-rfc7807': 'off',
|
|
66
|
+
'request-mime-type': 'off',
|
|
67
|
+
'response-contains-property': 'off',
|
|
68
|
+
'response-mime-type': 'off',
|
|
69
|
+
},
|
|
70
|
+
oas3_1Rules: {
|
|
71
|
+
'no-invalid-media-type-examples': 'error',
|
|
72
|
+
'no-server-example.com': 'error',
|
|
73
|
+
'no-server-trailing-slash': 'error',
|
|
74
|
+
'no-empty-servers': 'error',
|
|
75
|
+
'no-example-value-and-externalValue': 'error',
|
|
76
|
+
'no-unused-components': 'error',
|
|
77
|
+
'no-undefined-server-variable': 'error',
|
|
78
|
+
'no-server-variables-empty-enum': 'error',
|
|
79
|
+
'spec-components-invalid-map-name': 'error',
|
|
80
|
+
'boolean-parameter-prefixes': 'off',
|
|
81
|
+
'component-name-unique': 'off',
|
|
82
|
+
'operation-4xx-problem-details-rfc7807': 'off',
|
|
83
|
+
'request-mime-type': 'off',
|
|
84
|
+
'response-contains-property': 'off',
|
|
85
|
+
'response-mime-type': 'off',
|
|
86
|
+
},
|
|
87
|
+
async2Rules: {
|
|
88
|
+
'channels-kebab-case': 'off',
|
|
89
|
+
'no-channel-trailing-slash': 'off',
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export default recommendedStrict;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PluginStyleguideConfig } from './types';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
const recommended: PluginStyleguideConfig<'built-in'> = {
|
|
4
4
|
rules: {
|
|
5
5
|
'info-contact': 'off',
|
|
6
6
|
'info-license': 'warn',
|
|
@@ -27,11 +27,25 @@ export default {
|
|
|
27
27
|
'operation-singular-tag': 'off',
|
|
28
28
|
'no-unresolved-refs': 'error',
|
|
29
29
|
'no-enum-type-mismatch': 'error',
|
|
30
|
-
'boolean-parameter-prefixes': 'off',
|
|
31
30
|
'paths-kebab-case': 'off',
|
|
32
31
|
spec: 'error',
|
|
33
32
|
'spec-strict-refs': 'off',
|
|
34
|
-
'
|
|
33
|
+
'no-http-verbs-in-paths': 'off',
|
|
34
|
+
'no-invalid-parameter-examples': 'off',
|
|
35
|
+
'no-invalid-schema-examples': 'off',
|
|
36
|
+
'path-excludes-patterns': 'off',
|
|
37
|
+
'path-http-verbs-order': 'off',
|
|
38
|
+
'path-params-defined': 'off',
|
|
39
|
+
'path-segment-plural': 'off',
|
|
40
|
+
'required-string-property-missing-min-length': 'off',
|
|
41
|
+
'response-contains-header': 'off',
|
|
42
|
+
'scalar-property-missing-example': 'off',
|
|
43
|
+
},
|
|
44
|
+
oas2Rules: {
|
|
45
|
+
'boolean-parameter-prefixes': 'off',
|
|
46
|
+
'request-mime-type': 'off',
|
|
47
|
+
'response-contains-property': 'off',
|
|
48
|
+
'response-mime-type': 'off',
|
|
35
49
|
},
|
|
36
50
|
oas3_0Rules: {
|
|
37
51
|
'no-invalid-media-type-examples': {
|
|
@@ -46,6 +60,12 @@ export default {
|
|
|
46
60
|
'no-undefined-server-variable': 'error',
|
|
47
61
|
'no-server-variables-empty-enum': 'error',
|
|
48
62
|
'spec-components-invalid-map-name': 'error',
|
|
63
|
+
'boolean-parameter-prefixes': 'off',
|
|
64
|
+
'component-name-unique': 'off',
|
|
65
|
+
'operation-4xx-problem-details-rfc7807': 'off',
|
|
66
|
+
'request-mime-type': 'off',
|
|
67
|
+
'response-contains-property': 'off',
|
|
68
|
+
'response-mime-type': 'off',
|
|
49
69
|
},
|
|
50
70
|
oas3_1Rules: {
|
|
51
71
|
'no-invalid-media-type-examples': 'warn',
|
|
@@ -57,5 +77,17 @@ export default {
|
|
|
57
77
|
'no-undefined-server-variable': 'error',
|
|
58
78
|
'no-server-variables-empty-enum': 'error',
|
|
59
79
|
'spec-components-invalid-map-name': 'error',
|
|
80
|
+
'boolean-parameter-prefixes': 'off',
|
|
81
|
+
'component-name-unique': 'off',
|
|
82
|
+
'operation-4xx-problem-details-rfc7807': 'off',
|
|
83
|
+
'request-mime-type': 'off',
|
|
84
|
+
'response-contains-property': 'off',
|
|
85
|
+
'response-mime-type': 'off',
|
|
60
86
|
},
|
|
61
|
-
|
|
87
|
+
async2Rules: {
|
|
88
|
+
'channels-kebab-case': 'off',
|
|
89
|
+
'no-channel-trailing-slash': 'off',
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export default recommended;
|
package/src/config/types.ts
CHANGED
|
@@ -11,11 +11,19 @@ import type {
|
|
|
11
11
|
Async2PreprocessorsSet,
|
|
12
12
|
Async2DecoratorsSet,
|
|
13
13
|
Async2RuleSet,
|
|
14
|
+
RuleMap,
|
|
14
15
|
} from '../oas-types';
|
|
15
16
|
|
|
16
17
|
import type { NodeType } from '../types';
|
|
17
18
|
import { Location } from '../ref-utils';
|
|
18
19
|
import type { SkipFunctionContext } from '../visitors';
|
|
20
|
+
import {
|
|
21
|
+
BuiltInAsync2RuleId,
|
|
22
|
+
BuiltInCommonOASRuleId,
|
|
23
|
+
BuiltInCommonRuleId,
|
|
24
|
+
BuiltInOAS2RuleId,
|
|
25
|
+
BuiltInOAS3RuleId,
|
|
26
|
+
} from '../types/redocly-yaml';
|
|
19
27
|
|
|
20
28
|
export type RuleSeverity = ProblemSeverity | 'off';
|
|
21
29
|
|
|
@@ -37,17 +45,17 @@ export type PreprocessorConfig =
|
|
|
37
45
|
|
|
38
46
|
export type DecoratorConfig = PreprocessorConfig;
|
|
39
47
|
|
|
40
|
-
export type StyleguideRawConfig = {
|
|
48
|
+
export type StyleguideRawConfig<T = undefined> = {
|
|
41
49
|
plugins?: (string | Plugin)[];
|
|
42
50
|
extends?: string[];
|
|
43
51
|
doNotResolveExamples?: boolean;
|
|
44
52
|
recommendedFallback?: boolean;
|
|
45
53
|
|
|
46
|
-
rules?:
|
|
47
|
-
oas2Rules?:
|
|
48
|
-
oas3_0Rules?:
|
|
49
|
-
oas3_1Rules?:
|
|
50
|
-
async2Rules?:
|
|
54
|
+
rules?: RuleMap<BuiltInCommonRuleId | BuiltInCommonOASRuleId, RuleConfig, T>;
|
|
55
|
+
oas2Rules?: RuleMap<BuiltInOAS2RuleId, RuleConfig, T>;
|
|
56
|
+
oas3_0Rules?: RuleMap<BuiltInOAS3RuleId, RuleConfig, T>;
|
|
57
|
+
oas3_1Rules?: RuleMap<BuiltInOAS3RuleId, RuleConfig, T>;
|
|
58
|
+
async2Rules?: RuleMap<BuiltInAsync2RuleId, RuleConfig, T>;
|
|
51
59
|
|
|
52
60
|
preprocessors?: Record<string, PreprocessorConfig>;
|
|
53
61
|
oas2Preprocessors?: Record<string, PreprocessorConfig>;
|
|
@@ -118,7 +126,10 @@ export type Plugin = {
|
|
|
118
126
|
assertions?: AssertionsConfig;
|
|
119
127
|
};
|
|
120
128
|
|
|
121
|
-
export type PluginStyleguideConfig = Omit<
|
|
129
|
+
export type PluginStyleguideConfig<T = undefined> = Omit<
|
|
130
|
+
StyleguideRawConfig<T>,
|
|
131
|
+
'plugins' | 'extends'
|
|
132
|
+
>;
|
|
122
133
|
|
|
123
134
|
export type ResolveHeader =
|
|
124
135
|
| {
|
|
@@ -221,14 +232,17 @@ export type RulesFields =
|
|
|
221
232
|
| 'oas2Rules'
|
|
222
233
|
| 'oas3_0Rules'
|
|
223
234
|
| 'oas3_1Rules'
|
|
235
|
+
| 'async2Rules'
|
|
224
236
|
| 'preprocessors'
|
|
225
237
|
| 'oas2Preprocessors'
|
|
226
238
|
| 'oas3_0Preprocessors'
|
|
227
239
|
| 'oas3_1Preprocessors'
|
|
240
|
+
| 'async2Preprocessors'
|
|
228
241
|
| 'decorators'
|
|
229
242
|
| 'oas2Decorators'
|
|
230
243
|
| 'oas3_0Decorators'
|
|
231
|
-
| 'oas3_1Decorators'
|
|
244
|
+
| 'oas3_1Decorators'
|
|
245
|
+
| 'async2Decorators';
|
|
232
246
|
|
|
233
247
|
export enum AuthProviderType {
|
|
234
248
|
OIDC = 'OIDC',
|
package/src/config/utils.ts
CHANGED
|
@@ -55,16 +55,19 @@ function extractFlatConfig<
|
|
|
55
55
|
oas2Rules,
|
|
56
56
|
oas3_0Rules,
|
|
57
57
|
oas3_1Rules,
|
|
58
|
+
async2Rules,
|
|
58
59
|
|
|
59
60
|
preprocessors,
|
|
60
61
|
oas2Preprocessors,
|
|
61
62
|
oas3_0Preprocessors,
|
|
62
63
|
oas3_1Preprocessors,
|
|
64
|
+
async2Preprocessors,
|
|
63
65
|
|
|
64
66
|
decorators,
|
|
65
67
|
oas2Decorators,
|
|
66
68
|
oas3_0Decorators,
|
|
67
69
|
oas3_1Decorators,
|
|
70
|
+
async2Decorators,
|
|
68
71
|
|
|
69
72
|
...rawConfigRest
|
|
70
73
|
}: T): {
|
|
@@ -79,16 +82,19 @@ function extractFlatConfig<
|
|
|
79
82
|
oas2Rules,
|
|
80
83
|
oas3_0Rules,
|
|
81
84
|
oas3_1Rules,
|
|
85
|
+
async2Rules,
|
|
82
86
|
|
|
83
87
|
preprocessors,
|
|
84
88
|
oas2Preprocessors,
|
|
85
89
|
oas3_0Preprocessors,
|
|
86
90
|
oas3_1Preprocessors,
|
|
91
|
+
async2Preprocessors,
|
|
87
92
|
|
|
88
93
|
decorators,
|
|
89
94
|
oas2Decorators,
|
|
90
95
|
oas3_0Decorators,
|
|
91
96
|
oas3_1Decorators,
|
|
97
|
+
async2Decorators,
|
|
92
98
|
|
|
93
99
|
doNotResolveExamples: rawConfigRest.resolve?.doNotResolveExamples,
|
|
94
100
|
};
|
|
@@ -145,16 +151,19 @@ export function mergeExtends(rulesConfList: ResolvedStyleguideConfig[]) {
|
|
|
145
151
|
oas2Rules: {},
|
|
146
152
|
oas3_0Rules: {},
|
|
147
153
|
oas3_1Rules: {},
|
|
154
|
+
async2Rules: {},
|
|
148
155
|
|
|
149
156
|
preprocessors: {},
|
|
150
157
|
oas2Preprocessors: {},
|
|
151
158
|
oas3_0Preprocessors: {},
|
|
152
159
|
oas3_1Preprocessors: {},
|
|
160
|
+
async2Preprocessors: {},
|
|
153
161
|
|
|
154
162
|
decorators: {},
|
|
155
163
|
oas2Decorators: {},
|
|
156
164
|
oas3_0Decorators: {},
|
|
157
165
|
oas3_1Decorators: {},
|
|
166
|
+
async2Decorators: {},
|
|
158
167
|
|
|
159
168
|
plugins: [],
|
|
160
169
|
pluginPaths: [],
|
|
@@ -175,6 +184,8 @@ export function mergeExtends(rulesConfList: ResolvedStyleguideConfig[]) {
|
|
|
175
184
|
assignExisting(result.oas3_0Rules, rulesConf.rules || {});
|
|
176
185
|
Object.assign(result.oas3_1Rules, rulesConf.oas3_1Rules);
|
|
177
186
|
assignExisting(result.oas3_1Rules, rulesConf.rules || {});
|
|
187
|
+
Object.assign(result.async2Rules, rulesConf.async2Rules);
|
|
188
|
+
assignExisting(result.async2Rules, rulesConf.rules || {});
|
|
178
189
|
|
|
179
190
|
Object.assign(result.preprocessors, rulesConf.preprocessors);
|
|
180
191
|
Object.assign(result.oas2Preprocessors, rulesConf.oas2Preprocessors);
|
|
@@ -183,6 +194,8 @@ export function mergeExtends(rulesConfList: ResolvedStyleguideConfig[]) {
|
|
|
183
194
|
assignExisting(result.oas3_0Preprocessors, rulesConf.preprocessors || {});
|
|
184
195
|
Object.assign(result.oas3_1Preprocessors, rulesConf.oas3_1Preprocessors);
|
|
185
196
|
assignExisting(result.oas3_1Preprocessors, rulesConf.preprocessors || {});
|
|
197
|
+
Object.assign(result.async2Preprocessors, rulesConf.async2Preprocessors);
|
|
198
|
+
assignExisting(result.async2Preprocessors, rulesConf.preprocessors || {});
|
|
186
199
|
|
|
187
200
|
Object.assign(result.decorators, rulesConf.decorators);
|
|
188
201
|
Object.assign(result.oas2Decorators, rulesConf.oas2Decorators);
|
|
@@ -191,6 +204,8 @@ export function mergeExtends(rulesConfList: ResolvedStyleguideConfig[]) {
|
|
|
191
204
|
assignExisting(result.oas3_0Decorators, rulesConf.decorators || {});
|
|
192
205
|
Object.assign(result.oas3_1Decorators, rulesConf.oas3_1Decorators);
|
|
193
206
|
assignExisting(result.oas3_1Decorators, rulesConf.decorators || {});
|
|
207
|
+
Object.assign(result.async2Decorators, rulesConf.async2Decorators);
|
|
208
|
+
assignExisting(result.async2Decorators, rulesConf.decorators || {});
|
|
194
209
|
|
|
195
210
|
result.plugins!.push(...(rulesConf.plugins || []));
|
|
196
211
|
result.pluginPaths!.push(...(rulesConf.pluginPaths || []));
|
|
@@ -347,3 +362,5 @@ export function getUniquePlugins(plugins: Plugin[]): Plugin[] {
|
|
|
347
362
|
}
|
|
348
363
|
return results;
|
|
349
364
|
}
|
|
365
|
+
|
|
366
|
+
export class ConfigValidationError extends Error {}
|
|
@@ -2,7 +2,7 @@ import { Oas3Decorator } from '../../visitors';
|
|
|
2
2
|
import { Oas3Operation, Oas3RequestBody, Oas3Response } from '../../typings/openapi';
|
|
3
3
|
import { yamlAndJsonSyncReader } from '../../utils';
|
|
4
4
|
import { isRef } from '../../ref-utils';
|
|
5
|
-
import { ResolveFn, UserContext } from '../../walk';
|
|
5
|
+
import { NonUndefined, ResolveFn, UserContext } from '../../walk';
|
|
6
6
|
|
|
7
7
|
export const MediaTypeExamplesOverride: Oas3Decorator = ({ operationIds }) => {
|
|
8
8
|
return {
|
|
@@ -69,7 +69,7 @@ export const MediaTypeExamplesOverride: Oas3Decorator = ({ operationIds }) => {
|
|
|
69
69
|
};
|
|
70
70
|
};
|
|
71
71
|
|
|
72
|
-
function checkAndResolveRef<T>(node: any, resolver: ResolveFn): T | undefined {
|
|
72
|
+
function checkAndResolveRef<T extends NonUndefined>(node: any, resolver: ResolveFn): T | undefined {
|
|
73
73
|
if (!isRef(node)) {
|
|
74
74
|
return node;
|
|
75
75
|
}
|
package/src/lint.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { ProblemSeverity, WalkContext, walkDocument } from './walk';
|
|
|
5
5
|
import { StyleguideConfig, Config, initRules, defaultPlugin, resolvePlugins } from './config';
|
|
6
6
|
import { normalizeTypes } from './types';
|
|
7
7
|
import { releaseAjvInstance } from './rules/ajv';
|
|
8
|
-
import {
|
|
8
|
+
import { SpecVersion, getMajorSpecVersion, detectSpec, getTypes } from './oas-types';
|
|
9
9
|
import { ConfigTypes } from './types/redocly-yaml';
|
|
10
10
|
import { Spec } from './rules/common/spec';
|
|
11
11
|
|
|
@@ -65,8 +65,8 @@ export async function lintDocument(opts: {
|
|
|
65
65
|
visitorsData: {},
|
|
66
66
|
};
|
|
67
67
|
|
|
68
|
-
const preprocessors = initRules(rules
|
|
69
|
-
const regularRules = initRules(rules
|
|
68
|
+
const preprocessors = initRules(rules, config, 'preprocessors', specVersion);
|
|
69
|
+
const regularRules = initRules(rules, config, 'rules', specVersion);
|
|
70
70
|
|
|
71
71
|
let resolvedRefMap = await resolveDocument({
|
|
72
72
|
rootDocument: document,
|
package/src/oas-types.ts
CHANGED
|
@@ -10,6 +10,13 @@ import { Oas2Types } from './types/oas2';
|
|
|
10
10
|
import { Oas3Types } from './types/oas3';
|
|
11
11
|
import { Oas3_1Types } from './types/oas3_1';
|
|
12
12
|
import { AsyncApi2Types } from './types/asyncapi';
|
|
13
|
+
import {
|
|
14
|
+
BuiltInAsync2RuleId,
|
|
15
|
+
BuiltInCommonOASRuleId,
|
|
16
|
+
BuiltInCommonRuleId,
|
|
17
|
+
BuiltInOAS2RuleId,
|
|
18
|
+
BuiltInOAS3RuleId,
|
|
19
|
+
} from './types/redocly-yaml';
|
|
13
20
|
|
|
14
21
|
export type RuleSet<T> = Record<string, T>;
|
|
15
22
|
|
|
@@ -33,9 +40,25 @@ const typesMap = {
|
|
|
33
40
|
[SpecVersion.Async2]: AsyncApi2Types,
|
|
34
41
|
};
|
|
35
42
|
|
|
36
|
-
export type
|
|
37
|
-
|
|
38
|
-
|
|
43
|
+
export type RuleMap<Key extends string, RuleConfig, T> = Record<
|
|
44
|
+
T extends 'built-in' ? Key : string,
|
|
45
|
+
RuleConfig
|
|
46
|
+
>;
|
|
47
|
+
export type Oas3RuleSet<T = undefined> = RuleMap<
|
|
48
|
+
BuiltInCommonRuleId | BuiltInCommonOASRuleId | BuiltInOAS3RuleId | 'assertions',
|
|
49
|
+
Oas3Rule,
|
|
50
|
+
T
|
|
51
|
+
>;
|
|
52
|
+
export type Oas2RuleSet<T = undefined> = RuleMap<
|
|
53
|
+
BuiltInCommonRuleId | BuiltInCommonOASRuleId | BuiltInOAS2RuleId | 'assertions',
|
|
54
|
+
Oas2Rule,
|
|
55
|
+
T
|
|
56
|
+
>;
|
|
57
|
+
export type Async2RuleSet<T = undefined> = RuleMap<
|
|
58
|
+
BuiltInCommonRuleId | BuiltInAsync2RuleId | 'assertions',
|
|
59
|
+
Async2Rule,
|
|
60
|
+
T
|
|
61
|
+
>;
|
|
39
62
|
export type Oas3PreprocessorsSet = Record<string, Oas3Preprocessor>;
|
|
40
63
|
export type Oas2PreprocessorsSet = Record<string, Oas2Preprocessor>;
|
|
41
64
|
export type Async2PreprocessorsSet = Record<string, Async2Preprocessor>;
|