-
Notifications
You must be signed in to change notification settings - Fork 52
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
Code Editor (Specmatic Error - Line Highlighting) #1474
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
samyakOO7
requested review from
joelrosario,
harikrishnan83 and
StarKhan6368
and removed request for
joelrosario and
harikrishnan83
December 14, 2024 06:43
* main: (24 commits) Refactored StringPattern.matches - minor grammatical and spelling changes in tests - adding tests for contradicting length constraints and regex Merged latest Merged latest Specmatic String Pattern Tests Rectified Specmatic String Pattern Tests Rectified Specmatic String Pattern Tests String Pattern Validation Updated Removed unwanted arguments Changes for String Pattern Csv Source Tests Changes for String Pattern throwOnFailure() Fixed test cases File formatted File formatted File formatted #1417 making test and stub consistent when pattern is defined for String - Removing comments and instead renaming variables for readability - Removing redundant rows in parameterised test for min and max length based String generation - Adding test for regex based generation - Extracting regex generation code to separate method Updated Default Example Match Condition To the Top Pattern Validation Logic for Minimum Size Regex Pattern Validation Logic for Minimum Size Regex Cleaned code- Removed Cognitive Complexity ...
…e edit - made all return types non-null to keep it consistent
…essage class - extracting constants for some of the magic strings
harikrishnan83
requested changes
Dec 15, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add unit tests for ExampleValidationErrorMessage
jsonpath extraction logic
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Code Editor Specmatic Error Line Highlighting
The functionality implemented highlights error lines in a code editor using metadata and JSON paths derived from a Specmatic response.
Functionality:
4.Provide a fallback to use value line information if key is not available.
Key Features:
1.Error Highlighting:
The error lines are marked in the editor using editor.markText, with a CSS class (CodeMirror-lint-mark-error) for styling.
A tooltip is added to the highlighted line to display the error description.
2.Fallback for Missing Keys:
If the key location is not found in the pointers, the function falls back to using the value location for highlighting.
3.Dynamic Path Matching:
If the jsonPath does not match any pointer, the function trims the path from the leaf node backward (e.g., /store/location/city → /store/location) until a match is found.
4.Gutter Marker:
Adds a marker in the editor's gutter to visually indicate errors alongside the line numbers.
Optimization and Improvements
A utility function (findObjectByPath) matches paths dynamically, ensuring robustness even with incomplete paths.
Implements a strategy to handle missing paths by iteratively trimming the path and retrying.
Ensures that both key and value locations are checked for highlighting, covering all possible cases.