From d40594c4cf8109dacb515214b71571052151ac7b Mon Sep 17 00:00:00 2001 From: Tony Date: Wed, 9 Oct 2024 14:45:30 +0800 Subject: [PATCH] Fix slow large oneof validation --- src/parser/jsonParser.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/parser/jsonParser.ts b/src/parser/jsonParser.ts index 3336956..46fef32 100644 --- a/src/parser/jsonParser.ts +++ b/src/parser/jsonParser.ts @@ -261,6 +261,11 @@ export class ValidationResult { public mergeEnumValues(validationResult: ValidationResult): void { if (!this.enumValueMatch && !validationResult.enumValueMatch && this.enumValues && validationResult.enumValues) { this.enumValues = this.enumValues.concat(validationResult.enumValues); + } + } + + public updateEnumMismatchProblemMessages(): void { + if (!this.enumValueMatch && this.enumValues) { for (const error of this.problems) { if (error.code === ErrorCode.EnumValueMismatch) { error.message = l10n.t('Value is not accepted. Valid values: {0}.', this.enumValues.map(v => JSON.stringify(v)).join(', ')); @@ -497,6 +502,7 @@ function validate(n: ASTNode | undefined, schema: JSONSchema, validationResult: }); } if (bestMatch) { + bestMatch.validationResult.updateEnumMismatchProblemMessages(); validationResult.merge(bestMatch.validationResult); matchingSchemas.merge(bestMatch.matchingSchemas); }