Skip to content

Conversation

@peterbroadhurst
Copy link
Contributor

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.

err := json.Unmarshal([]byte(`{
"and": [
{
"or": [
{
"equal": [
{
"field": "tag",
"value": "a"
}
]
},
{
"equal": [
{
"field": "tag",
"value": "b"
}
]
}
]
},
{
"equal": [
{
"field": "cid",
"value": "12345"
}
]
}
]
}`), &qf)

@peterbroadhurst peterbroadhurst requested a review from a team as a code owner November 16, 2025 15:51
Comment on lines +46 to +47
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
Copy link
Contributor Author

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: array

Then 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: array

Copy link
Contributor

@EnriqueL8 EnriqueL8 Dec 1, 2025

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?

Copy link
Contributor

@EnriqueL8 EnriqueL8 left a 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Or creates an AND condition between multiple queries
// And creates an AND condition between multiple queries

Comment on lines +46 to +47
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
Copy link
Contributor

@EnriqueL8 EnriqueL8 Dec 1, 2025

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants