The entrypoint for adding JSON:API behavior to an Ash domain
Global configuration for JSON:API
- open_api
- routes
- base_route
- get
- index
- post
- patch
- delete
- related
- relationship
- post_to_relationship
- patch_relationship
- delete_from_relationship
- route
- get
- index
- post
- patch
- delete
- related
- relationship
- post_to_relationship
- patch_relationship
- delete_from_relationship
- route
- base_route
json_api do
prefix "/json_api"
log_errors? true
end
| Name | Type | Default | Docs |
|---|---|---|---|
router{: #json_api-router } |
atom |
The router that you created for this Domain. Used by test helpers to send requests | |
show_raised_errors?{: #json_api-show_raised_errors? } |
boolean |
false |
For security purposes, if an error is raised then Ash simply shows a generic error. If you want to show those errors, set this to true. |
prefix{: #json_api-prefix } |
String.t |
The route prefix at which you are serving the JSON:API | |
serve_schema?{: #json_api-serve_schema? } |
boolean |
false |
Whether or not create a /schema route that serves the JSON schema of your API |
authorize?{: #json_api-authorize? } |
boolean |
true |
Whether or not to perform authorization on requests. |
log_errors?{: #json_api-log_errors? } |
boolean |
true |
Whether or not to log any errors produced |
include_nil_values?{: #json_api-include_nil_values? } |
boolean |
true |
Whether or not to include properties for values that are nil in the JSON output |
error_handler{: #json_api-error_handler } |
mfa |
Set an MFA to intercept/handle any errors that are generated. The function will be called with a AshJsonApi.Error struct and a context map, and should return a modified AshJsonApi.Error struct. The context map contains :domain and :resource. For example: elixir defmodule MyApp.ErrorHandler do def handle_error(error, _context) do %{error | detail: "Something went wrong"} end end And in your domain: elixir json_api do error_handler {MyApp.ErrorHandler, :handle_error, []} end |
|
require_type_on_create?{: #json_api-require_type_on_create? } |
boolean |
false |
When true, POST create requests MUST include type in data. Default false for backwards compatibility; in a future major version may default to true. |
OpenAPI configurations
json_api do
...
open_api do
tag "Users"
group_by :api
end
end
| Name | Type | Default | Docs |
|---|---|---|---|
tag{: #json_api-open_api-tag } |
String.t |
Tag to be used when used by :group_by | |
group_by{: #json_api-open_api-group_by } |
:domain | :resource |
:resource |
Group by :domain or :resource |
Configure the routes that will be exposed via the JSON:API
- base_route
- get
- index
- post
- patch
- delete
- related
- relationship
- post_to_relationship
- patch_relationship
- delete_from_relationship
- route
- get
- index
- post
- patch
- delete
- related
- relationship
- post_to_relationship
- patch_relationship
- delete_from_relationship
- route
routes do
base "/posts"
get :read
get :me, route: "/me"
index :read
post :confirm_name, route: "/confirm_name"
patch :update
related :comments, :read
relationship :comments, :read
post_to_relationship :comments
patch_relationship :comments
delete_from_relationship :comments
end
base_route route, resource \\ nilSets a prefix for a list of contained routes
- get
- index
- post
- patch
- delete
- related
- relationship
- post_to_relationship
- patch_relationship
- delete_from_relationship
- route
base_route "/posts" do
index :read
get :read
end
base_route "/comments" do
index :read
end
| Name | Type | Default | Docs |
|---|---|---|---|
route{: #json_api-routes-base_route-route .spark-required} |
String.t |
The route prefix to use for contained routes | |
resource{: #json_api-routes-base_route-resource } |
module |
The resource that the contained routes will use by default |
get resource \\ nil, actionA GET route to retrieve a single record
get :read
get :read, path_param_is_composite_key: :id
| Name | Type | Default | Docs |
|---|---|---|---|
resource{: #json_api-routes-base_route-get-resource } |
module |
The resource that the route's action is defined on | |
action{: #json_api-routes-base_route-get-action .spark-required} |
atom |
The action to call when this route is hit |
| Name | Type | Default | Docs |
|---|---|---|---|
route{: #json_api-routes-base_route-get-route } |
String.t |
"/:id" |
The path of the route |
default_fields{: #json_api-routes-base_route-get-default_fields } |
list(atom) |
A list of fields to be shown in the attributes of the called route | |
primary?{: #json_api-routes-base_route-get-primary? } |
boolean |
false |
Whether or not this is the route that should be linked to by default when rendering links to this type of route |
metadata{: #json_api-routes-base_route-get-metadata } |
(any, any, any -> any) |
A function to generate arbitrary top-level metadata for the JSON:API response | |
modify_conn{: #json_api-routes-base_route-get-modify_conn } |
(any, any, any, any -> any) |
A function to modify the conn before responding. Used for things like setting headers based on the response. Takes conn, subject, result, request. See the modify_conn guide for more details and examples. |
|
action_names_in_schema{: #json_api-routes-base_route-get-action_names_in_schema } |
keyword |
A mapping of action names to how they should appear in the OpenAPI schema. You only need to set this if you see a warning during schema generation. | |
name{: #json_api-routes-base_route-get-name } |
String.t |
A globally unique name for this route, to be used when generating docs and open api specifications | |
description{: #json_api-routes-base_route-get-description } |
String.t |
A human-friendly description of this specific route to use in generated documentation and OpenAPI. If provided, this overrides the action description. | |
derive_sort?{: #json_api-routes-base_route-get-derive_sort? } |
boolean |
true |
Whether or not to derive a sort parameter based on the sortable fields of the resource |
derive_filter?{: #json_api-routes-base_route-get-derive_filter? } |
boolean |
true |
Whether or not to derive a filter parameter based on the sortable fields of the resource |
path_param_is_composite_key{: #json_api-routes-base_route-get-path_param_is_composite_key } |
atom |
The path parameter that should be parsed as a composite primary key. When specified (e.g., :id), the parameter will be split using the resource's primary key delimiter and mapped to individual primary key fields. This is required for resources with composite primary keys to work correctly with GET, PATCH, and DELETE operations. See the composite primary keys documentation for more details. |
Target: AshJsonApi.Resource.Route
index resource \\ nil, actionA GET route to retrieve a list of records
index :read
| Name | Type | Default | Docs |
|---|---|---|---|
resource{: #json_api-routes-base_route-index-resource } |
module |
The resource that the route's action is defined on | |
action{: #json_api-routes-base_route-index-action .spark-required} |
atom |
The action to call when this route is hit |
| Name | Type | Default | Docs |
|---|---|---|---|
paginate?{: #json_api-routes-base_route-index-paginate? } |
boolean |
true |
|
route{: #json_api-routes-base_route-index-route } |
String.t |
"/" |
The path of the route |
default_fields{: #json_api-routes-base_route-index-default_fields } |
list(atom) |
A list of fields to be shown in the attributes of the called route | |
primary?{: #json_api-routes-base_route-index-primary? } |
boolean |
false |
Whether or not this is the route that should be linked to by default when rendering links to this type of route |
metadata{: #json_api-routes-base_route-index-metadata } |
(any, any, any -> any) |
A function to generate arbitrary top-level metadata for the JSON:API response | |
modify_conn{: #json_api-routes-base_route-index-modify_conn } |
(any, any, any, any -> any) |
A function to modify the conn before responding. Used for things like setting headers based on the response. Takes conn, subject, result, request. See the modify_conn guide for more details and examples. |
|
action_names_in_schema{: #json_api-routes-base_route-index-action_names_in_schema } |
keyword |
A mapping of action names to how they should appear in the OpenAPI schema. You only need to set this if you see a warning during schema generation. | |
name{: #json_api-routes-base_route-index-name } |
String.t |
A globally unique name for this route, to be used when generating docs and open api specifications | |
description{: #json_api-routes-base_route-index-description } |
String.t |
A human-friendly description of this specific route to use in generated documentation and OpenAPI. If provided, this overrides the action description. | |
derive_sort?{: #json_api-routes-base_route-index-derive_sort? } |
boolean |
true |
Whether or not to derive a sort parameter based on the sortable fields of the resource |
derive_filter?{: #json_api-routes-base_route-index-derive_filter? } |
boolean |
true |
Whether or not to derive a filter parameter based on the sortable fields of the resource |
path_param_is_composite_key{: #json_api-routes-base_route-index-path_param_is_composite_key } |
atom |
The path parameter that should be parsed as a composite primary key. When specified (e.g., :id), the parameter will be split using the resource's primary key delimiter and mapped to individual primary key fields. This is required for resources with composite primary keys to work correctly with GET, PATCH, and DELETE operations. See the composite primary keys documentation for more details. |
Target: AshJsonApi.Resource.Route
post resource \\ nil, actionA POST route to create a record
post :create
| Name | Type | Default | Docs |
|---|---|---|---|
resource{: #json_api-routes-base_route-post-resource } |
module |
The resource that the route's action is defined on | |
action{: #json_api-routes-base_route-post-action .spark-required} |
atom |
The action to call when this route is hit |
| Name | Type | Default | Docs |
|---|---|---|---|
route{: #json_api-routes-base_route-post-route } |
String.t |
"/" |
The path of the route |
default_fields{: #json_api-routes-base_route-post-default_fields } |
list(atom) |
A list of fields to be shown in the attributes of the called route | |
primary?{: #json_api-routes-base_route-post-primary? } |
boolean |
false |
Whether or not this is the route that should be linked to by default when rendering links to this type of route |
metadata{: #json_api-routes-base_route-post-metadata } |
(any, any, any -> any) |
A function to generate arbitrary top-level metadata for the JSON:API response | |
modify_conn{: #json_api-routes-base_route-post-modify_conn } |
(any, any, any, any -> any) |
A function to modify the conn before responding. Used for things like setting headers based on the response. Takes conn, subject, result, request. See the modify_conn guide for more details and examples. |
|
query_params{: #json_api-routes-base_route-post-query_params } |
list(atom) |
[] |
A list of action inputs to accept as query parameters. |
action_names_in_schema{: #json_api-routes-base_route-post-action_names_in_schema } |
keyword |
A mapping of action names to how they should appear in the OpenAPI schema. You only need to set this if you see a warning during schema generation. | |
name{: #json_api-routes-base_route-post-name } |
String.t |
A globally unique name for this route, to be used when generating docs and open api specifications | |
description{: #json_api-routes-base_route-post-description } |
String.t |
A human-friendly description of this specific route to use in generated documentation and OpenAPI. If provided, this overrides the action description. | |
derive_sort?{: #json_api-routes-base_route-post-derive_sort? } |
boolean |
true |
Whether or not to derive a sort parameter based on the sortable fields of the resource |
derive_filter?{: #json_api-routes-base_route-post-derive_filter? } |
boolean |
true |
Whether or not to derive a filter parameter based on the sortable fields of the resource |
path_param_is_composite_key{: #json_api-routes-base_route-post-path_param_is_composite_key } |
atom |
The path parameter that should be parsed as a composite primary key. When specified (e.g., :id), the parameter will be split using the resource's primary key delimiter and mapped to individual primary key fields. This is required for resources with composite primary keys to work correctly with GET, PATCH, and DELETE operations. See the composite primary keys documentation for more details. | |
relationship_arguments{: #json_api-routes-base_route-post-relationship_arguments } |
list(atom | {:id, atom}) |
[] |
Arguments to be used to edit relationships. See the relationships guide for more. |
upsert?{: #json_api-routes-base_route-post-upsert? } |
boolean |
false |
Whether or not to use the upsert?: true option when calling Ash.create/2. |
upsert_identity{: #json_api-routes-base_route-post-upsert_identity } |
atom |
false |
Which identity to use for the upsert |
Target: AshJsonApi.Resource.Route
patch resource \\ nil, actionA PATCH route to update a record
patch :update
patch :update, path_param_is_composite_key: :id
| Name | Type | Default | Docs |
|---|---|---|---|
resource{: #json_api-routes-base_route-patch-resource } |
module |
The resource that the route's action is defined on | |
action{: #json_api-routes-base_route-patch-action .spark-required} |
atom |
The action to call when this route is hit |
| Name | Type | Default | Docs |
|---|---|---|---|
relationship_arguments{: #json_api-routes-base_route-patch-relationship_arguments } |
any |
[] |
Arguments to be used to edit relationships. See the relationships guide for more. |
read_action{: #json_api-routes-base_route-patch-read_action } |
atom |
The read action to use to look the record up before updating | |
route{: #json_api-routes-base_route-patch-route } |
String.t |
"/:id" |
The path of the route |
default_fields{: #json_api-routes-base_route-patch-default_fields } |
list(atom) |
A list of fields to be shown in the attributes of the called route | |
primary?{: #json_api-routes-base_route-patch-primary? } |
boolean |
false |
Whether or not this is the route that should be linked to by default when rendering links to this type of route |
metadata{: #json_api-routes-base_route-patch-metadata } |
(any, any, any -> any) |
A function to generate arbitrary top-level metadata for the JSON:API response | |
modify_conn{: #json_api-routes-base_route-patch-modify_conn } |
(any, any, any, any -> any) |
A function to modify the conn before responding. Used for things like setting headers based on the response. Takes conn, subject, result, request. See the modify_conn guide for more details and examples. |
|
query_params{: #json_api-routes-base_route-patch-query_params } |
list(atom) |
[] |
A list of action inputs to accept as query parameters. |
action_names_in_schema{: #json_api-routes-base_route-patch-action_names_in_schema } |
keyword |
A mapping of action names to how they should appear in the OpenAPI schema. You only need to set this if you see a warning during schema generation. | |
name{: #json_api-routes-base_route-patch-name } |
String.t |
A globally unique name for this route, to be used when generating docs and open api specifications | |
description{: #json_api-routes-base_route-patch-description } |
String.t |
A human-friendly description of this specific route to use in generated documentation and OpenAPI. If provided, this overrides the action description. | |
derive_sort?{: #json_api-routes-base_route-patch-derive_sort? } |
boolean |
true |
Whether or not to derive a sort parameter based on the sortable fields of the resource |
derive_filter?{: #json_api-routes-base_route-patch-derive_filter? } |
boolean |
true |
Whether or not to derive a filter parameter based on the sortable fields of the resource |
path_param_is_composite_key{: #json_api-routes-base_route-patch-path_param_is_composite_key } |
atom |
The path parameter that should be parsed as a composite primary key. When specified (e.g., :id), the parameter will be split using the resource's primary key delimiter and mapped to individual primary key fields. This is required for resources with composite primary keys to work correctly with GET, PATCH, and DELETE operations. See the composite primary keys documentation for more details. |
Target: AshJsonApi.Resource.Route
delete resource \\ nil, actionA DELETE route to destroy a record
delete :destroy
delete :destroy, path_param_is_composite_key: :id
| Name | Type | Default | Docs |
|---|---|---|---|
resource{: #json_api-routes-base_route-delete-resource } |
module |
The resource that the route's action is defined on | |
action{: #json_api-routes-base_route-delete-action .spark-required} |
atom |
The action to call when this route is hit |
| Name | Type | Default | Docs |
|---|---|---|---|
read_action{: #json_api-routes-base_route-delete-read_action } |
atom |
The read action to use to look the record up before updating | |
route{: #json_api-routes-base_route-delete-route } |
String.t |
"/:id" |
The path of the route |
default_fields{: #json_api-routes-base_route-delete-default_fields } |
list(atom) |
A list of fields to be shown in the attributes of the called route | |
primary?{: #json_api-routes-base_route-delete-primary? } |
boolean |
false |
Whether or not this is the route that should be linked to by default when rendering links to this type of route |
metadata{: #json_api-routes-base_route-delete-metadata } |
(any, any, any -> any) |
A function to generate arbitrary top-level metadata for the JSON:API response | |
modify_conn{: #json_api-routes-base_route-delete-modify_conn } |
(any, any, any, any -> any) |
A function to modify the conn before responding. Used for things like setting headers based on the response. Takes conn, subject, result, request. See the modify_conn guide for more details and examples. |
|
query_params{: #json_api-routes-base_route-delete-query_params } |
list(atom) |
[] |
A list of action inputs to accept as query parameters. |
action_names_in_schema{: #json_api-routes-base_route-delete-action_names_in_schema } |
keyword |
A mapping of action names to how they should appear in the OpenAPI schema. You only need to set this if you see a warning during schema generation. | |
name{: #json_api-routes-base_route-delete-name } |
String.t |
A globally unique name for this route, to be used when generating docs and open api specifications | |
description{: #json_api-routes-base_route-delete-description } |
String.t |
A human-friendly description of this specific route to use in generated documentation and OpenAPI. If provided, this overrides the action description. | |
derive_sort?{: #json_api-routes-base_route-delete-derive_sort? } |
boolean |
true |
Whether or not to derive a sort parameter based on the sortable fields of the resource |
derive_filter?{: #json_api-routes-base_route-delete-derive_filter? } |
boolean |
true |
Whether or not to derive a filter parameter based on the sortable fields of the resource |
path_param_is_composite_key{: #json_api-routes-base_route-delete-path_param_is_composite_key } |
atom |
The path parameter that should be parsed as a composite primary key. When specified (e.g., :id), the parameter will be split using the resource's primary key delimiter and mapped to individual primary key fields. This is required for resources with composite primary keys to work correctly with GET, PATCH, and DELETE operations. See the composite primary keys documentation for more details. |
Target: AshJsonApi.Resource.Route
related resource \\ nil, relationship, actionA GET route to read the related resources of a relationship
related :comments, :read
| Name | Type | Default | Docs |
|---|---|---|---|
resource{: #json_api-routes-base_route-related-resource } |
module |
The resource that the route's action is defined on | |
relationship{: #json_api-routes-base_route-related-relationship .spark-required} |
atom |
||
action{: #json_api-routes-base_route-related-action .spark-required} |
atom |
The action to call when this route is hit |
| Name | Type | Default | Docs |
|---|---|---|---|
route{: #json_api-routes-base_route-related-route } |
String.t |
The path of the route - Defaults to /:id/[relationship_name] | |
default_fields{: #json_api-routes-base_route-related-default_fields } |
list(atom) |
A list of fields to be shown in the attributes of the called route | |
primary?{: #json_api-routes-base_route-related-primary? } |
boolean |
false |
Whether or not this is the route that should be linked to by default when rendering links to this type of route |
metadata{: #json_api-routes-base_route-related-metadata } |
(any, any, any -> any) |
A function to generate arbitrary top-level metadata for the JSON:API response | |
modify_conn{: #json_api-routes-base_route-related-modify_conn } |
(any, any, any, any -> any) |
A function to modify the conn before responding. Used for things like setting headers based on the response. Takes conn, subject, result, request. See the modify_conn guide for more details and examples. |
|
query_params{: #json_api-routes-base_route-related-query_params } |
list(atom) |
[] |
A list of action inputs to accept as query parameters. |
action_names_in_schema{: #json_api-routes-base_route-related-action_names_in_schema } |
keyword |
A mapping of action names to how they should appear in the OpenAPI schema. You only need to set this if you see a warning during schema generation. | |
name{: #json_api-routes-base_route-related-name } |
String.t |
A globally unique name for this route, to be used when generating docs and open api specifications | |
description{: #json_api-routes-base_route-related-description } |
String.t |
A human-friendly description of this specific route to use in generated documentation and OpenAPI. If provided, this overrides the action description. | |
derive_sort?{: #json_api-routes-base_route-related-derive_sort? } |
boolean |
true |
Whether or not to derive a sort parameter based on the sortable fields of the resource |
derive_filter?{: #json_api-routes-base_route-related-derive_filter? } |
boolean |
true |
Whether or not to derive a filter parameter based on the sortable fields of the resource |
path_param_is_composite_key{: #json_api-routes-base_route-related-path_param_is_composite_key } |
atom |
The path parameter that should be parsed as a composite primary key. When specified (e.g., :id), the parameter will be split using the resource's primary key delimiter and mapped to individual primary key fields. This is required for resources with composite primary keys to work correctly with GET, PATCH, and DELETE operations. See the composite primary keys documentation for more details. |
Target: AshJsonApi.Resource.Route
relationship resource \\ nil, relationship, actionA READ route to read the relationship, returns resource identifiers.
relationship :comments, :read
| Name | Type | Default | Docs |
|---|---|---|---|
resource{: #json_api-routes-base_route-relationship-resource } |
module |
The resource that the route's action is defined on | |
relationship{: #json_api-routes-base_route-relationship-relationship .spark-required} |
atom |
||
action{: #json_api-routes-base_route-relationship-action .spark-required} |
atom |
The action to call when this route is hit |
| Name | Type | Default | Docs |
|---|---|---|---|
route{: #json_api-routes-base_route-relationship-route } |
String.t |
The path of the route - Defaults to /:id/relationships/[relationship_name] | |
default_fields{: #json_api-routes-base_route-relationship-default_fields } |
list(atom) |
A list of fields to be shown in the attributes of the called route | |
primary?{: #json_api-routes-base_route-relationship-primary? } |
boolean |
false |
Whether or not this is the route that should be linked to by default when rendering links to this type of route |
metadata{: #json_api-routes-base_route-relationship-metadata } |
(any, any, any -> any) |
A function to generate arbitrary top-level metadata for the JSON:API response | |
modify_conn{: #json_api-routes-base_route-relationship-modify_conn } |
(any, any, any, any -> any) |
A function to modify the conn before responding. Used for things like setting headers based on the response. Takes conn, subject, result, request. See the modify_conn guide for more details and examples. |
|
query_params{: #json_api-routes-base_route-relationship-query_params } |
list(atom) |
[] |
A list of action inputs to accept as query parameters. |
action_names_in_schema{: #json_api-routes-base_route-relationship-action_names_in_schema } |
keyword |
A mapping of action names to how they should appear in the OpenAPI schema. You only need to set this if you see a warning during schema generation. | |
name{: #json_api-routes-base_route-relationship-name } |
String.t |
A globally unique name for this route, to be used when generating docs and open api specifications | |
description{: #json_api-routes-base_route-relationship-description } |
String.t |
A human-friendly description of this specific route to use in generated documentation and OpenAPI. If provided, this overrides the action description. | |
derive_sort?{: #json_api-routes-base_route-relationship-derive_sort? } |
boolean |
true |
Whether or not to derive a sort parameter based on the sortable fields of the resource |
derive_filter?{: #json_api-routes-base_route-relationship-derive_filter? } |
boolean |
true |
Whether or not to derive a filter parameter based on the sortable fields of the resource |
path_param_is_composite_key{: #json_api-routes-base_route-relationship-path_param_is_composite_key } |
atom |
The path parameter that should be parsed as a composite primary key. When specified (e.g., :id), the parameter will be split using the resource's primary key delimiter and mapped to individual primary key fields. This is required for resources with composite primary keys to work correctly with GET, PATCH, and DELETE operations. See the composite primary keys documentation for more details. |
Target: AshJsonApi.Resource.Route
post_to_relationship resource \\ nil, relationshipA POST route to create related entities using resource identifiers
post_to_relationship :comments
| Name | Type | Default | Docs |
|---|---|---|---|
resource{: #json_api-routes-base_route-post_to_relationship-resource } |
module |
The resource that the route's action is defined on | |
relationship{: #json_api-routes-base_route-post_to_relationship-relationship .spark-required} |
atom |
| Name | Type | Default | Docs |
|---|---|---|---|
route{: #json_api-routes-base_route-post_to_relationship-route } |
String.t |
The path of the route - Defaults to /:id/relationships/[relationship_name] | |
default_fields{: #json_api-routes-base_route-post_to_relationship-default_fields } |
list(atom) |
A list of fields to be shown in the attributes of the called route | |
primary?{: #json_api-routes-base_route-post_to_relationship-primary? } |
boolean |
false |
Whether or not this is the route that should be linked to by default when rendering links to this type of route |
metadata{: #json_api-routes-base_route-post_to_relationship-metadata } |
(any, any, any -> any) |
A function to generate arbitrary top-level metadata for the JSON:API response | |
modify_conn{: #json_api-routes-base_route-post_to_relationship-modify_conn } |
(any, any, any, any -> any) |
A function to modify the conn before responding. Used for things like setting headers based on the response. Takes conn, subject, result, request. See the modify_conn guide for more details and examples. |
|
query_params{: #json_api-routes-base_route-post_to_relationship-query_params } |
list(atom) |
[] |
A list of action inputs to accept as query parameters. |
action_names_in_schema{: #json_api-routes-base_route-post_to_relationship-action_names_in_schema } |
keyword |
A mapping of action names to how they should appear in the OpenAPI schema. You only need to set this if you see a warning during schema generation. | |
name{: #json_api-routes-base_route-post_to_relationship-name } |
String.t |
A globally unique name for this route, to be used when generating docs and open api specifications | |
description{: #json_api-routes-base_route-post_to_relationship-description } |
String.t |
A human-friendly description of this specific route to use in generated documentation and OpenAPI. If provided, this overrides the action description. | |
derive_sort?{: #json_api-routes-base_route-post_to_relationship-derive_sort? } |
boolean |
true |
Whether or not to derive a sort parameter based on the sortable fields of the resource |
derive_filter?{: #json_api-routes-base_route-post_to_relationship-derive_filter? } |
boolean |
true |
Whether or not to derive a filter parameter based on the sortable fields of the resource |
path_param_is_composite_key{: #json_api-routes-base_route-post_to_relationship-path_param_is_composite_key } |
atom |
The path parameter that should be parsed as a composite primary key. When specified (e.g., :id), the parameter will be split using the resource's primary key delimiter and mapped to individual primary key fields. This is required for resources with composite primary keys to work correctly with GET, PATCH, and DELETE operations. See the composite primary keys documentation for more details. |
Target: AshJsonApi.Resource.Route
patch_relationship resource \\ nil, relationshipA PATCH route to update a relationship using resource identifiers
patch_relationship :comments
| Name | Type | Default | Docs |
|---|---|---|---|
resource{: #json_api-routes-base_route-patch_relationship-resource } |
module |
The resource that the route's action is defined on | |
relationship{: #json_api-routes-base_route-patch_relationship-relationship .spark-required} |
atom |
| Name | Type | Default | Docs |
|---|---|---|---|
route{: #json_api-routes-base_route-patch_relationship-route } |
String.t |
The path of the route - Defaults to /:id/relationships/[relationship_name] | |
default_fields{: #json_api-routes-base_route-patch_relationship-default_fields } |
list(atom) |
A list of fields to be shown in the attributes of the called route | |
primary?{: #json_api-routes-base_route-patch_relationship-primary? } |
boolean |
false |
Whether or not this is the route that should be linked to by default when rendering links to this type of route |
metadata{: #json_api-routes-base_route-patch_relationship-metadata } |
(any, any, any -> any) |
A function to generate arbitrary top-level metadata for the JSON:API response | |
modify_conn{: #json_api-routes-base_route-patch_relationship-modify_conn } |
(any, any, any, any -> any) |
A function to modify the conn before responding. Used for things like setting headers based on the response. Takes conn, subject, result, request. See the modify_conn guide for more details and examples. |
|
query_params{: #json_api-routes-base_route-patch_relationship-query_params } |
list(atom) |
[] |
A list of action inputs to accept as query parameters. |
action_names_in_schema{: #json_api-routes-base_route-patch_relationship-action_names_in_schema } |
keyword |
A mapping of action names to how they should appear in the OpenAPI schema. You only need to set this if you see a warning during schema generation. | |
name{: #json_api-routes-base_route-patch_relationship-name } |
String.t |
A globally unique name for this route, to be used when generating docs and open api specifications | |
description{: #json_api-routes-base_route-patch_relationship-description } |
String.t |
A human-friendly description of this specific route to use in generated documentation and OpenAPI. If provided, this overrides the action description. | |
derive_sort?{: #json_api-routes-base_route-patch_relationship-derive_sort? } |
boolean |
true |
Whether or not to derive a sort parameter based on the sortable fields of the resource |
derive_filter?{: #json_api-routes-base_route-patch_relationship-derive_filter? } |
boolean |
true |
Whether or not to derive a filter parameter based on the sortable fields of the resource |
path_param_is_composite_key{: #json_api-routes-base_route-patch_relationship-path_param_is_composite_key } |
atom |
The path parameter that should be parsed as a composite primary key. When specified (e.g., :id), the parameter will be split using the resource's primary key delimiter and mapped to individual primary key fields. This is required for resources with composite primary keys to work correctly with GET, PATCH, and DELETE operations. See the composite primary keys documentation for more details. |
Target: AshJsonApi.Resource.Route
delete_from_relationship resource \\ nil, relationshipA DELETE route to remove related entities using resource identifiers
delete_from_relationship :comments
| Name | Type | Default | Docs |
|---|---|---|---|
resource{: #json_api-routes-base_route-delete_from_relationship-resource } |
module |
The resource that the route's action is defined on | |
relationship{: #json_api-routes-base_route-delete_from_relationship-relationship .spark-required} |
atom |
| Name | Type | Default | Docs |
|---|---|---|---|
route{: #json_api-routes-base_route-delete_from_relationship-route } |
String.t |
The path of the route - Defaults to /:id/relationships/[relationship_name] | |
default_fields{: #json_api-routes-base_route-delete_from_relationship-default_fields } |
list(atom) |
A list of fields to be shown in the attributes of the called route | |
primary?{: #json_api-routes-base_route-delete_from_relationship-primary? } |
boolean |
false |
Whether or not this is the route that should be linked to by default when rendering links to this type of route |
metadata{: #json_api-routes-base_route-delete_from_relationship-metadata } |
(any, any, any -> any) |
A function to generate arbitrary top-level metadata for the JSON:API response | |
modify_conn{: #json_api-routes-base_route-delete_from_relationship-modify_conn } |
(any, any, any, any -> any) |
A function to modify the conn before responding. Used for things like setting headers based on the response. Takes conn, subject, result, request. See the modify_conn guide for more details and examples. |
|
query_params{: #json_api-routes-base_route-delete_from_relationship-query_params } |
list(atom) |
[] |
A list of action inputs to accept as query parameters. |
action_names_in_schema{: #json_api-routes-base_route-delete_from_relationship-action_names_in_schema } |
keyword |
A mapping of action names to how they should appear in the OpenAPI schema. You only need to set this if you see a warning during schema generation. | |
name{: #json_api-routes-base_route-delete_from_relationship-name } |
String.t |
A globally unique name for this route, to be used when generating docs and open api specifications | |
description{: #json_api-routes-base_route-delete_from_relationship-description } |
String.t |
A human-friendly description of this specific route to use in generated documentation and OpenAPI. If provided, this overrides the action description. | |
derive_sort?{: #json_api-routes-base_route-delete_from_relationship-derive_sort? } |
boolean |
true |
Whether or not to derive a sort parameter based on the sortable fields of the resource |
derive_filter?{: #json_api-routes-base_route-delete_from_relationship-derive_filter? } |
boolean |
true |
Whether or not to derive a filter parameter based on the sortable fields of the resource |
path_param_is_composite_key{: #json_api-routes-base_route-delete_from_relationship-path_param_is_composite_key } |
atom |
The path parameter that should be parsed as a composite primary key. When specified (e.g., :id), the parameter will be split using the resource's primary key delimiter and mapped to individual primary key fields. This is required for resources with composite primary keys to work correctly with GET, PATCH, and DELETE operations. See the composite primary keys documentation for more details. |
Target: AshJsonApi.Resource.Route
route resource \\ nil, method, route, actionA route for a generic action.
route :get, "say_hi/:name", :say_hello
| Name | Type | Default | Docs |
|---|---|---|---|
resource{: #json_api-routes-base_route-route-resource } |
module |
The resource that the route's action is defined on | |
method{: #json_api-routes-base_route-route-method .spark-required} |
atom |
The HTTP method for the route, e.g :get, or :post |
|
route{: #json_api-routes-base_route-route-route .spark-required} |
String.t |
The path of the route | |
action{: #json_api-routes-base_route-route-action .spark-required} |
atom |
The action to call when this route is hit |
| Name | Type | Default | Docs |
|---|---|---|---|
wrap_in_result?{: #json_api-routes-base_route-route-wrap_in_result? } |
boolean |
false |
Whether or not the action result should be wrapped in {result: <result>} |
default_fields{: #json_api-routes-base_route-route-default_fields } |
list(atom) |
A list of fields to be shown in the attributes of the called route | |
primary?{: #json_api-routes-base_route-route-primary? } |
boolean |
false |
Whether or not this is the route that should be linked to by default when rendering links to this type of route |
metadata{: #json_api-routes-base_route-route-metadata } |
(any, any, any -> any) |
A function to generate arbitrary top-level metadata for the JSON:API response | |
modify_conn{: #json_api-routes-base_route-route-modify_conn } |
(any, any, any, any -> any) |
A function to modify the conn before responding. Used for things like setting headers based on the response. Takes conn, subject, result, request. See the modify_conn guide for more details and examples. |
|
query_params{: #json_api-routes-base_route-route-query_params } |
list(atom) |
[] |
A list of action inputs to accept as query parameters. |
action_names_in_schema{: #json_api-routes-base_route-route-action_names_in_schema } |
keyword |
A mapping of action names to how they should appear in the OpenAPI schema. You only need to set this if you see a warning during schema generation. | |
name{: #json_api-routes-base_route-route-name } |
String.t |
A globally unique name for this route, to be used when generating docs and open api specifications | |
description{: #json_api-routes-base_route-route-description } |
String.t |
A human-friendly description of this specific route to use in generated documentation and OpenAPI. If provided, this overrides the action description. | |
derive_sort?{: #json_api-routes-base_route-route-derive_sort? } |
boolean |
true |
Whether or not to derive a sort parameter based on the sortable fields of the resource |
derive_filter?{: #json_api-routes-base_route-route-derive_filter? } |
boolean |
true |
Whether or not to derive a filter parameter based on the sortable fields of the resource |
path_param_is_composite_key{: #json_api-routes-base_route-route-path_param_is_composite_key } |
atom |
The path parameter that should be parsed as a composite primary key. When specified (e.g., :id), the parameter will be split using the resource's primary key delimiter and mapped to individual primary key fields. This is required for resources with composite primary keys to work correctly with GET, PATCH, and DELETE operations. See the composite primary keys documentation for more details. |
Target: AshJsonApi.Resource.Route
Target: AshJsonApi.Domain.BaseRoute
get resource, actionA GET route to retrieve a single record
get :read
get :read, path_param_is_composite_key: :id
| Name | Type | Default | Docs |
|---|---|---|---|
resource{: #json_api-routes-get-resource } |
module |
The resource that the route's action is defined on | |
action{: #json_api-routes-get-action .spark-required} |
atom |
The action to call when this route is hit |
| Name | Type | Default | Docs |
|---|---|---|---|
route{: #json_api-routes-get-route } |
String.t |
"/:id" |
The path of the route |
default_fields{: #json_api-routes-get-default_fields } |
list(atom) |
A list of fields to be shown in the attributes of the called route | |
primary?{: #json_api-routes-get-primary? } |
boolean |
false |
Whether or not this is the route that should be linked to by default when rendering links to this type of route |
metadata{: #json_api-routes-get-metadata } |
(any, any, any -> any) |
A function to generate arbitrary top-level metadata for the JSON:API response | |
modify_conn{: #json_api-routes-get-modify_conn } |
(any, any, any, any -> any) |
A function to modify the conn before responding. Used for things like setting headers based on the response. Takes conn, subject, result, request. See the modify_conn guide for more details and examples. |
|
action_names_in_schema{: #json_api-routes-get-action_names_in_schema } |
keyword |
A mapping of action names to how they should appear in the OpenAPI schema. You only need to set this if you see a warning during schema generation. | |
name{: #json_api-routes-get-name } |
String.t |
A globally unique name for this route, to be used when generating docs and open api specifications | |
description{: #json_api-routes-get-description } |
String.t |
A human-friendly description of this specific route to use in generated documentation and OpenAPI. If provided, this overrides the action description. | |
derive_sort?{: #json_api-routes-get-derive_sort? } |
boolean |
true |
Whether or not to derive a sort parameter based on the sortable fields of the resource |
derive_filter?{: #json_api-routes-get-derive_filter? } |
boolean |
true |
Whether or not to derive a filter parameter based on the sortable fields of the resource |
path_param_is_composite_key{: #json_api-routes-get-path_param_is_composite_key } |
atom |
The path parameter that should be parsed as a composite primary key. When specified (e.g., :id), the parameter will be split using the resource's primary key delimiter and mapped to individual primary key fields. This is required for resources with composite primary keys to work correctly with GET, PATCH, and DELETE operations. See the composite primary keys documentation for more details. |
Target: AshJsonApi.Resource.Route
index resource, actionA GET route to retrieve a list of records
index :read
| Name | Type | Default | Docs |
|---|---|---|---|
resource{: #json_api-routes-index-resource } |
module |
The resource that the route's action is defined on | |
action{: #json_api-routes-index-action .spark-required} |
atom |
The action to call when this route is hit |
| Name | Type | Default | Docs |
|---|---|---|---|
paginate?{: #json_api-routes-index-paginate? } |
boolean |
true |
|
route{: #json_api-routes-index-route } |
String.t |
"/" |
The path of the route |
default_fields{: #json_api-routes-index-default_fields } |
list(atom) |
A list of fields to be shown in the attributes of the called route | |
primary?{: #json_api-routes-index-primary? } |
boolean |
false |
Whether or not this is the route that should be linked to by default when rendering links to this type of route |
metadata{: #json_api-routes-index-metadata } |
(any, any, any -> any) |
A function to generate arbitrary top-level metadata for the JSON:API response | |
modify_conn{: #json_api-routes-index-modify_conn } |
(any, any, any, any -> any) |
A function to modify the conn before responding. Used for things like setting headers based on the response. Takes conn, subject, result, request. See the modify_conn guide for more details and examples. |
|
action_names_in_schema{: #json_api-routes-index-action_names_in_schema } |
keyword |
A mapping of action names to how they should appear in the OpenAPI schema. You only need to set this if you see a warning during schema generation. | |
name{: #json_api-routes-index-name } |
String.t |
A globally unique name for this route, to be used when generating docs and open api specifications | |
description{: #json_api-routes-index-description } |
String.t |
A human-friendly description of this specific route to use in generated documentation and OpenAPI. If provided, this overrides the action description. | |
derive_sort?{: #json_api-routes-index-derive_sort? } |
boolean |
true |
Whether or not to derive a sort parameter based on the sortable fields of the resource |
derive_filter?{: #json_api-routes-index-derive_filter? } |
boolean |
true |
Whether or not to derive a filter parameter based on the sortable fields of the resource |
path_param_is_composite_key{: #json_api-routes-index-path_param_is_composite_key } |
atom |
The path parameter that should be parsed as a composite primary key. When specified (e.g., :id), the parameter will be split using the resource's primary key delimiter and mapped to individual primary key fields. This is required for resources with composite primary keys to work correctly with GET, PATCH, and DELETE operations. See the composite primary keys documentation for more details. |
Target: AshJsonApi.Resource.Route
post resource, actionA POST route to create a record
post :create
| Name | Type | Default | Docs |
|---|---|---|---|
resource{: #json_api-routes-post-resource } |
module |
The resource that the route's action is defined on | |
action{: #json_api-routes-post-action .spark-required} |
atom |
The action to call when this route is hit |
| Name | Type | Default | Docs |
|---|---|---|---|
route{: #json_api-routes-post-route } |
String.t |
"/" |
The path of the route |
default_fields{: #json_api-routes-post-default_fields } |
list(atom) |
A list of fields to be shown in the attributes of the called route | |
primary?{: #json_api-routes-post-primary? } |
boolean |
false |
Whether or not this is the route that should be linked to by default when rendering links to this type of route |
metadata{: #json_api-routes-post-metadata } |
(any, any, any -> any) |
A function to generate arbitrary top-level metadata for the JSON:API response | |
modify_conn{: #json_api-routes-post-modify_conn } |
(any, any, any, any -> any) |
A function to modify the conn before responding. Used for things like setting headers based on the response. Takes conn, subject, result, request. See the modify_conn guide for more details and examples. |
|
query_params{: #json_api-routes-post-query_params } |
list(atom) |
[] |
A list of action inputs to accept as query parameters. |
action_names_in_schema{: #json_api-routes-post-action_names_in_schema } |
keyword |
A mapping of action names to how they should appear in the OpenAPI schema. You only need to set this if you see a warning during schema generation. | |
name{: #json_api-routes-post-name } |
String.t |
A globally unique name for this route, to be used when generating docs and open api specifications | |
description{: #json_api-routes-post-description } |
String.t |
A human-friendly description of this specific route to use in generated documentation and OpenAPI. If provided, this overrides the action description. | |
derive_sort?{: #json_api-routes-post-derive_sort? } |
boolean |
true |
Whether or not to derive a sort parameter based on the sortable fields of the resource |
derive_filter?{: #json_api-routes-post-derive_filter? } |
boolean |
true |
Whether or not to derive a filter parameter based on the sortable fields of the resource |
path_param_is_composite_key{: #json_api-routes-post-path_param_is_composite_key } |
atom |
The path parameter that should be parsed as a composite primary key. When specified (e.g., :id), the parameter will be split using the resource's primary key delimiter and mapped to individual primary key fields. This is required for resources with composite primary keys to work correctly with GET, PATCH, and DELETE operations. See the composite primary keys documentation for more details. | |
relationship_arguments{: #json_api-routes-post-relationship_arguments } |
list(atom | {:id, atom}) |
[] |
Arguments to be used to edit relationships. See the relationships guide for more. |
upsert?{: #json_api-routes-post-upsert? } |
boolean |
false |
Whether or not to use the upsert?: true option when calling Ash.create/2. |
upsert_identity{: #json_api-routes-post-upsert_identity } |
atom |
false |
Which identity to use for the upsert |
Target: AshJsonApi.Resource.Route
patch resource, actionA PATCH route to update a record
patch :update
patch :update, path_param_is_composite_key: :id
| Name | Type | Default | Docs |
|---|---|---|---|
resource{: #json_api-routes-patch-resource } |
module |
The resource that the route's action is defined on | |
action{: #json_api-routes-patch-action .spark-required} |
atom |
The action to call when this route is hit |
| Name | Type | Default | Docs |
|---|---|---|---|
relationship_arguments{: #json_api-routes-patch-relationship_arguments } |
any |
[] |
Arguments to be used to edit relationships. See the relationships guide for more. |
read_action{: #json_api-routes-patch-read_action } |
atom |
The read action to use to look the record up before updating | |
route{: #json_api-routes-patch-route } |
String.t |
"/:id" |
The path of the route |
default_fields{: #json_api-routes-patch-default_fields } |
list(atom) |
A list of fields to be shown in the attributes of the called route | |
primary?{: #json_api-routes-patch-primary? } |
boolean |
false |
Whether or not this is the route that should be linked to by default when rendering links to this type of route |
metadata{: #json_api-routes-patch-metadata } |
(any, any, any -> any) |
A function to generate arbitrary top-level metadata for the JSON:API response | |
modify_conn{: #json_api-routes-patch-modify_conn } |
(any, any, any, any -> any) |
A function to modify the conn before responding. Used for things like setting headers based on the response. Takes conn, subject, result, request. See the modify_conn guide for more details and examples. |
|
query_params{: #json_api-routes-patch-query_params } |
list(atom) |
[] |
A list of action inputs to accept as query parameters. |
action_names_in_schema{: #json_api-routes-patch-action_names_in_schema } |
keyword |
A mapping of action names to how they should appear in the OpenAPI schema. You only need to set this if you see a warning during schema generation. | |
name{: #json_api-routes-patch-name } |
String.t |
A globally unique name for this route, to be used when generating docs and open api specifications | |
description{: #json_api-routes-patch-description } |
String.t |
A human-friendly description of this specific route to use in generated documentation and OpenAPI. If provided, this overrides the action description. | |
derive_sort?{: #json_api-routes-patch-derive_sort? } |
boolean |
true |
Whether or not to derive a sort parameter based on the sortable fields of the resource |
derive_filter?{: #json_api-routes-patch-derive_filter? } |
boolean |
true |
Whether or not to derive a filter parameter based on the sortable fields of the resource |
path_param_is_composite_key{: #json_api-routes-patch-path_param_is_composite_key } |
atom |
The path parameter that should be parsed as a composite primary key. When specified (e.g., :id), the parameter will be split using the resource's primary key delimiter and mapped to individual primary key fields. This is required for resources with composite primary keys to work correctly with GET, PATCH, and DELETE operations. See the composite primary keys documentation for more details. |
Target: AshJsonApi.Resource.Route
delete resource, actionA DELETE route to destroy a record
delete :destroy
delete :destroy, path_param_is_composite_key: :id
| Name | Type | Default | Docs |
|---|---|---|---|
resource{: #json_api-routes-delete-resource } |
module |
The resource that the route's action is defined on | |
action{: #json_api-routes-delete-action .spark-required} |
atom |
The action to call when this route is hit |
| Name | Type | Default | Docs |
|---|---|---|---|
read_action{: #json_api-routes-delete-read_action } |
atom |
The read action to use to look the record up before updating | |
route{: #json_api-routes-delete-route } |
String.t |
"/:id" |
The path of the route |
default_fields{: #json_api-routes-delete-default_fields } |
list(atom) |
A list of fields to be shown in the attributes of the called route | |
primary?{: #json_api-routes-delete-primary? } |
boolean |
false |
Whether or not this is the route that should be linked to by default when rendering links to this type of route |
metadata{: #json_api-routes-delete-metadata } |
(any, any, any -> any) |
A function to generate arbitrary top-level metadata for the JSON:API response | |
modify_conn{: #json_api-routes-delete-modify_conn } |
(any, any, any, any -> any) |
A function to modify the conn before responding. Used for things like setting headers based on the response. Takes conn, subject, result, request. See the modify_conn guide for more details and examples. |
|
query_params{: #json_api-routes-delete-query_params } |
list(atom) |
[] |
A list of action inputs to accept as query parameters. |
action_names_in_schema{: #json_api-routes-delete-action_names_in_schema } |
keyword |
A mapping of action names to how they should appear in the OpenAPI schema. You only need to set this if you see a warning during schema generation. | |
name{: #json_api-routes-delete-name } |
String.t |
A globally unique name for this route, to be used when generating docs and open api specifications | |
description{: #json_api-routes-delete-description } |
String.t |
A human-friendly description of this specific route to use in generated documentation and OpenAPI. If provided, this overrides the action description. | |
derive_sort?{: #json_api-routes-delete-derive_sort? } |
boolean |
true |
Whether or not to derive a sort parameter based on the sortable fields of the resource |
derive_filter?{: #json_api-routes-delete-derive_filter? } |
boolean |
true |
Whether or not to derive a filter parameter based on the sortable fields of the resource |
path_param_is_composite_key{: #json_api-routes-delete-path_param_is_composite_key } |
atom |
The path parameter that should be parsed as a composite primary key. When specified (e.g., :id), the parameter will be split using the resource's primary key delimiter and mapped to individual primary key fields. This is required for resources with composite primary keys to work correctly with GET, PATCH, and DELETE operations. See the composite primary keys documentation for more details. |
Target: AshJsonApi.Resource.Route
related resource, relationship, actionA GET route to read the related resources of a relationship
related :comments, :read
| Name | Type | Default | Docs |
|---|---|---|---|
resource{: #json_api-routes-related-resource } |
module |
The resource that the route's action is defined on | |
relationship{: #json_api-routes-related-relationship .spark-required} |
atom |
||
action{: #json_api-routes-related-action .spark-required} |
atom |
The action to call when this route is hit |
| Name | Type | Default | Docs |
|---|---|---|---|
route{: #json_api-routes-related-route } |
String.t |
The path of the route - Defaults to /:id/[relationship_name] | |
default_fields{: #json_api-routes-related-default_fields } |
list(atom) |
A list of fields to be shown in the attributes of the called route | |
primary?{: #json_api-routes-related-primary? } |
boolean |
false |
Whether or not this is the route that should be linked to by default when rendering links to this type of route |
metadata{: #json_api-routes-related-metadata } |
(any, any, any -> any) |
A function to generate arbitrary top-level metadata for the JSON:API response | |
modify_conn{: #json_api-routes-related-modify_conn } |
(any, any, any, any -> any) |
A function to modify the conn before responding. Used for things like setting headers based on the response. Takes conn, subject, result, request. See the modify_conn guide for more details and examples. |
|
query_params{: #json_api-routes-related-query_params } |
list(atom) |
[] |
A list of action inputs to accept as query parameters. |
action_names_in_schema{: #json_api-routes-related-action_names_in_schema } |
keyword |
A mapping of action names to how they should appear in the OpenAPI schema. You only need to set this if you see a warning during schema generation. | |
name{: #json_api-routes-related-name } |
String.t |
A globally unique name for this route, to be used when generating docs and open api specifications | |
description{: #json_api-routes-related-description } |
String.t |
A human-friendly description of this specific route to use in generated documentation and OpenAPI. If provided, this overrides the action description. | |
derive_sort?{: #json_api-routes-related-derive_sort? } |
boolean |
true |
Whether or not to derive a sort parameter based on the sortable fields of the resource |
derive_filter?{: #json_api-routes-related-derive_filter? } |
boolean |
true |
Whether or not to derive a filter parameter based on the sortable fields of the resource |
path_param_is_composite_key{: #json_api-routes-related-path_param_is_composite_key } |
atom |
The path parameter that should be parsed as a composite primary key. When specified (e.g., :id), the parameter will be split using the resource's primary key delimiter and mapped to individual primary key fields. This is required for resources with composite primary keys to work correctly with GET, PATCH, and DELETE operations. See the composite primary keys documentation for more details. |
Target: AshJsonApi.Resource.Route
relationship resource, relationship, actionA READ route to read the relationship, returns resource identifiers.
relationship :comments, :read
| Name | Type | Default | Docs |
|---|---|---|---|
resource{: #json_api-routes-relationship-resource } |
module |
The resource that the route's action is defined on | |
relationship{: #json_api-routes-relationship-relationship .spark-required} |
atom |
||
action{: #json_api-routes-relationship-action .spark-required} |
atom |
The action to call when this route is hit |
| Name | Type | Default | Docs |
|---|---|---|---|
route{: #json_api-routes-relationship-route } |
String.t |
The path of the route - Defaults to /:id/relationships/[relationship_name] | |
default_fields{: #json_api-routes-relationship-default_fields } |
list(atom) |
A list of fields to be shown in the attributes of the called route | |
primary?{: #json_api-routes-relationship-primary? } |
boolean |
false |
Whether or not this is the route that should be linked to by default when rendering links to this type of route |
metadata{: #json_api-routes-relationship-metadata } |
(any, any, any -> any) |
A function to generate arbitrary top-level metadata for the JSON:API response | |
modify_conn{: #json_api-routes-relationship-modify_conn } |
(any, any, any, any -> any) |
A function to modify the conn before responding. Used for things like setting headers based on the response. Takes conn, subject, result, request. See the modify_conn guide for more details and examples. |
|
query_params{: #json_api-routes-relationship-query_params } |
list(atom) |
[] |
A list of action inputs to accept as query parameters. |
action_names_in_schema{: #json_api-routes-relationship-action_names_in_schema } |
keyword |
A mapping of action names to how they should appear in the OpenAPI schema. You only need to set this if you see a warning during schema generation. | |
name{: #json_api-routes-relationship-name } |
String.t |
A globally unique name for this route, to be used when generating docs and open api specifications | |
description{: #json_api-routes-relationship-description } |
String.t |
A human-friendly description of this specific route to use in generated documentation and OpenAPI. If provided, this overrides the action description. | |
derive_sort?{: #json_api-routes-relationship-derive_sort? } |
boolean |
true |
Whether or not to derive a sort parameter based on the sortable fields of the resource |
derive_filter?{: #json_api-routes-relationship-derive_filter? } |
boolean |
true |
Whether or not to derive a filter parameter based on the sortable fields of the resource |
path_param_is_composite_key{: #json_api-routes-relationship-path_param_is_composite_key } |
atom |
The path parameter that should be parsed as a composite primary key. When specified (e.g., :id), the parameter will be split using the resource's primary key delimiter and mapped to individual primary key fields. This is required for resources with composite primary keys to work correctly with GET, PATCH, and DELETE operations. See the composite primary keys documentation for more details. |
Target: AshJsonApi.Resource.Route
post_to_relationship resource, relationshipA POST route to create related entities using resource identifiers
post_to_relationship :comments
| Name | Type | Default | Docs |
|---|---|---|---|
resource{: #json_api-routes-post_to_relationship-resource } |
module |
The resource that the route's action is defined on | |
relationship{: #json_api-routes-post_to_relationship-relationship .spark-required} |
atom |
| Name | Type | Default | Docs |
|---|---|---|---|
route{: #json_api-routes-post_to_relationship-route } |
String.t |
The path of the route - Defaults to /:id/relationships/[relationship_name] | |
default_fields{: #json_api-routes-post_to_relationship-default_fields } |
list(atom) |
A list of fields to be shown in the attributes of the called route | |
primary?{: #json_api-routes-post_to_relationship-primary? } |
boolean |
false |
Whether or not this is the route that should be linked to by default when rendering links to this type of route |
metadata{: #json_api-routes-post_to_relationship-metadata } |
(any, any, any -> any) |
A function to generate arbitrary top-level metadata for the JSON:API response | |
modify_conn{: #json_api-routes-post_to_relationship-modify_conn } |
(any, any, any, any -> any) |
A function to modify the conn before responding. Used for things like setting headers based on the response. Takes conn, subject, result, request. See the modify_conn guide for more details and examples. |
|
query_params{: #json_api-routes-post_to_relationship-query_params } |
list(atom) |
[] |
A list of action inputs to accept as query parameters. |
action_names_in_schema{: #json_api-routes-post_to_relationship-action_names_in_schema } |
keyword |
A mapping of action names to how they should appear in the OpenAPI schema. You only need to set this if you see a warning during schema generation. | |
name{: #json_api-routes-post_to_relationship-name } |
String.t |
A globally unique name for this route, to be used when generating docs and open api specifications | |
description{: #json_api-routes-post_to_relationship-description } |
String.t |
A human-friendly description of this specific route to use in generated documentation and OpenAPI. If provided, this overrides the action description. | |
derive_sort?{: #json_api-routes-post_to_relationship-derive_sort? } |
boolean |
true |
Whether or not to derive a sort parameter based on the sortable fields of the resource |
derive_filter?{: #json_api-routes-post_to_relationship-derive_filter? } |
boolean |
true |
Whether or not to derive a filter parameter based on the sortable fields of the resource |
path_param_is_composite_key{: #json_api-routes-post_to_relationship-path_param_is_composite_key } |
atom |
The path parameter that should be parsed as a composite primary key. When specified (e.g., :id), the parameter will be split using the resource's primary key delimiter and mapped to individual primary key fields. This is required for resources with composite primary keys to work correctly with GET, PATCH, and DELETE operations. See the composite primary keys documentation for more details. |
Target: AshJsonApi.Resource.Route
patch_relationship resource, relationshipA PATCH route to update a relationship using resource identifiers
patch_relationship :comments
| Name | Type | Default | Docs |
|---|---|---|---|
resource{: #json_api-routes-patch_relationship-resource } |
module |
The resource that the route's action is defined on | |
relationship{: #json_api-routes-patch_relationship-relationship .spark-required} |
atom |
| Name | Type | Default | Docs |
|---|---|---|---|
route{: #json_api-routes-patch_relationship-route } |
String.t |
The path of the route - Defaults to /:id/relationships/[relationship_name] | |
default_fields{: #json_api-routes-patch_relationship-default_fields } |
list(atom) |
A list of fields to be shown in the attributes of the called route | |
primary?{: #json_api-routes-patch_relationship-primary? } |
boolean |
false |
Whether or not this is the route that should be linked to by default when rendering links to this type of route |
metadata{: #json_api-routes-patch_relationship-metadata } |
(any, any, any -> any) |
A function to generate arbitrary top-level metadata for the JSON:API response | |
modify_conn{: #json_api-routes-patch_relationship-modify_conn } |
(any, any, any, any -> any) |
A function to modify the conn before responding. Used for things like setting headers based on the response. Takes conn, subject, result, request. See the modify_conn guide for more details and examples. |
|
query_params{: #json_api-routes-patch_relationship-query_params } |
list(atom) |
[] |
A list of action inputs to accept as query parameters. |
action_names_in_schema{: #json_api-routes-patch_relationship-action_names_in_schema } |
keyword |
A mapping of action names to how they should appear in the OpenAPI schema. You only need to set this if you see a warning during schema generation. | |
name{: #json_api-routes-patch_relationship-name } |
String.t |
A globally unique name for this route, to be used when generating docs and open api specifications | |
description{: #json_api-routes-patch_relationship-description } |
String.t |
A human-friendly description of this specific route to use in generated documentation and OpenAPI. If provided, this overrides the action description. | |
derive_sort?{: #json_api-routes-patch_relationship-derive_sort? } |
boolean |
true |
Whether or not to derive a sort parameter based on the sortable fields of the resource |
derive_filter?{: #json_api-routes-patch_relationship-derive_filter? } |
boolean |
true |
Whether or not to derive a filter parameter based on the sortable fields of the resource |
path_param_is_composite_key{: #json_api-routes-patch_relationship-path_param_is_composite_key } |
atom |
The path parameter that should be parsed as a composite primary key. When specified (e.g., :id), the parameter will be split using the resource's primary key delimiter and mapped to individual primary key fields. This is required for resources with composite primary keys to work correctly with GET, PATCH, and DELETE operations. See the composite primary keys documentation for more details. |
Target: AshJsonApi.Resource.Route
delete_from_relationship resource, relationshipA DELETE route to remove related entities using resource identifiers
delete_from_relationship :comments
| Name | Type | Default | Docs |
|---|---|---|---|
resource{: #json_api-routes-delete_from_relationship-resource } |
module |
The resource that the route's action is defined on | |
relationship{: #json_api-routes-delete_from_relationship-relationship .spark-required} |
atom |
| Name | Type | Default | Docs |
|---|---|---|---|
route{: #json_api-routes-delete_from_relationship-route } |
String.t |
The path of the route - Defaults to /:id/relationships/[relationship_name] | |
default_fields{: #json_api-routes-delete_from_relationship-default_fields } |
list(atom) |
A list of fields to be shown in the attributes of the called route | |
primary?{: #json_api-routes-delete_from_relationship-primary? } |
boolean |
false |
Whether or not this is the route that should be linked to by default when rendering links to this type of route |
metadata{: #json_api-routes-delete_from_relationship-metadata } |
(any, any, any -> any) |
A function to generate arbitrary top-level metadata for the JSON:API response | |
modify_conn{: #json_api-routes-delete_from_relationship-modify_conn } |
(any, any, any, any -> any) |
A function to modify the conn before responding. Used for things like setting headers based on the response. Takes conn, subject, result, request. See the modify_conn guide for more details and examples. |
|
query_params{: #json_api-routes-delete_from_relationship-query_params } |
list(atom) |
[] |
A list of action inputs to accept as query parameters. |
action_names_in_schema{: #json_api-routes-delete_from_relationship-action_names_in_schema } |
keyword |
A mapping of action names to how they should appear in the OpenAPI schema. You only need to set this if you see a warning during schema generation. | |
name{: #json_api-routes-delete_from_relationship-name } |
String.t |
A globally unique name for this route, to be used when generating docs and open api specifications | |
description{: #json_api-routes-delete_from_relationship-description } |
String.t |
A human-friendly description of this specific route to use in generated documentation and OpenAPI. If provided, this overrides the action description. | |
derive_sort?{: #json_api-routes-delete_from_relationship-derive_sort? } |
boolean |
true |
Whether or not to derive a sort parameter based on the sortable fields of the resource |
derive_filter?{: #json_api-routes-delete_from_relationship-derive_filter? } |
boolean |
true |
Whether or not to derive a filter parameter based on the sortable fields of the resource |
path_param_is_composite_key{: #json_api-routes-delete_from_relationship-path_param_is_composite_key } |
atom |
The path parameter that should be parsed as a composite primary key. When specified (e.g., :id), the parameter will be split using the resource's primary key delimiter and mapped to individual primary key fields. This is required for resources with composite primary keys to work correctly with GET, PATCH, and DELETE operations. See the composite primary keys documentation for more details. |
Target: AshJsonApi.Resource.Route
route resource, method, route, actionA route for a generic action.
route :get, "say_hi/:name", :say_hello
| Name | Type | Default | Docs |
|---|---|---|---|
resource{: #json_api-routes-route-resource } |
module |
The resource that the route's action is defined on | |
method{: #json_api-routes-route-method .spark-required} |
atom |
The HTTP method for the route, e.g :get, or :post |
|
route{: #json_api-routes-route-route .spark-required} |
String.t |
The path of the route | |
action{: #json_api-routes-route-action .spark-required} |
atom |
The action to call when this route is hit |
| Name | Type | Default | Docs |
|---|---|---|---|
wrap_in_result?{: #json_api-routes-route-wrap_in_result? } |
boolean |
false |
Whether or not the action result should be wrapped in {result: <result>} |
default_fields{: #json_api-routes-route-default_fields } |
list(atom) |
A list of fields to be shown in the attributes of the called route | |
primary?{: #json_api-routes-route-primary? } |
boolean |
false |
Whether or not this is the route that should be linked to by default when rendering links to this type of route |
metadata{: #json_api-routes-route-metadata } |
(any, any, any -> any) |
A function to generate arbitrary top-level metadata for the JSON:API response | |
modify_conn{: #json_api-routes-route-modify_conn } |
(any, any, any, any -> any) |
A function to modify the conn before responding. Used for things like setting headers based on the response. Takes conn, subject, result, request. See the modify_conn guide for more details and examples. |
|
query_params{: #json_api-routes-route-query_params } |
list(atom) |
[] |
A list of action inputs to accept as query parameters. |
action_names_in_schema{: #json_api-routes-route-action_names_in_schema } |
keyword |
A mapping of action names to how they should appear in the OpenAPI schema. You only need to set this if you see a warning during schema generation. | |
name{: #json_api-routes-route-name } |
String.t |
A globally unique name for this route, to be used when generating docs and open api specifications | |
description{: #json_api-routes-route-description } |
String.t |
A human-friendly description of this specific route to use in generated documentation and OpenAPI. If provided, this overrides the action description. | |
derive_sort?{: #json_api-routes-route-derive_sort? } |
boolean |
true |
Whether or not to derive a sort parameter based on the sortable fields of the resource |
derive_filter?{: #json_api-routes-route-derive_filter? } |
boolean |
true |
Whether or not to derive a filter parameter based on the sortable fields of the resource |
path_param_is_composite_key{: #json_api-routes-route-path_param_is_composite_key } |
atom |
The path parameter that should be parsed as a composite primary key. When specified (e.g., :id), the parameter will be split using the resource's primary key delimiter and mapped to individual primary key fields. This is required for resources with composite primary keys to work correctly with GET, PATCH, and DELETE operations. See the composite primary keys documentation for more details. |
Target: AshJsonApi.Resource.Route