From de16b4cbd56cd9836609ab79487a6e3e06df964d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ro=C5=BCek?= Date: Tue, 25 Apr 2023 10:47:12 +0200 Subject: [PATCH] feat(core): relax formats validation (#2151) --- .../core/src/ruleset/meta/json-extensions.json | 17 +---------------- .../validation/__tests__/validation.test.ts | 6 +++--- 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/packages/core/src/ruleset/meta/json-extensions.json b/packages/core/src/ruleset/meta/json-extensions.json index b57698d83..f3c6186ec 100644 --- a/packages/core/src/ruleset/meta/json-extensions.json +++ b/packages/core/src/ruleset/meta/json-extensions.json @@ -36,22 +36,7 @@ }, "Format": { "$anchor": "format", - "enum": [ - "oas2", - "oas3", - "oas3.0", - "oas3.1", - "asyncapi2", - "json-schema", - "json-schema-loose", - "json-schema-draft4", - "json-schema-draft6", - "json-schema-draft7", - "json-schema-draft-2019-09", - "json-schema-2019-09", - "json-schema-draft-2020-12", - "json-schema-2020-12" - ], + "type": "string", "errorMessage": "must be a valid format" }, "Functions": { diff --git a/packages/core/src/ruleset/validation/__tests__/validation.test.ts b/packages/core/src/ruleset/validation/__tests__/validation.test.ts index 001427667..3cfab69b9 100644 --- a/packages/core/src/ruleset/validation/__tests__/validation.test.ts +++ b/packages/core/src/ruleset/validation/__tests__/validation.test.ts @@ -941,14 +941,14 @@ describe('JSON Ruleset Validation', () => { it.each<[unknown, RulesetValidationError[]]>([ [ - [2, 'a'], + [2, null], [ new RulesetValidationError('invalid-format', 'must be a valid format', ['formats', '0']), new RulesetValidationError('invalid-format', 'must be a valid format', ['formats', '1']), ], ], [2, [new RulesetValidationError('invalid-ruleset-definition', 'must be an array of formats', ['formats'])]], - [[''], [new RulesetValidationError('invalid-format', 'must be a valid format', ['formats', '0'])]], + [[null], [new RulesetValidationError('invalid-format', 'must be a valid format', ['formats', '0'])]], ])('recognizes invalid ruleset %p formats syntax', (formats, errors) => { expect( assertValidRuleset.bind( @@ -985,7 +985,7 @@ describe('JSON Ruleset Validation', () => { it.each<[unknown, RulesetValidationError[]]>([ [ - [2, 'a'], + [2, null], [ new RulesetValidationError('invalid-format', 'must be a valid format', ['rules', 'rule', 'formats', '0']), new RulesetValidationError('invalid-format', 'must be a valid format', ['rules', 'rule', 'formats', '1']),