AshJsonApi.Domain
View SourceThe entrypoint for adding JSON:API behavior to an Ash domain
json_api
Global configuration for JSON:API
Nested DSLs
- 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
Examples
json_api do
prefix "/json_api"
log_errors? true
end
Options
| Name | Type | Default | Docs |
|---|---|---|---|
router | atom | The router that you created for this Domain. Used by test helpers to send requests | |
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 | String.t | The route prefix at which you are serving the JSON:API | |
serve_schema? | boolean | false | Whether or not create a /schema route that serves the JSON schema of your API |
authorize? | boolean | true | Whether or not to perform authorization on requests. |
log_errors? | boolean | true | Whether or not to log any errors produced |
include_nil_values? | boolean | true | Whether or not to include properties for values that are nil in the JSON output |
json_api.open_api
OpenAPI configurations
Examples
json_api do
...
open_api do
tag "Users"
group_by :api
end
end
Options
| Name | Type | Default | Docs |
|---|---|---|---|
tag | String.t | Tag to be used when used by :group_by | |
group_by | :domain | :resource | :resource | Group by :domain or :resource |
json_api.routes
Configure the routes that will be exposed via the JSON:API
Nested DSLs
- 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
Examples
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
json_api.routes.base_route
base_route route, resource \\ nilSets a prefix for a list of contained routes
Nested DSLs
- get
- index
- post
- patch
- delete
- related
- relationship
- post_to_relationship
- patch_relationship
- delete_from_relationship
- route
Examples
base_route "/posts" do
index :read
get :read
end
base_route "/comments" do
index :read
end
Arguments
| Name | Type | Default | Docs |
|---|---|---|---|
route | String.t | The route prefix to use for contained routes | |
resource | module | The resource that the contained routes will use by default |
json_api.routes.base_route.get
get resource \\ nil, actionA GET route to retrieve a single record
Examples
get :readget :read, path_param_is_composite_key: :idArguments
| Name | Type | Default | Docs |
|---|---|---|---|
resource | module | The resource that the route's action is defined on | |
action | atom | The action to call when this route is hit |
Options
| Name | Type | Default | Docs |
|---|---|---|---|
route | String.t | "/:id" | The path of the route |
default_fields | list(atom) | A list of fields to be shown in the attributes of the called 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 | (any, any, any -> any) | A function to generate arbitrary top-level metadata for the JSON:API response | |
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 | 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 | String.t | A globally unique name for this route, to be used when generating docs and open api specifications | |
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? | boolean | true | Whether or not to derive a sort parameter based on the sortable fields of the resource |
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 | 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. |
Introspection
Target: AshJsonApi.Resource.Route
json_api.routes.base_route.index
index resource \\ nil, actionA GET route to retrieve a list of records
Examples
index :readArguments
| Name | Type | Default | Docs |
|---|---|---|---|
resource | module | The resource that the route's action is defined on | |
action | atom | The action to call when this route is hit |
Options
| Name | Type | Default | Docs |
|---|---|---|---|
paginate? | boolean | true | |
route | String.t | "/" | The path of the route |
default_fields | list(atom) | A list of fields to be shown in the attributes of the called 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 | (any, any, any -> any) | A function to generate arbitrary top-level metadata for the JSON:API response | |
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 | 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 | String.t | A globally unique name for this route, to be used when generating docs and open api specifications | |
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? | boolean | true | Whether or not to derive a sort parameter based on the sortable fields of the resource |
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 | 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. |
Introspection
Target: AshJsonApi.Resource.Route
json_api.routes.base_route.post
post resource \\ nil, actionA POST route to create a record
Examples
post :createArguments
| Name | Type | Default | Docs |
|---|---|---|---|
resource | module | The resource that the route's action is defined on | |
action | atom | The action to call when this route is hit |
Options
| Name | Type | Default | Docs |
|---|---|---|---|
route | String.t | "/" | The path of the route |
default_fields | list(atom) | A list of fields to be shown in the attributes of the called 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 | (any, any, any -> any) | A function to generate arbitrary top-level metadata for the JSON:API response | |
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 | list(atom) | [] | A list of action inputs to accept as query parameters. |
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 | String.t | A globally unique name for this route, to be used when generating docs and open api specifications | |
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? | boolean | true | Whether or not to derive a sort parameter based on the sortable fields of the resource |
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 | 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 | list(atom | {:id, atom}) | [] | Arguments to be used to edit relationships. See the relationships guide for more. |
upsert? | boolean | false | Whether or not to use the upsert?: true option when calling Ash.create/2. |
upsert_identity | atom | false | Which identity to use for the upsert |
Introspection
Target: AshJsonApi.Resource.Route
json_api.routes.base_route.patch
patch resource \\ nil, actionA PATCH route to update a record
Examples
patch :updatepatch :update, path_param_is_composite_key: :idArguments
| Name | Type | Default | Docs |
|---|---|---|---|
resource | module | The resource that the route's action is defined on | |
action | atom | The action to call when this route is hit |
Options
| Name | Type | Default | Docs |
|---|---|---|---|
relationship_arguments | any | [] | Arguments to be used to edit relationships. See the relationships guide for more. |
read_action | atom | The read action to use to look the record up before updating | |
route | String.t | "/:id" | The path of the route |
default_fields | list(atom) | A list of fields to be shown in the attributes of the called 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 | (any, any, any -> any) | A function to generate arbitrary top-level metadata for the JSON:API response | |
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 | list(atom) | [] | A list of action inputs to accept as query parameters. |
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 | String.t | A globally unique name for this route, to be used when generating docs and open api specifications | |
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? | boolean | true | Whether or not to derive a sort parameter based on the sortable fields of the resource |
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 | 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. |
Introspection
Target: AshJsonApi.Resource.Route
json_api.routes.base_route.delete
delete resource \\ nil, actionA DELETE route to destroy a record
Examples
delete :destroydelete :destroy, path_param_is_composite_key: :idArguments
| Name | Type | Default | Docs |
|---|---|---|---|
resource | module | The resource that the route's action is defined on | |
action | atom | The action to call when this route is hit |
Options
| Name | Type | Default | Docs |
|---|---|---|---|
read_action | atom | The read action to use to look the record up before updating | |
route | String.t | "/:id" | The path of the route |
default_fields | list(atom) | A list of fields to be shown in the attributes of the called 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 | (any, any, any -> any) | A function to generate arbitrary top-level metadata for the JSON:API response | |
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 | list(atom) | [] | A list of action inputs to accept as query parameters. |
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 | String.t | A globally unique name for this route, to be used when generating docs and open api specifications | |
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? | boolean | true | Whether or not to derive a sort parameter based on the sortable fields of the resource |
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 | 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. |
Introspection
Target: AshJsonApi.Resource.Route
json_api.routes.base_route.related
related resource \\ nil, relationship, actionA GET route to read the related resources of a relationship
Examples
related :comments, :readArguments
| Name | Type | Default | Docs |
|---|---|---|---|
resource | module | The resource that the route's action is defined on | |
relationship | atom | ||
action | atom | The action to call when this route is hit |
Options
| Name | Type | Default | Docs |
|---|---|---|---|
route | String.t | The path of the route - Defaults to /:id/[relationship_name] | |
default_fields | list(atom) | A list of fields to be shown in the attributes of the called 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 | (any, any, any -> any) | A function to generate arbitrary top-level metadata for the JSON:API response | |
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 | list(atom) | [] | A list of action inputs to accept as query parameters. |
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 | String.t | A globally unique name for this route, to be used when generating docs and open api specifications | |
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? | boolean | true | Whether or not to derive a sort parameter based on the sortable fields of the resource |
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 | 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. |
Introspection
Target: AshJsonApi.Resource.Route
json_api.routes.base_route.relationship
relationship resource \\ nil, relationship, actionA READ route to read the relationship, returns resource identifiers.
Examples
relationship :comments, :readArguments
| Name | Type | Default | Docs |
|---|---|---|---|
resource | module | The resource that the route's action is defined on | |
relationship | atom | ||
action | atom | The action to call when this route is hit |
Options
| Name | Type | Default | Docs |
|---|---|---|---|
route | String.t | The path of the route - Defaults to /:id/relationships/[relationship_name] | |
default_fields | list(atom) | A list of fields to be shown in the attributes of the called 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 | (any, any, any -> any) | A function to generate arbitrary top-level metadata for the JSON:API response | |
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 | list(atom) | [] | A list of action inputs to accept as query parameters. |
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 | String.t | A globally unique name for this route, to be used when generating docs and open api specifications | |
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? | boolean | true | Whether or not to derive a sort parameter based on the sortable fields of the resource |
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 | 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. |
Introspection
Target: AshJsonApi.Resource.Route
json_api.routes.base_route.post_to_relationship
post_to_relationship resource \\ nil, relationshipA POST route to create related entities using resource identifiers
Examples
post_to_relationship :commentsArguments
| Name | Type | Default | Docs |
|---|---|---|---|
resource | module | The resource that the route's action is defined on | |
relationship | atom |
Options
| Name | Type | Default | Docs |
|---|---|---|---|
route | String.t | The path of the route - Defaults to /:id/relationships/[relationship_name] | |
default_fields | list(atom) | A list of fields to be shown in the attributes of the called 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 | (any, any, any -> any) | A function to generate arbitrary top-level metadata for the JSON:API response | |
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 | list(atom) | [] | A list of action inputs to accept as query parameters. |
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 | String.t | A globally unique name for this route, to be used when generating docs and open api specifications | |
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? | boolean | true | Whether or not to derive a sort parameter based on the sortable fields of the resource |
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 | 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. |
Introspection
Target: AshJsonApi.Resource.Route
json_api.routes.base_route.patch_relationship
patch_relationship resource \\ nil, relationshipA PATCH route to update a relationship using resource identifiers
Examples
patch_relationship :commentsArguments
| Name | Type | Default | Docs |
|---|---|---|---|
resource | module | The resource that the route's action is defined on | |
relationship | atom |
Options
| Name | Type | Default | Docs |
|---|---|---|---|
route | String.t | The path of the route - Defaults to /:id/relationships/[relationship_name] | |
default_fields | list(atom) | A list of fields to be shown in the attributes of the called 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 | (any, any, any -> any) | A function to generate arbitrary top-level metadata for the JSON:API response | |
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 | list(atom) | [] | A list of action inputs to accept as query parameters. |
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 | String.t | A globally unique name for this route, to be used when generating docs and open api specifications | |
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? | boolean | true | Whether or not to derive a sort parameter based on the sortable fields of the resource |
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 | 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. |
Introspection
Target: AshJsonApi.Resource.Route
json_api.routes.base_route.delete_from_relationship
delete_from_relationship resource \\ nil, relationshipA DELETE route to remove related entities using resource identifiers
Examples
delete_from_relationship :commentsArguments
| Name | Type | Default | Docs |
|---|---|---|---|
resource | module | The resource that the route's action is defined on | |
relationship | atom |
Options
| Name | Type | Default | Docs |
|---|---|---|---|
route | String.t | The path of the route - Defaults to /:id/relationships/[relationship_name] | |
default_fields | list(atom) | A list of fields to be shown in the attributes of the called 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 | (any, any, any -> any) | A function to generate arbitrary top-level metadata for the JSON:API response | |
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 | list(atom) | [] | A list of action inputs to accept as query parameters. |
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 | String.t | A globally unique name for this route, to be used when generating docs and open api specifications | |
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? | boolean | true | Whether or not to derive a sort parameter based on the sortable fields of the resource |
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 | 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. |
Introspection
Target: AshJsonApi.Resource.Route
json_api.routes.base_route.route
route resource \\ nil, method, route, actionA route for a generic action.
Examples
route :get, "say_hi/:name", :say_helloArguments
| Name | Type | Default | Docs |
|---|---|---|---|
resource | module | The resource that the route's action is defined on | |
method | atom | The HTTP method for the route, e.g :get, or :post | |
route | String.t | The path of the route | |
action | atom | The action to call when this route is hit |
Options
| Name | Type | Default | Docs |
|---|---|---|---|
wrap_in_result? | boolean | false | Whether or not the action result should be wrapped in {result: <result>} |
default_fields | list(atom) | A list of fields to be shown in the attributes of the called 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 | (any, any, any -> any) | A function to generate arbitrary top-level metadata for the JSON:API response | |
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 | list(atom) | [] | A list of action inputs to accept as query parameters. |
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 | String.t | A globally unique name for this route, to be used when generating docs and open api specifications | |
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? | boolean | true | Whether or not to derive a sort parameter based on the sortable fields of the resource |
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 | 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. |
Introspection
Target: AshJsonApi.Resource.Route
Introspection
Target: AshJsonApi.Domain.BaseRoute
json_api.routes.get
get resource, actionA GET route to retrieve a single record
Examples
get :readget :read, path_param_is_composite_key: :idArguments
| Name | Type | Default | Docs |
|---|---|---|---|
resource | module | The resource that the route's action is defined on | |
action | atom | The action to call when this route is hit |
Options
| Name | Type | Default | Docs |
|---|---|---|---|
route | String.t | "/:id" | The path of the route |
default_fields | list(atom) | A list of fields to be shown in the attributes of the called 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 | (any, any, any -> any) | A function to generate arbitrary top-level metadata for the JSON:API response | |
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 | 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 | String.t | A globally unique name for this route, to be used when generating docs and open api specifications | |
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? | boolean | true | Whether or not to derive a sort parameter based on the sortable fields of the resource |
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 | 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. |
Introspection
Target: AshJsonApi.Resource.Route
json_api.routes.index
index resource, actionA GET route to retrieve a list of records
Examples
index :readArguments
| Name | Type | Default | Docs |
|---|---|---|---|
resource | module | The resource that the route's action is defined on | |
action | atom | The action to call when this route is hit |
Options
| Name | Type | Default | Docs |
|---|---|---|---|
paginate? | boolean | true | |
route | String.t | "/" | The path of the route |
default_fields | list(atom) | A list of fields to be shown in the attributes of the called 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 | (any, any, any -> any) | A function to generate arbitrary top-level metadata for the JSON:API response | |
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 | 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 | String.t | A globally unique name for this route, to be used when generating docs and open api specifications | |
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? | boolean | true | Whether or not to derive a sort parameter based on the sortable fields of the resource |
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 | 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. |
Introspection
Target: AshJsonApi.Resource.Route
json_api.routes.post
post resource, actionA POST route to create a record
Examples
post :createArguments
| Name | Type | Default | Docs |
|---|---|---|---|
resource | module | The resource that the route's action is defined on | |
action | atom | The action to call when this route is hit |
Options
| Name | Type | Default | Docs |
|---|---|---|---|
route | String.t | "/" | The path of the route |
default_fields | list(atom) | A list of fields to be shown in the attributes of the called 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 | (any, any, any -> any) | A function to generate arbitrary top-level metadata for the JSON:API response | |
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 | list(atom) | [] | A list of action inputs to accept as query parameters. |
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 | String.t | A globally unique name for this route, to be used when generating docs and open api specifications | |
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? | boolean | true | Whether or not to derive a sort parameter based on the sortable fields of the resource |
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 | 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 | list(atom | {:id, atom}) | [] | Arguments to be used to edit relationships. See the relationships guide for more. |
upsert? | boolean | false | Whether or not to use the upsert?: true option when calling Ash.create/2. |
upsert_identity | atom | false | Which identity to use for the upsert |
Introspection
Target: AshJsonApi.Resource.Route
json_api.routes.patch
patch resource, actionA PATCH route to update a record
Examples
patch :updatepatch :update, path_param_is_composite_key: :idArguments
| Name | Type | Default | Docs |
|---|---|---|---|
resource | module | The resource that the route's action is defined on | |
action | atom | The action to call when this route is hit |
Options
| Name | Type | Default | Docs |
|---|---|---|---|
relationship_arguments | any | [] | Arguments to be used to edit relationships. See the relationships guide for more. |
read_action | atom | The read action to use to look the record up before updating | |
route | String.t | "/:id" | The path of the route |
default_fields | list(atom) | A list of fields to be shown in the attributes of the called 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 | (any, any, any -> any) | A function to generate arbitrary top-level metadata for the JSON:API response | |
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 | list(atom) | [] | A list of action inputs to accept as query parameters. |
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 | String.t | A globally unique name for this route, to be used when generating docs and open api specifications | |
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? | boolean | true | Whether or not to derive a sort parameter based on the sortable fields of the resource |
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 | 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. |
Introspection
Target: AshJsonApi.Resource.Route
json_api.routes.delete
delete resource, actionA DELETE route to destroy a record
Examples
delete :destroydelete :destroy, path_param_is_composite_key: :idArguments
| Name | Type | Default | Docs |
|---|---|---|---|
resource | module | The resource that the route's action is defined on | |
action | atom | The action to call when this route is hit |
Options
| Name | Type | Default | Docs |
|---|---|---|---|
read_action | atom | The read action to use to look the record up before updating | |
route | String.t | "/:id" | The path of the route |
default_fields | list(atom) | A list of fields to be shown in the attributes of the called 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 | (any, any, any -> any) | A function to generate arbitrary top-level metadata for the JSON:API response | |
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 | list(atom) | [] | A list of action inputs to accept as query parameters. |
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 | String.t | A globally unique name for this route, to be used when generating docs and open api specifications | |
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? | boolean | true | Whether or not to derive a sort parameter based on the sortable fields of the resource |
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 | 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. |
Introspection
Target: AshJsonApi.Resource.Route
json_api.routes.related
related resource, relationship, actionA GET route to read the related resources of a relationship
Examples
related :comments, :readArguments
| Name | Type | Default | Docs |
|---|---|---|---|
resource | module | The resource that the route's action is defined on | |
relationship | atom | ||
action | atom | The action to call when this route is hit |
Options
| Name | Type | Default | Docs |
|---|---|---|---|
route | String.t | The path of the route - Defaults to /:id/[relationship_name] | |
default_fields | list(atom) | A list of fields to be shown in the attributes of the called 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 | (any, any, any -> any) | A function to generate arbitrary top-level metadata for the JSON:API response | |
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 | list(atom) | [] | A list of action inputs to accept as query parameters. |
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 | String.t | A globally unique name for this route, to be used when generating docs and open api specifications | |
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? | boolean | true | Whether or not to derive a sort parameter based on the sortable fields of the resource |
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 | 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. |
Introspection
Target: AshJsonApi.Resource.Route
json_api.routes.relationship
relationship resource, relationship, actionA READ route to read the relationship, returns resource identifiers.
Examples
relationship :comments, :readArguments
| Name | Type | Default | Docs |
|---|---|---|---|
resource | module | The resource that the route's action is defined on | |
relationship | atom | ||
action | atom | The action to call when this route is hit |
Options
| Name | Type | Default | Docs |
|---|---|---|---|
route | String.t | The path of the route - Defaults to /:id/relationships/[relationship_name] | |
default_fields | list(atom) | A list of fields to be shown in the attributes of the called 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 | (any, any, any -> any) | A function to generate arbitrary top-level metadata for the JSON:API response | |
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 | list(atom) | [] | A list of action inputs to accept as query parameters. |
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 | String.t | A globally unique name for this route, to be used when generating docs and open api specifications | |
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? | boolean | true | Whether or not to derive a sort parameter based on the sortable fields of the resource |
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 | 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. |
Introspection
Target: AshJsonApi.Resource.Route
json_api.routes.post_to_relationship
post_to_relationship resource, relationshipA POST route to create related entities using resource identifiers
Examples
post_to_relationship :commentsArguments
| Name | Type | Default | Docs |
|---|---|---|---|
resource | module | The resource that the route's action is defined on | |
relationship | atom |
Options
| Name | Type | Default | Docs |
|---|---|---|---|
route | String.t | The path of the route - Defaults to /:id/relationships/[relationship_name] | |
default_fields | list(atom) | A list of fields to be shown in the attributes of the called 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 | (any, any, any -> any) | A function to generate arbitrary top-level metadata for the JSON:API response | |
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 | list(atom) | [] | A list of action inputs to accept as query parameters. |
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 | String.t | A globally unique name for this route, to be used when generating docs and open api specifications | |
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? | boolean | true | Whether or not to derive a sort parameter based on the sortable fields of the resource |
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 | 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. |
Introspection
Target: AshJsonApi.Resource.Route
json_api.routes.patch_relationship
patch_relationship resource, relationshipA PATCH route to update a relationship using resource identifiers
Examples
patch_relationship :commentsArguments
| Name | Type | Default | Docs |
|---|---|---|---|
resource | module | The resource that the route's action is defined on | |
relationship | atom |
Options
| Name | Type | Default | Docs |
|---|---|---|---|
route | String.t | The path of the route - Defaults to /:id/relationships/[relationship_name] | |
default_fields | list(atom) | A list of fields to be shown in the attributes of the called 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 | (any, any, any -> any) | A function to generate arbitrary top-level metadata for the JSON:API response | |
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 | list(atom) | [] | A list of action inputs to accept as query parameters. |
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 | String.t | A globally unique name for this route, to be used when generating docs and open api specifications | |
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? | boolean | true | Whether or not to derive a sort parameter based on the sortable fields of the resource |
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 | 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. |
Introspection
Target: AshJsonApi.Resource.Route
json_api.routes.delete_from_relationship
delete_from_relationship resource, relationshipA DELETE route to remove related entities using resource identifiers
Examples
delete_from_relationship :commentsArguments
| Name | Type | Default | Docs |
|---|---|---|---|
resource | module | The resource that the route's action is defined on | |
relationship | atom |
Options
| Name | Type | Default | Docs |
|---|---|---|---|
route | String.t | The path of the route - Defaults to /:id/relationships/[relationship_name] | |
default_fields | list(atom) | A list of fields to be shown in the attributes of the called 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 | (any, any, any -> any) | A function to generate arbitrary top-level metadata for the JSON:API response | |
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 | list(atom) | [] | A list of action inputs to accept as query parameters. |
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 | String.t | A globally unique name for this route, to be used when generating docs and open api specifications | |
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? | boolean | true | Whether or not to derive a sort parameter based on the sortable fields of the resource |
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 | 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. |
Introspection
Target: AshJsonApi.Resource.Route
json_api.routes.route
route resource, method, route, actionA route for a generic action.
Examples
route :get, "say_hi/:name", :say_helloArguments
| Name | Type | Default | Docs |
|---|---|---|---|
resource | module | The resource that the route's action is defined on | |
method | atom | The HTTP method for the route, e.g :get, or :post | |
route | String.t | The path of the route | |
action | atom | The action to call when this route is hit |
Options
| Name | Type | Default | Docs |
|---|---|---|---|
wrap_in_result? | boolean | false | Whether or not the action result should be wrapped in {result: <result>} |
default_fields | list(atom) | A list of fields to be shown in the attributes of the called 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 | (any, any, any -> any) | A function to generate arbitrary top-level metadata for the JSON:API response | |
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 | list(atom) | [] | A list of action inputs to accept as query parameters. |
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 | String.t | A globally unique name for this route, to be used when generating docs and open api specifications | |
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? | boolean | true | Whether or not to derive a sort parameter based on the sortable fields of the resource |
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 | 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. |
Introspection
Target: AshJsonApi.Resource.Route