Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix slow large oneof validation #247

Merged
merged 2 commits into from
Dec 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading