(feat) O3-3790: Indicate errors in JSON schema #339
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Requirements
Summary
Error Handling in Schema Validation
This PR addresses the two types of errors we encounter when working with schemas:
1. Syntax Errors in the JSON Schema:
These errors occur when attempting to parse an invalid JSON string, typically caught using the
JSON.parse()method. The error message should clearly guide the user on the nature and location of the issue. Previously, while we caught these errors, we did not display them to users.2. Invalid Schema According to OpenMRS Form Schema:
These errors are thrown by the Ajv JSON schema validator when validating the JSON against the
openmrs.org/form.schema.json. This aspect has been handled correctly in the current implementation.Enhancements Introduced in This PR:
Displaying Syntax Errors: Syntax errors will now be shown to users via an
InlineNotification, providing clear feedback on the issue.Guided Error Resolution: Users will be prompted to resolve these errors one at a time, ensuring a smoother debugging process. Therefore we can't have this:
Screenshots
Pr implementation
Screancast
This is the implementation in this PR
json-errors.webm
Related Issue
https://openmrs.atlassian.net/browse/O3-3790
Other
Previously, Ajv validation was failing due to errors in the OpenMRS form schema. However, these issues were resolved in a recent commit by @denniskigen.