You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: documentation/dsls/DSL-AshJsonApi.Domain.md
+37-37Lines changed: 37 additions & 37 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,11 +3,11 @@ This file was generated by Spark. Do not edit it by hand.
3
3
-->
4
4
# AshJsonApi.Domain
5
5
6
-
The entrypoint for adding JSON:API behavior to an Ash domain
6
+
The entrypoint for adding JSON:API behavior to an Ash domain
7
7
8
8
9
9
## json_api
10
-
Global configuration for JSON:API
10
+
Global configuration for JSON:API
11
11
12
12
13
13
### Nested DSLs
@@ -40,10 +40,10 @@ Global configuration for JSON:API
40
40
41
41
### Examples
42
42
```
43
-
json_api do
44
-
prefix "/json_api"
45
-
log_errors? true
46
-
end
43
+
json_api do
44
+
prefix "/json_api"
45
+
log_errors? true
46
+
end
47
47
48
48
```
49
49
@@ -61,7 +61,7 @@ end
61
61
|[`authorize?`](#json_api-authorize?){: #json_api-authorize? } |`boolean`|`true`| Whether or not to perform authorization on requests. |
62
62
|[`log_errors?`](#json_api-log_errors?){: #json_api-log_errors? } |`boolean`|`true`| Whether or not to log any errors produced |
63
63
|[`include_nil_values?`](#json_api-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 |
64
-
| [`error_handler`](#json_api-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 ``` |
64
+
|[`error_handler`](#json_api-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 ```|
65
65
|[`require_type_on_create?`](#json_api-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. |
66
66
67
67
@@ -72,13 +72,13 @@ OpenAPI configurations
72
72
73
73
### Examples
74
74
```
75
-
json_api do
76
-
...
77
-
open_api do
78
-
tag "Users"
79
-
group_by :api
80
-
end
81
-
end
75
+
json_api do
76
+
...
77
+
open_api do
78
+
tag "Users"
79
+
group_by :api
80
+
end
81
+
end
82
82
83
83
```
84
84
@@ -126,20 +126,20 @@ Configure the routes that will be exposed via the JSON:API
Copy file name to clipboardExpand all lines: documentation/dsls/DSL-AshJsonApi.Resource.md
+48-46Lines changed: 48 additions & 46 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@ This file was generated by Spark. Do not edit it by hand.
3
3
-->
4
4
# AshJsonApi.Resource
5
5
6
-
The entrypoint for adding JSON:API behavior to a resource"
6
+
The entrypoint for adding JSON:API behavior to a resource"
7
7
8
8
9
9
## json_api
@@ -27,30 +27,30 @@ Configure the resource's behavior in the JSON:API
27
27
28
28
### Examples
29
29
```
30
-
json_api do
31
-
type "post"
32
-
includes [
33
-
friends: [
34
-
:comments
35
-
],
36
-
comments: []
37
-
]
38
-
39
-
routes do
40
-
base "/posts"
41
-
42
-
get :read
43
-
get :me, route: "/me"
44
-
index :read
45
-
post :confirm_name, route: "/confirm_name"
46
-
patch :update
47
-
related :comments, :read
48
-
relationship :comments, :read
49
-
post_to_relationship :comments
50
-
patch_relationship :comments
51
-
delete_from_relationship :comments
52
-
end
53
-
end
30
+
json_api do
31
+
type "post"
32
+
includes [
33
+
friends: [
34
+
:comments
35
+
],
36
+
comments: []
37
+
]
38
+
39
+
routes do
40
+
base "/posts"
41
+
42
+
get :read
43
+
get :me, route: "/me"
44
+
index :read
45
+
post :confirm_name, route: "/confirm_name"
46
+
patch :update
47
+
related :comments, :read
48
+
relationship :comments, :read
49
+
post_to_relationship :comments
50
+
patch_relationship :comments
51
+
delete_from_relationship :comments
52
+
end
53
+
end
54
54
55
55
```
56
56
@@ -69,9 +69,11 @@ end
69
69
|[`default_fields`](#json_api-default_fields){: #json_api-default_fields } |`list(atom)`|| The fields to include in the object if the `fields` query parameter does not specify. Defaults to all public |
70
70
|[`derive_sort?`](#json_api-derive_sort?){: #json_api-derive_sort? } |`boolean`|`true`| Whether or not to derive a sort parameter based on the sortable fields of the resource |
71
71
|[`derive_filter?`](#json_api-derive_filter?){: #json_api-derive_filter? } |`boolean`|`true`| Whether or not to derive a filter parameter based on the sortable fields of the resource |
72
-
| [`field_names`](#json_api-field_names){: #json_api-field_names } | `:camelize \| :dasherize \| keyword \| (any -> any)` | | Renames fields (attributes, relationships, calculations, and aggregates) in the JSON:API output and input. Can be one of the atoms `:camelize` or `:dasherize` for automatic conversion, a keyword list of `[ash_name: :json_api_name]` mappings, or a 1-arity function that receives an atom field name and returns the desired JSON:API name (atom or string). ```elixir field_names :camelize # first_name → firstName field_names :dasherize # first_name → first-name ``` Or with a keyword list: ```elixir field_names [ first_name: :firstName, last_name: :lastName ] ``` Or with a function for custom logic: ```elixir field_names fn name -> camelized = name \|> to_string() \|> Macro.camelize() {first, rest} = String.split_at(camelized, 1) String.downcase(first) <> rest end ``` Names are applied consistently across serialization, request parsing, sort/filter parameters, field selection, error source pointers, relationship keys, and schema generation. |
73
-
| [`argument_names`](#json_api-argument_names){: #json_api-argument_names } | `:camelize \| :dasherize \| keyword \| (any, any -> any)` | | Renames action arguments in the JSON:API request body and schema. Can be one of the atoms `:camelize` or `:dasherize` for automatic conversion, a nested keyword list of `[action_name: [ash_name: :json_api_name]]` mappings, or a 2-arity function that receives `(action_name, argument_name)` atoms and returns the desired JSON:API name (atom or string). ```elixir argument_names :camelize # publish_at → publishAt argument_names :dasherize # publish_at → publish-at ``` Or with a keyword list: ```elixir argument_names [ create: [my_arg: :myArg], update: [my_arg: :myArg]] ``` Or with a function: ```elixir argument_names fn _action, name -> camelized = name \|> to_string() \|> Macro.camelize() {first, rest} = String.split_at(camelized, 1) String.downcase(first) <> rest end ``` |
74
-
| [`calculation_argument_names`](#json_api-calculation_argument_names){: #json_api-calculation_argument_names } | `:camelize \| :dasherize \| keyword \| (any, any -> any)` | | Renames calculation arguments in the JSON:API request and schema. Works the same way as `argument_names` but applies to calculation arguments instead of action arguments. The 2-arity function receives `(calculation_name, argument_name)`. Can be one of the atoms `:camelize` or `:dasherize` for automatic conversion, a nested keyword list of `[calc_name: [ash_name: :json_api_name]]` mappings, or a 2-arity function that receives `(calculation_name, argument_name)` atoms and returns the desired JSON:API name (atom or string). ```elixir calculation_argument_names :camelize # publish_at → publishAt calculation_argument_names :dasherize # publish_at → publish-at ``` Or with a keyword list: ```elixir calculation_argument_names [ full_name: [separator: :sep] ] ``` Or with a function: ```elixir calculation_argument_names fn _calc, name -> camelized = name \|> to_string() \|> Macro.camelize() {first, rest} = String.split_at(camelized, 1) String.downcase(first) <> rest end ``` |
72
+
|[`relationship_meta_in`](#json_api-relationship_meta_in){: #json_api-relationship_meta_in } |`keyword`|`[]`| Configures how incoming JSON:API`meta` keys on relationship resource identifiers map to join resource attributes for many_to_many relationship writes. Use together with `relationship_meta_out` for reads. Each relationship you want to support must declare both mappings explicitly. |
73
+
|[`relationship_meta_out`](#json_api-relationship_meta_out){: #json_api-relationship_meta_out } |`keyword`|`[]`| Configures how join resource attributes map to outgoing JSON:API`meta` keys on relationship resource identifiers for many_to_many relationship reads. Use together with `relationship_meta_in` for writes. Each relationship you want to support must declare both mappings explicitly. |
74
+
| [`field_names`](#json_api-field_names){: #json_api-field_names } | `:camelize \| :dasherize \| keyword \| (any -> any)` | | Renames fields (attributes, relationships, calculations, and aggregates) in the JSON:API output and input. Can be one of the atoms `:camelize` or `:dasherize` for automatic conversion, a keyword list of `[ash_name: :json_api_name]` mappings, or a 1-arity function that receives an atom field name and returns the desired JSON:API name (atom or string). ```elixir field_names :camelize # first_name → firstName field_names :dasherize # first_name → first-name ``` Or with a keyword list: ```elixir field_names [ first_name: :firstName, last_name: :lastName ] ``` Or with a function for custom logic: ```elixir field_names fn name -> camelized = name \|> to_string() \|> Macro.camelize() {first, rest} = String.split_at(camelized, 1) String.downcase(first) <> rest end ``` Names are applied consistently across serialization, request parsing, sort/filter parameters, field selection, error source pointers, relationship keys, and schema generation. |
75
+
|[`argument_names`](#json_api-argument_names){: #json_api-argument_names } |`:camelize \| :dasherize \| keyword \| (any, any -> any)`|| Renames action arguments in the JSON:API request body and schema. Can be one of the atoms `:camelize` or `:dasherize` for automatic conversion, a nested keyword list of `[action_name: [ash_name: :json_api_name]]` mappings, or a 2-arity function that receives `(action_name, argument_name)` atoms and returns the desired JSON:API name (atom or string). ```elixir argument_names :camelize # publish_at → publishAt argument_names :dasherize # publish_at → publish-at ``` Or with a keyword list: ```elixir argument_names [ create: [my_arg: :myArg], update: [my_arg: :myArg] ] ``` Or with a function: ```elixir argument_names fn _action, name -> camelized = name \|> to_string() \|> Macro.camelize() {first, rest} = String.split_at(camelized, 1) String.downcase(first) <> rest end ```|
76
+
| [`calculation_argument_names`](#json_api-calculation_argument_names){: #json_api-calculation_argument_names } | `:camelize \| :dasherize \| keyword \| (any, any -> any)` | | Renames calculation arguments in the JSON:API request and schema. Works the same way as `argument_names` but applies to calculation arguments instead of action arguments. The 2-arity function receives `(calculation_name, argument_name)`. Can be one of the atoms `:camelize` or `:dasherize` for automatic conversion, a nested keyword list of `[calc_name: [ash_name: :json_api_name]]` mappings, or a 2-arity function that receives `(calculation_name, argument_name)` atoms and returns the desired JSON:API name (atom or string). ```elixir calculation_argument_names :camelize # publish_at → publishAt calculation_argument_names :dasherize # publish_at → publish-at ``` Or with a keyword list: ```elixir calculation_argument_names [ full_name: [separator: :sep] ] ``` Or with a function: ```elixir calculation_argument_names fn _calc, name -> camelized = name \|> to_string() \|> Macro.camelize() {first, rest} = String.split_at(camelized, 1) String.downcase(first) <> rest end ``` |
75
77
76
78
77
79
### json_api.routes
@@ -93,20 +95,20 @@ Configure the routes that will be exposed via the JSON:API
93
95
94
96
### Examples
95
97
```
96
-
routes do
97
-
base "/posts"
98
-
99
-
get :read
100
-
get :me, route: "/me"
101
-
index :read
102
-
post :confirm_name, route: "/confirm_name"
103
-
patch :update
104
-
related :comments, :read
105
-
relationship :comments, :read
106
-
post_to_relationship :comments
107
-
patch_relationship :comments
108
-
delete_from_relationship :comments
109
-
end
98
+
routes do
99
+
base "/posts"
100
+
101
+
get :read
102
+
get :me, route: "/me"
103
+
index :read
104
+
post :confirm_name, route: "/confirm_name"
105
+
patch :update
106
+
related :comments, :read
107
+
relationship :comments, :read
108
+
post_to_relationship :comments
109
+
patch_relationship :comments
110
+
delete_from_relationship :comments
111
+
end
110
112
111
113
```
112
114
@@ -667,10 +669,10 @@ Encode the id of the JSON API response from selected attributes of a resource
0 commit comments