-
Couldn't load subscription status.
- Fork 0
feat: ✨ exclude required issues at a given JSON path #138
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
base: main
Are you sure you want to change the base?
Conversation
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.
Just some initial comments and questions before doing a deeper dive
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.
Hmm, ok, there's more confusion then 🤔 😵💫
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.
Great progress!! 🎉 🎉 some minor edits and comments, otherwise 👍
Co-authored-by: Luke W. Johnston <[email protected]>
…/check-datapackage into feat/excluding-required
| def _get_array_parts(path_part: str) -> Optional[re.Match[str]]: | ||
| """Extract the name and index from a JSON path part representing an array.""" | ||
| return re.search(r"(\w+)\[(\d+)\]$", path_part) |
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.
Is this what you meant?
Description
This PR adds some logic to handle excluding required issues at a given JSON path.
The main problem here comes down to the following:
Given
Exclude(type="required", jsonpath="$.resources[*].name")andIssue(type="required", jsonpath="$.resources[3].name"), how can I detect that$.resources[*].namematches$.resources[3].name? I cannot get all matches in the descriptor for$.resources[*].namebecause, when the field is missing, there will be none.One approach would be to decide it based on JSON path syntax. This will get thorny quite quickly and would be a partial reimplementation of
jsonpathanyway.Here, I went with the approach of taking
$.resources[3].nameand building an object that has this field:{"resources": [{}, {}, {}, {"name": {}}]}. It doesn't matter what the field contains, as long as it exists. Testing$.resources[*].nameon this object (usingjsonpath) works nicely.I initially thought this was very hacky, but I'm coming around to it. But if anyone has better ideas, don't hold back!
Closes #121
Needs an in-depth review.
Checklist
just run-all