-
Notifications
You must be signed in to change notification settings - Fork 14
Add option for explicit nested AND sub-queries #199
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
Signed-off-by: Peter Broadhurst <[email protected]>
Signed-off-by: Peter Broadhurst <[email protected]>
Signed-off-by: Peter Broadhurst <[email protected]>
| FilterJSONOr = ffm("FilterJSON.or", "Array of sub-queries") // Note due to complex issue in swagger generator AND/OR need to be identical | ||
| FilterJSONAnd = ffm("FilterJSON.and", "Array of sub-queries") // ^^^ the `description` field is getting pushed to the sub-schema definition, and is non-deterministic |
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.
What happens in the swagger generator is this:
or:
items:
$ref: '#/components/schemas/FilterJSON'
type: arrayThen depending on non-deterministic behavior, the FilterJSON schema gets a description from _ethertheandoror` definition.
That makes swagger generation non-deterministic.
IMHO this is a bug, and the swagger should look like this - but that would be a hard contribution to build+validate to the openapi3gen package:
or:
description: "the description of the reference to the object"
items:
$ref: '#/components/schemas/FilterJSON'
type: arrayThere 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.
Do we want to raise this as an issue to the openapi3gen pkg or/and this repo before we forget about this thinking?
EnriqueL8
left a comment
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.
Looks great @peterbroadhurst - left a few suggestions of typos and question on raising issue.
| // Or creates an OR condition between multiple queries | ||
| Or(...QueryBuilder) QueryBuilder | ||
|
|
||
| // And creates an OR condition between multiple queries |
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.
| // And creates an OR condition between multiple queries | |
| // And creates an AND condition between multiple queries |
| return qb | ||
| } | ||
|
|
||
| // Or creates an AND condition between multiple queries |
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.
| // Or creates an AND condition between multiple queries | |
| // And creates an AND condition between multiple queries |
| FilterJSONOr = ffm("FilterJSON.or", "Array of sub-queries") // Note due to complex issue in swagger generator AND/OR need to be identical | ||
| FilterJSONAnd = ffm("FilterJSON.and", "Array of sub-queries") // ^^^ the `description` field is getting pushed to the sub-schema definition, and is non-deterministic |
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.
Do we want to raise this as an issue to the openapi3gen pkg or/and this repo before we forget about this thinking?
I hit a scenario that I couldn't describe with our JSONQuery syntax.
See in this test, we have a top-level AND where one of the sub-queries is an OR. This couldn't be described before.
firefly-common/pkg/ffapi/restfilter_json_test.go
Lines 145 to 176 in 8f24fbf