@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
|
@@ -5,160 +5,160 @@ StyleguideConfig {
|
|
|
5
5
|
"_usedRules": Set {},
|
|
6
6
|
"_usedVersions": Set {},
|
|
7
7
|
"configFile": undefined,
|
|
8
|
-
"decorators":
|
|
9
|
-
"async2":
|
|
10
|
-
"oas2":
|
|
11
|
-
"oas3_0":
|
|
12
|
-
"oas3_1":
|
|
13
|
-
},
|
|
14
|
-
"oas2":
|
|
15
|
-
"oas2":
|
|
16
|
-
"oas3_0":
|
|
17
|
-
"oas3_1":
|
|
18
|
-
},
|
|
19
|
-
"oas3_0":
|
|
20
|
-
"oas2":
|
|
21
|
-
"oas3_0":
|
|
22
|
-
"oas3_1":
|
|
23
|
-
},
|
|
24
|
-
"oas3_1":
|
|
25
|
-
"oas2":
|
|
26
|
-
"oas3_0":
|
|
27
|
-
"oas3_1":
|
|
8
|
+
"decorators": {
|
|
9
|
+
"async2": {
|
|
10
|
+
"oas2": {},
|
|
11
|
+
"oas3_0": {},
|
|
12
|
+
"oas3_1": {},
|
|
13
|
+
},
|
|
14
|
+
"oas2": {
|
|
15
|
+
"oas2": {},
|
|
16
|
+
"oas3_0": {},
|
|
17
|
+
"oas3_1": {},
|
|
18
|
+
},
|
|
19
|
+
"oas3_0": {
|
|
20
|
+
"oas2": {},
|
|
21
|
+
"oas3_0": {},
|
|
22
|
+
"oas3_1": {},
|
|
23
|
+
},
|
|
24
|
+
"oas3_1": {
|
|
25
|
+
"oas2": {},
|
|
26
|
+
"oas3_0": {},
|
|
27
|
+
"oas3_1": {},
|
|
28
28
|
},
|
|
29
29
|
},
|
|
30
30
|
"doNotResolveExamples": false,
|
|
31
|
-
"extendPaths":
|
|
32
|
-
"ignore":
|
|
33
|
-
"https://some-path.yaml":
|
|
31
|
+
"extendPaths": [],
|
|
32
|
+
"ignore": {
|
|
33
|
+
"https://some-path.yaml": {
|
|
34
34
|
"no-unused-components": Set {
|
|
35
35
|
"#/components/schemas/Foo",
|
|
36
36
|
},
|
|
37
37
|
},
|
|
38
|
-
"some-path/openapi.yaml":
|
|
38
|
+
"some-path/openapi.yaml": {
|
|
39
39
|
"no-unused-components": Set {
|
|
40
40
|
"#/components/schemas/Foo",
|
|
41
41
|
},
|
|
42
42
|
},
|
|
43
43
|
},
|
|
44
|
-
"pluginPaths":
|
|
45
|
-
"plugins":
|
|
46
|
-
"preprocessors":
|
|
47
|
-
"async2":
|
|
48
|
-
"oas2":
|
|
49
|
-
"oas3_0":
|
|
50
|
-
"oas3_1":
|
|
51
|
-
},
|
|
52
|
-
"oas2":
|
|
53
|
-
"oas2":
|
|
54
|
-
"oas3_0":
|
|
55
|
-
"oas3_1":
|
|
56
|
-
},
|
|
57
|
-
"oas3_0":
|
|
58
|
-
"oas2":
|
|
59
|
-
"oas3_0":
|
|
60
|
-
"oas3_1":
|
|
61
|
-
},
|
|
62
|
-
"oas3_1":
|
|
63
|
-
"oas2":
|
|
64
|
-
"oas3_0":
|
|
65
|
-
"oas3_1":
|
|
44
|
+
"pluginPaths": [],
|
|
45
|
+
"plugins": [],
|
|
46
|
+
"preprocessors": {
|
|
47
|
+
"async2": {
|
|
48
|
+
"oas2": {},
|
|
49
|
+
"oas3_0": {},
|
|
50
|
+
"oas3_1": {},
|
|
51
|
+
},
|
|
52
|
+
"oas2": {
|
|
53
|
+
"oas2": {},
|
|
54
|
+
"oas3_0": {},
|
|
55
|
+
"oas3_1": {},
|
|
56
|
+
},
|
|
57
|
+
"oas3_0": {
|
|
58
|
+
"oas2": {},
|
|
59
|
+
"oas3_0": {},
|
|
60
|
+
"oas3_1": {},
|
|
61
|
+
},
|
|
62
|
+
"oas3_1": {
|
|
63
|
+
"oas2": {},
|
|
64
|
+
"oas3_0": {},
|
|
65
|
+
"oas3_1": {},
|
|
66
66
|
},
|
|
67
67
|
},
|
|
68
|
-
"rawConfig":
|
|
68
|
+
"rawConfig": {
|
|
69
69
|
"_usedRules": Set {},
|
|
70
70
|
"_usedVersions": Set {},
|
|
71
71
|
"configFile": "redocly.yaml",
|
|
72
|
-
"decorators":
|
|
73
|
-
"oas2":
|
|
74
|
-
"oas3_0":
|
|
75
|
-
"oas3_1":
|
|
72
|
+
"decorators": {
|
|
73
|
+
"oas2": {},
|
|
74
|
+
"oas3_0": {},
|
|
75
|
+
"oas3_1": {},
|
|
76
76
|
},
|
|
77
77
|
"doNotResolveExamples": false,
|
|
78
|
-
"ignore":
|
|
79
|
-
"plugins":
|
|
80
|
-
"preprocessors":
|
|
81
|
-
"oas2":
|
|
82
|
-
"oas3_0":
|
|
83
|
-
"oas3_1":
|
|
78
|
+
"ignore": {},
|
|
79
|
+
"plugins": [],
|
|
80
|
+
"preprocessors": {
|
|
81
|
+
"oas2": {},
|
|
82
|
+
"oas3_0": {},
|
|
83
|
+
"oas3_1": {},
|
|
84
84
|
},
|
|
85
|
-
"rawConfig":
|
|
86
|
-
"plugins":
|
|
87
|
-
"rules":
|
|
85
|
+
"rawConfig": {
|
|
86
|
+
"plugins": [],
|
|
87
|
+
"rules": {
|
|
88
88
|
"no-empty-servers": "error",
|
|
89
89
|
"operation-summary": "error",
|
|
90
90
|
},
|
|
91
91
|
},
|
|
92
92
|
"recommendedFallback": false,
|
|
93
|
-
"rules":
|
|
94
|
-
"oas2":
|
|
93
|
+
"rules": {
|
|
94
|
+
"oas2": {
|
|
95
95
|
"no-empty-servers": "error",
|
|
96
96
|
"operation-summary": "error",
|
|
97
97
|
},
|
|
98
|
-
"oas3_0":
|
|
98
|
+
"oas3_0": {
|
|
99
99
|
"no-empty-servers": "error",
|
|
100
100
|
"operation-summary": "error",
|
|
101
101
|
},
|
|
102
|
-
"oas3_1":
|
|
102
|
+
"oas3_1": {
|
|
103
103
|
"no-empty-servers": "error",
|
|
104
104
|
"operation-summary": "error",
|
|
105
105
|
},
|
|
106
106
|
},
|
|
107
107
|
},
|
|
108
108
|
"recommendedFallback": false,
|
|
109
|
-
"rules":
|
|
110
|
-
"async2":
|
|
111
|
-
"oas2":
|
|
109
|
+
"rules": {
|
|
110
|
+
"async2": {
|
|
111
|
+
"oas2": {
|
|
112
112
|
"no-empty-servers": "error",
|
|
113
113
|
"operation-summary": "error",
|
|
114
114
|
},
|
|
115
|
-
"oas3_0":
|
|
115
|
+
"oas3_0": {
|
|
116
116
|
"no-empty-servers": "error",
|
|
117
117
|
"operation-summary": "error",
|
|
118
118
|
},
|
|
119
|
-
"oas3_1":
|
|
119
|
+
"oas3_1": {
|
|
120
120
|
"no-empty-servers": "error",
|
|
121
121
|
"operation-summary": "error",
|
|
122
122
|
},
|
|
123
123
|
},
|
|
124
|
-
"oas2":
|
|
125
|
-
"oas2":
|
|
124
|
+
"oas2": {
|
|
125
|
+
"oas2": {
|
|
126
126
|
"no-empty-servers": "error",
|
|
127
127
|
"operation-summary": "error",
|
|
128
128
|
},
|
|
129
|
-
"oas3_0":
|
|
129
|
+
"oas3_0": {
|
|
130
130
|
"no-empty-servers": "error",
|
|
131
131
|
"operation-summary": "error",
|
|
132
132
|
},
|
|
133
|
-
"oas3_1":
|
|
133
|
+
"oas3_1": {
|
|
134
134
|
"no-empty-servers": "error",
|
|
135
135
|
"operation-summary": "error",
|
|
136
136
|
},
|
|
137
137
|
},
|
|
138
|
-
"oas3_0":
|
|
139
|
-
"oas2":
|
|
138
|
+
"oas3_0": {
|
|
139
|
+
"oas2": {
|
|
140
140
|
"no-empty-servers": "error",
|
|
141
141
|
"operation-summary": "error",
|
|
142
142
|
},
|
|
143
|
-
"oas3_0":
|
|
143
|
+
"oas3_0": {
|
|
144
144
|
"no-empty-servers": "error",
|
|
145
145
|
"operation-summary": "error",
|
|
146
146
|
},
|
|
147
|
-
"oas3_1":
|
|
147
|
+
"oas3_1": {
|
|
148
148
|
"no-empty-servers": "error",
|
|
149
149
|
"operation-summary": "error",
|
|
150
150
|
},
|
|
151
151
|
},
|
|
152
|
-
"oas3_1":
|
|
153
|
-
"oas2":
|
|
152
|
+
"oas3_1": {
|
|
153
|
+
"oas2": {
|
|
154
154
|
"no-empty-servers": "error",
|
|
155
155
|
"operation-summary": "error",
|
|
156
156
|
},
|
|
157
|
-
"oas3_0":
|
|
157
|
+
"oas3_0": {
|
|
158
158
|
"no-empty-servers": "error",
|
|
159
159
|
"operation-summary": "error",
|
|
160
160
|
},
|
|
161
|
-
"oas3_1":
|
|
161
|
+
"oas3_1": {
|
|
162
162
|
"no-empty-servers": "error",
|
|
163
163
|
"operation-summary": "error",
|
|
164
164
|
},
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { colorize } from '../../logger';
|
|
2
2
|
import { Asserts, asserts } from '../../rules/common/assertions/asserts';
|
|
3
3
|
import { resolveStyleguideConfig, resolveApis, resolveConfig } from '../config-resolvers';
|
|
4
|
+
import recommended from '../recommended';
|
|
5
|
+
|
|
4
6
|
const path = require('path');
|
|
5
7
|
|
|
6
|
-
import type { StyleguideRawConfig, RawConfig } from '../types';
|
|
8
|
+
import type { StyleguideRawConfig, RawConfig, PluginStyleguideConfig } from '../types';
|
|
7
9
|
|
|
8
10
|
const configPath = path.join(__dirname, 'fixtures/resolve-config/redocly.yaml');
|
|
9
11
|
const baseStyleguideConfig: StyleguideRawConfig = {
|
|
@@ -220,6 +222,33 @@ describe('resolveStyleguideConfig', () => {
|
|
|
220
222
|
]);
|
|
221
223
|
expect(styleguide.pluginPaths!.map(removeAbsolutePath)).toEqual([]);
|
|
222
224
|
});
|
|
225
|
+
it('should resolve `recommended-strict` ruleset correctly', async () => {
|
|
226
|
+
const expectedStrict = JSON.parse(
|
|
227
|
+
JSON.stringify(recommended)
|
|
228
|
+
) as PluginStyleguideConfig<'built-in'>;
|
|
229
|
+
for (const section of Object.values(expectedStrict)) {
|
|
230
|
+
for (let ruleName in section as any) {
|
|
231
|
+
// @ts-ignore
|
|
232
|
+
if (section[ruleName] === 'warn') {
|
|
233
|
+
// @ts-ignore
|
|
234
|
+
section[ruleName] = 'error';
|
|
235
|
+
}
|
|
236
|
+
// @ts-ignore
|
|
237
|
+
if (section[ruleName]?.severity === 'warn') {
|
|
238
|
+
// @ts-ignore
|
|
239
|
+
section[ruleName].severity = 'error';
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
const recommendedStrictPreset = JSON.parse(
|
|
244
|
+
JSON.stringify(
|
|
245
|
+
await resolveStyleguideConfig({
|
|
246
|
+
styleguideConfig: { extends: ['recommended-strict'] },
|
|
247
|
+
})
|
|
248
|
+
)
|
|
249
|
+
);
|
|
250
|
+
expect(recommendedStrictPreset).toMatchObject(expectedStrict);
|
|
251
|
+
});
|
|
223
252
|
});
|
|
224
253
|
|
|
225
254
|
describe('resolveApis', () => {
|
|
@@ -69,95 +69,95 @@ describe('getMergedConfig', () => {
|
|
|
69
69
|
it('should get styleguide defined in "apis" section', () => {
|
|
70
70
|
expect(getMergedConfig(testConfig, 'test@v1')).toMatchInlineSnapshot(`
|
|
71
71
|
Config {
|
|
72
|
-
"apis":
|
|
73
|
-
"test@v1":
|
|
72
|
+
"apis": {
|
|
73
|
+
"test@v1": {
|
|
74
74
|
"root": "resources/pets.yaml",
|
|
75
|
-
"styleguide":
|
|
76
|
-
"rules":
|
|
75
|
+
"styleguide": {
|
|
76
|
+
"rules": {
|
|
77
77
|
"operation-summary": "warn",
|
|
78
78
|
},
|
|
79
79
|
},
|
|
80
80
|
},
|
|
81
81
|
},
|
|
82
82
|
"configFile": "redocly.yaml",
|
|
83
|
-
"files":
|
|
83
|
+
"files": [],
|
|
84
84
|
"organization": "redocly-test",
|
|
85
|
-
"rawConfig":
|
|
86
|
-
"apis":
|
|
87
|
-
"test@v1":
|
|
85
|
+
"rawConfig": {
|
|
86
|
+
"apis": {
|
|
87
|
+
"test@v1": {
|
|
88
88
|
"root": "resources/pets.yaml",
|
|
89
|
-
"styleguide":
|
|
90
|
-
"rules":
|
|
89
|
+
"styleguide": {
|
|
90
|
+
"rules": {
|
|
91
91
|
"operation-summary": "warn",
|
|
92
92
|
},
|
|
93
93
|
},
|
|
94
94
|
},
|
|
95
95
|
},
|
|
96
|
-
"files":
|
|
96
|
+
"files": [],
|
|
97
97
|
"organization": "redocly-test",
|
|
98
|
-
"styleguide":
|
|
99
|
-
"extendPaths":
|
|
100
|
-
"pluginPaths":
|
|
101
|
-
"rules":
|
|
98
|
+
"styleguide": {
|
|
99
|
+
"extendPaths": [],
|
|
100
|
+
"pluginPaths": [],
|
|
101
|
+
"rules": {
|
|
102
102
|
"operation-summary": "warn",
|
|
103
103
|
},
|
|
104
104
|
},
|
|
105
105
|
"telemetry": "on",
|
|
106
|
-
"theme":
|
|
106
|
+
"theme": {},
|
|
107
107
|
},
|
|
108
108
|
"region": undefined,
|
|
109
|
-
"resolve":
|
|
110
|
-
"http":
|
|
109
|
+
"resolve": {
|
|
110
|
+
"http": {
|
|
111
111
|
"customFetch": undefined,
|
|
112
|
-
"headers":
|
|
112
|
+
"headers": [],
|
|
113
113
|
},
|
|
114
114
|
},
|
|
115
115
|
"styleguide": StyleguideConfig {
|
|
116
116
|
"_usedRules": Set {},
|
|
117
117
|
"_usedVersions": Set {},
|
|
118
118
|
"configFile": "redocly.yaml",
|
|
119
|
-
"decorators":
|
|
120
|
-
"async2":
|
|
121
|
-
"oas2":
|
|
122
|
-
"oas3_0":
|
|
123
|
-
"oas3_1":
|
|
119
|
+
"decorators": {
|
|
120
|
+
"async2": {},
|
|
121
|
+
"oas2": {},
|
|
122
|
+
"oas3_0": {},
|
|
123
|
+
"oas3_1": {},
|
|
124
124
|
},
|
|
125
125
|
"doNotResolveExamples": false,
|
|
126
|
-
"extendPaths":
|
|
127
|
-
"ignore":
|
|
128
|
-
"pluginPaths":
|
|
129
|
-
"plugins":
|
|
130
|
-
"preprocessors":
|
|
131
|
-
"async2":
|
|
132
|
-
"oas2":
|
|
133
|
-
"oas3_0":
|
|
134
|
-
"oas3_1":
|
|
126
|
+
"extendPaths": [],
|
|
127
|
+
"ignore": {},
|
|
128
|
+
"pluginPaths": [],
|
|
129
|
+
"plugins": [],
|
|
130
|
+
"preprocessors": {
|
|
131
|
+
"async2": {},
|
|
132
|
+
"oas2": {},
|
|
133
|
+
"oas3_0": {},
|
|
134
|
+
"oas3_1": {},
|
|
135
135
|
},
|
|
136
|
-
"rawConfig":
|
|
137
|
-
"extendPaths":
|
|
138
|
-
"pluginPaths":
|
|
139
|
-
"rules":
|
|
136
|
+
"rawConfig": {
|
|
137
|
+
"extendPaths": [],
|
|
138
|
+
"pluginPaths": [],
|
|
139
|
+
"rules": {
|
|
140
140
|
"operation-summary": "warn",
|
|
141
141
|
},
|
|
142
142
|
},
|
|
143
143
|
"recommendedFallback": false,
|
|
144
|
-
"rules":
|
|
145
|
-
"async2":
|
|
144
|
+
"rules": {
|
|
145
|
+
"async2": {
|
|
146
146
|
"operation-summary": "warn",
|
|
147
147
|
},
|
|
148
|
-
"oas2":
|
|
148
|
+
"oas2": {
|
|
149
149
|
"operation-summary": "warn",
|
|
150
150
|
},
|
|
151
|
-
"oas3_0":
|
|
151
|
+
"oas3_0": {
|
|
152
152
|
"operation-summary": "warn",
|
|
153
153
|
},
|
|
154
|
-
"oas3_1":
|
|
154
|
+
"oas3_1": {
|
|
155
155
|
"operation-summary": "warn",
|
|
156
156
|
},
|
|
157
157
|
},
|
|
158
158
|
},
|
|
159
159
|
"telemetry": "on",
|
|
160
|
-
"theme":
|
|
160
|
+
"theme": {},
|
|
161
161
|
}
|
|
162
162
|
`);
|
|
163
163
|
});
|
|
@@ -172,103 +172,103 @@ describe('getMergedConfig', () => {
|
|
|
172
172
|
it('should handle wrong alias - return the same styleguide, empty features', () => {
|
|
173
173
|
expect(getMergedConfig(testConfig, 'wrong-alias')).toMatchInlineSnapshot(`
|
|
174
174
|
Config {
|
|
175
|
-
"apis":
|
|
176
|
-
"test@v1":
|
|
175
|
+
"apis": {
|
|
176
|
+
"test@v1": {
|
|
177
177
|
"root": "resources/pets.yaml",
|
|
178
|
-
"styleguide":
|
|
179
|
-
"rules":
|
|
178
|
+
"styleguide": {
|
|
179
|
+
"rules": {
|
|
180
180
|
"operation-summary": "warn",
|
|
181
181
|
},
|
|
182
182
|
},
|
|
183
183
|
},
|
|
184
184
|
},
|
|
185
185
|
"configFile": "redocly.yaml",
|
|
186
|
-
"files":
|
|
186
|
+
"files": [],
|
|
187
187
|
"organization": "redocly-test",
|
|
188
|
-
"rawConfig":
|
|
189
|
-
"apis":
|
|
190
|
-
"test@v1":
|
|
188
|
+
"rawConfig": {
|
|
189
|
+
"apis": {
|
|
190
|
+
"test@v1": {
|
|
191
191
|
"root": "resources/pets.yaml",
|
|
192
|
-
"styleguide":
|
|
193
|
-
"rules":
|
|
192
|
+
"styleguide": {
|
|
193
|
+
"rules": {
|
|
194
194
|
"operation-summary": "warn",
|
|
195
195
|
},
|
|
196
196
|
},
|
|
197
197
|
},
|
|
198
198
|
},
|
|
199
|
-
"files":
|
|
199
|
+
"files": [],
|
|
200
200
|
"organization": "redocly-test",
|
|
201
|
-
"styleguide":
|
|
202
|
-
"extendPaths":
|
|
203
|
-
"pluginPaths":
|
|
204
|
-
"plugins":
|
|
205
|
-
"rules":
|
|
201
|
+
"styleguide": {
|
|
202
|
+
"extendPaths": [],
|
|
203
|
+
"pluginPaths": [],
|
|
204
|
+
"plugins": [],
|
|
205
|
+
"rules": {
|
|
206
206
|
"no-empty-servers": "error",
|
|
207
207
|
"operation-summary": "error",
|
|
208
208
|
},
|
|
209
209
|
},
|
|
210
210
|
"telemetry": "on",
|
|
211
|
-
"theme":
|
|
211
|
+
"theme": {},
|
|
212
212
|
},
|
|
213
213
|
"region": undefined,
|
|
214
|
-
"resolve":
|
|
215
|
-
"http":
|
|
214
|
+
"resolve": {
|
|
215
|
+
"http": {
|
|
216
216
|
"customFetch": undefined,
|
|
217
|
-
"headers":
|
|
217
|
+
"headers": [],
|
|
218
218
|
},
|
|
219
219
|
},
|
|
220
220
|
"styleguide": StyleguideConfig {
|
|
221
221
|
"_usedRules": Set {},
|
|
222
222
|
"_usedVersions": Set {},
|
|
223
223
|
"configFile": "redocly.yaml",
|
|
224
|
-
"decorators":
|
|
225
|
-
"async2":
|
|
226
|
-
"oas2":
|
|
227
|
-
"oas3_0":
|
|
228
|
-
"oas3_1":
|
|
224
|
+
"decorators": {
|
|
225
|
+
"async2": {},
|
|
226
|
+
"oas2": {},
|
|
227
|
+
"oas3_0": {},
|
|
228
|
+
"oas3_1": {},
|
|
229
229
|
},
|
|
230
230
|
"doNotResolveExamples": false,
|
|
231
|
-
"extendPaths":
|
|
232
|
-
"ignore":
|
|
233
|
-
"pluginPaths":
|
|
234
|
-
"plugins":
|
|
235
|
-
"preprocessors":
|
|
236
|
-
"async2":
|
|
237
|
-
"oas2":
|
|
238
|
-
"oas3_0":
|
|
239
|
-
"oas3_1":
|
|
231
|
+
"extendPaths": [],
|
|
232
|
+
"ignore": {},
|
|
233
|
+
"pluginPaths": [],
|
|
234
|
+
"plugins": [],
|
|
235
|
+
"preprocessors": {
|
|
236
|
+
"async2": {},
|
|
237
|
+
"oas2": {},
|
|
238
|
+
"oas3_0": {},
|
|
239
|
+
"oas3_1": {},
|
|
240
240
|
},
|
|
241
|
-
"rawConfig":
|
|
242
|
-
"extendPaths":
|
|
243
|
-
"pluginPaths":
|
|
244
|
-
"plugins":
|
|
245
|
-
"rules":
|
|
241
|
+
"rawConfig": {
|
|
242
|
+
"extendPaths": [],
|
|
243
|
+
"pluginPaths": [],
|
|
244
|
+
"plugins": [],
|
|
245
|
+
"rules": {
|
|
246
246
|
"no-empty-servers": "error",
|
|
247
247
|
"operation-summary": "error",
|
|
248
248
|
},
|
|
249
249
|
},
|
|
250
250
|
"recommendedFallback": false,
|
|
251
|
-
"rules":
|
|
252
|
-
"async2":
|
|
251
|
+
"rules": {
|
|
252
|
+
"async2": {
|
|
253
253
|
"no-empty-servers": "error",
|
|
254
254
|
"operation-summary": "error",
|
|
255
255
|
},
|
|
256
|
-
"oas2":
|
|
256
|
+
"oas2": {
|
|
257
257
|
"no-empty-servers": "error",
|
|
258
258
|
"operation-summary": "error",
|
|
259
259
|
},
|
|
260
|
-
"oas3_0":
|
|
260
|
+
"oas3_0": {
|
|
261
261
|
"no-empty-servers": "error",
|
|
262
262
|
"operation-summary": "error",
|
|
263
263
|
},
|
|
264
|
-
"oas3_1":
|
|
264
|
+
"oas3_1": {
|
|
265
265
|
"no-empty-servers": "error",
|
|
266
266
|
"operation-summary": "error",
|
|
267
267
|
},
|
|
268
268
|
},
|
|
269
269
|
},
|
|
270
270
|
"telemetry": "on",
|
|
271
|
-
"theme":
|
|
271
|
+
"theme": {},
|
|
272
272
|
}
|
|
273
273
|
`);
|
|
274
274
|
});
|
|
@@ -172,17 +172,21 @@ function verifyExtendedConfig(
|
|
|
172
172
|
const recommendedRules = defaultPlugin?.configs?.[extendsRuleSet];
|
|
173
173
|
expect(recommendedRules).toBeDefined();
|
|
174
174
|
|
|
175
|
-
verifyOasRules(config.styleguide.rules.oas2, overridesRules, recommendedRules?.rules || {});
|
|
176
175
|
verifyOasRules(
|
|
177
|
-
config.styleguide.rules.
|
|
176
|
+
config.styleguide.rules.oas2,
|
|
178
177
|
overridesRules,
|
|
179
|
-
|
|
180
|
-
);
|
|
181
|
-
verifyOasRules(
|
|
182
|
-
config.styleguide.rules.oas3_1,
|
|
183
|
-
overridesRules,
|
|
184
|
-
Object.assign({}, recommendedRules?.rules, recommendedRules?.oas3_1Rules)
|
|
178
|
+
{ ...recommendedRules?.rules, ...recommendedRules?.oas2Rules } || {}
|
|
185
179
|
);
|
|
180
|
+
|
|
181
|
+
verifyOasRules(config.styleguide.rules.oas3_0, overridesRules, {
|
|
182
|
+
...recommendedRules?.rules,
|
|
183
|
+
...recommendedRules?.oas3_0Rules,
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
verifyOasRules(config.styleguide.rules.oas3_1, overridesRules, {
|
|
187
|
+
...recommendedRules?.rules,
|
|
188
|
+
...recommendedRules?.oas3_1Rules,
|
|
189
|
+
});
|
|
186
190
|
}
|
|
187
191
|
|
|
188
192
|
function verifyOasRules(
|
|
@@ -78,25 +78,25 @@ describe('transformConfig', () => {
|
|
|
78
78
|
makeTestRawConfig('styleguide', 'styleguide')
|
|
79
79
|
);
|
|
80
80
|
expect(transformedRawConfig).toMatchInlineSnapshot(`
|
|
81
|
-
|
|
82
|
-
"apis":
|
|
83
|
-
"test@v1":
|
|
81
|
+
{
|
|
82
|
+
"apis": {
|
|
83
|
+
"test@v1": {
|
|
84
84
|
"root": "root.yaml",
|
|
85
|
-
"styleguide":
|
|
86
|
-
"rules":
|
|
85
|
+
"styleguide": {
|
|
86
|
+
"rules": {
|
|
87
87
|
"operation-2xx-response": "error",
|
|
88
88
|
},
|
|
89
89
|
},
|
|
90
90
|
},
|
|
91
91
|
},
|
|
92
|
-
"styleguide":
|
|
93
|
-
"rules":
|
|
92
|
+
"styleguide": {
|
|
93
|
+
"rules": {
|
|
94
94
|
"operation-4xx-response": "warn",
|
|
95
95
|
},
|
|
96
96
|
},
|
|
97
|
-
"theme":
|
|
98
|
-
"mockServer":
|
|
99
|
-
"openapi":
|
|
97
|
+
"theme": {
|
|
98
|
+
"mockServer": {},
|
|
99
|
+
"openapi": {},
|
|
100
100
|
},
|
|
101
101
|
}
|
|
102
102
|
`);
|
|
@@ -111,20 +111,20 @@ describe('transformConfig', () => {
|
|
|
111
111
|
testRawConfig.apis = undefined;
|
|
112
112
|
testRawConfig.apiDefinitions = { legacyApiDefinition: 'file.yaml' };
|
|
113
113
|
expect(utils.transformConfig(testRawConfig)).toMatchInlineSnapshot(`
|
|
114
|
-
|
|
115
|
-
"apis":
|
|
116
|
-
"legacyApiDefinition":
|
|
114
|
+
{
|
|
115
|
+
"apis": {
|
|
116
|
+
"legacyApiDefinition": {
|
|
117
117
|
"root": "file.yaml",
|
|
118
118
|
},
|
|
119
119
|
},
|
|
120
|
-
"styleguide":
|
|
121
|
-
"rules":
|
|
120
|
+
"styleguide": {
|
|
121
|
+
"rules": {
|
|
122
122
|
"operation-4xx-response": "warn",
|
|
123
123
|
},
|
|
124
124
|
},
|
|
125
|
-
"theme":
|
|
126
|
-
"mockServer":
|
|
127
|
-
"openapi":
|
|
125
|
+
"theme": {
|
|
126
|
+
"mockServer": {},
|
|
127
|
+
"openapi": {},
|
|
128
128
|
},
|
|
129
129
|
}
|
|
130
130
|
`);
|