fix(ApiExplorer): Modified the predicate filter files to use type string. BED-6051
Description
Modified the predicate filters to use type string instead of integer and boolean. This enabled the predicates to be read correctly instead of throwing a validation error when entering a value such as, "eq:7".
Motivation and Context
Resolves BED-6051
Why is this change required? What problem does it solve?
The change is required to correctly enable the use of predicates in fields that traditionally are looking for an integer or boolean.
How Has This Been Tested?
Manually tested making requests using the API Explorer, using with and without predicates.
Screenshots (optional):
Types of changes
- Bug fix (non-breaking change which fixes an issue)
Checklist:
- [x] I have met the contributing prerequisites
- Assigned myself to this PR
- Added the appropriate labels
- Associated an issue: https://github.com/SpecterOps/BloodHound/issues/672
- Read the Contributing guide: https://github.com/SpecterOps/BloodHound/wiki/Contributing
- [x] I have ensured that related documentation is up-to-date
- Open API docs
- Code comments (GoDocs / JSDocs)
- [x] I have followed proper test practices
- Added/updated tests to cover my changes
- All new and existing tests passed
Summary by CodeRabbit
- Changes
- API filter parameters for integer and boolean fields now accept string-formatted predicates (e.g., "eq:7", "gt:3", "eq:true") instead of native integer/boolean values.
- Examples added to the API schema to illustrate the new string predicate formats for filtering.
โ๏ธ Tip: You can customize this high-level summary in your review settings.
Walkthrough
OpenAPI predicate filter schemas changed types from native primitives (integer, boolean) to string across source YAML files and the generated OpenAPI JSON; examples/examples block were added for the new string-based predicate formats.
Changes
| Cohort / File(s) | Change Summary |
|---|---|
Source schema updates packages/go/openapi/src/schemas/api.params.predicate.filter.integer.yaml, packages/go/openapi/src/schemas/api.params.predicate.filter.integer-strict.yaml, packages/go/openapi/src/schemas/api.params.predicate.filter.boolean.yaml |
Changed type from integer/boolean to string; added examples or example entries (e.g., eq:7, gt:3, eq:true) while descriptions remained unchanged. |
Generated OpenAPI documentation packages/go/openapi/doc/openapi.json |
Updated compiled schema entries (api.params.predicate.filter.integer, api.params.predicate.filter.integer-strict, api.params.predicate.filter.boolean) to type: "string" and included example(s)/examples reflecting predicate syntax. |
Estimated code review effort
๐ฏ 2 (Simple) | โฑ๏ธ ~10 minutes
- Homogeneous, small edits across schema files and the generated spec.
- Pay attention to:
api.params.predicate.filter.integer.yamlโ examples added (equals/greaterthan).api.params.predicate.filter.integer-strict.yamlโ exampleeq:7.api.params.predicate.filter.boolean.yamlโ exampleeq:true.packages/go/openapi/doc/openapi.jsonโ ensure generated spec consistency and no leftover type mismatches.
Suggested reviewers
- specter-flq
- urangel
Poem
๐ฐ
I hopped through schemas, light and spry,
Turned numbers and truths into quoted sky.
Examples tucked in pockets neat,
Predicates now speak in strings so sweet.
โจ
Pre-merge checks and finishing touches
โ Passed checks (3 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title check | โ Passed | The title clearly and specifically describes the main change: modifying predicate filter files to use string type, with the ticket reference BED-6051. |
| Docstring Coverage | โ Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |
| Description check | โ Passed | The PR description provides clear context, motivation, testing details, and includes the associated Jira ticket (BED-6051) with most checklist items completed. |
โจ Finishing touches
- [ ] ๐ Generate docstrings
๐งช Generate unit tests (beta)
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
- [ ] Commit unit tests in branch
BED-6051/ApiExplorer-Predicates
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.