PhoenixApiToolkit.GenericRequestValidator.resource_schema

You're seeing just the function resource_schema, go back to PhoenixApiToolkit.GenericRequestValidator module for more information.
Link to this function

resource_schema(extra_fields \\ %{}, comparables \\ %{})

View Source

Creates a generic schema for a REST resource.

In general, REST resources will support an integer id as a path parameter, and the index endpoint will support order_by, limit and offset. Additionally, some endpoints will support a lock_version for optimistic locking using Ecto.Changeset.optimistic_lock/3.

Additional fields can be passed along to the extra_fields parameter. Fields that can (usefully) be compared with smaller than / greater than comparisons can be passed in comparables. The value you pass AND a "_lt" (smaller than) and "_gte" (greater than or equal to) variant will be added to the schema.

Examples

# the result can be fed to cast/3
iex> resource_schema() |> Ecto.Changeset.cast(%{}, [])
#Ecto.Changeset<action: nil, changes: %{}, errors: [], data: %{}, valid?: true>

# an extended schema can be created by providing a map of fields
iex> resource_schema(%{first_name: :string})
{%{}, %{first_name: :string, id: :integer, limit: :integer, lock_version: :integer, offset: :integer, order_by: :string}}

# fields passed to the "comparables" parameter are added literally AND with _lt and _gte variants
iex> resource_schema(%{}, %{date_of_birth: :date}) |> elem(1) |> Map.has_key?(:date_of_birth_lt)
true