Skip to content

Commit fa280a3

Browse files
authored
fix: validate configurable rules severity overrides correctly in config (#1872)
1 parent 4681d7c commit fa280a3

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

.changeset/dry-candles-lie.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@redocly/openapi-core": patch
3+
---
4+
5+
Resolved an issue where overrides for the severity of configurable rules raised warnings when validating the config.

packages/core/src/types/redocly-yaml.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,10 +392,18 @@ const Rules: NodeType = {
392392
properties: {},
393393
additionalProperties: (value: unknown, key: string) => {
394394
if (key.startsWith('rule/')) {
395-
return 'Assert';
395+
if (typeof value === 'string') {
396+
return { enum: ['error', 'warn', 'off'] };
397+
} else {
398+
return 'Assert';
399+
}
396400
} else if (key.startsWith('assert/')) {
397401
// keep the old assert/ prefix as an alias
398-
return 'Assert';
402+
if (typeof value === 'string') {
403+
return { enum: ['error', 'warn', 'off'] };
404+
} else {
405+
return 'Assert';
406+
}
399407
} else if (builtInRules.includes(key as BuiltInRuleId) || isCustomRuleId(key)) {
400408
if (typeof value === 'string') {
401409
return { enum: ['error', 'warn', 'off'] };

0 commit comments

Comments
 (0)