Skip to content

Commit dc0fdbb

Browse files
committed
chore: format
1 parent 5f6dd80 commit dc0fdbb

2 files changed

Lines changed: 85 additions & 83 deletions

File tree

documentation/dsls/DSL-AshJsonApi.Domain.md

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ This file was generated by Spark. Do not edit it by hand.
33
-->
44
# AshJsonApi.Domain
55

6-
The entrypoint for adding JSON:API behavior to an Ash domain
6+
The entrypoint for adding JSON:API behavior to an Ash domain
77

88

99
## json_api
10-
Global configuration for JSON:API
10+
Global configuration for JSON:API
1111

1212

1313
### Nested DSLs
@@ -40,10 +40,10 @@ Global configuration for JSON:API
4040

4141
### Examples
4242
```
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
4747
4848
```
4949

@@ -61,7 +61,7 @@ end
6161
| [`authorize?`](#json_api-authorize?){: #json_api-authorize? } | `boolean` | `true` | Whether or not to perform authorization on requests. |
6262
| [`log_errors?`](#json_api-log_errors?){: #json_api-log_errors? } | `boolean` | `true` | Whether or not to log any errors produced |
6363
| [`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 ``` |
6565
| [`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. |
6666

6767

@@ -72,13 +72,13 @@ OpenAPI configurations
7272

7373
### Examples
7474
```
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
8282
8383
```
8484

@@ -126,20 +126,20 @@ Configure the routes that will be exposed via the JSON:API
126126

127127
### Examples
128128
```
129-
routes do
130-
base "/posts"
131-
132-
get :read
133-
get :me, route: "/me"
134-
index :read
135-
post :confirm_name, route: "/confirm_name"
136-
patch :update
137-
related :comments, :read
138-
relationship :comments, :read
139-
post_to_relationship :comments
140-
patch_relationship :comments
141-
delete_from_relationship :comments
142-
end
129+
routes do
130+
base "/posts"
131+
132+
get :read
133+
get :me, route: "/me"
134+
index :read
135+
post :confirm_name, route: "/confirm_name"
136+
patch :update
137+
related :comments, :read
138+
relationship :comments, :read
139+
post_to_relationship :comments
140+
patch_relationship :comments
141+
delete_from_relationship :comments
142+
end
143143
144144
```
145145

@@ -152,7 +152,7 @@ base_route route, resource \\ nil
152152
```
153153

154154

155-
Sets a prefix for a list of contained routes
155+
Sets a prefix for a list of contained routes
156156

157157

158158
### Nested DSLs
@@ -171,14 +171,14 @@ Sets a prefix for a list of contained routes
171171

172172
### Examples
173173
```
174-
base_route "/posts" do
175-
index :read
176-
get :read
177-
end
178-
179-
base_route "/comments" do
180-
index :read
181-
end
174+
base_route "/posts" do
175+
index :read
176+
get :read
177+
end
178+
179+
base_route "/comments" do
180+
index :read
181+
end
182182
183183
```
184184

documentation/dsls/DSL-AshJsonApi.Resource.md

Lines changed: 48 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ This file was generated by Spark. Do not edit it by hand.
33
-->
44
# AshJsonApi.Resource
55

6-
The entrypoint for adding JSON:API behavior to a resource"
6+
The entrypoint for adding JSON:API behavior to a resource"
77

88

99
## json_api
@@ -27,30 +27,30 @@ Configure the resource's behavior in the JSON:API
2727

2828
### Examples
2929
```
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
5454
5555
```
5656

@@ -69,9 +69,11 @@ end
6969
| [`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 |
7070
| [`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 |
7171
| [`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 ``` |
7577

7678

7779
### json_api.routes
@@ -93,20 +95,20 @@ Configure the routes that will be exposed via the JSON:API
9395

9496
### Examples
9597
```
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
110112
111113
```
112114

@@ -667,10 +669,10 @@ Encode the id of the JSON API response from selected attributes of a resource
667669

668670
### Examples
669671
```
670-
primary_key do
671-
keys [:first_name, :last_name]
672-
delimiter "~"
673-
end
672+
primary_key do
673+
keys [:first_name, :last_name]
674+
delimiter "~"
675+
end
674676
675677
```
676678

0 commit comments

Comments
 (0)