@redocly/openapi-core 1.3.0 → 1.4.1
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 +18 -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 +25 -25
- 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 +6 -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.js +26 -14
- 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/decorators/oas2/remove-unused-components.d.ts +2 -0
- package/lib/{rules → decorators}/oas2/remove-unused-components.js +1 -1
- package/lib/decorators/oas3/remove-unused-components.d.ts +2 -0
- package/lib/{rules → decorators}/oas3/remove-unused-components.js +2 -2
- package/lib/env.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/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/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 +18 -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 +38 -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/bundle.ts +4 -4
- 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/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 +15 -0
- package/src/decorators/common/media-type-examples-override.ts +2 -2
- package/src/{rules → decorators}/oas2/remove-unused-components.ts +3 -3
- package/src/{rules → decorators}/oas3/remove-unused-components.ts +3 -3
- package/src/env.ts +1 -1
- 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/oas3_1.ts +12 -0
- package/src/types/redocly-yaml.ts +75 -40
- package/src/visitors.ts +10 -21
- package/src/walk.ts +23 -10
- package/tsconfig.tsbuildinfo +1 -1
- package/lib/rules/oas2/remove-unused-components.d.ts +0 -2
- package/lib/rules/oas3/remove-unused-components.d.ts +0 -2
- /package/src/{rules → decorators}/oas2/__tests__/remove-unused-components.test.ts +0 -0
- /package/src/{rules → decorators}/oas3/__tests__/remove-unused-components.test.ts +0 -0
|
@@ -6,63 +6,78 @@ const theme_config_1 = require("./theme-config");
|
|
|
6
6
|
const _1 = require(".");
|
|
7
7
|
const oas3_1_1 = require("./oas3_1");
|
|
8
8
|
const utils_1 = require("../utils");
|
|
9
|
-
const
|
|
9
|
+
const builtInCommonRules = [
|
|
10
10
|
'spec',
|
|
11
11
|
'info-contact',
|
|
12
|
-
'
|
|
12
|
+
'operation-operationId',
|
|
13
|
+
'tag-description',
|
|
14
|
+
'tags-alphabetical',
|
|
15
|
+
];
|
|
16
|
+
const builtInCommonOASRules = [
|
|
13
17
|
'info-license-url',
|
|
18
|
+
'info-license',
|
|
19
|
+
'no-ambiguous-paths',
|
|
20
|
+
'no-enum-type-mismatch',
|
|
21
|
+
'no-http-verbs-in-paths',
|
|
22
|
+
'no-identical-paths',
|
|
23
|
+
'no-invalid-parameter-examples',
|
|
24
|
+
'no-invalid-schema-examples',
|
|
25
|
+
'no-path-trailing-slash',
|
|
14
26
|
'operation-2xx-response',
|
|
15
27
|
'operation-4xx-response',
|
|
16
|
-
'operation-
|
|
17
|
-
'assertions',
|
|
28
|
+
'operation-description',
|
|
18
29
|
'operation-operationId-unique',
|
|
30
|
+
'operation-operationId-url-safe',
|
|
19
31
|
'operation-parameters-unique',
|
|
20
|
-
'
|
|
32
|
+
'operation-singular-tag',
|
|
33
|
+
'operation-summary',
|
|
21
34
|
'operation-tag-defined',
|
|
22
|
-
'
|
|
23
|
-
'no-enum-type-mismatch',
|
|
24
|
-
'no-path-trailing-slash',
|
|
25
|
-
'no-empty-servers',
|
|
35
|
+
'parameter-description',
|
|
26
36
|
'path-declaration-must-exist',
|
|
27
|
-
'
|
|
28
|
-
'
|
|
29
|
-
'operation-summary',
|
|
30
|
-
'tags-alphabetical',
|
|
31
|
-
'no-server-example.com',
|
|
32
|
-
'no-server-trailing-slash',
|
|
33
|
-
'tag-description',
|
|
34
|
-
'operation-description',
|
|
35
|
-
'no-unused-components',
|
|
37
|
+
'path-excludes-patterns',
|
|
38
|
+
'path-http-verbs-order',
|
|
36
39
|
'path-not-include-query',
|
|
37
40
|
'path-params-defined',
|
|
38
|
-
'
|
|
39
|
-
'
|
|
41
|
+
'path-parameters-defined',
|
|
42
|
+
'path-segment-plural',
|
|
43
|
+
'paths-kebab-case',
|
|
44
|
+
'required-string-property-missing-min-length',
|
|
45
|
+
'response-contains-header',
|
|
46
|
+
'scalar-property-missing-example',
|
|
40
47
|
'security-defined',
|
|
48
|
+
'spec-strict-refs',
|
|
41
49
|
'no-unresolved-refs',
|
|
42
|
-
|
|
50
|
+
];
|
|
51
|
+
const builtInOAS2Rules = [
|
|
43
52
|
'boolean-parameter-prefixes',
|
|
44
|
-
'
|
|
53
|
+
'request-mime-type',
|
|
54
|
+
'response-contains-property',
|
|
55
|
+
'response-mime-type',
|
|
56
|
+
];
|
|
57
|
+
const builtInOAS3Rules = [
|
|
58
|
+
'boolean-parameter-prefixes',
|
|
59
|
+
'component-name-unique',
|
|
60
|
+
'no-empty-servers',
|
|
61
|
+
'no-example-value-and-externalValue',
|
|
45
62
|
'no-invalid-media-type-examples',
|
|
46
|
-
'no-
|
|
47
|
-
'no-
|
|
48
|
-
'no-undefined-server-variable',
|
|
63
|
+
'no-server-example.com',
|
|
64
|
+
'no-server-trailing-slash',
|
|
49
65
|
'no-server-variables-empty-enum',
|
|
50
|
-
'no-
|
|
51
|
-
'
|
|
66
|
+
'no-undefined-server-variable',
|
|
67
|
+
'no-unused-components',
|
|
68
|
+
'operation-4xx-problem-details-rfc7807',
|
|
52
69
|
'request-mime-type',
|
|
53
|
-
'response-mime-type',
|
|
54
|
-
'path-segment-plural',
|
|
55
|
-
'no-invalid-schema-examples',
|
|
56
|
-
'no-invalid-parameter-examples',
|
|
57
|
-
'response-contains-header',
|
|
58
70
|
'response-contains-property',
|
|
59
|
-
'
|
|
71
|
+
'response-mime-type',
|
|
60
72
|
'spec-components-invalid-map-name',
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
73
|
+
];
|
|
74
|
+
const builtInAsync2Rules = ['channels-kebab-case', 'no-channel-trailing-slash'];
|
|
75
|
+
const builtInRules = [
|
|
76
|
+
...builtInCommonRules,
|
|
77
|
+
...builtInCommonOASRules,
|
|
78
|
+
...builtInOAS2Rules,
|
|
79
|
+
...builtInOAS3Rules,
|
|
80
|
+
...builtInAsync2Rules,
|
|
66
81
|
];
|
|
67
82
|
const nodeTypesList = [
|
|
68
83
|
'any',
|
|
@@ -138,14 +153,17 @@ const ConfigStyleguide = {
|
|
|
138
153
|
oas2Rules: 'Rules',
|
|
139
154
|
oas3_0Rules: 'Rules',
|
|
140
155
|
oas3_1Rules: 'Rules',
|
|
156
|
+
async2Rules: 'Rules',
|
|
141
157
|
preprocessors: { type: 'object' },
|
|
142
158
|
oas2Preprocessors: { type: 'object' },
|
|
143
159
|
oas3_0Preprocessors: { type: 'object' },
|
|
144
160
|
oas3_1Preprocessors: { type: 'object' },
|
|
161
|
+
async2Preprocessors: { type: 'object' },
|
|
145
162
|
decorators: { type: 'object' },
|
|
146
163
|
oas2Decorators: { type: 'object' },
|
|
147
164
|
oas3_0Decorators: { type: 'object' },
|
|
148
165
|
oas3_1Decorators: { type: 'object' },
|
|
166
|
+
async2Decorators: { type: 'object' },
|
|
149
167
|
},
|
|
150
168
|
};
|
|
151
169
|
const RootConfigStyleguide = {
|
|
@@ -208,7 +226,7 @@ const Rules = {
|
|
|
208
226
|
// keep the old assert/ prefix as an alias
|
|
209
227
|
return 'Assert';
|
|
210
228
|
}
|
|
211
|
-
else if (
|
|
229
|
+
else if (builtInRules.includes(key) || (0, utils_1.isCustomRuleId)(key)) {
|
|
212
230
|
if (typeof value === 'string') {
|
|
213
231
|
return { enum: ['error', 'warn', 'off'] };
|
|
214
232
|
}
|
|
@@ -309,7 +327,7 @@ const Assert = {
|
|
|
309
327
|
properties: {
|
|
310
328
|
subject: 'AssertionDefinitionSubject',
|
|
311
329
|
assertions: 'AssertionDefinitionAssertions',
|
|
312
|
-
where: _1.listOf('AssertDefinition'),
|
|
330
|
+
where: (0, _1.listOf)('AssertDefinition'),
|
|
313
331
|
message: { type: 'string' },
|
|
314
332
|
suggest: { type: 'array', items: { type: 'string' } },
|
|
315
333
|
severity: { enum: ['error', 'warn', 'off'] },
|
|
@@ -357,8 +375,8 @@ const ConfigLabels = {
|
|
|
357
375
|
};
|
|
358
376
|
const ConfigSidebarLinks = {
|
|
359
377
|
properties: {
|
|
360
|
-
beforeInfo: _1.listOf('CommonConfigSidebarLinks'),
|
|
361
|
-
end: _1.listOf('CommonConfigSidebarLinks'),
|
|
378
|
+
beforeInfo: (0, _1.listOf)('CommonConfigSidebarLinks'),
|
|
379
|
+
end: (0, _1.listOf)('CommonConfigSidebarLinks'),
|
|
362
380
|
},
|
|
363
381
|
};
|
|
364
382
|
const CommonConfigSidebarLinks = {
|
|
@@ -386,7 +404,7 @@ const CommonColorProps = {
|
|
|
386
404
|
},
|
|
387
405
|
};
|
|
388
406
|
const BorderThemeColors = {
|
|
389
|
-
properties: utils_1.pickObjectProps(CommonThemeColors.properties, ['light', 'dark']),
|
|
407
|
+
properties: (0, utils_1.pickObjectProps)(CommonThemeColors.properties, ['light', 'dark']),
|
|
390
408
|
};
|
|
391
409
|
const HttpColors = {
|
|
392
410
|
properties: {
|
|
@@ -410,7 +428,7 @@ const ResponseColors = {
|
|
|
410
428
|
},
|
|
411
429
|
};
|
|
412
430
|
const SecondaryColors = {
|
|
413
|
-
properties: utils_1.omitObjectProps(CommonThemeColors.properties, ['dark']),
|
|
431
|
+
properties: (0, utils_1.omitObjectProps)(CommonThemeColors.properties, ['dark']),
|
|
414
432
|
};
|
|
415
433
|
const TextThemeColors = {
|
|
416
434
|
properties: {
|
|
@@ -458,10 +476,10 @@ const FontConfig = {
|
|
|
458
476
|
},
|
|
459
477
|
};
|
|
460
478
|
const ButtonsConfig = {
|
|
461
|
-
properties: Object.assign(Object.assign({}, utils_1.omitObjectProps(FontConfig.properties, ['fontSize', 'lineHeight'])), { borderRadius: { type: 'string' }, hoverStyle: { type: 'string' }, boxShadow: { type: 'string' }, hoverBoxShadow: { type: 'string' }, sizes: 'Sizes' }),
|
|
479
|
+
properties: Object.assign(Object.assign({}, (0, utils_1.omitObjectProps)(FontConfig.properties, ['fontSize', 'lineHeight'])), { borderRadius: { type: 'string' }, hoverStyle: { type: 'string' }, boxShadow: { type: 'string' }, hoverBoxShadow: { type: 'string' }, sizes: 'Sizes' }),
|
|
462
480
|
};
|
|
463
481
|
const BadgeFontConfig = {
|
|
464
|
-
properties: utils_1.pickObjectProps(FontConfig.properties, ['fontSize', 'lineHeight']),
|
|
482
|
+
properties: (0, utils_1.pickObjectProps)(FontConfig.properties, ['fontSize', 'lineHeight']),
|
|
465
483
|
};
|
|
466
484
|
const BadgeSizes = {
|
|
467
485
|
properties: {
|
|
@@ -470,7 +488,7 @@ const BadgeSizes = {
|
|
|
470
488
|
},
|
|
471
489
|
};
|
|
472
490
|
const HttpBadgesConfig = {
|
|
473
|
-
properties: Object.assign(Object.assign({}, utils_1.omitObjectProps(FontConfig.properties, ['fontSize', 'lineHeight'])), { borderRadius: { type: 'string' }, color: { type: 'string' }, sizes: 'BadgeSizes' }),
|
|
491
|
+
properties: Object.assign(Object.assign({}, (0, utils_1.omitObjectProps)(FontConfig.properties, ['fontSize', 'lineHeight'])), { borderRadius: { type: 'string' }, color: { type: 'string' }, sizes: 'BadgeSizes' }),
|
|
474
492
|
};
|
|
475
493
|
const LabelControls = {
|
|
476
494
|
properties: {
|
|
@@ -556,7 +574,7 @@ const GroupItemsConfig = {
|
|
|
556
574
|
},
|
|
557
575
|
};
|
|
558
576
|
const Level1Items = {
|
|
559
|
-
properties: utils_1.pickObjectProps(GroupItemsConfig.properties, ['textTransform']),
|
|
577
|
+
properties: (0, utils_1.pickObjectProps)(GroupItemsConfig.properties, ['textTransform']),
|
|
560
578
|
};
|
|
561
579
|
const SpacingConfig = {
|
|
562
580
|
properties: {
|
|
@@ -569,7 +587,7 @@ const SpacingConfig = {
|
|
|
569
587
|
},
|
|
570
588
|
};
|
|
571
589
|
const Sidebar = {
|
|
572
|
-
properties: Object.assign(Object.assign({}, utils_1.omitObjectProps(FontConfig.properties, ['fontWeight', 'lineHeight'])), { activeBgColor: { type: 'string' }, activeTextColor: { type: 'string' }, backgroundColor: { type: 'string' }, borderRadius: { type: 'string' }, breakPath: { type: 'boolean' }, caretColor: { type: 'string' }, caretSize: { type: 'string' }, groupItems: 'GroupItemsConfig', level1items: 'Level1Items', rightLineColor: { type: 'string' }, separatorLabelColor: { type: 'string' }, showAtBreakpoint: { type: 'string' }, spacing: 'SpacingConfig', textColor: { type: 'string' }, width: { type: 'string' } }),
|
|
590
|
+
properties: Object.assign(Object.assign({}, (0, utils_1.omitObjectProps)(FontConfig.properties, ['fontWeight', 'lineHeight'])), { activeBgColor: { type: 'string' }, activeTextColor: { type: 'string' }, backgroundColor: { type: 'string' }, borderRadius: { type: 'string' }, breakPath: { type: 'boolean' }, caretColor: { type: 'string' }, caretSize: { type: 'string' }, groupItems: 'GroupItemsConfig', level1items: 'Level1Items', rightLineColor: { type: 'string' }, separatorLabelColor: { type: 'string' }, showAtBreakpoint: { type: 'string' }, spacing: 'SpacingConfig', textColor: { type: 'string' }, width: { type: 'string' } }),
|
|
573
591
|
};
|
|
574
592
|
const Heading = {
|
|
575
593
|
properties: Object.assign(Object.assign({}, FontConfig.properties), { color: { type: 'string' }, transform: { type: 'string' } }),
|
|
@@ -589,7 +607,7 @@ const CodeConfig = {
|
|
|
589
607
|
}, wrap: { type: 'boolean' } }),
|
|
590
608
|
};
|
|
591
609
|
const HeadingsConfig = {
|
|
592
|
-
properties: utils_1.omitObjectProps(FontConfig.properties, ['fontSize']),
|
|
610
|
+
properties: (0, utils_1.omitObjectProps)(FontConfig.properties, ['fontSize']),
|
|
593
611
|
};
|
|
594
612
|
const LinksConfig = {
|
|
595
613
|
properties: {
|
|
@@ -601,10 +619,10 @@ const LinksConfig = {
|
|
|
601
619
|
},
|
|
602
620
|
};
|
|
603
621
|
const Typography = {
|
|
604
|
-
properties: Object.assign(Object.assign({ code: 'CodeConfig', fieldName: 'FontConfig' }, utils_1.pickObjectProps(FontConfig.properties, ['fontSize', 'fontFamily'])), { fontWeightBold: { type: 'string' }, fontWeightLight: { type: 'string' }, fontWeightRegular: { type: 'string' }, heading1: 'Heading', heading2: 'Heading', heading3: 'Heading', headings: 'HeadingsConfig', lineHeight: { type: 'string' }, links: 'LinksConfig', optimizeSpeed: { type: 'boolean' }, rightPanelHeading: 'Heading', smoothing: { enum: ['auto', 'none', 'antialiased', 'subpixel-antialiased', 'grayscale'] } }),
|
|
622
|
+
properties: Object.assign(Object.assign({ code: 'CodeConfig', fieldName: 'FontConfig' }, (0, utils_1.pickObjectProps)(FontConfig.properties, ['fontSize', 'fontFamily'])), { fontWeightBold: { type: 'string' }, fontWeightLight: { type: 'string' }, fontWeightRegular: { type: 'string' }, heading1: 'Heading', heading2: 'Heading', heading3: 'Heading', headings: 'HeadingsConfig', lineHeight: { type: 'string' }, links: 'LinksConfig', optimizeSpeed: { type: 'boolean' }, rightPanelHeading: 'Heading', smoothing: { enum: ['auto', 'none', 'antialiased', 'subpixel-antialiased', 'grayscale'] } }),
|
|
605
623
|
};
|
|
606
624
|
const TokenProps = {
|
|
607
|
-
properties: Object.assign({ color: { type: 'string' } }, utils_1.omitObjectProps(FontConfig.properties, ['fontWeight'])),
|
|
625
|
+
properties: Object.assign({ color: { type: 'string' } }, (0, utils_1.omitObjectProps)(FontConfig.properties, ['fontWeight'])),
|
|
608
626
|
};
|
|
609
627
|
const CodeBlock = {
|
|
610
628
|
properties: {
|
|
@@ -680,7 +698,7 @@ const ConfigTheme = {
|
|
|
680
698
|
const GenerateCodeSamples = {
|
|
681
699
|
properties: {
|
|
682
700
|
skipOptionalParameters: { type: 'boolean' },
|
|
683
|
-
languages: _1.listOf('ConfigLanguage'),
|
|
701
|
+
languages: (0, _1.listOf)('ConfigLanguage'),
|
|
684
702
|
},
|
|
685
703
|
required: ['languages'],
|
|
686
704
|
};
|
|
@@ -596,4 +596,4 @@ var ScorecardStatus;
|
|
|
596
596
|
ScorecardStatus["BelowMinimum"] = "Below minimum";
|
|
597
597
|
ScorecardStatus["Highest"] = "Highest";
|
|
598
598
|
ScorecardStatus["Minimum"] = "Minimum";
|
|
599
|
-
})(ScorecardStatus
|
|
599
|
+
})(ScorecardStatus || (exports.ScorecardStatus = ScorecardStatus = {}));
|
package/lib/typings/common.d.ts
CHANGED
|
@@ -4,5 +4,5 @@ export interface StatsRow {
|
|
|
4
4
|
color: 'red' | 'yellow' | 'green' | 'white' | 'magenta' | 'cyan';
|
|
5
5
|
items?: Set<string>;
|
|
6
6
|
}
|
|
7
|
-
export
|
|
8
|
-
export
|
|
7
|
+
export type StatsName = 'operations' | 'refs' | 'tags' | 'externalDocs' | 'pathItems' | 'links' | 'schemas' | 'parameters';
|
|
8
|
+
export type StatsAccumulator = Record<StatsName, StatsRow>;
|
package/lib/typings/openapi.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ export interface Oas3Paths {
|
|
|
35
35
|
export interface OasRef {
|
|
36
36
|
$ref: string;
|
|
37
37
|
}
|
|
38
|
-
export
|
|
38
|
+
export type Referenced<T> = OasRef | T;
|
|
39
39
|
export interface Oas3PathItem {
|
|
40
40
|
summary?: string;
|
|
41
41
|
description?: string;
|
|
@@ -147,7 +147,7 @@ export interface Oas3Schema {
|
|
|
147
147
|
xml?: Oas3Xml;
|
|
148
148
|
'x-tags'?: string[];
|
|
149
149
|
}
|
|
150
|
-
export
|
|
150
|
+
export type Oas3_1Schema = Oas3Schema & {
|
|
151
151
|
type?: string | string[];
|
|
152
152
|
examples?: any[];
|
|
153
153
|
};
|
|
@@ -183,8 +183,8 @@ export interface Oas3Encoding {
|
|
|
183
183
|
explode: boolean;
|
|
184
184
|
allowReserved: boolean;
|
|
185
185
|
}
|
|
186
|
-
export
|
|
187
|
-
export
|
|
186
|
+
export type Oas3ParameterLocation = 'query' | 'header' | 'path' | 'cookie';
|
|
187
|
+
export type Oas3ParameterStyle = 'matrix' | 'label' | 'form' | 'simple' | 'spaceDelimited' | 'pipeDelimited' | 'deepObject';
|
|
188
188
|
export interface Oas3RequestBody {
|
|
189
189
|
description?: string;
|
|
190
190
|
required?: boolean;
|
|
@@ -210,7 +210,7 @@ export interface Oas3Response {
|
|
|
210
210
|
export interface Oas3Link {
|
|
211
211
|
$ref?: string;
|
|
212
212
|
}
|
|
213
|
-
export
|
|
213
|
+
export type Oas3Header = Omit<Oas3Parameter, 'in' | 'name'>;
|
|
214
214
|
export interface Oas3Callback {
|
|
215
215
|
[name: string]: Oas3PathItem;
|
|
216
216
|
}
|
|
@@ -243,7 +243,7 @@ export interface Oas3Components {
|
|
|
243
243
|
[name: string]: Referenced<Oas3Callback>;
|
|
244
244
|
};
|
|
245
245
|
}
|
|
246
|
-
export
|
|
246
|
+
export type Oas3ComponentName = keyof Oas3Components;
|
|
247
247
|
export interface Oas3SecurityRequirement {
|
|
248
248
|
[name: string]: string[];
|
|
249
249
|
}
|
package/lib/typings/swagger.d.ts
CHANGED
|
@@ -73,7 +73,7 @@ export interface Oas2Operation {
|
|
|
73
73
|
'x-code-samples'?: Oas2XCodeSample[];
|
|
74
74
|
'x-hideTryItPanel'?: boolean;
|
|
75
75
|
}
|
|
76
|
-
export
|
|
76
|
+
export type Oas2Parameter = Oas2BodyParameter | Oas2SimpleParameter;
|
|
77
77
|
export interface Oas2BodyParameter {
|
|
78
78
|
name: string;
|
|
79
79
|
in: 'body';
|
|
@@ -169,11 +169,11 @@ export interface Oas2Schema {
|
|
|
169
169
|
xml?: Oas2Xml;
|
|
170
170
|
'x-tags'?: string[];
|
|
171
171
|
}
|
|
172
|
-
export
|
|
172
|
+
export type Oas2ParameterLocation = 'query' | 'header' | 'path' | 'formData';
|
|
173
173
|
export interface Oas2Responses {
|
|
174
174
|
[code: string]: Oas2Response;
|
|
175
175
|
}
|
|
176
|
-
export
|
|
176
|
+
export type Oas2Header = Oas2Items & {
|
|
177
177
|
description?: 'string';
|
|
178
178
|
};
|
|
179
179
|
export interface Oas2Response {
|
package/lib/utils.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { UserContext } from './walk';
|
|
2
2
|
import { HttpResolveConfig } from './config';
|
|
3
3
|
export { parseYaml, stringifyYaml } from './js-yaml';
|
|
4
|
-
export
|
|
4
|
+
export type StackFrame<T> = {
|
|
5
5
|
prev: StackFrame<T> | null;
|
|
6
6
|
value: T;
|
|
7
7
|
};
|
|
8
|
-
export
|
|
9
|
-
export
|
|
8
|
+
export type Stack<T> = StackFrame<T> | null;
|
|
9
|
+
export type StackNonEmpty<T> = StackFrame<T>;
|
|
10
10
|
export declare function pushStack<T, P extends Stack<T> = Stack<T>>(head: P, value: T): {
|
|
11
11
|
prev: P;
|
|
12
12
|
value: T;
|
|
13
13
|
};
|
|
14
14
|
export declare function popStack<T, P extends Stack<T>>(head: P): StackFrame<T> | null;
|
|
15
|
-
export
|
|
15
|
+
export type BundleOutputFormat = 'json' | 'yml' | 'yaml';
|
|
16
16
|
export declare function loadYaml<T>(filename: string): Promise<T>;
|
|
17
17
|
export declare function isDefined<T>(x: T | undefined): x is T;
|
|
18
18
|
export declare function isPlainObject(value: any): value is object;
|
|
@@ -44,7 +44,7 @@ export declare function isCustomRuleId(id: string): boolean;
|
|
|
44
44
|
export declare function doesYamlFileExist(filePath: string): boolean;
|
|
45
45
|
export declare function showWarningForDeprecatedField(deprecatedField: string, updatedField?: string, updatedObject?: string): void;
|
|
46
46
|
export declare function showErrorForDeprecatedField(deprecatedField: string, updatedField?: string, updatedObject?: string): void;
|
|
47
|
-
export
|
|
47
|
+
export type Falsy = undefined | null | false | '' | 0;
|
|
48
48
|
export declare function isTruthy<Truthy>(value: Truthy | Falsy): value is Truthy;
|
|
49
49
|
export declare function identity<T>(value: T): T;
|
|
50
50
|
export declare function keysOf<T>(obj: T): (keyof T)[];
|
package/lib/utils.js
CHANGED
|
@@ -33,7 +33,7 @@ exports.popStack = popStack;
|
|
|
33
33
|
function loadYaml(filename) {
|
|
34
34
|
return __awaiter(this, void 0, void 0, function* () {
|
|
35
35
|
const contents = yield fs.promises.readFile(filename, 'utf-8');
|
|
36
|
-
return js_yaml_1.parseYaml(contents);
|
|
36
|
+
return (0, js_yaml_1.parseYaml)(contents);
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
39
|
exports.loadYaml = loadYaml;
|
|
@@ -141,7 +141,7 @@ function readFileAsStringSync(filePath) {
|
|
|
141
141
|
exports.readFileAsStringSync = readFileAsStringSync;
|
|
142
142
|
function yamlAndJsonSyncReader(filePath) {
|
|
143
143
|
const content = fs.readFileSync(filePath, 'utf-8');
|
|
144
|
-
return js_yaml_1.parseYaml(content);
|
|
144
|
+
return (0, js_yaml_1.parseYaml)(content);
|
|
145
145
|
}
|
|
146
146
|
exports.yamlAndJsonSyncReader = yamlAndJsonSyncReader;
|
|
147
147
|
function isPathParameter(pathSegment) {
|
|
@@ -189,7 +189,7 @@ function isCustomRuleId(id) {
|
|
|
189
189
|
}
|
|
190
190
|
exports.isCustomRuleId = isCustomRuleId;
|
|
191
191
|
function doesYamlFileExist(filePath) {
|
|
192
|
-
return ((path_1.extname(filePath) === '.yaml' || path_1.extname(filePath) === '.yml') &&
|
|
192
|
+
return (((0, path_1.extname)(filePath) === '.yaml' || (0, path_1.extname)(filePath) === '.yml') &&
|
|
193
193
|
fs.hasOwnProperty('existsSync') &&
|
|
194
194
|
fs.existsSync(filePath));
|
|
195
195
|
}
|
package/lib/visitors.d.ts
CHANGED
|
@@ -5,20 +5,20 @@ import type { Stack } from './utils';
|
|
|
5
5
|
import type { UserContext, ResolveResult, ProblemSeverity } from './walk';
|
|
6
6
|
import type { Location } from './ref-utils';
|
|
7
7
|
import { Async2Definition } from './typings/asyncapi';
|
|
8
|
-
export
|
|
9
|
-
export
|
|
8
|
+
export type SkipFunctionContext = Pick<UserContext, 'location' | 'rawNode' | 'resolve' | 'rawLocation'>;
|
|
9
|
+
export type VisitFunction<T> = (node: T, ctx: UserContext & {
|
|
10
10
|
ignoreNextVisitorsOnNode: () => void;
|
|
11
11
|
}, parents?: any, context?: any) => void;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
type VisitRefFunction = (node: OasRef, ctx: UserContext, resolved: ResolveResult<any>) => void;
|
|
13
|
+
type SkipFunction<T> = (node: T, key: string | number, ctx: SkipFunctionContext) => boolean;
|
|
14
|
+
type VisitObject<T> = {
|
|
15
15
|
enter?: VisitFunction<T>;
|
|
16
16
|
leave?: VisitFunction<T>;
|
|
17
17
|
skip?: SkipFunction<T>;
|
|
18
18
|
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
export type NestedVisitObject<T, P> = VisitObject<T> & NestedVisitor<P>;
|
|
20
|
+
type VisitFunctionOrObject<T> = VisitFunction<T> | VisitObject<T>;
|
|
21
|
+
export type VisitorNode<T> = {
|
|
22
22
|
ruleId: string;
|
|
23
23
|
severity: ProblemSeverity;
|
|
24
24
|
context: VisitorLevelContext | VisitorSkippedLevelContext;
|
|
@@ -26,14 +26,14 @@ declare type VisitorNode<T> = {
|
|
|
26
26
|
visit: VisitFunction<T>;
|
|
27
27
|
skip?: SkipFunction<T>;
|
|
28
28
|
};
|
|
29
|
-
|
|
29
|
+
type VisitorRefNode = {
|
|
30
30
|
ruleId: string;
|
|
31
31
|
severity: ProblemSeverity;
|
|
32
32
|
context: VisitorLevelContext;
|
|
33
33
|
depth: number;
|
|
34
34
|
visit: VisitRefFunction;
|
|
35
35
|
};
|
|
36
|
-
export
|
|
36
|
+
export type VisitorLevelContext = {
|
|
37
37
|
isSkippedLevel: false;
|
|
38
38
|
type: NormalizedNodeType;
|
|
39
39
|
parent: VisitorLevelContext | null;
|
|
@@ -45,13 +45,13 @@ export declare type VisitorLevelContext = {
|
|
|
45
45
|
location?: Location;
|
|
46
46
|
}>;
|
|
47
47
|
};
|
|
48
|
-
export
|
|
48
|
+
export type VisitorSkippedLevelContext = {
|
|
49
49
|
isSkippedLevel: true;
|
|
50
50
|
parent: VisitorLevelContext;
|
|
51
51
|
seen: Set<any>;
|
|
52
52
|
};
|
|
53
|
-
|
|
54
|
-
export
|
|
53
|
+
export type NormalizeVisitor<Fn> = Fn extends VisitFunction<infer T> ? VisitorNode<T> : never;
|
|
54
|
+
export type BaseVisitor = {
|
|
55
55
|
any?: {
|
|
56
56
|
enter?: VisitFunction<any>;
|
|
57
57
|
leave?: VisitFunction<any>;
|
|
@@ -62,7 +62,7 @@ export declare type BaseVisitor = {
|
|
|
62
62
|
leave?: VisitRefFunction;
|
|
63
63
|
} | VisitRefFunction;
|
|
64
64
|
};
|
|
65
|
-
|
|
65
|
+
type Oas3FlatVisitor = {
|
|
66
66
|
Root?: VisitFunctionOrObject<Oas3Definition>;
|
|
67
67
|
Tag?: VisitFunctionOrObject<Oas3Tag>;
|
|
68
68
|
ExternalDocs?: VisitFunctionOrObject<Oas3ExternalDocs>;
|
|
@@ -110,7 +110,7 @@ declare type Oas3FlatVisitor = {
|
|
|
110
110
|
SecurityScheme?: VisitFunctionOrObject<Oas3SecurityScheme>;
|
|
111
111
|
SpecExtension?: VisitFunctionOrObject<unknown>;
|
|
112
112
|
};
|
|
113
|
-
|
|
113
|
+
type Oas2FlatVisitor = {
|
|
114
114
|
Root?: VisitFunctionOrObject<Oas2Definition>;
|
|
115
115
|
Tag?: VisitFunctionOrObject<Oas2Tag>;
|
|
116
116
|
ExternalDocs?: VisitFunctionOrObject<Oas2ExternalDocs>;
|
|
@@ -133,28 +133,26 @@ declare type Oas2FlatVisitor = {
|
|
|
133
133
|
NamedResponses?: VisitFunctionOrObject<Record<string, Oas2Response>>;
|
|
134
134
|
NamedParameters?: VisitFunctionOrObject<Record<string, Oas2Parameter>>;
|
|
135
135
|
SecurityScheme?: VisitFunctionOrObject<Oas2SecurityScheme>;
|
|
136
|
+
NamedSecuritySchemes?: VisitFunctionOrObject<Record<string, Oas2SecurityScheme>>;
|
|
136
137
|
SpecExtension?: VisitFunctionOrObject<unknown>;
|
|
137
138
|
};
|
|
138
|
-
|
|
139
|
+
type Async2FlatVisitor = {
|
|
139
140
|
Root?: VisitFunctionOrObject<Async2Definition>;
|
|
140
141
|
};
|
|
141
|
-
|
|
142
|
+
type Oas3NestedVisitor = {
|
|
142
143
|
[T in keyof Oas3FlatVisitor]: Oas3FlatVisitor[T] extends Function ? Oas3FlatVisitor[T] : Oas3FlatVisitor[T] & NestedVisitor<Oas3NestedVisitor>;
|
|
143
144
|
};
|
|
144
|
-
|
|
145
|
+
type Oas2NestedVisitor = {
|
|
145
146
|
[T in keyof Oas2FlatVisitor]: Oas2FlatVisitor[T] extends Function ? Oas2FlatVisitor[T] : Oas2FlatVisitor[T] & NestedVisitor<Oas2NestedVisitor>;
|
|
146
147
|
};
|
|
147
|
-
|
|
148
|
+
type Async2NestedVisitor = {
|
|
148
149
|
[T in keyof Async2FlatVisitor]: Async2FlatVisitor[T] extends Function ? Async2FlatVisitor[T] : Async2FlatVisitor[T] & NestedVisitor<Async2NestedVisitor>;
|
|
149
150
|
};
|
|
150
|
-
export
|
|
151
|
-
export
|
|
152
|
-
export
|
|
153
|
-
export
|
|
154
|
-
export
|
|
155
|
-
export declare type Async2TransformVisitor = BaseVisitor & Async2FlatVisitor & Record<string, VisitFunction<any> | VisitObject<any>>;
|
|
156
|
-
export declare type NestedVisitor<T> = Exclude<T, 'any' | 'ref' | 'Root'>;
|
|
157
|
-
export declare type NormalizedOasVisitors<T extends BaseVisitor> = {
|
|
151
|
+
export type Oas3Visitor = BaseVisitor & Oas3NestedVisitor & Record<string, VisitFunction<any> | NestedVisitObject<any, Oas3NestedVisitor>>;
|
|
152
|
+
export type Oas2Visitor = BaseVisitor & Oas2NestedVisitor & Record<string, VisitFunction<any> | NestedVisitObject<any, Oas2NestedVisitor>>;
|
|
153
|
+
export type Async2Visitor = BaseVisitor & Async2NestedVisitor & Record<string, VisitFunction<any> | NestedVisitObject<any, Async2NestedVisitor>>;
|
|
154
|
+
export type NestedVisitor<T> = Exclude<T, 'any' | 'ref' | 'Root'>;
|
|
155
|
+
export type NormalizedOasVisitors<T extends BaseVisitor> = {
|
|
158
156
|
[V in keyof T]-?: {
|
|
159
157
|
enter: Array<NormalizeVisitor<T[V]>>;
|
|
160
158
|
leave: Array<NormalizeVisitor<T[V]>>;
|
|
@@ -169,19 +167,19 @@ export declare type NormalizedOasVisitors<T extends BaseVisitor> = {
|
|
|
169
167
|
leave: Array<VisitorNode<any>>;
|
|
170
168
|
};
|
|
171
169
|
};
|
|
172
|
-
export
|
|
173
|
-
export
|
|
174
|
-
export
|
|
175
|
-
export
|
|
176
|
-
export
|
|
177
|
-
export
|
|
178
|
-
export
|
|
179
|
-
export
|
|
180
|
-
export
|
|
181
|
-
export
|
|
182
|
-
export
|
|
183
|
-
export
|
|
184
|
-
export
|
|
170
|
+
export type Oas3Rule = (options: Record<string, any>) => Oas3Visitor | Oas3Visitor[];
|
|
171
|
+
export type Oas2Rule = (options: Record<string, any>) => Oas2Visitor | Oas2Visitor[];
|
|
172
|
+
export type Async2Rule = (options: Record<string, any>) => Async2Visitor | Async2Visitor[];
|
|
173
|
+
export type Oas3Preprocessor = (options: Record<string, any>) => Oas3Visitor;
|
|
174
|
+
export type Oas2Preprocessor = (options: Record<string, any>) => Oas2Visitor;
|
|
175
|
+
export type Async2Preprocessor = (options: Record<string, any>) => Async2Visitor;
|
|
176
|
+
export type Oas3Decorator = (options: Record<string, any>) => Oas3Visitor;
|
|
177
|
+
export type Oas2Decorator = (options: Record<string, any>) => Oas2Visitor;
|
|
178
|
+
export type Async2Decorator = (options: Record<string, any>) => Async2Visitor;
|
|
179
|
+
export type OasRule = Oas3Rule;
|
|
180
|
+
export type OasPreprocessor = Oas3Preprocessor;
|
|
181
|
+
export type OasDecorator = Oas3Decorator;
|
|
182
|
+
export type RuleInstanceConfig = {
|
|
185
183
|
ruleId: string;
|
|
186
184
|
severity: ProblemSeverity;
|
|
187
185
|
};
|
package/lib/walk.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { Referenced } from './typings/openapi';
|
|
2
|
-
import type { NormalizedOasVisitors } from './visitors';
|
|
2
|
+
import type { NormalizedOasVisitors, BaseVisitor } from './visitors';
|
|
3
3
|
import type { ResolvedRefMap, Document } from './resolve';
|
|
4
4
|
import type { NormalizedNodeType } from './types';
|
|
5
5
|
import type { RuleSeverity } from './config';
|
|
6
6
|
import { Location } from './ref-utils';
|
|
7
7
|
import { ResolveError, YamlParseError, Source } from './resolve';
|
|
8
8
|
import { SpecVersion } from './oas-types';
|
|
9
|
-
|
|
10
|
-
export
|
|
9
|
+
export type NonUndefined = string | number | boolean | symbol | bigint | object | Record<string, any>;
|
|
10
|
+
export type ResolveResult<T extends NonUndefined> = {
|
|
11
11
|
node: T;
|
|
12
12
|
location: Location;
|
|
13
13
|
error?: ResolveError | YamlParseError;
|
|
@@ -16,8 +16,8 @@ export declare type ResolveResult<T extends NonUndefined> = {
|
|
|
16
16
|
location: undefined;
|
|
17
17
|
error?: ResolveError | YamlParseError;
|
|
18
18
|
};
|
|
19
|
-
export
|
|
20
|
-
export
|
|
19
|
+
export type ResolveFn = <T extends NonUndefined>(node: Referenced<T>, from?: string) => ResolveResult<T>;
|
|
20
|
+
export type UserContext = {
|
|
21
21
|
report(problem: Problem): void;
|
|
22
22
|
location: Location;
|
|
23
23
|
rawNode: any;
|
|
@@ -30,23 +30,23 @@ export declare type UserContext = {
|
|
|
30
30
|
oasVersion: SpecVersion;
|
|
31
31
|
getVisitorData: () => Record<string, unknown>;
|
|
32
32
|
};
|
|
33
|
-
export
|
|
33
|
+
export type Loc = {
|
|
34
34
|
line: number;
|
|
35
35
|
col: number;
|
|
36
36
|
};
|
|
37
|
-
export
|
|
37
|
+
export type PointerLocationObject = {
|
|
38
38
|
source: Source;
|
|
39
39
|
reportOnKey?: boolean;
|
|
40
40
|
pointer: string;
|
|
41
41
|
};
|
|
42
|
-
export
|
|
42
|
+
export type LineColLocationObject = Omit<PointerLocationObject, 'pointer'> & {
|
|
43
43
|
pointer: undefined;
|
|
44
44
|
start: Loc;
|
|
45
45
|
end?: Loc;
|
|
46
46
|
};
|
|
47
|
-
export
|
|
48
|
-
export
|
|
49
|
-
export
|
|
47
|
+
export type LocationObject = LineColLocationObject | PointerLocationObject;
|
|
48
|
+
export type ProblemSeverity = 'error' | 'warn';
|
|
49
|
+
export type Problem = {
|
|
50
50
|
message: string;
|
|
51
51
|
suggest?: string[];
|
|
52
52
|
location?: Partial<LocationObject> | Array<Partial<LocationObject>>;
|
|
@@ -54,7 +54,7 @@ export declare type Problem = {
|
|
|
54
54
|
forceSeverity?: RuleSeverity;
|
|
55
55
|
ruleId?: string;
|
|
56
56
|
};
|
|
57
|
-
export
|
|
57
|
+
export type NormalizedProblem = {
|
|
58
58
|
message: string;
|
|
59
59
|
ruleId: string;
|
|
60
60
|
severity: ProblemSeverity;
|
|
@@ -63,17 +63,16 @@ export declare type NormalizedProblem = {
|
|
|
63
63
|
suggest: string[];
|
|
64
64
|
ignored?: boolean;
|
|
65
65
|
};
|
|
66
|
-
export
|
|
66
|
+
export type WalkContext = {
|
|
67
67
|
problems: NormalizedProblem[];
|
|
68
68
|
oasVersion: SpecVersion;
|
|
69
69
|
visitorsData: Record<string, Record<string, unknown>>;
|
|
70
70
|
refTypes?: Map<string, NormalizedNodeType>;
|
|
71
71
|
};
|
|
72
|
-
export declare function walkDocument<T>(opts: {
|
|
72
|
+
export declare function walkDocument<T extends BaseVisitor>(opts: {
|
|
73
73
|
document: Document;
|
|
74
74
|
rootType: NormalizedNodeType;
|
|
75
75
|
normalizedVisitors: NormalizedOasVisitors<T>;
|
|
76
76
|
resolvedRefMap: ResolvedRefMap;
|
|
77
77
|
ctx: WalkContext;
|
|
78
78
|
}): void;
|
|
79
|
-
export {};
|