Skip to content

Commit

Permalink
Fix slow large oneof validation
Browse files Browse the repository at this point in the history
  • Loading branch information
Legend-Master committed Oct 9, 2024
1 parent 493010d commit d40594c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/parser/jsonParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(', '));
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit d40594c

Please sign in to comment.