ash_json_api_wrapper/lib/field.ex
Zach Daniel 418de7a1bd improvement: WIP on open api resource generator
improvement: update ash
2023-09-25 10:16:47 -04:00

35 lines
1.3 KiB
Elixir

defmodule AshJsonApiWrapper.Field do
defstruct [:name, :path, :write_path, :filter_handler]
@type t :: %__MODULE__{}
def schema do
[
name: [
type: :atom,
required: true,
doc: "The attribute this field is configuring"
],
path: [
type: :string,
doc: "The path of the value for this field, relative to the entity's path"
],
write_path: [
type: {:list, :string},
doc: "The list path of the value for this field when writing."
],
filter_handler: [
type: :any,
doc: """
Specification for how the field is handled when used in filters. This is relatively limited at the moment.
Supports the following:
* `:simple` - Sets the value directly into the query params.
* `{:simple, "key" | ["path", "to", "key"]}` - Sets the value directly into the query params using the provided key.
* `{:place_in_list, ["path", "to", "list"]}` - Supports `or equals` and `in` filters over the given field, by placing their values in the provided list.
* `{:place_in_csv_list, ["path", "to", "list"]}` - Supports `or equals` and `in` filters over the given field, by placing their values in the provided list.
"""
]
]
end
end