Skip to content

Commit

Permalink
fix: nested boolean filters accept a list of filters, not a single fi…
Browse files Browse the repository at this point in the history
…lter
  • Loading branch information
zachdaniel committed Dec 3, 2024
1 parent d87f4c2 commit 3df3a9c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
16 changes: 12 additions & 4 deletions lib/ash_json_api/json_schema/open_api.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2253,11 +2253,19 @@ if Code.ensure_loaded?(OpenApiSpex) do
defp boolean_filter_fields(resource) do
if Ash.DataLayer.can?(:boolean_filter, resource) do
[
and: %Reference{
"$ref": "#/components/schemas/#{AshJsonApi.Resource.Info.type(resource)}-filter"
and: %Schema{
type: :array,
items: %Reference{
"$ref": "#/components/schemas/#{AshJsonApi.Resource.Info.type(resource)}-filter"
},
uniqueItems: true
},
or: %Reference{
"$ref": "#/components/schemas/#{AshJsonApi.Resource.Info.type(resource)}-filter"
or: %Schema{
type: :array,
items: %Reference{
"$ref": "#/components/schemas/#{AshJsonApi.Resource.Info.type(resource)}-filter"
},
uniqueItems: true
},
not: %Reference{
"$ref": "#/components/schemas/#{AshJsonApi.Resource.Info.type(resource)}-filter"
Expand Down
18 changes: 15 additions & 3 deletions test/acceptance/open_api_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -467,12 +467,24 @@ defmodule Test.Acceptance.OpenApiTest do
hidden: %OpenApiSpex.Reference{"$ref": "#/components/schemas/post-filter-hidden"},
id: %OpenApiSpex.Reference{"$ref": "#/components/schemas/post-filter-id"},
name: %OpenApiSpex.Reference{"$ref": "#/components/schemas/post-filter-name"},
and: %OpenApiSpex.Reference{"$ref": "#/components/schemas/post-filter"},
and: %Schema{
type: :array,
items: %OpenApiSpex.Reference{
"$ref": "#/components/schemas/post-filter"
},
uniqueItems: true
},
or: %Schema{
type: :array,
items: %OpenApiSpex.Reference{
"$ref": "#/components/schemas/post-filter"
},
uniqueItems: true
},
name_twice: %OpenApiSpex.Reference{
"$ref": "#/components/schemas/post-filter-name_twice"
},
not: %OpenApiSpex.Reference{"$ref": "#/components/schemas/post-filter"},
or: %OpenApiSpex.Reference{"$ref": "#/components/schemas/post-filter"}
not: %OpenApiSpex.Reference{"$ref": "#/components/schemas/post-filter"}
}
} = schema

Expand Down

0 comments on commit 3df3a9c

Please sign in to comment.