This is page 10 of 10. Use http://codebase.md/m-gonzalo/cosa-sai?lines=true&page={x} to view the full context.
# Directory Structure
```
├── .gitignore
├── bun.lock
├── Dockerfile
├── package.json
├── prompts
│ └── default.txt
├── README.md
├── smithery.yaml
├── src
│ ├── db.ts
│ ├── gemini.ts
│ ├── index.ts
│ ├── logger.ts
│ └── types.ts
├── test
│ ├── docs
│ │ ├── ash-docs
│ │ │ ├── ash_admin.md
│ │ │ ├── ash_appsignal.md
│ │ │ ├── ash_archival.md
│ │ │ ├── ash_authentication_phoenix.md
│ │ │ ├── ash_authentication.md
│ │ │ ├── ash_cloak.md
│ │ │ ├── ash_csv.md
│ │ │ ├── ash_cubdb.md
│ │ │ ├── ash_double_entry.md
│ │ │ ├── ash_graphql.md
│ │ │ ├── ash_json_api.md
│ │ │ ├── ash_money.md
│ │ │ ├── ash_oban.md
│ │ │ ├── ash_phoenix.md
│ │ │ ├── ash_postgres.md
│ │ │ ├── ash_rbac.md
│ │ │ ├── ash_sqlite.md
│ │ │ ├── ash_state_machine.md
│ │ │ └── ash.md
│ │ ├── bun-elysia-docs
│ │ │ ├── bun.sh.md
│ │ │ └── elysiajs.com.md
│ │ ├── javascript-docs
│ │ │ └── sample.md
│ │ └── phoenix-docs
│ │ └── phx-docs.md
│ └── prompts
│ ├── ash-framework.txt
│ ├── bun-elysia.txt
│ ├── javascript.txt
│ └── phoenix.txt
└── tsconfig.json
```
# Files
--------------------------------------------------------------------------------
/test/docs/ash-docs/ash_json_api.md:
--------------------------------------------------------------------------------
```markdown
1 | [](https://github.com/ash-project/ash_json_api)
2 |
3 | [ash\_json\_api](https://github.com/ash-project/ash_json_api)
4 |
5 | v1.4.16
6 |
7 | - Pages
8 | - Modules
9 | - Mix Tasks
10 |
11 | <!--THE END-->
12 |
13 | <!--THE END-->
14 |
15 | <!--THE END-->
16 |
17 | Search documentation of ash\_json\_api
18 |
19 | Settings
20 |
21 | # [View Source](https://github.com/ash-project/ash_json_api "View Source") API Reference ash\_json\_api v1.4.16
22 |
23 | ## [](api-reference.html#modules)Modules
24 |
25 | [AshJsonApi](AshJsonApi.html)
26 |
27 | Introspection functions for [`AshJsonApi`](AshJsonApi.html#content) domains.
28 |
29 | [AshJsonApi.Domain](AshJsonApi.Domain.html)
30 |
31 | The entrypoint for adding JSON:API behavior to an Ash domain
32 |
33 | [AshJsonApi.Domain.BaseRoute](AshJsonApi.Domain.BaseRoute.html)
34 |
35 | Introspection target for base routes in [`AshJsonApi.Domain`](AshJsonApi.Domain.html)
36 |
37 | [AshJsonApi.Domain.Info](AshJsonApi.Domain.Info.html)
38 |
39 | Introspection helpers for AshJsonApi.Domain
40 |
41 | [AshJsonApi.Domain.Verifiers.VerifyActions](AshJsonApi.Domain.Verifiers.VerifyActions.html)
42 |
43 | Verifies that all actions are valid for each route.
44 |
45 | [AshJsonApi.Domain.Verifiers.VerifyHasType](AshJsonApi.Domain.Verifiers.VerifyHasType.html)
46 |
47 | Verifies that a resource has a type if it has any routes that need it.
48 |
49 | [AshJsonApi.Domain.Verifiers.VerifyQueryParams](AshJsonApi.Domain.Verifiers.VerifyQueryParams.html)
50 |
51 | Verify query params are not reserved or shadowed by the route
52 |
53 | [AshJsonApi.Domain.Verifiers.VerifyRelationships](AshJsonApi.Domain.Verifiers.VerifyRelationships.html)
54 |
55 | Verifies that any routes that reference a relationship reference a public one
56 |
57 | [AshJsonApi.Error](AshJsonApi.Error.html)
58 |
59 | Represents an AshJsonApi Error
60 |
61 | [AshJsonApi.Error.InvalidBody](AshJsonApi.Error.InvalidBody.html)
62 |
63 | Returned when the request body provided is invalid
64 |
65 | [AshJsonApi.Error.InvalidField](AshJsonApi.Error.InvalidField.html)
66 |
67 | Returned when a field is requested that does not exist or is invalid
68 |
69 | [AshJsonApi.Error.InvalidHeader](AshJsonApi.Error.InvalidHeader.html)
70 |
71 | Returned when a header provided is invalid
72 |
73 | [AshJsonApi.Error.InvalidIncludes](AshJsonApi.Error.InvalidIncludes.html)
74 |
75 | Returned when the includes string provided in the query parameter `include` is invalid.
76 |
77 | [AshJsonApi.Error.InvalidPagination](AshJsonApi.Error.InvalidPagination.html)
78 |
79 | Returned when one of the nested parameters provided in the query parameter `page` is invalid
80 |
81 | [AshJsonApi.Error.InvalidQuery](AshJsonApi.Error.InvalidQuery.html)
82 |
83 | Returned when the query provided is invalid
84 |
85 | [AshJsonApi.Error.InvalidType](AshJsonApi.Error.InvalidType.html)
86 |
87 | Returned when a field is requested for a type that does not exist or is invalid
88 |
89 | [AshJsonApi.Error.NotFound](AshJsonApi.Error.NotFound.html)
90 |
91 | Returned when a record was explicitly requested, but could not be found.
92 |
93 | [AshJsonApi.Error.UnacceptableMediaType](AshJsonApi.Error.UnacceptableMediaType.html)
94 |
95 | Returned when the client does not provide (via the `Content-Type` header) the correct json API media type: application/vnd.api+json
96 |
97 | [AshJsonApi.Error.UnsupportedMediaType](AshJsonApi.Error.UnsupportedMediaType.html)
98 |
99 | Returned when the client does not accept (via the `Accept` header) the json API media type: application/vnd.api+json
100 |
101 | [AshJsonApi.Igniter](AshJsonApi.Igniter.html)
102 |
103 | Codemods and utilities for working with AshJsonApi & Igniter
104 |
105 | [AshJsonApi.OpenApi](AshJsonApi.OpenApi.html)
106 |
107 | Provides functions for generating schemas and operations for OpenApi definitions.
108 |
109 | [AshJsonApi.Plug.Parser](AshJsonApi.Plug.Parser.html)
110 |
111 | Extracts ash multipart request body.
112 |
113 | [AshJsonApi.Resource](AshJsonApi.Resource.html)
114 |
115 | The entrypoint for adding JSON:API behavior to a resource"
116 |
117 | [AshJsonApi.Resource.Info](AshJsonApi.Resource.Info.html)
118 |
119 | Introspection helpers for AshJsonApi.Resource
120 |
121 | [AshJsonApi.Resource.Route](AshJsonApi.Resource.Route.html)
122 |
123 | Represents a route for a resource
124 |
125 | [AshJsonApi.Resource.Verifiers.VerifyActions](AshJsonApi.Resource.Verifiers.VerifyActions.html)
126 |
127 | Verifies that all actions are valid for each route.
128 |
129 | [AshJsonApi.Resource.Verifiers.VerifyHasType](AshJsonApi.Resource.Verifiers.VerifyHasType.html)
130 |
131 | Verifies that a resource has a type if it has any routes that need it.
132 |
133 | [AshJsonApi.Resource.Verifiers.VerifyIncludes](AshJsonApi.Resource.Verifiers.VerifyIncludes.html)
134 |
135 | Verifies that all includes are valid public relationships
136 |
137 | [AshJsonApi.Resource.Verifiers.VerifyQueryParams](AshJsonApi.Resource.Verifiers.VerifyQueryParams.html)
138 |
139 | Verify query params are not reserved or shadowed by the route
140 |
141 | [AshJsonApi.Resource.Verifiers.VerifyRelationships](AshJsonApi.Resource.Verifiers.VerifyRelationships.html)
142 |
143 | Verifies that any routes that reference a relationship reference a public one
144 |
145 | [AshJsonApi.Router](AshJsonApi.Router.html)
146 |
147 | Use this module to create a router for your AshJsonApi.
148 |
149 | [AshJsonApi.Test](AshJsonApi.Test.html)
150 |
151 | Utilities for testing AshJsonApi.
152 |
153 | [AshJsonApi.ToJsonApiError](AshJsonApi.ToJsonApiError.html)
154 |
155 | A protocol for turning an Ash exception into an AshJsonApi.Error
156 |
157 | [AshJsonApi.Type](AshJsonApi.Type.html)
158 |
159 | The behaviour for customizing how a datatype is rendered and written in AshJsonApi.
160 |
161 | ## [](api-reference.html#mix-tasks)Mix Tasks
162 |
163 | [mix ash\_json\_api.install](Mix.Tasks.AshJsonApi.Install.html)
164 |
165 | Installs AshJsonApi. Should be run with `mix igniter.install ash_json_api`
166 |
167 | [Next Page → Home](readme.html)
168 |
169 | [Hex Package](https://hex.pm/packages/ash_json_api/1.4.16) [Hex Preview](https://preview.hex.pm/preview/ash_json_api/1.4.16) Search HexDocs [Download ePub version](ash_json_api.epub "ePub version")
170 |
171 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.31.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
172 | [](https://github.com/ash-project/ash_json_api)
173 |
174 | [ash\_json\_api](https://github.com/ash-project/ash_json_api)
175 |
176 | v1.4.16
177 |
178 | - Pages
179 | - Modules
180 | - Mix Tasks
181 |
182 | <!--THE END-->
183 |
184 | <!--THE END-->
185 |
186 | <!--THE END-->
187 |
188 | Search documentation of ash\_json\_api
189 |
190 | Settings
191 |
192 | # [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/domain/domain.ex#L61 "View Source") AshJsonApi.Domain.BaseRoute (ash\_json\_api v1.4.16)
193 |
194 | Introspection target for base routes in [`AshJsonApi.Domain`](AshJsonApi.Domain.html)
195 |
196 | [Hex Package](https://hex.pm/packages/ash_json_api/1.4.16) [Hex Preview](https://preview.hex.pm/preview/ash_json_api/1.4.16) Search HexDocs [Download ePub version](ash_json_api.epub "ePub version")
197 |
198 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.31.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
199 | [](https://github.com/ash-project/ash_json_api)
200 |
201 | [ash\_json\_api](https://github.com/ash-project/ash_json_api)
202 |
203 | v1.4.16
204 |
205 | - Pages
206 | - Modules
207 | - Mix Tasks
208 |
209 | <!--THE END-->
210 |
211 | <!--THE END-->
212 |
213 | <!--THE END-->
214 |
215 | Search documentation of ash\_json\_api
216 |
217 | Settings
218 |
219 | # [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/domain/domain.ex#L1 "View Source") AshJsonApi.Domain (ash\_json\_api v1.4.16)
220 |
221 | The entrypoint for adding JSON:API behavior to an Ash domain
222 |
223 | # [](AshJsonApi.Domain.html#summary)Summary
224 |
225 | ## [Functions](AshJsonApi.Domain.html#functions)
226 |
227 | [install(igniter, module, arg, path, argv)](AshJsonApi.Domain.html#install/5)
228 |
229 | [json\_api(body)](AshJsonApi.Domain.html#json_api/1)
230 |
231 | # [](AshJsonApi.Domain.html#functions)Functions
232 |
233 | [Link to this function](AshJsonApi.Domain.html#install/5 "Link to this function")
234 |
235 | # install(igniter, module, arg, path, argv)
236 |
237 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/domain/domain.ex#L189 "View Source")
238 |
239 | [Link to this macro](AshJsonApi.Domain.html#json_api/1 "Link to this macro")
240 |
241 | # json\_api(body)
242 |
243 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/domain/domain.ex#L182 "View Source") (macro)
244 |
245 | [Hex Package](https://hex.pm/packages/ash_json_api/1.4.16) [Hex Preview](https://preview.hex.pm/preview/ash_json_api/1.4.16) Search HexDocs [Download ePub version](ash_json_api.epub "ePub version")
246 |
247 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.31.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
248 | [](https://github.com/ash-project/ash_json_api)
249 |
250 | [ash\_json\_api](https://github.com/ash-project/ash_json_api)
251 |
252 | v1.4.16
253 |
254 | - Pages
255 | - Modules
256 | - Mix Tasks
257 |
258 | <!--THE END-->
259 |
260 | <!--THE END-->
261 |
262 | <!--THE END-->
263 |
264 | Search documentation of ash\_json\_api
265 |
266 | Settings
267 |
268 | # [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/domain/info.ex#L1 "View Source") AshJsonApi.Domain.Info (ash\_json\_api v1.4.16)
269 |
270 | Introspection helpers for AshJsonApi.Domain
271 |
272 | # [](AshJsonApi.Domain.Info.html#summary)Summary
273 |
274 | ## [Functions](AshJsonApi.Domain.Info.html#functions)
275 |
276 | [authorize?(domain)](AshJsonApi.Domain.Info.html#authorize?/1)
277 |
278 | [group\_by(domain)](AshJsonApi.Domain.Info.html#group_by/1)
279 |
280 | [include\_nil\_values?(domain)](AshJsonApi.Domain.Info.html#include_nil_values?/1)
281 |
282 | [log\_errors?(domain)](AshJsonApi.Domain.Info.html#log_errors?/1)
283 |
284 | [prefix(domain)](AshJsonApi.Domain.Info.html#prefix/1)
285 |
286 | [router(domain)](AshJsonApi.Domain.Info.html#router/1)
287 |
288 | [routes(domain)](AshJsonApi.Domain.Info.html#routes/1)
289 |
290 | [serve\_schema?(domain)](AshJsonApi.Domain.Info.html#serve_schema?/1)
291 |
292 | [show\_raised\_errors?(domain)](AshJsonApi.Domain.Info.html#show_raised_errors?/1)
293 |
294 | [tag(domain)](AshJsonApi.Domain.Info.html#tag/1)
295 |
296 | # [](AshJsonApi.Domain.Info.html#functions)Functions
297 |
298 | [Link to this function](AshJsonApi.Domain.Info.html#authorize?/1 "Link to this function")
299 |
300 | # authorize?(domain)
301 |
302 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/domain/info.ex#L29 "View Source")
303 |
304 | [Link to this function](AshJsonApi.Domain.Info.html#group_by/1 "Link to this function")
305 |
306 | # group\_by(domain)
307 |
308 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/domain/info.ex#L13 "View Source")
309 |
310 | [Link to this function](AshJsonApi.Domain.Info.html#include_nil_values?/1 "Link to this function")
311 |
312 | # include\_nil\_values?(domain)
313 |
314 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/domain/info.ex#L42 "View Source")
315 |
316 | [Link to this function](AshJsonApi.Domain.Info.html#log_errors?/1 "Link to this function")
317 |
318 | # log\_errors?(domain)
319 |
320 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/domain/info.ex#L33 "View Source")
321 |
322 | [Link to this function](AshJsonApi.Domain.Info.html#prefix/1 "Link to this function")
323 |
324 | # prefix(domain)
325 |
326 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/domain/info.ex#L17 "View Source")
327 |
328 | [Link to this function](AshJsonApi.Domain.Info.html#router/1 "Link to this function")
329 |
330 | # router(domain)
331 |
332 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/domain/info.ex#L37 "View Source")
333 |
334 | [Link to this function](AshJsonApi.Domain.Info.html#routes/1 "Link to this function")
335 |
336 | # routes(domain)
337 |
338 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/domain/info.ex#L25 "View Source")
339 |
340 | [Link to this function](AshJsonApi.Domain.Info.html#serve_schema?/1 "Link to this function")
341 |
342 | # serve\_schema?(domain)
343 |
344 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/domain/info.ex#L21 "View Source")
345 |
346 | [Link to this function](AshJsonApi.Domain.Info.html#show_raised_errors?/1 "Link to this function")
347 |
348 | # show\_raised\_errors?(domain)
349 |
350 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/domain/info.ex#L9 "View Source")
351 |
352 | [Link to this function](AshJsonApi.Domain.Info.html#tag/1 "Link to this function")
353 |
354 | # tag(domain)
355 |
356 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/domain/info.ex#L5 "View Source")
357 |
358 | [Hex Package](https://hex.pm/packages/ash_json_api/1.4.16) [Hex Preview](https://preview.hex.pm/preview/ash_json_api/1.4.16) Search HexDocs [Download ePub version](ash_json_api.epub "ePub version")
359 |
360 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.31.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
361 | [](https://github.com/ash-project/ash_json_api)
362 |
363 | [ash\_json\_api](https://github.com/ash-project/ash_json_api)
364 |
365 | v1.4.16
366 |
367 | - Pages
368 | - Modules
369 | - Mix Tasks
370 |
371 | <!--THE END-->
372 |
373 | <!--THE END-->
374 |
375 | <!--THE END-->
376 |
377 | Search documentation of ash\_json\_api
378 |
379 | Settings
380 |
381 | # [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/domain/verifiers/verify_actions.ex#L1 "View Source") AshJsonApi.Domain.Verifiers.VerifyActions (ash\_json\_api v1.4.16)
382 |
383 | Verifies that all actions are valid for each route.
384 |
385 | [Hex Package](https://hex.pm/packages/ash_json_api/1.4.16) [Hex Preview](https://preview.hex.pm/preview/ash_json_api/1.4.16) Search HexDocs [Download ePub version](ash_json_api.epub "ePub version")
386 |
387 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.31.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
388 | [](https://github.com/ash-project/ash_json_api)
389 |
390 | [ash\_json\_api](https://github.com/ash-project/ash_json_api)
391 |
392 | v1.4.16
393 |
394 | - Pages
395 | - Modules
396 | - Mix Tasks
397 |
398 | <!--THE END-->
399 |
400 | <!--THE END-->
401 |
402 | <!--THE END-->
403 |
404 | Search documentation of ash\_json\_api
405 |
406 | Settings
407 |
408 | # [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/domain/verifiers/verify_has_type.ex#L1 "View Source") AshJsonApi.Domain.Verifiers.VerifyHasType (ash\_json\_api v1.4.16)
409 |
410 | Verifies that a resource has a type if it has any routes that need it.
411 |
412 | [Hex Package](https://hex.pm/packages/ash_json_api/1.4.16) [Hex Preview](https://preview.hex.pm/preview/ash_json_api/1.4.16) Search HexDocs [Download ePub version](ash_json_api.epub "ePub version")
413 |
414 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.31.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
415 | [](https://github.com/ash-project/ash_json_api)
416 |
417 | [ash\_json\_api](https://github.com/ash-project/ash_json_api)
418 |
419 | v1.4.16
420 |
421 | - Pages
422 | - Modules
423 | - Mix Tasks
424 |
425 | <!--THE END-->
426 |
427 | <!--THE END-->
428 |
429 | <!--THE END-->
430 |
431 | Search documentation of ash\_json\_api
432 |
433 | Settings
434 |
435 | # [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/domain/verifiers/verify_query_params.ex#L1 "View Source") AshJsonApi.Domain.Verifiers.VerifyQueryParams (ash\_json\_api v1.4.16)
436 |
437 | Verify query params are not reserved or shadowed by the route
438 |
439 | [Hex Package](https://hex.pm/packages/ash_json_api/1.4.16) [Hex Preview](https://preview.hex.pm/preview/ash_json_api/1.4.16) Search HexDocs [Download ePub version](ash_json_api.epub "ePub version")
440 |
441 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.31.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
442 | [](https://github.com/ash-project/ash_json_api)
443 |
444 | [ash\_json\_api](https://github.com/ash-project/ash_json_api)
445 |
446 | v1.4.16
447 |
448 | - Pages
449 | - Modules
450 | - Mix Tasks
451 |
452 | <!--THE END-->
453 |
454 | <!--THE END-->
455 |
456 | <!--THE END-->
457 |
458 | Search documentation of ash\_json\_api
459 |
460 | Settings
461 |
462 | # [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/domain/verifiers/verify_relationships.ex#L1 "View Source") AshJsonApi.Domain.Verifiers.VerifyRelationships (ash\_json\_api v1.4.16)
463 |
464 | Verifies that any routes that reference a relationship reference a public one
465 |
466 | # [](AshJsonApi.Domain.Verifiers.VerifyRelationships.html#summary)Summary
467 |
468 | ## [Functions](AshJsonApi.Domain.Verifiers.VerifyRelationships.html#functions)
469 |
470 | [verify(dsl)](AshJsonApi.Domain.Verifiers.VerifyRelationships.html#verify/1)
471 |
472 | Callback implementation for [`Spark.Dsl.Verifier.verify/1`](../spark/2.2.36/Spark.Dsl.Verifier.html#c:verify/1).
473 |
474 | # [](AshJsonApi.Domain.Verifiers.VerifyRelationships.html#functions)Functions
475 |
476 | [Link to this function](AshJsonApi.Domain.Verifiers.VerifyRelationships.html#verify/1 "Link to this function")
477 |
478 | # verify(dsl)
479 |
480 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/domain/verifiers/verify_relationships.ex#L5 "View Source")
481 |
482 | Callback implementation for [`Spark.Dsl.Verifier.verify/1`](../spark/2.2.36/Spark.Dsl.Verifier.html#c:verify/1).
483 |
484 | [Hex Package](https://hex.pm/packages/ash_json_api/1.4.16) [Hex Preview](https://preview.hex.pm/preview/ash_json_api/1.4.16) Search HexDocs [Download ePub version](ash_json_api.epub "ePub version")
485 |
486 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.31.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
487 | [](https://github.com/ash-project/ash_json_api)
488 |
489 | [ash\_json\_api](https://github.com/ash-project/ash_json_api)
490 |
491 | v1.4.16
492 |
493 | - Pages
494 | - Modules
495 | - Mix Tasks
496 |
497 | <!--THE END-->
498 |
499 | <!--THE END-->
500 |
501 | <!--THE END-->
502 |
503 | Search documentation of ash\_json\_api
504 |
505 | Settings
506 |
507 | # [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/error/error.ex#L1 "View Source") AshJsonApi.Error (ash\_json\_api v1.4.16)
508 |
509 | Represents an AshJsonApi Error
510 |
511 | # [](AshJsonApi.Error.html#summary)Summary
512 |
513 | ## [Types](AshJsonApi.Error.html#types)
514 |
515 | [t()](AshJsonApi.Error.html#t:t/0)
516 |
517 | ## [Functions](AshJsonApi.Error.html#functions)
518 |
519 | [class\_to\_status(arg1)](AshJsonApi.Error.html#class_to_status/1)
520 |
521 | Turns an error class into an HTTP status code
522 |
523 | [format\_log(error)](AshJsonApi.Error.html#format_log/1)
524 |
525 | [new(opts)](AshJsonApi.Error.html#new/1)
526 |
527 | [to\_json\_api\_errors(domain, resource, errors, type)](AshJsonApi.Error.html#to_json_api_errors/4)
528 |
529 | [with\_source\_pointer(built\_error, arg2, resource, type)](AshJsonApi.Error.html#with_source_pointer/4)
530 |
531 | # [](AshJsonApi.Error.html#types)Types
532 |
533 | [Link to this type](AshJsonApi.Error.html#t:t/0 "Link to this type")
534 |
535 | # t()
536 |
537 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/error/error.ex#L15 "View Source")
538 |
539 | ```
540 | @type t() :: %AshJsonApi.Error{
541 | about: term(),
542 | code: term(),
543 | detail: term(),
544 | id: term(),
545 | internal_description: term(),
546 | log_level: term(),
547 | meta: term(),
548 | source_parameter: term(),
549 | source_pointer: term(),
550 | status_code: term(),
551 | title: term()
552 | }
553 | ```
554 |
555 | # [](AshJsonApi.Error.html#functions)Functions
556 |
557 | [Link to this function](AshJsonApi.Error.html#class_to_status/1 "Link to this function")
558 |
559 | # class\_to\_status(arg1)
560 |
561 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/error/error.ex#L124 "View Source")
562 |
563 | Turns an error class into an HTTP status code
564 |
565 | [Link to this function](AshJsonApi.Error.html#format_log/1 "Link to this function")
566 |
567 | # format\_log(error)
568 |
569 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/error/error.ex#L132 "View Source")
570 |
571 | [Link to this function](AshJsonApi.Error.html#new/1 "Link to this function")
572 |
573 | # new(opts)
574 |
575 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/error/error.ex#L128 "View Source")
576 |
577 | [Link to this function](AshJsonApi.Error.html#to_json_api_errors/4 "Link to this function")
578 |
579 | # to\_json\_api\_errors(domain, resource, errors, type)
580 |
581 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/error/error.ex#L21 "View Source")
582 |
583 | [Link to this function](AshJsonApi.Error.html#with_source_pointer/4 "Link to this function")
584 |
585 | # with\_source\_pointer(built\_error, arg2, resource, type)
586 |
587 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/error/error.ex#L166 "View Source")
588 |
589 | [Hex Package](https://hex.pm/packages/ash_json_api/1.4.16) [Hex Preview](https://preview.hex.pm/preview/ash_json_api/1.4.16) Search HexDocs [Download ePub version](ash_json_api.epub "ePub version")
590 |
591 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.31.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
592 | [](https://github.com/ash-project/ash_json_api)
593 |
594 | [ash\_json\_api](https://github.com/ash-project/ash_json_api)
595 |
596 | v1.4.16
597 |
598 | - Pages
599 | - Modules
600 | - Mix Tasks
601 |
602 | <!--THE END-->
603 |
604 | <!--THE END-->
605 |
606 | <!--THE END-->
607 |
608 | Search documentation of ash\_json\_api
609 |
610 | Settings
611 |
612 | # [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/error/invalid_body.ex#L1 "View Source") AshJsonApi.Error.InvalidBody exception (ash\_json\_api v1.4.16)
613 |
614 | Returned when the request body provided is invalid
615 |
616 | # [](AshJsonApi.Error.InvalidBody.html#summary)Summary
617 |
618 | ## [Functions](AshJsonApi.Error.InvalidBody.html#functions)
619 |
620 | [exception()](AshJsonApi.Error.InvalidBody.html#exception/0)
621 |
622 | # [](AshJsonApi.Error.InvalidBody.html#functions)Functions
623 |
624 | [Link to this function](AshJsonApi.Error.InvalidBody.html#exception/0 "Link to this function")
625 |
626 | # exception()
627 |
628 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/error/invalid_body.ex#L6 "View Source")
629 |
630 | [Hex Package](https://hex.pm/packages/ash_json_api/1.4.16) [Hex Preview](https://preview.hex.pm/preview/ash_json_api/1.4.16) Search HexDocs [Download ePub version](ash_json_api.epub "ePub version")
631 |
632 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.31.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
633 | [](https://github.com/ash-project/ash_json_api)
634 |
635 | [ash\_json\_api](https://github.com/ash-project/ash_json_api)
636 |
637 | v1.4.16
638 |
639 | - Pages
640 | - Modules
641 | - Mix Tasks
642 |
643 | <!--THE END-->
644 |
645 | <!--THE END-->
646 |
647 | <!--THE END-->
648 |
649 | Search documentation of ash\_json\_api
650 |
651 | Settings
652 |
653 | # [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/error/invalid_field.ex#L1 "View Source") AshJsonApi.Error.InvalidField exception (ash\_json\_api v1.4.16)
654 |
655 | Returned when a field is requested that does not exist or is invalid
656 |
657 | # [](AshJsonApi.Error.InvalidField.html#summary)Summary
658 |
659 | ## [Functions](AshJsonApi.Error.InvalidField.html#functions)
660 |
661 | [exception()](AshJsonApi.Error.InvalidField.html#exception/0)
662 |
663 | # [](AshJsonApi.Error.InvalidField.html#functions)Functions
664 |
665 | [Link to this function](AshJsonApi.Error.InvalidField.html#exception/0 "Link to this function")
666 |
667 | # exception()
668 |
669 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/error/invalid_field.ex#L6 "View Source")
670 |
671 | [Hex Package](https://hex.pm/packages/ash_json_api/1.4.16) [Hex Preview](https://preview.hex.pm/preview/ash_json_api/1.4.16) Search HexDocs [Download ePub version](ash_json_api.epub "ePub version")
672 |
673 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.31.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
674 | [](https://github.com/ash-project/ash_json_api)
675 |
676 | [ash\_json\_api](https://github.com/ash-project/ash_json_api)
677 |
678 | v1.4.16
679 |
680 | - Pages
681 | - Modules
682 | - Mix Tasks
683 |
684 | <!--THE END-->
685 |
686 | <!--THE END-->
687 |
688 | <!--THE END-->
689 |
690 | Search documentation of ash\_json\_api
691 |
692 | Settings
693 |
694 | # [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/error/invalid_header.ex#L1 "View Source") AshJsonApi.Error.InvalidHeader exception (ash\_json\_api v1.4.16)
695 |
696 | Returned when a header provided is invalid
697 |
698 | # [](AshJsonApi.Error.InvalidHeader.html#summary)Summary
699 |
700 | ## [Functions](AshJsonApi.Error.InvalidHeader.html#functions)
701 |
702 | [exception()](AshJsonApi.Error.InvalidHeader.html#exception/0)
703 |
704 | # [](AshJsonApi.Error.InvalidHeader.html#functions)Functions
705 |
706 | [Link to this function](AshJsonApi.Error.InvalidHeader.html#exception/0 "Link to this function")
707 |
708 | # exception()
709 |
710 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/error/invalid_header.ex#L6 "View Source")
711 |
712 | [Hex Package](https://hex.pm/packages/ash_json_api/1.4.16) [Hex Preview](https://preview.hex.pm/preview/ash_json_api/1.4.16) Search HexDocs [Download ePub version](ash_json_api.epub "ePub version")
713 |
714 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.31.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
715 | [](https://github.com/ash-project/ash_json_api)
716 |
717 | [ash\_json\_api](https://github.com/ash-project/ash_json_api)
718 |
719 | v1.4.16
720 |
721 | - Pages
722 | - Modules
723 | - Mix Tasks
724 |
725 | <!--THE END-->
726 |
727 | <!--THE END-->
728 |
729 | <!--THE END-->
730 |
731 | Search documentation of ash\_json\_api
732 |
733 | Settings
734 |
735 | # [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/error/invalid_includes.ex#L1 "View Source") AshJsonApi.Error.InvalidIncludes exception (ash\_json\_api v1.4.16)
736 |
737 | Returned when the includes string provided in the query parameter `include` is invalid.
738 |
739 | # [](AshJsonApi.Error.InvalidIncludes.html#summary)Summary
740 |
741 | ## [Types](AshJsonApi.Error.InvalidIncludes.html#types)
742 |
743 | [t()](AshJsonApi.Error.InvalidIncludes.html#t:t/0)
744 |
745 | ## [Functions](AshJsonApi.Error.InvalidIncludes.html#functions)
746 |
747 | [exception()](AshJsonApi.Error.InvalidIncludes.html#exception/0)
748 |
749 | # [](AshJsonApi.Error.InvalidIncludes.html#types)Types
750 |
751 | [Link to this type](AshJsonApi.Error.InvalidIncludes.html#t:t/0 "Link to this type")
752 |
753 | # t()
754 |
755 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/error/invalid_includes.ex#L8 "View Source")
756 |
757 | ```
758 | @type t() :: %AshJsonApi.Error.InvalidIncludes{
759 | __exception__: true,
760 | bread_crumbs: term(),
761 | class: term(),
762 | includes: term(),
763 | path: term(),
764 | splode: term(),
765 | stacktrace: term(),
766 | vars: term()
767 | }
768 | ```
769 |
770 | # [](AshJsonApi.Error.InvalidIncludes.html#functions)Functions
771 |
772 | [Link to this function](AshJsonApi.Error.InvalidIncludes.html#exception/0 "Link to this function")
773 |
774 | # exception()
775 |
776 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/error/invalid_includes.ex#L6 "View Source")
777 |
778 | [Hex Package](https://hex.pm/packages/ash_json_api/1.4.16) [Hex Preview](https://preview.hex.pm/preview/ash_json_api/1.4.16) Search HexDocs [Download ePub version](ash_json_api.epub "ePub version")
779 |
780 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.31.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
781 | [](https://github.com/ash-project/ash_json_api)
782 |
783 | [ash\_json\_api](https://github.com/ash-project/ash_json_api)
784 |
785 | v1.4.16
786 |
787 | - Pages
788 | - Modules
789 | - Mix Tasks
790 |
791 | <!--THE END-->
792 |
793 | <!--THE END-->
794 |
795 | <!--THE END-->
796 |
797 | Search documentation of ash\_json\_api
798 |
799 | Settings
800 |
801 | # [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/error/invalid_pagination.ex#L1 "View Source") AshJsonApi.Error.InvalidPagination exception (ash\_json\_api v1.4.16)
802 |
803 | Returned when one of the nested parameters provided in the query parameter `page` is invalid
804 |
805 | # [](AshJsonApi.Error.InvalidPagination.html#summary)Summary
806 |
807 | ## [Functions](AshJsonApi.Error.InvalidPagination.html#functions)
808 |
809 | [exception()](AshJsonApi.Error.InvalidPagination.html#exception/0)
810 |
811 | # [](AshJsonApi.Error.InvalidPagination.html#functions)Functions
812 |
813 | [Link to this function](AshJsonApi.Error.InvalidPagination.html#exception/0 "Link to this function")
814 |
815 | # exception()
816 |
817 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/error/invalid_pagination.ex#L6 "View Source")
818 |
819 | [Hex Package](https://hex.pm/packages/ash_json_api/1.4.16) [Hex Preview](https://preview.hex.pm/preview/ash_json_api/1.4.16) Search HexDocs [Download ePub version](ash_json_api.epub "ePub version")
820 |
821 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.31.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
822 | [](https://github.com/ash-project/ash_json_api)
823 |
824 | [ash\_json\_api](https://github.com/ash-project/ash_json_api)
825 |
826 | v1.4.16
827 |
828 | - Pages
829 | - Modules
830 | - Mix Tasks
831 |
832 | <!--THE END-->
833 |
834 | <!--THE END-->
835 |
836 | <!--THE END-->
837 |
838 | Search documentation of ash\_json\_api
839 |
840 | Settings
841 |
842 | # [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/error/invalid_query.ex#L1 "View Source") AshJsonApi.Error.InvalidQuery exception (ash\_json\_api v1.4.16)
843 |
844 | Returned when the query provided is invalid
845 |
846 | # [](AshJsonApi.Error.InvalidQuery.html#summary)Summary
847 |
848 | ## [Functions](AshJsonApi.Error.InvalidQuery.html#functions)
849 |
850 | [exception()](AshJsonApi.Error.InvalidQuery.html#exception/0)
851 |
852 | # [](AshJsonApi.Error.InvalidQuery.html#functions)Functions
853 |
854 | [Link to this function](AshJsonApi.Error.InvalidQuery.html#exception/0 "Link to this function")
855 |
856 | # exception()
857 |
858 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/error/invalid_query.ex#L5 "View Source")
859 |
860 | [Hex Package](https://hex.pm/packages/ash_json_api/1.4.16) [Hex Preview](https://preview.hex.pm/preview/ash_json_api/1.4.16) Search HexDocs [Download ePub version](ash_json_api.epub "ePub version")
861 |
862 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.31.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
863 | [](https://github.com/ash-project/ash_json_api)
864 |
865 | [ash\_json\_api](https://github.com/ash-project/ash_json_api)
866 |
867 | v1.4.16
868 |
869 | - Pages
870 | - Modules
871 | - Mix Tasks
872 |
873 | <!--THE END-->
874 |
875 | <!--THE END-->
876 |
877 | <!--THE END-->
878 |
879 | Search documentation of ash\_json\_api
880 |
881 | Settings
882 |
883 | # [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/error/invalid_type.ex#L1 "View Source") AshJsonApi.Error.InvalidType exception (ash\_json\_api v1.4.16)
884 |
885 | Returned when a field is requested for a type that does not exist or is invalid
886 |
887 | # [](AshJsonApi.Error.InvalidType.html#summary)Summary
888 |
889 | ## [Functions](AshJsonApi.Error.InvalidType.html#functions)
890 |
891 | [exception()](AshJsonApi.Error.InvalidType.html#exception/0)
892 |
893 | # [](AshJsonApi.Error.InvalidType.html#functions)Functions
894 |
895 | [Link to this function](AshJsonApi.Error.InvalidType.html#exception/0 "Link to this function")
896 |
897 | # exception()
898 |
899 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/error/invalid_type.ex#L5 "View Source")
900 |
901 | [Hex Package](https://hex.pm/packages/ash_json_api/1.4.16) [Hex Preview](https://preview.hex.pm/preview/ash_json_api/1.4.16) Search HexDocs [Download ePub version](ash_json_api.epub "ePub version")
902 |
903 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.31.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
904 | [](https://github.com/ash-project/ash_json_api)
905 |
906 | [ash\_json\_api](https://github.com/ash-project/ash_json_api)
907 |
908 | v1.4.16
909 |
910 | - Pages
911 | - Modules
912 | - Mix Tasks
913 |
914 | <!--THE END-->
915 |
916 | <!--THE END-->
917 |
918 | <!--THE END-->
919 |
920 | Search documentation of ash\_json\_api
921 |
922 | Settings
923 |
924 | # [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/error/not_found.ex#L1 "View Source") AshJsonApi.Error.NotFound exception (ash\_json\_api v1.4.16)
925 |
926 | Returned when a record was explicitly requested, but could not be found.
927 |
928 | # [](AshJsonApi.Error.NotFound.html#summary)Summary
929 |
930 | ## [Functions](AshJsonApi.Error.NotFound.html#functions)
931 |
932 | [exception()](AshJsonApi.Error.NotFound.html#exception/0)
933 |
934 | # [](AshJsonApi.Error.NotFound.html#functions)Functions
935 |
936 | [Link to this function](AshJsonApi.Error.NotFound.html#exception/0 "Link to this function")
937 |
938 | # exception()
939 |
940 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/error/not_found.ex#L6 "View Source")
941 |
942 | [Hex Package](https://hex.pm/packages/ash_json_api/1.4.16) [Hex Preview](https://preview.hex.pm/preview/ash_json_api/1.4.16) Search HexDocs [Download ePub version](ash_json_api.epub "ePub version")
943 |
944 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.31.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
945 | [](https://github.com/ash-project/ash_json_api)
946 |
947 | [ash\_json\_api](https://github.com/ash-project/ash_json_api)
948 |
949 | v1.4.16
950 |
951 | - Pages
952 | - Modules
953 | - Mix Tasks
954 |
955 | <!--THE END-->
956 |
957 | <!--THE END-->
958 |
959 | <!--THE END-->
960 |
961 | Search documentation of ash\_json\_api
962 |
963 | Settings
964 |
965 | # [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/error/unacceptable_media_type.ex#L1 "View Source") AshJsonApi.Error.UnacceptableMediaType exception (ash\_json\_api v1.4.16)
966 |
967 | Returned when the client does not provide (via the `Content-Type` header) the correct json API media type: application/vnd.api+json
968 |
969 | # [](AshJsonApi.Error.UnacceptableMediaType.html#summary)Summary
970 |
971 | ## [Functions](AshJsonApi.Error.UnacceptableMediaType.html#functions)
972 |
973 | [exception()](AshJsonApi.Error.UnacceptableMediaType.html#exception/0)
974 |
975 | # [](AshJsonApi.Error.UnacceptableMediaType.html#functions)Functions
976 |
977 | [Link to this function](AshJsonApi.Error.UnacceptableMediaType.html#exception/0 "Link to this function")
978 |
979 | # exception()
980 |
981 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/error/unacceptable_media_type.ex#L5 "View Source")
982 |
983 | [Hex Package](https://hex.pm/packages/ash_json_api/1.4.16) [Hex Preview](https://preview.hex.pm/preview/ash_json_api/1.4.16) Search HexDocs [Download ePub version](ash_json_api.epub "ePub version")
984 |
985 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.31.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
986 | [](https://github.com/ash-project/ash_json_api)
987 |
988 | [ash\_json\_api](https://github.com/ash-project/ash_json_api)
989 |
990 | v1.4.16
991 |
992 | - Pages
993 | - Modules
994 | - Mix Tasks
995 |
996 | <!--THE END-->
997 |
998 | <!--THE END-->
999 |
1000 | <!--THE END-->
1001 |
1002 | Search documentation of ash\_json\_api
1003 |
1004 | Settings
1005 |
1006 | # [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/error/unsupported_media_type.ex#L1 "View Source") AshJsonApi.Error.UnsupportedMediaType exception (ash\_json\_api v1.4.16)
1007 |
1008 | Returned when the client does not accept (via the `Accept` header) the json API media type: application/vnd.api+json
1009 |
1010 | # [](AshJsonApi.Error.UnsupportedMediaType.html#summary)Summary
1011 |
1012 | ## [Functions](AshJsonApi.Error.UnsupportedMediaType.html#functions)
1013 |
1014 | [exception()](AshJsonApi.Error.UnsupportedMediaType.html#exception/0)
1015 |
1016 | # [](AshJsonApi.Error.UnsupportedMediaType.html#functions)Functions
1017 |
1018 | [Link to this function](AshJsonApi.Error.UnsupportedMediaType.html#exception/0 "Link to this function")
1019 |
1020 | # exception()
1021 |
1022 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/error/unsupported_media_type.ex#L5 "View Source")
1023 |
1024 | [Hex Package](https://hex.pm/packages/ash_json_api/1.4.16) [Hex Preview](https://preview.hex.pm/preview/ash_json_api/1.4.16) Search HexDocs [Download ePub version](ash_json_api.epub "ePub version")
1025 |
1026 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.31.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
1027 | [](https://github.com/ash-project/ash_json_api)
1028 |
1029 | [ash\_json\_api](https://github.com/ash-project/ash_json_api)
1030 |
1031 | v1.4.16
1032 |
1033 | - Pages
1034 | - Modules
1035 | - Mix Tasks
1036 |
1037 | <!--THE END-->
1038 |
1039 | <!--THE END-->
1040 |
1041 | <!--THE END-->
1042 |
1043 | Search documentation of ash\_json\_api
1044 |
1045 | Settings
1046 |
1047 | # [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api.ex#L1 "View Source") AshJsonApi (ash\_json\_api v1.4.16)
1048 |
1049 | Introspection functions for [`AshJsonApi`](AshJsonApi.html#content) domains.
1050 |
1051 | For domain DSL documentation, see [`AshJsonApi.Domain`](AshJsonApi.Domain.html).
1052 |
1053 | For Resource DSL documentation, see [`AshJsonApi.Resource`](AshJsonApi.Resource.html)
1054 |
1055 | To get started, see the [getting started guide](getting-started-with-ash-json-api.html)
1056 |
1057 | # [](AshJsonApi.html#summary)Summary
1058 |
1059 | ## [Functions](AshJsonApi.html#functions)
1060 |
1061 | [authorize?(domain)](AshJsonApi.html#authorize?/1) deprecated
1062 |
1063 | See [`AshJsonApi.Domain.Info.authorize?/1`](AshJsonApi.Domain.Info.html#authorize?/1).
1064 |
1065 | [log\_errors?(domain)](AshJsonApi.html#log_errors?/1) deprecated
1066 |
1067 | See [`AshJsonApi.Domain.Info.log_errors?/1`](AshJsonApi.Domain.Info.html#log_errors?/1).
1068 |
1069 | [prefix(domain)](AshJsonApi.html#prefix/1) deprecated
1070 |
1071 | See [`AshJsonApi.Domain.Info.prefix/1`](AshJsonApi.Domain.Info.html#prefix/1).
1072 |
1073 | [router(domain)](AshJsonApi.html#router/1) deprecated
1074 |
1075 | See [`AshJsonApi.Domain.Info.router/1`](AshJsonApi.Domain.Info.html#router/1).
1076 |
1077 | [serve\_schema?(domain)](AshJsonApi.html#serve_schema?/1) deprecated
1078 |
1079 | See [`AshJsonApi.Domain.Info.serve_schema?/1`](AshJsonApi.Domain.Info.html#serve_schema?/1).
1080 |
1081 | # [](AshJsonApi.html#functions)Functions
1082 |
1083 | [Link to this function](AshJsonApi.html#authorize?/1 "Link to this function")
1084 |
1085 | # authorize?(domain)
1086 |
1087 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api.ex#L19 "View Source")
1088 |
1089 | This function is deprecated. See \`AshJsonApi.Domain.Info.authorize?/1\`.
1090 |
1091 | See [`AshJsonApi.Domain.Info.authorize?/1`](AshJsonApi.Domain.Info.html#authorize?/1).
1092 |
1093 | [Link to this function](AshJsonApi.html#log_errors?/1 "Link to this function")
1094 |
1095 | # log\_errors?(domain)
1096 |
1097 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api.ex#L22 "View Source")
1098 |
1099 | This function is deprecated. See \`AshJsonApi.Domain.Info.log\_errors?/1\`.
1100 |
1101 | See [`AshJsonApi.Domain.Info.log_errors?/1`](AshJsonApi.Domain.Info.html#log_errors?/1).
1102 |
1103 | [Link to this function](AshJsonApi.html#prefix/1 "Link to this function")
1104 |
1105 | # prefix(domain)
1106 |
1107 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api.ex#L13 "View Source")
1108 |
1109 | This function is deprecated. See \`AshJsonApi.Domain.Info.prefix/1\`.
1110 |
1111 | See [`AshJsonApi.Domain.Info.prefix/1`](AshJsonApi.Domain.Info.html#prefix/1).
1112 |
1113 | [Link to this function](AshJsonApi.html#router/1 "Link to this function")
1114 |
1115 | # router(domain)
1116 |
1117 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api.ex#L25 "View Source")
1118 |
1119 | This function is deprecated. See \`AshJsonApi.Domain.Info.router/1\`.
1120 |
1121 | See [`AshJsonApi.Domain.Info.router/1`](AshJsonApi.Domain.Info.html#router/1).
1122 |
1123 | [Link to this function](AshJsonApi.html#serve_schema?/1 "Link to this function")
1124 |
1125 | # serve\_schema?(domain)
1126 |
1127 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api.ex#L16 "View Source")
1128 |
1129 | This function is deprecated. See \`AshJsonApi.Domain.Info.serve\_schema?/1\`.
1130 |
1131 | See [`AshJsonApi.Domain.Info.serve_schema?/1`](AshJsonApi.Domain.Info.html#serve_schema?/1).
1132 |
1133 | [Hex Package](https://hex.pm/packages/ash_json_api/1.4.16) [Hex Preview](https://preview.hex.pm/preview/ash_json_api/1.4.16) Search HexDocs [Download ePub version](ash_json_api.epub "ePub version")
1134 |
1135 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.31.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
1136 | [](https://github.com/ash-project/ash_json_api)
1137 |
1138 | [ash\_json\_api](https://github.com/ash-project/ash_json_api)
1139 |
1140 | v1.4.16
1141 |
1142 | - Pages
1143 | - Modules
1144 | - Mix Tasks
1145 |
1146 | <!--THE END-->
1147 |
1148 | <!--THE END-->
1149 |
1150 | <!--THE END-->
1151 |
1152 | Search documentation of ash\_json\_api
1153 |
1154 | Settings
1155 |
1156 | # [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/igniter.ex#L2 "View Source") AshJsonApi.Igniter (ash\_json\_api v1.4.16)
1157 |
1158 | Codemods and utilities for working with AshJsonApi & Igniter
1159 |
1160 | # [](AshJsonApi.Igniter.html#summary)Summary
1161 |
1162 | ## [Functions](AshJsonApi.Igniter.html#functions)
1163 |
1164 | [ash\_json\_api\_routers(igniter)](AshJsonApi.Igniter.html#ash_json_api_routers/1)
1165 |
1166 | Returns all modules that `use AshJsonApi.Router`
1167 |
1168 | [find\_ash\_json\_api\_router(igniter, domain)](AshJsonApi.Igniter.html#find_ash_json_api_router/2)
1169 |
1170 | Returns the AshJsonApi router containing the domain in question, or a list of all AshJsonApi schemas
1171 |
1172 | [setup\_ash\_json\_api\_router(igniter, ash\_phoenix\_router\_name \\\\ nil)](AshJsonApi.Igniter.html#setup_ash_json_api_router/2)
1173 |
1174 | Sets up an [`AshJsonApi.Router`](AshJsonApi.Router.html) for AshJsonApi
1175 |
1176 | [setup\_phoenix(igniter, ash\_phoenix\_router\_name \\\\ nil)](AshJsonApi.Igniter.html#setup_phoenix/2)
1177 |
1178 | Sets up the phoenix module for AshJsonApi
1179 |
1180 | # [](AshJsonApi.Igniter.html#functions)Functions
1181 |
1182 | [Link to this function](AshJsonApi.Igniter.html#ash_json_api_routers/1 "Link to this function")
1183 |
1184 | # ash\_json\_api\_routers(igniter)
1185 |
1186 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/igniter.ex#L225 "View Source")
1187 |
1188 | Returns all modules that `use AshJsonApi.Router`
1189 |
1190 | [Link to this function](AshJsonApi.Igniter.html#find_ash_json_api_router/2 "Link to this function")
1191 |
1192 | # find\_ash\_json\_api\_router(igniter, domain)
1193 |
1194 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/igniter.ex#L6 "View Source")
1195 |
1196 | Returns the AshJsonApi router containing the domain in question, or a list of all AshJsonApi schemas
1197 |
1198 | [Link to this function](AshJsonApi.Igniter.html#setup_ash_json_api_router/2 "Link to this function")
1199 |
1200 | # setup\_ash\_json\_api\_router(igniter, ash\_phoenix\_router\_name \\\\ nil)
1201 |
1202 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/igniter.ex#L37 "View Source")
1203 |
1204 | Sets up an [`AshJsonApi.Router`](AshJsonApi.Router.html) for AshJsonApi
1205 |
1206 | [Link to this function](AshJsonApi.Igniter.html#setup_phoenix/2 "Link to this function")
1207 |
1208 | # setup\_phoenix(igniter, ash\_phoenix\_router\_name \\\\ nil)
1209 |
1210 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/igniter.ex#L79 "View Source")
1211 |
1212 | Sets up the phoenix module for AshJsonApi
1213 |
1214 | [Hex Package](https://hex.pm/packages/ash_json_api/1.4.16) [Hex Preview](https://preview.hex.pm/preview/ash_json_api/1.4.16) Search HexDocs [Download ePub version](ash_json_api.epub "ePub version")
1215 |
1216 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.31.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
1217 | [](https://github.com/ash-project/ash_json_api)
1218 |
1219 | [ash\_json\_api](https://github.com/ash-project/ash_json_api)
1220 |
1221 | v1.4.16
1222 |
1223 | - Pages
1224 | - Modules
1225 | - Mix Tasks
1226 |
1227 | <!--THE END-->
1228 |
1229 | <!--THE END-->
1230 |
1231 | <!--THE END-->
1232 |
1233 | Search documentation of ash\_json\_api
1234 |
1235 | Settings
1236 |
1237 | # [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/json_schema/open_api.ex#L2 "View Source") AshJsonApi.OpenApi (ash\_json\_api v1.4.16)
1238 |
1239 | Provides functions for generating schemas and operations for OpenApi definitions.
1240 |
1241 | Add `open_api_spex` to your `mix.exs` deps for the required struct definitions.
1242 |
1243 | ## [](AshJsonApi.OpenApi.html#module-example)Example
1244 |
1245 | ```
1246 | defmodule MyApp.OpenApi do
1247 | alias OpenApiSpex.{OpenApi, Info, Server, Components}
1248 |
1249 | def spec do
1250 | %OpenApi{
1251 | info: %Info{
1252 | title: "MyApp JSON API",
1253 | version: "1.1"
1254 | },
1255 | servers: [
1256 | Server.from_endpoint(MyAppWeb.Endpoint)
1257 | ],
1258 | paths: AshJsonApi.OpenApi.paths(MyApp.Api),
1259 | tags: AshJsonApi.OpenApi.tags(MyApp.Api),
1260 | components: %Components{
1261 | responses: AshJsonApi.OpenApi.responses(),
1262 | schemas: AshJsonApi.OpenApi.schemas(MyApp.Api)
1263 | }
1264 | }
1265 | end
1266 | end
1267 | ```
1268 |
1269 | # [](AshJsonApi.OpenApi.html#summary)Summary
1270 |
1271 | ## [Functions](AshJsonApi.OpenApi.html#functions)
1272 |
1273 | [define\_filter?(domains, resource)](AshJsonApi.OpenApi.html#define_filter?/2)
1274 |
1275 | [paths(domains, all\_domains, opts)](AshJsonApi.OpenApi.html#paths/3)
1276 |
1277 | Paths (routes) from the domain.
1278 |
1279 | [raw\_filter\_type(attribute\_or\_aggregate, resource)](AshJsonApi.OpenApi.html#raw_filter_type/2)
1280 |
1281 | [resource\_filter\_fields\_fields\_only(resource)](AshJsonApi.OpenApi.html#resource_filter_fields_fields_only/1)
1282 |
1283 | [responses()](AshJsonApi.OpenApi.html#responses/0)
1284 |
1285 | Common responses to include in the API Spec.
1286 |
1287 | [schemas(domains)](AshJsonApi.OpenApi.html#schemas/1)
1288 |
1289 | Resource schemas to include in the API spec.
1290 |
1291 | [spec(opts \\\\ \[\], conn \\\\ nil)](AshJsonApi.OpenApi.html#spec/2)
1292 |
1293 | [tags(domains)](AshJsonApi.OpenApi.html#tags/1)
1294 |
1295 | Tags based on resource names to include in the API spec
1296 |
1297 | [tags(domain, domains)](AshJsonApi.OpenApi.html#tags/2)
1298 |
1299 | [write\_attributes(resource, arguments, action, route, format)](AshJsonApi.OpenApi.html#write_attributes/5)
1300 |
1301 | # [](AshJsonApi.OpenApi.html#functions)Functions
1302 |
1303 | [Link to this function](AshJsonApi.OpenApi.html#define_filter?/2 "Link to this function")
1304 |
1305 | # define\_filter?(domains, resource)
1306 |
1307 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/json_schema/open_api.ex#L192 "View Source")
1308 |
1309 | [Link to this function](AshJsonApi.OpenApi.html#paths/3 "Link to this function")
1310 |
1311 | # paths(domains, all\_domains, opts)
1312 |
1313 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/json_schema/open_api.ex#L1058 "View Source")
1314 |
1315 | ```
1316 | @spec paths(
1317 | domain :: module() | [module()],
1318 | module() | [module()],
1319 | opts :: Keyword.t()
1320 | ) ::
1321 | OpenApiSpex.Paths.t()
1322 | ```
1323 |
1324 | Paths (routes) from the domain.
1325 |
1326 | [Link to this function](AshJsonApi.OpenApi.html#raw_filter_type/2 "Link to this function")
1327 |
1328 | # raw\_filter\_type(attribute\_or\_aggregate, resource)
1329 |
1330 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/json_schema/open_api.ex#L2137 "View Source")
1331 |
1332 | [Link to this function](AshJsonApi.OpenApi.html#resource_filter_fields_fields_only/1 "Link to this function")
1333 |
1334 | # resource\_filter\_fields\_fields\_only(resource)
1335 |
1336 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/json_schema/open_api.ex#L2177 "View Source")
1337 |
1338 | [Link to this function](AshJsonApi.OpenApi.html#responses/0 "Link to this function")
1339 |
1340 | # responses()
1341 |
1342 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/json_schema/open_api.ex#L123 "View Source")
1343 |
1344 | ```
1345 | @spec responses() :: OpenApiSpex.Components.responses_map()
1346 | ```
1347 |
1348 | Common responses to include in the API Spec.
1349 |
1350 | [Link to this function](AshJsonApi.OpenApi.html#schemas/1 "Link to this function")
1351 |
1352 | # schemas(domains)
1353 |
1354 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/json_schema/open_api.ex#L140 "View Source")
1355 |
1356 | ```
1357 | @spec schemas(domain :: module() | [module()]) :: %{
1358 | required(String.t()) => OpenApiSpex.Schema.t()
1359 | }
1360 | ```
1361 |
1362 | Resource schemas to include in the API spec.
1363 |
1364 | [Link to this function](AshJsonApi.OpenApi.html#spec/2 "Link to this function")
1365 |
1366 | # spec(opts \\\\ \[], conn \\\\ nil)
1367 |
1368 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/json_schema/open_api.ex#L59 "View Source")
1369 |
1370 | [Link to this function](AshJsonApi.OpenApi.html#tags/1 "Link to this function")
1371 |
1372 | # tags(domains)
1373 |
1374 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/json_schema/open_api.ex#L1024 "View Source")
1375 |
1376 | ```
1377 | @spec tags(domain :: module() | [module()]) :: [OpenApiSpex.Tag.t()]
1378 | ```
1379 |
1380 | Tags based on resource names to include in the API spec
1381 |
1382 | [Link to this function](AshJsonApi.OpenApi.html#tags/2 "Link to this function")
1383 |
1384 | # tags(domain, domains)
1385 |
1386 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/json_schema/open_api.ex#L1028 "View Source")
1387 |
1388 | [Link to this function](AshJsonApi.OpenApi.html#write_attributes/5 "Link to this function")
1389 |
1390 | # write\_attributes(resource, arguments, action, route, format)
1391 |
1392 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/json_schema/open_api.ex#L1766 "View Source")
1393 |
1394 | ```
1395 | @spec write_attributes(
1396 | resource :: module(),
1397 | [Ash.Resource.Actions.Argument.t()],
1398 | action :: term(),
1399 | route :: term(),
1400 | format :: content_type_format()
1401 | ) :: %{required(atom()) => OpenApiSpex.Schema.t()}
1402 | ```
1403 |
1404 | [Hex Package](https://hex.pm/packages/ash_json_api/1.4.16) [Hex Preview](https://preview.hex.pm/preview/ash_json_api/1.4.16) Search HexDocs [Download ePub version](ash_json_api.epub "ePub version")
1405 |
1406 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.31.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
1407 | [](https://github.com/ash-project/ash_json_api)
1408 |
1409 | [ash\_json\_api](https://github.com/ash-project/ash_json_api)
1410 |
1411 | v1.4.16
1412 |
1413 | - Pages
1414 | - Modules
1415 | - Mix Tasks
1416 |
1417 | <!--THE END-->
1418 |
1419 | <!--THE END-->
1420 |
1421 | <!--THE END-->
1422 |
1423 | Search documentation of ash\_json\_api
1424 |
1425 | Settings
1426 |
1427 | # [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/plug/parser.ex#L1 "View Source") AshJsonApi.Plug.Parser (ash\_json\_api v1.4.16)
1428 |
1429 | Extracts ash multipart request body.
1430 |
1431 | For use with [`Plug.Parsers`](../plug/1.16.1/Plug.Parsers.html), as in the example below.
1432 |
1433 | ## [](AshJsonApi.Plug.Parser.html#module-examples)Examples
1434 |
1435 | Should be used with [`Plug.Parsers`](../plug/1.16.1/Plug.Parsers.html):
1436 |
1437 | ```
1438 | plug Plug.Parsers,
1439 | parsers: [:urlencoded, :multipart, :json, AshJsonApi.Plug.Parser],
1440 | pass: ["*/*"],
1441 | json_decoder: Jason
1442 | ```
1443 |
1444 | ## [](AshJsonApi.Plug.Parser.html#module-protocol)Protocol
1445 |
1446 | To use files in your request, send a [multipart](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types#multipart) with the content type `multipart/x.ash+form-data`. The request MUST contain a JSON object with the key `data` and the value of the object you want to send.
1447 |
1448 | The request MAY contain other keys with the value of the file you want to send. The parser will walk through all of the `data` JSON and replace each string equal to a part name with the content of the part. This means that if you have a part named `users_csv` and a key in the `data` JSON object with the value `users_csv`, the parser will replace the string with the content of the part.
1449 |
1450 | > #### Conflicting Part names
1451 | >
1452 | > Ensure that each part name is unique and does not naturally occur inside as a string in the `data` JSON object. If a part name is found in the `data` JSON object, the parser will replace it with the content of the part.
1453 | >
1454 | > It is recommended to use a unique value like a UUID as the part name.
1455 |
1456 | ## [](AshJsonApi.Plug.Parser.html#module-example-http-message)Example HTTP Message
1457 |
1458 | ```
1459 | POST /action
1460 | Host: example.com
1461 | Content-Length: 2740
1462 | Content-Type: multipart/x.ash+form-data; boundary=abcde12345
1463 | --abcde12345
1464 | Content-Disposition: form-data; name="data"
1465 | Content-Type: application/vnd.api+json
1466 |
1467 | {"users": "users_csv", "meatdata": "metadata_json"}
1468 | --abcde12345
1469 | Content-Disposition: form-data; name="users_csv"; filename="users.csv"
1470 | Content-Type: text/csv
1471 |
1472 | [file content goes here]
1473 | --abcde12345
1474 | Content-Disposition: form-data; name="metadata_json"; filename="metadata.json"
1475 | Content-Type: application/json
1476 |
1477 | [file content goes there]
1478 | --abcde12345--
1479 | ```
1480 |
1481 | [Hex Package](https://hex.pm/packages/ash_json_api/1.4.16) [Hex Preview](https://preview.hex.pm/preview/ash_json_api/1.4.16) Search HexDocs [Download ePub version](ash_json_api.epub "ePub version")
1482 |
1483 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.31.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
1484 | [](https://github.com/ash-project/ash_json_api)
1485 |
1486 | [ash\_json\_api](https://github.com/ash-project/ash_json_api)
1487 |
1488 | v1.4.16
1489 |
1490 | - Pages
1491 | - Modules
1492 | - Mix Tasks
1493 |
1494 | <!--THE END-->
1495 |
1496 | <!--THE END-->
1497 |
1498 | <!--THE END-->
1499 |
1500 | Search documentation of ash\_json\_api
1501 |
1502 | Settings
1503 |
1504 | # [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/resource/resource.ex#L1 "View Source") AshJsonApi.Resource (ash\_json\_api v1.4.16)
1505 |
1506 | The entrypoint for adding JSON:API behavior to a resource"
1507 |
1508 | # [](AshJsonApi.Resource.html#summary)Summary
1509 |
1510 | ## [Functions](AshJsonApi.Resource.html#functions)
1511 |
1512 | [base\_route(resource)](AshJsonApi.Resource.html#base_route/1) deprecated
1513 |
1514 | See [`AshJsonApi.Resource.Info.base_route/1`](AshJsonApi.Resource.Info.html#base_route/1).
1515 |
1516 | [encode\_primary\_key(record)](AshJsonApi.Resource.html#encode_primary_key/1)
1517 |
1518 | [includes(resource)](AshJsonApi.Resource.html#includes/1) deprecated
1519 |
1520 | See [`AshJsonApi.Resource.Info.includes/1`](AshJsonApi.Resource.Info.html#includes/1).
1521 |
1522 | [install(igniter, module, arg, path, argv)](AshJsonApi.Resource.html#install/5)
1523 |
1524 | [json\_api(body)](AshJsonApi.Resource.html#json_api/1)
1525 |
1526 | [only\_primary\_key?(resource, field)](AshJsonApi.Resource.html#only_primary_key?/2)
1527 |
1528 | [primary\_key\_delimiter(resource)](AshJsonApi.Resource.html#primary_key_delimiter/1) deprecated
1529 |
1530 | See [`AshJsonApi.Resource.Info.primary_key_delimiter/1`](AshJsonApi.Resource.Info.html#primary_key_delimiter/1).
1531 |
1532 | [primary\_key\_fields(resource)](AshJsonApi.Resource.html#primary_key_fields/1) deprecated
1533 |
1534 | See [`AshJsonApi.Resource.Info.primary_key_fields/1`](AshJsonApi.Resource.Info.html#primary_key_fields/1).
1535 |
1536 | [route(resource, domains, criteria \\\\ %{})](AshJsonApi.Resource.html#route/3)
1537 |
1538 | [routes(resource, domains)](AshJsonApi.Resource.html#routes/2) deprecated
1539 |
1540 | See [`AshJsonApi.Resource.Info.routes/2`](AshJsonApi.Resource.Info.html#routes/2).
1541 |
1542 | [type(resource)](AshJsonApi.Resource.html#type/1) deprecated
1543 |
1544 | See [`AshJsonApi.Resource.Info.type/1`](AshJsonApi.Resource.Info.html#type/1).
1545 |
1546 | # [](AshJsonApi.Resource.html#functions)Functions
1547 |
1548 | [Link to this function](AshJsonApi.Resource.html#base_route/1 "Link to this function")
1549 |
1550 | # base\_route(resource)
1551 |
1552 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/resource/resource.ex#L564 "View Source")
1553 |
1554 | This function is deprecated. See AshJsonApi.Resource.Info.base\_route/1.
1555 |
1556 | See [`AshJsonApi.Resource.Info.base_route/1`](AshJsonApi.Resource.Info.html#base_route/1).
1557 |
1558 | [Link to this function](AshJsonApi.Resource.html#encode_primary_key/1 "Link to this function")
1559 |
1560 | # encode\_primary\_key(record)
1561 |
1562 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/resource/resource.ex#L575 "View Source")
1563 |
1564 | [Link to this function](AshJsonApi.Resource.html#includes/1 "Link to this function")
1565 |
1566 | # includes(resource)
1567 |
1568 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/resource/resource.ex#L561 "View Source")
1569 |
1570 | This function is deprecated. See AshJsonApi.Resource.Info.includes/1.
1571 |
1572 | See [`AshJsonApi.Resource.Info.includes/1`](AshJsonApi.Resource.Info.html#includes/1).
1573 |
1574 | [Link to this function](AshJsonApi.Resource.html#install/5 "Link to this function")
1575 |
1576 | # install(igniter, module, arg, path, argv)
1577 |
1578 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/resource/resource.ex#L404 "View Source")
1579 |
1580 | [Link to this macro](AshJsonApi.Resource.html#json_api/1 "Link to this macro")
1581 |
1582 | # json\_api(body)
1583 |
1584 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/resource/resource.ex#L551 "View Source") (macro)
1585 |
1586 | [Link to this function](AshJsonApi.Resource.html#only_primary_key?/2 "Link to this function")
1587 |
1588 | # only\_primary\_key?(resource, field)
1589 |
1590 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/resource/resource.ex#L629 "View Source")
1591 |
1592 | [Link to this function](AshJsonApi.Resource.html#primary_key_delimiter/1 "Link to this function")
1593 |
1594 | # primary\_key\_delimiter(resource)
1595 |
1596 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/resource/resource.ex#L570 "View Source")
1597 |
1598 | This function is deprecated. See AshJsonApi.Resource.Info.primary\_key\_delimiter/1.
1599 |
1600 | See [`AshJsonApi.Resource.Info.primary_key_delimiter/1`](AshJsonApi.Resource.Info.html#primary_key_delimiter/1).
1601 |
1602 | [Link to this function](AshJsonApi.Resource.html#primary_key_fields/1 "Link to this function")
1603 |
1604 | # primary\_key\_fields(resource)
1605 |
1606 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/resource/resource.ex#L567 "View Source")
1607 |
1608 | This function is deprecated. See AshJsonApi.Resource.Info.primary\_key\_fields/1.
1609 |
1610 | See [`AshJsonApi.Resource.Info.primary_key_fields/1`](AshJsonApi.Resource.Info.html#primary_key_fields/1).
1611 |
1612 | [Link to this function](AshJsonApi.Resource.html#route/3 "Link to this function")
1613 |
1614 | # route(resource, domains, criteria \\\\ %{})
1615 |
1616 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/resource/resource.ex#L598 "View Source")
1617 |
1618 | [Link to this function](AshJsonApi.Resource.html#routes/2 "Link to this function")
1619 |
1620 | # routes(resource, domains)
1621 |
1622 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/resource/resource.ex#L573 "View Source")
1623 |
1624 | This function is deprecated. See AshJsonApi.Resource.Info.routes/1.
1625 |
1626 | See [`AshJsonApi.Resource.Info.routes/2`](AshJsonApi.Resource.Info.html#routes/2).
1627 |
1628 | [Link to this function](AshJsonApi.Resource.html#type/1 "Link to this function")
1629 |
1630 | # type(resource)
1631 |
1632 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/resource/resource.ex#L558 "View Source")
1633 |
1634 | This function is deprecated. See AshJsonApi.Resource.Info.type/1.
1635 |
1636 | See [`AshJsonApi.Resource.Info.type/1`](AshJsonApi.Resource.Info.html#type/1).
1637 |
1638 | [Hex Package](https://hex.pm/packages/ash_json_api/1.4.16) [Hex Preview](https://preview.hex.pm/preview/ash_json_api/1.4.16) Search HexDocs [Download ePub version](ash_json_api.epub "ePub version")
1639 |
1640 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.31.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
1641 | [](https://github.com/ash-project/ash_json_api)
1642 |
1643 | [ash\_json\_api](https://github.com/ash-project/ash_json_api)
1644 |
1645 | v1.4.16
1646 |
1647 | - Pages
1648 | - Modules
1649 | - Mix Tasks
1650 |
1651 | <!--THE END-->
1652 |
1653 | <!--THE END-->
1654 |
1655 | <!--THE END-->
1656 |
1657 | Search documentation of ash\_json\_api
1658 |
1659 | Settings
1660 |
1661 | # [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/resource/info.ex#L1 "View Source") AshJsonApi.Resource.Info (ash\_json\_api v1.4.16)
1662 |
1663 | Introspection helpers for AshJsonApi.Resource
1664 |
1665 | # [](AshJsonApi.Resource.Info.html#summary)Summary
1666 |
1667 | ## [Functions](AshJsonApi.Resource.Info.html#functions)
1668 |
1669 | [base\_route(resource)](AshJsonApi.Resource.Info.html#base_route/1)
1670 |
1671 | [default\_fields(resource)](AshJsonApi.Resource.Info.html#default_fields/1)
1672 |
1673 | [derive\_filter?(resource)](AshJsonApi.Resource.Info.html#derive_filter?/1)
1674 |
1675 | [derive\_sort?(resource)](AshJsonApi.Resource.Info.html#derive_sort?/1)
1676 |
1677 | [include\_nil\_values?(resource)](AshJsonApi.Resource.Info.html#include_nil_values?/1)
1678 |
1679 | [includes(resource)](AshJsonApi.Resource.Info.html#includes/1)
1680 |
1681 | [primary\_key\_delimiter(resource)](AshJsonApi.Resource.Info.html#primary_key_delimiter/1)
1682 |
1683 | [primary\_key\_fields(resource)](AshJsonApi.Resource.Info.html#primary_key_fields/1)
1684 |
1685 | [routes(resource, domain\_or\_domains \\\\ \[\])](AshJsonApi.Resource.Info.html#routes/2)
1686 |
1687 | [type(resource)](AshJsonApi.Resource.Info.html#type/1)
1688 |
1689 | # [](AshJsonApi.Resource.Info.html#functions)Functions
1690 |
1691 | [Link to this function](AshJsonApi.Resource.Info.html#base_route/1 "Link to this function")
1692 |
1693 | # base\_route(resource)
1694 |
1695 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/resource/info.ex#L22 "View Source")
1696 |
1697 | [Link to this function](AshJsonApi.Resource.Info.html#default_fields/1 "Link to this function")
1698 |
1699 | # default\_fields(resource)
1700 |
1701 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/resource/info.ex#L53 "View Source")
1702 |
1703 | [Link to this function](AshJsonApi.Resource.Info.html#derive_filter?/1 "Link to this function")
1704 |
1705 | # derive\_filter?(resource)
1706 |
1707 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/resource/info.ex#L10 "View Source")
1708 |
1709 | [Link to this function](AshJsonApi.Resource.Info.html#derive_sort?/1 "Link to this function")
1710 |
1711 | # derive\_sort?(resource)
1712 |
1713 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/resource/info.ex#L14 "View Source")
1714 |
1715 | [Link to this function](AshJsonApi.Resource.Info.html#include_nil_values?/1 "Link to this function")
1716 |
1717 | # include\_nil\_values?(resource)
1718 |
1719 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/resource/info.ex#L49 "View Source")
1720 |
1721 | [Link to this function](AshJsonApi.Resource.Info.html#includes/1 "Link to this function")
1722 |
1723 | # includes(resource)
1724 |
1725 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/resource/info.ex#L18 "View Source")
1726 |
1727 | [Link to this function](AshJsonApi.Resource.Info.html#primary_key_delimiter/1 "Link to this function")
1728 |
1729 | # primary\_key\_delimiter(resource)
1730 |
1731 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/resource/info.ex#L30 "View Source")
1732 |
1733 | [Link to this function](AshJsonApi.Resource.Info.html#primary_key_fields/1 "Link to this function")
1734 |
1735 | # primary\_key\_fields(resource)
1736 |
1737 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/resource/info.ex#L26 "View Source")
1738 |
1739 | [Link to this function](AshJsonApi.Resource.Info.html#routes/2 "Link to this function")
1740 |
1741 | # routes(resource, domain\_or\_domains \\\\ \[])
1742 |
1743 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/resource/info.ex#L34 "View Source")
1744 |
1745 | [Link to this function](AshJsonApi.Resource.Info.html#type/1 "Link to this function")
1746 |
1747 | # type(resource)
1748 |
1749 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/resource/info.ex#L6 "View Source")
1750 |
1751 | [Hex Package](https://hex.pm/packages/ash_json_api/1.4.16) [Hex Preview](https://preview.hex.pm/preview/ash_json_api/1.4.16) Search HexDocs [Download ePub version](ash_json_api.epub "ePub version")
1752 |
1753 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.31.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
1754 | [](https://github.com/ash-project/ash_json_api)
1755 |
1756 | [ash\_json\_api](https://github.com/ash-project/ash_json_api)
1757 |
1758 | v1.4.16
1759 |
1760 | - Pages
1761 | - Modules
1762 | - Mix Tasks
1763 |
1764 | <!--THE END-->
1765 |
1766 | <!--THE END-->
1767 |
1768 | <!--THE END-->
1769 |
1770 | Search documentation of ash\_json\_api
1771 |
1772 | Settings
1773 |
1774 | # [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/resource/route.ex#L1 "View Source") AshJsonApi.Resource.Route (ash\_json\_api v1.4.16)
1775 |
1776 | Represents a route for a resource
1777 |
1778 | # [](AshJsonApi.Resource.Route.html#summary)Summary
1779 |
1780 | ## [Types](AshJsonApi.Resource.Route.html#types)
1781 |
1782 | [t()](AshJsonApi.Resource.Route.html#t:t/0)
1783 |
1784 | # [](AshJsonApi.Resource.Route.html#types)Types
1785 |
1786 | [Link to this type](AshJsonApi.Resource.Route.html#t:t/0 "Link to this type")
1787 |
1788 | # t()
1789 |
1790 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/resource/route.ex#L27 "View Source")
1791 |
1792 | ```
1793 | @type t() :: %AshJsonApi.Resource.Route{
1794 | action: term(),
1795 | action_type: term(),
1796 | controller: term(),
1797 | default_fields: term(),
1798 | derive_filter?: term(),
1799 | derive_sort?: term(),
1800 | metadata: term(),
1801 | method: term(),
1802 | modify_conn: term(),
1803 | name: term(),
1804 | primary?: term(),
1805 | query_params: term(),
1806 | read_action: term(),
1807 | relationship: term(),
1808 | relationship_arguments: term(),
1809 | resource: term(),
1810 | route: term(),
1811 | type: term(),
1812 | upsert?: term(),
1813 | upsert_identity: term(),
1814 | wrap_in_result?: term()
1815 | }
1816 | ```
1817 |
1818 | [Hex Package](https://hex.pm/packages/ash_json_api/1.4.16) [Hex Preview](https://preview.hex.pm/preview/ash_json_api/1.4.16) Search HexDocs [Download ePub version](ash_json_api.epub "ePub version")
1819 |
1820 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.31.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
1821 | [](https://github.com/ash-project/ash_json_api)
1822 |
1823 | [ash\_json\_api](https://github.com/ash-project/ash_json_api)
1824 |
1825 | v1.4.16
1826 |
1827 | - Pages
1828 | - Modules
1829 | - Mix Tasks
1830 |
1831 | <!--THE END-->
1832 |
1833 | <!--THE END-->
1834 |
1835 | <!--THE END-->
1836 |
1837 | Search documentation of ash\_json\_api
1838 |
1839 | Settings
1840 |
1841 | # [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/resource/verifiers/verify_actions.ex#L1 "View Source") AshJsonApi.Resource.Verifiers.VerifyActions (ash\_json\_api v1.4.16)
1842 |
1843 | Verifies that all actions are valid for each route.
1844 |
1845 | [Hex Package](https://hex.pm/packages/ash_json_api/1.4.16) [Hex Preview](https://preview.hex.pm/preview/ash_json_api/1.4.16) Search HexDocs [Download ePub version](ash_json_api.epub "ePub version")
1846 |
1847 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.31.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
1848 | [](https://github.com/ash-project/ash_json_api)
1849 |
1850 | [ash\_json\_api](https://github.com/ash-project/ash_json_api)
1851 |
1852 | v1.4.16
1853 |
1854 | - Pages
1855 | - Modules
1856 | - Mix Tasks
1857 |
1858 | <!--THE END-->
1859 |
1860 | <!--THE END-->
1861 |
1862 | <!--THE END-->
1863 |
1864 | Search documentation of ash\_json\_api
1865 |
1866 | Settings
1867 |
1868 | # [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/resource/verifiers/verify_has_type.ex#L1 "View Source") AshJsonApi.Resource.Verifiers.VerifyHasType (ash\_json\_api v1.4.16)
1869 |
1870 | Verifies that a resource has a type if it has any routes that need it.
1871 |
1872 | [Hex Package](https://hex.pm/packages/ash_json_api/1.4.16) [Hex Preview](https://preview.hex.pm/preview/ash_json_api/1.4.16) Search HexDocs [Download ePub version](ash_json_api.epub "ePub version")
1873 |
1874 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.31.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
1875 | [](https://github.com/ash-project/ash_json_api)
1876 |
1877 | [ash\_json\_api](https://github.com/ash-project/ash_json_api)
1878 |
1879 | v1.4.16
1880 |
1881 | - Pages
1882 | - Modules
1883 | - Mix Tasks
1884 |
1885 | <!--THE END-->
1886 |
1887 | <!--THE END-->
1888 |
1889 | <!--THE END-->
1890 |
1891 | Search documentation of ash\_json\_api
1892 |
1893 | Settings
1894 |
1895 | # [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/resource/verifiers/verify_includes.ex#L1 "View Source") AshJsonApi.Resource.Verifiers.VerifyIncludes (ash\_json\_api v1.4.16)
1896 |
1897 | Verifies that all includes are valid public relationships
1898 |
1899 | [Hex Package](https://hex.pm/packages/ash_json_api/1.4.16) [Hex Preview](https://preview.hex.pm/preview/ash_json_api/1.4.16) Search HexDocs [Download ePub version](ash_json_api.epub "ePub version")
1900 |
1901 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.31.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
1902 | [](https://github.com/ash-project/ash_json_api)
1903 |
1904 | [ash\_json\_api](https://github.com/ash-project/ash_json_api)
1905 |
1906 | v1.4.16
1907 |
1908 | - Pages
1909 | - Modules
1910 | - Mix Tasks
1911 |
1912 | <!--THE END-->
1913 |
1914 | <!--THE END-->
1915 |
1916 | <!--THE END-->
1917 |
1918 | Search documentation of ash\_json\_api
1919 |
1920 | Settings
1921 |
1922 | # [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/resource/verifiers/verify_query_params.ex#L1 "View Source") AshJsonApi.Resource.Verifiers.VerifyQueryParams (ash\_json\_api v1.4.16)
1923 |
1924 | Verify query params are not reserved or shadowed by the route
1925 |
1926 | [Hex Package](https://hex.pm/packages/ash_json_api/1.4.16) [Hex Preview](https://preview.hex.pm/preview/ash_json_api/1.4.16) Search HexDocs [Download ePub version](ash_json_api.epub "ePub version")
1927 |
1928 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.31.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
1929 | [](https://github.com/ash-project/ash_json_api)
1930 |
1931 | [ash\_json\_api](https://github.com/ash-project/ash_json_api)
1932 |
1933 | v1.4.16
1934 |
1935 | - Pages
1936 | - Modules
1937 | - Mix Tasks
1938 |
1939 | <!--THE END-->
1940 |
1941 | <!--THE END-->
1942 |
1943 | <!--THE END-->
1944 |
1945 | Search documentation of ash\_json\_api
1946 |
1947 | Settings
1948 |
1949 | # [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/resource/verifiers/verify_relationships.ex#L1 "View Source") AshJsonApi.Resource.Verifiers.VerifyRelationships (ash\_json\_api v1.4.16)
1950 |
1951 | Verifies that any routes that reference a relationship reference a public one
1952 |
1953 | # [](AshJsonApi.Resource.Verifiers.VerifyRelationships.html#summary)Summary
1954 |
1955 | ## [Functions](AshJsonApi.Resource.Verifiers.VerifyRelationships.html#functions)
1956 |
1957 | [verify(dsl)](AshJsonApi.Resource.Verifiers.VerifyRelationships.html#verify/1)
1958 |
1959 | Callback implementation for [`Spark.Dsl.Verifier.verify/1`](../spark/2.2.36/Spark.Dsl.Verifier.html#c:verify/1).
1960 |
1961 | # [](AshJsonApi.Resource.Verifiers.VerifyRelationships.html#functions)Functions
1962 |
1963 | [Link to this function](AshJsonApi.Resource.Verifiers.VerifyRelationships.html#verify/1 "Link to this function")
1964 |
1965 | # verify(dsl)
1966 |
1967 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/resource/verifiers/verify_relationships.ex#L5 "View Source")
1968 |
1969 | Callback implementation for [`Spark.Dsl.Verifier.verify/1`](../spark/2.2.36/Spark.Dsl.Verifier.html#c:verify/1).
1970 |
1971 | [Hex Package](https://hex.pm/packages/ash_json_api/1.4.16) [Hex Preview](https://preview.hex.pm/preview/ash_json_api/1.4.16) Search HexDocs [Download ePub version](ash_json_api.epub "ePub version")
1972 |
1973 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.31.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
1974 | [](https://github.com/ash-project/ash_json_api)
1975 |
1976 | [ash\_json\_api](https://github.com/ash-project/ash_json_api)
1977 |
1978 | v1.4.16
1979 |
1980 | - Pages
1981 | - Modules
1982 | - Mix Tasks
1983 |
1984 | <!--THE END-->
1985 |
1986 | <!--THE END-->
1987 |
1988 | <!--THE END-->
1989 |
1990 | Search documentation of ash\_json\_api
1991 |
1992 | Settings
1993 |
1994 | # [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/router.ex#L1 "View Source") AshJsonApi.Router (ash\_json\_api v1.4.16)
1995 |
1996 | Use this module to create a router for your AshJsonApi.
1997 |
1998 | To use this, create a module and do the following:
1999 |
2000 | ```
2001 | defmodule YourRouter do
2002 | use AshJsonApi.Router,
2003 | domains: [YourDomain, YourOtherDomain],
2004 | # these next two are optional, only add them if you want those endpoints
2005 | open_api: "/open_api",
2006 | json_schema: "/json_schema",
2007 | # tell us where it is mounted in your router
2008 | prefix: "/api/json"
2009 | end
2010 | ```
2011 |
2012 | Then in your Phoenix router or plug pipeline, forward to this plug. In phoenix, that looks like this:
2013 |
2014 | ```
2015 | forward "/api", YourRouter
2016 | ```
2017 |
2018 | [Hex Package](https://hex.pm/packages/ash_json_api/1.4.16) [Hex Preview](https://preview.hex.pm/preview/ash_json_api/1.4.16) Search HexDocs [Download ePub version](ash_json_api.epub "ePub version")
2019 |
2020 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.31.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
2021 | [](https://github.com/ash-project/ash_json_api)
2022 |
2023 | [ash\_json\_api](https://github.com/ash-project/ash_json_api)
2024 |
2025 | v1.4.16
2026 |
2027 | - Pages
2028 | - Modules
2029 | - Mix Tasks
2030 |
2031 | <!--THE END-->
2032 |
2033 | <!--THE END-->
2034 |
2035 | <!--THE END-->
2036 |
2037 | Search documentation of ash\_json\_api
2038 |
2039 | Settings
2040 |
2041 | # [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/test/test.ex#L1 "View Source") AshJsonApi.Test (ash\_json\_api v1.4.16)
2042 |
2043 | Utilities for testing AshJsonApi.
2044 |
2045 | ## [](AshJsonApi.Test.html#module-making-requests)Making Requests
2046 |
2047 | The request testing functions get/patch/post/delete all support the following options
2048 |
2049 | - `:status`: Asserts that the response has the provided status after making the request
2050 | - `:router`: The corresponding JsonApiRouter to go through. Can be set statically in config, see below for more.
2051 | - `:actor`: Sets the provided actor as the actor for the request
2052 | - `:tenant`: Sets the provided tenant as the tenant for the request
2053 |
2054 | A standard test would look like this:
2055 |
2056 | ```
2057 | test "can list posts", %{current_user: current_user} do
2058 | Domain
2059 | # GET /posts
2060 | # assert resp.status == 200
2061 | |> get("/posts", status: 200, actor: current_user, router: MyAppWeb.JsonApiRouter)
2062 | # pattern match on the data key of the response
2063 | |> assert_data_matches([
2064 | %{
2065 | "attributes" => %{
2066 | "name" => "foo"
2067 | }
2068 | }
2069 | ])
2070 | end
2071 | ```
2072 |
2073 | # [](AshJsonApi.Test.html#summary)Summary
2074 |
2075 | ## [Functions](AshJsonApi.Test.html#functions)
2076 |
2077 | [assert\_data\_equals(conn, expected\_data)](AshJsonApi.Test.html#assert_data_equals/2)
2078 |
2079 | Assert that the response body's `"data"` equals an exact value
2080 |
2081 | [assert\_data\_matches(conn, data\_pattern)](AshJsonApi.Test.html#assert_data_matches/2)
2082 |
2083 | Assert that the response body's `"data"` matches a pattern
2084 |
2085 | [assert\_has\_error(conn, fields)](AshJsonApi.Test.html#assert_has_error/2)
2086 |
2087 | Asserts that an error is in the response where each key present in the provided map has the same value in the error.
2088 |
2089 | [assert\_has\_matching\_include(conn, function)](AshJsonApi.Test.html#assert_has_matching_include/2)
2090 |
2091 | Assert that the given function returns true for at least one included record
2092 |
2093 | [delete(domain, path, opts \\\\ \[\])](AshJsonApi.Test.html#delete/3)
2094 |
2095 | Sends a DELETE request to the given path. See the module docs for more.
2096 |
2097 | [get(domain, path, opts \\\\ \[\])](AshJsonApi.Test.html#get/3)
2098 |
2099 | Sends a GET request to the given path. See the module docs for more.
2100 |
2101 | [multipart\_post(domain, path, body, opts \\\\ \[\])](AshJsonApi.Test.html#multipart_post/4)
2102 |
2103 | Sends a multipart POST request to the given path. See the module docs for more.
2104 |
2105 | [patch(domain, path, body, opts \\\\ \[\])](AshJsonApi.Test.html#patch/4)
2106 |
2107 | Sends a PATCH request to the given path. See the module docs for more.
2108 |
2109 | [post(domain, path, body, opts \\\\ \[\])](AshJsonApi.Test.html#post/4)
2110 |
2111 | Sends a POST request to the given path. See the module docs for more.
2112 |
2113 | [refute\_has\_matching\_include(conn, function)](AshJsonApi.Test.html#refute_has_matching_include/2)
2114 |
2115 | Refute that the given function returns true for at least one included record
2116 |
2117 | # [](AshJsonApi.Test.html#functions)Functions
2118 |
2119 | [Link to this macro](AshJsonApi.Test.html#assert_data_equals/2 "Link to this macro")
2120 |
2121 | # assert\_data\_equals(conn, expected\_data)
2122 |
2123 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/test/test.ex#L288 "View Source") (macro)
2124 |
2125 | Assert that the response body's `"data"` equals an exact value
2126 |
2127 | [Link to this macro](AshJsonApi.Test.html#assert_data_matches/2 "Link to this macro")
2128 |
2129 | # assert\_data\_matches(conn, data\_pattern)
2130 |
2131 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/test/test.ex#L301 "View Source") (macro)
2132 |
2133 | Assert that the response body's `"data"` matches a pattern
2134 |
2135 | [Link to this macro](AshJsonApi.Test.html#assert_has_error/2 "Link to this macro")
2136 |
2137 | # assert\_has\_error(conn, fields)
2138 |
2139 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/test/test.ex#L422 "View Source") (macro)
2140 |
2141 | Asserts that an error is in the response where each key present in the provided map has the same value in the error.
2142 |
2143 | ## [](AshJsonApi.Test.html#assert_has_error/2-example)Example
2144 |
2145 | ```
2146 | Domain
2147 | |> delete("/posts/1", status: 404)
2148 | |> assert_has_error(%{
2149 | "code" => "not_found",
2150 | "detail" => "No post record found with `id: 1`",
2151 | "title" => "Entity Not Found"
2152 | })
2153 | ```
2154 |
2155 | [Link to this macro](AshJsonApi.Test.html#assert_has_matching_include/2 "Link to this macro")
2156 |
2157 | # assert\_has\_matching\_include(conn, function)
2158 |
2159 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/test/test.ex#L451 "View Source") (macro)
2160 |
2161 | Assert that the given function returns true for at least one included record
2162 |
2163 | ## [](AshJsonApi.Test.html#assert_has_matching_include/2-example)Example
2164 |
2165 | Domain |> get("/posts/#{post.id}/?include=author", status: 200) |> assert\_has\_matching\_include(fn %{"type" => "author", "id" => ^author\_id} ->
2166 |
2167 | ```
2168 | true
2169 | ```
2170 |
2171 | _ ->
2172 |
2173 | ```
2174 | false
2175 | ```
2176 |
2177 | end)
2178 |
2179 | [Link to this function](AshJsonApi.Test.html#delete/3 "Link to this function")
2180 |
2181 | # delete(domain, path, opts \\\\ \[])
2182 |
2183 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/test/test.ex#L245 "View Source")
2184 |
2185 | Sends a DELETE request to the given path. See the module docs for more.
2186 |
2187 | [Link to this function](AshJsonApi.Test.html#get/3 "Link to this function")
2188 |
2189 | # get(domain, path, opts \\\\ \[])
2190 |
2191 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/test/test.ex#L41 "View Source")
2192 |
2193 | Sends a GET request to the given path. See the module docs for more.
2194 |
2195 | [Link to this function](AshJsonApi.Test.html#multipart_post/4 "Link to this function")
2196 |
2197 | # multipart\_post(domain, path, body, opts \\\\ \[])
2198 |
2199 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/test/test.ex#L133 "View Source")
2200 |
2201 | Sends a multipart POST request to the given path. See the module docs for more.
2202 |
2203 | [Link to this function](AshJsonApi.Test.html#patch/4 "Link to this function")
2204 |
2205 | # patch(domain, path, body, opts \\\\ \[])
2206 |
2207 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/test/test.ex#L198 "View Source")
2208 |
2209 | Sends a PATCH request to the given path. See the module docs for more.
2210 |
2211 | [Link to this function](AshJsonApi.Test.html#post/4 "Link to this function")
2212 |
2213 | # post(domain, path, body, opts \\\\ \[])
2214 |
2215 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/test/test.ex#L85 "View Source")
2216 |
2217 | Sends a POST request to the given path. See the module docs for more.
2218 |
2219 | [Link to this macro](AshJsonApi.Test.html#refute_has_matching_include/2 "Link to this macro")
2220 |
2221 | # refute\_has\_matching\_include(conn, function)
2222 |
2223 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/test/test.ex#L479 "View Source") (macro)
2224 |
2225 | Refute that the given function returns true for at least one included record
2226 |
2227 | ## [](AshJsonApi.Test.html#refute_has_matching_include/2-example)Example
2228 |
2229 | Domain |> get("/posts/#{post.id}/?include=author", status: 200) |> refute\_has\_matching\_include(fn %{"type" => "author", "id" => ^author\_id} ->
2230 |
2231 | ```
2232 | true
2233 | ```
2234 |
2235 | _ ->
2236 |
2237 | ```
2238 | false
2239 | ```
2240 |
2241 | end)
2242 |
2243 | [Hex Package](https://hex.pm/packages/ash_json_api/1.4.16) [Hex Preview](https://preview.hex.pm/preview/ash_json_api/1.4.16) Search HexDocs [Download ePub version](ash_json_api.epub "ePub version")
2244 |
2245 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.31.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
2246 | [](https://github.com/ash-project/ash_json_api)
2247 |
2248 | [ash\_json\_api](https://github.com/ash-project/ash_json_api)
2249 |
2250 | v1.4.16
2251 |
2252 | - Pages
2253 | - Modules
2254 | - Mix Tasks
2255 |
2256 | <!--THE END-->
2257 |
2258 | <!--THE END-->
2259 |
2260 | <!--THE END-->
2261 |
2262 | Search documentation of ash\_json\_api
2263 |
2264 | Settings
2265 |
2266 | # [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/error/to_json_api_error.ex#L1 "View Source") AshJsonApi.ToJsonApiError protocol (ash\_json\_api v1.4.16)
2267 |
2268 | A protocol for turning an Ash exception into an AshJsonApi.Error
2269 |
2270 | To use, implement the protocol for a builtin Ash exception type or for your own custom Ash exception.
2271 |
2272 | ## [](AshJsonApi.ToJsonApiError.html#module-example)Example
2273 |
2274 | ```
2275 | defmodule NotAvailable do
2276 | use Ash.Error.Exception
2277 |
2278 | use Splode.Error,
2279 | fields: [],
2280 | class: :invalid
2281 |
2282 | defimpl AshJsonApi.ToJsonApiError do
2283 | def to_json_api_error(error) do
2284 | %AshJsonApi.Error{
2285 | id: Ash.UUID.generate(),
2286 | status_code: 409,
2287 | code: "not_available",
2288 | title: "not_available",
2289 | detail: "Not available"
2290 | }
2291 | end
2292 | end
2293 | end
2294 | ```
2295 |
2296 | # [](AshJsonApi.ToJsonApiError.html#summary)Summary
2297 |
2298 | ## [Types](AshJsonApi.ToJsonApiError.html#types)
2299 |
2300 | [t()](AshJsonApi.ToJsonApiError.html#t:t/0)
2301 |
2302 | All the types that implement this protocol.
2303 |
2304 | ## [Functions](AshJsonApi.ToJsonApiError.html#functions)
2305 |
2306 | [to\_json\_api\_error(struct)](AshJsonApi.ToJsonApiError.html#to_json_api_error/1)
2307 |
2308 | # [](AshJsonApi.ToJsonApiError.html#types)Types
2309 |
2310 | [Link to this type](AshJsonApi.ToJsonApiError.html#t:t/0 "Link to this type")
2311 |
2312 | # t()
2313 |
2314 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/error/to_json_api_error.ex#L1 "View Source")
2315 |
2316 | ```
2317 | @type t() :: term()
2318 | ```
2319 |
2320 | All the types that implement this protocol.
2321 |
2322 | # [](AshJsonApi.ToJsonApiError.html#functions)Functions
2323 |
2324 | [Link to this function](AshJsonApi.ToJsonApiError.html#to_json_api_error/1 "Link to this function")
2325 |
2326 | # to\_json\_api\_error(struct)
2327 |
2328 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/error/to_json_api_error.ex#L33 "View Source")
2329 |
2330 | ```
2331 | @spec to_json_api_error(term()) :: AshJsonApi.Error.t() | [AshJsonApi.Error.t()]
2332 | ```
2333 |
2334 | [Hex Package](https://hex.pm/packages/ash_json_api/1.4.16) [Hex Preview](https://preview.hex.pm/preview/ash_json_api/1.4.16) Search HexDocs [Download ePub version](ash_json_api.epub "ePub version")
2335 |
2336 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.31.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
2337 | [](https://github.com/ash-project/ash_json_api)
2338 |
2339 | [ash\_json\_api](https://github.com/ash-project/ash_json_api)
2340 |
2341 | v1.4.16
2342 |
2343 | - Pages
2344 | - Modules
2345 | - Mix Tasks
2346 |
2347 | <!--THE END-->
2348 |
2349 | <!--THE END-->
2350 |
2351 | <!--THE END-->
2352 |
2353 | Search documentation of ash\_json\_api
2354 |
2355 | Settings
2356 |
2357 | # [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/type.ex#L1 "View Source") AshJsonApi.Type behaviour (ash\_json\_api v1.4.16)
2358 |
2359 | The behaviour for customizing how a datatype is rendered and written in AshJsonApi.
2360 |
2361 | # [](AshJsonApi.Type.html#summary)Summary
2362 |
2363 | ## [Callbacks](AshJsonApi.Type.html#callbacks)
2364 |
2365 | [json\_schema(t)](AshJsonApi.Type.html#c:json_schema/1)
2366 |
2367 | [json\_write\_schema(t)](AshJsonApi.Type.html#c:json_write_schema/1)
2368 |
2369 | # [](AshJsonApi.Type.html#callbacks)Callbacks
2370 |
2371 | [Link to this callback](AshJsonApi.Type.html#c:json_schema/1 "Link to this callback")
2372 |
2373 | # json\_schema(t)
2374 |
2375 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/type.ex#L6 "View Source") (optional)
2376 |
2377 | ```
2378 | @callback json_schema(Keyword.t()) :: map()
2379 | ```
2380 |
2381 | [Link to this callback](AshJsonApi.Type.html#c:json_write_schema/1 "Link to this callback")
2382 |
2383 | # json\_write\_schema(t)
2384 |
2385 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/ash_json_api/type.ex#L7 "View Source")
2386 |
2387 | ```
2388 | @callback json_write_schema(Keyword.t()) :: map()
2389 | ```
2390 |
2391 | [Hex Package](https://hex.pm/packages/ash_json_api/1.4.16) [Hex Preview](https://preview.hex.pm/preview/ash_json_api/1.4.16) Search HexDocs [Download ePub version](ash_json_api.epub "ePub version")
2392 |
2393 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.31.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
2394 | [](https://github.com/ash-project/ash_json_api)
2395 |
2396 | [ash\_json\_api](https://github.com/ash-project/ash_json_api)
2397 |
2398 | v1.4.16
2399 |
2400 | - Pages
2401 | - Modules
2402 | - Mix Tasks
2403 |
2404 | <!--THE END-->
2405 |
2406 | <!--THE END-->
2407 |
2408 | <!--THE END-->
2409 |
2410 | Search documentation of ash\_json\_api
2411 |
2412 | Settings
2413 |
2414 | # [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/documentation/topics/authenticate-with-json-api.md#L1 "View Source") Authenticating with AshJsonApi
2415 |
2416 | Authenticating with AshJsonApi requires a few things. The first thing to note is that this is not something that is provided for you out of the box by `ash_authentication`.
2417 |
2418 | You will need to:
2419 |
2420 | - connect the authentication action to a route manually
2421 | - need to extract the resulting authentication token
2422 | - set it as a header or as metadata to provide it to the client to use on future requests
2423 |
2424 | You may also need to add a policy bypass to your resource, to make the action accessible via a non-AshAuthenticationPhoenix liveview.
2425 |
2426 | ## [](authenticate-with-json-api.html#the-route)The route
2427 |
2428 | In this example, we will use the standard `:sign_in_with_password` action that is created by `ash_authentication` under the hood, and we will return the token as part of the response metadata.
2429 |
2430 | ```
2431 | # In your User module
2432 | defmodule <YourApp>.<YourDomain>.User do
2433 | json_api do
2434 | routes do
2435 | # Read actions that return *only one resource* are allowed to be used with
2436 | # `post` routes.
2437 | post :sign_in_with_password do
2438 | route "/sign_in"
2439 |
2440 | # Given a successful request, we will modify the response to include the
2441 | # generated token
2442 | metadata fn _subject, user, _request ->
2443 | %{token: user.__metadata__.token}
2444 | end
2445 | end
2446 | end
2447 | end
2448 | end
2449 | ```
2450 |
2451 | This will add the token to the `meta` key in a successful API response, eg.
2452 |
2453 | ```
2454 | {
2455 | {
2456 | "data": {
2457 | "attributes": { ... },
2458 | ...
2459 | },
2460 | "meta": {
2461 | "token": "eyJhbGc..."
2462 | }
2463 | }
2464 | ```
2465 |
2466 | [← Previous Page Authorize with AshJsonApi](authorize-with-json-api.html)
2467 |
2468 | [Next Page → DSL: AshJsonApi.Resource](dsl-ashjsonapi-resource.html)
2469 |
2470 | [Hex Package](https://hex.pm/packages/ash_json_api/1.4.16) [Hex Preview](https://preview.hex.pm/preview/ash_json_api/1.4.16) ([current file](https://preview.hex.pm/preview/ash_json_api/1.4.16/show/documentation/topics/authenticate-with-json-api.md)) Search HexDocs [Download ePub version](ash_json_api.epub "ePub version")
2471 |
2472 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.31.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
2473 | [](https://github.com/ash-project/ash_json_api)
2474 |
2475 | [ash\_json\_api](https://github.com/ash-project/ash_json_api)
2476 |
2477 | v1.4.16
2478 |
2479 | - Pages
2480 | - Modules
2481 | - Mix Tasks
2482 |
2483 | <!--THE END-->
2484 |
2485 | <!--THE END-->
2486 |
2487 | <!--THE END-->
2488 |
2489 | Search documentation of ash\_json\_api
2490 |
2491 | Settings
2492 |
2493 | # [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/documentation/topics/authorize-with-json-api.md#L1 "View Source") Authorize with AshJsonApi
2494 |
2495 | By default, `authorize?` in the domain is set to true. To disable authorization entirely for a given domain in graphql, use:
2496 |
2497 | ```
2498 | json_api do
2499 | authorize? false
2500 | end
2501 | ```
2502 |
2503 | This is typically only necessary for testing purposes.
2504 |
2505 | If you are doing authorization, you'll need to provide an `actor`.
2506 |
2507 | ## [](authorize-with-json-api.html#setting-the-actor-manually)Setting the actor manually
2508 |
2509 | If you are using AshAuthentication, this will be done for you. To set the `actor` for authorization, you'll need to add an `actor` key to the `conn`. Typically, you would have a plug that fetches the current user and uses [`Ash.PlugHelpers.set_actor/2`](../ash/3.4.47/Ash.PlugHelpers.html#set_actor/2) to set the actor in the `conn` (likewise with [`Ash.PlugHelpers.set_tenant/2`](../ash/3.4.47/Ash.PlugHelpers.html#set_tenant/2)).
2510 |
2511 | ```
2512 | defmodule MyAppWeb.Router do
2513 | pipeline :api do
2514 | # ...
2515 | plug :get_actor_from_token
2516 | end
2517 |
2518 | def get_actor_from_token(conn, _opts) do
2519 | with ["" <> token] <- get_req_header(conn, "authorization"),
2520 | {:ok, user, _claims} <- MyApp.Guardian.resource_from_token(token) do
2521 | conn
2522 | |> Ash.PlugHelpers.set_actor(user)
2523 | else
2524 | _ -> conn
2525 | end
2526 | end
2527 | end
2528 | ```
2529 |
2530 | [← Previous Page Upgrading to AshJsonApi to 1.0](upgrade.html)
2531 |
2532 | [Next Page → Authenticating with AshJsonApi](authenticate-with-json-api.html)
2533 |
2534 | [Hex Package](https://hex.pm/packages/ash_json_api/1.4.16) [Hex Preview](https://preview.hex.pm/preview/ash_json_api/1.4.16) ([current file](https://preview.hex.pm/preview/ash_json_api/1.4.16/show/documentation/topics/authorize-with-json-api.md)) Search HexDocs [Download ePub version](ash_json_api.epub "ePub version")
2535 |
2536 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.31.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
2537 | [](https://github.com/ash-project/ash_json_api)
2538 |
2539 | [ash\_json\_api](https://github.com/ash-project/ash_json_api)
2540 |
2541 | v1.4.16
2542 |
2543 | - Pages
2544 | - Modules
2545 | - Mix Tasks
2546 |
2547 | <!--THE END-->
2548 |
2549 | <!--THE END-->
2550 |
2551 | <!--THE END-->
2552 |
2553 | Search documentation of ash\_json\_api
2554 |
2555 | Settings
2556 |
2557 | # [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/documentation/dsls/DSL-AshJsonApi.Domain.md#L1 "View Source") DSL: AshJsonApi.Domain
2558 |
2559 | The entrypoint for adding JSON:API behavior to an Ash domain
2560 |
2561 | ## [](dsl-ashjsonapi-domain.html#json_api)json\_api
2562 |
2563 | Global configuration for JSON:API
2564 |
2565 | ### [](dsl-ashjsonapi-domain.html#nested-dsls)Nested DSLs
2566 |
2567 | - [open\_api](dsl-ashjsonapi-domain.html#json_api-open_api)
2568 | - [routes](dsl-ashjsonapi-domain.html#json_api-routes)
2569 |
2570 | - base\_route
2571 |
2572 | - get
2573 | - index
2574 | - post
2575 | - patch
2576 | - delete
2577 | - related
2578 | - relationship
2579 | - post\_to\_relationship
2580 | - patch\_relationship
2581 | - delete\_from\_relationship
2582 | - route
2583 | - get
2584 | - index
2585 | - post
2586 | - patch
2587 | - delete
2588 | - related
2589 | - relationship
2590 | - post\_to\_relationship
2591 | - patch\_relationship
2592 | - delete\_from\_relationship
2593 | - route
2594 |
2595 | ### [](dsl-ashjsonapi-domain.html#examples)Examples
2596 |
2597 | ```
2598 | json_api do
2599 | prefix "/json_api"
2600 | log_errors? true
2601 | end
2602 | ```
2603 |
2604 | ### [](dsl-ashjsonapi-domain.html#options)Options
2605 |
2606 | NameTypeDefaultDocs[`router`](dsl-ashjsonapi-domain.html#json_api-router)`atom`The router that you created for this Domain. Used by test helpers to send requests[`show_raised_errors?`](dsl-ashjsonapi-domain.html#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`](dsl-ashjsonapi-domain.html#json_api-prefix)`String.t`The route prefix at which you are serving the JSON:API[`serve_schema?`](dsl-ashjsonapi-domain.html#json_api-serve_schema?)`boolean``false`Whether or not create a /schema route that serves the JSON schema of your API[`authorize?`](dsl-ashjsonapi-domain.html#json_api-authorize?)`boolean``true`Whether or not to perform authorization on requests.[`log_errors?`](dsl-ashjsonapi-domain.html#json_api-log_errors?)`boolean``true`Whether or not to log any errors produced[`include_nil_values?`](dsl-ashjsonapi-domain.html#json_api-include_nil_values?)`boolean``true`Whether or not to include properties for values that are nil in the JSON output
2607 |
2608 | ## [](dsl-ashjsonapi-domain.html#json_api-open_api)json\_api.open\_api
2609 |
2610 | OpenAPI configurations
2611 |
2612 | ### [](dsl-ashjsonapi-domain.html#examples-1)Examples
2613 |
2614 | ```
2615 | json_api do
2616 | ...
2617 | open_api do
2618 | tag "Users"
2619 | group_by :api
2620 | end
2621 | end
2622 | ```
2623 |
2624 | ### [](dsl-ashjsonapi-domain.html#options-1)Options
2625 |
2626 | NameTypeDefaultDocs[`tag`](dsl-ashjsonapi-domain.html#json_api-open_api-tag)`String.t`Tag to be used when used by :group\_by[`group_by`](dsl-ashjsonapi-domain.html#json_api-open_api-group_by)`:domain | :resource``:resource`Group by :domain or :resource
2627 |
2628 | ## [](dsl-ashjsonapi-domain.html#json_api-routes)json\_api.routes
2629 |
2630 | Configure the routes that will be exposed via the JSON:API
2631 |
2632 | ### [](dsl-ashjsonapi-domain.html#nested-dsls-1)Nested DSLs
2633 |
2634 | - [base\_route](dsl-ashjsonapi-domain.html#json_api-routes-base_route)
2635 |
2636 | - get
2637 | - index
2638 | - post
2639 | - patch
2640 | - delete
2641 | - related
2642 | - relationship
2643 | - post\_to\_relationship
2644 | - patch\_relationship
2645 | - delete\_from\_relationship
2646 | - route
2647 | - [get](dsl-ashjsonapi-domain.html#json_api-routes-get)
2648 | - [index](dsl-ashjsonapi-domain.html#json_api-routes-index)
2649 | - [post](dsl-ashjsonapi-domain.html#json_api-routes-post)
2650 | - [patch](dsl-ashjsonapi-domain.html#json_api-routes-patch)
2651 | - [delete](dsl-ashjsonapi-domain.html#json_api-routes-delete)
2652 | - [related](dsl-ashjsonapi-domain.html#json_api-routes-related)
2653 | - [relationship](dsl-ashjsonapi-domain.html#json_api-routes-relationship)
2654 | - [post\_to\_relationship](dsl-ashjsonapi-domain.html#json_api-routes-post_to_relationship)
2655 | - [patch\_relationship](dsl-ashjsonapi-domain.html#json_api-routes-patch_relationship)
2656 | - [delete\_from\_relationship](dsl-ashjsonapi-domain.html#json_api-routes-delete_from_relationship)
2657 | - [route](dsl-ashjsonapi-domain.html#json_api-routes-route)
2658 |
2659 | ### [](dsl-ashjsonapi-domain.html#examples-2)Examples
2660 |
2661 | ```
2662 | routes do
2663 | base "/posts"
2664 |
2665 | get :read
2666 | get :me, route: "/me"
2667 | index :read
2668 | post :confirm_name, route: "/confirm_name"
2669 | patch :update
2670 | related :comments, :read
2671 | relationship :comments, :read
2672 | post_to_relationship :comments
2673 | patch_relationship :comments
2674 | delete_from_relationship :comments
2675 | end
2676 | ```
2677 |
2678 | ## [](dsl-ashjsonapi-domain.html#json_api-routes-base_route)json\_api.routes.base\_route
2679 |
2680 | ```
2681 | base_route route, resource \\ nil
2682 | ```
2683 |
2684 | Sets a prefix for a list of contained routes
2685 |
2686 | ### [](dsl-ashjsonapi-domain.html#nested-dsls-2)Nested DSLs
2687 |
2688 | - [get](dsl-ashjsonapi-domain.html#json_api-routes-base_route-get)
2689 | - [index](dsl-ashjsonapi-domain.html#json_api-routes-base_route-index)
2690 | - [post](dsl-ashjsonapi-domain.html#json_api-routes-base_route-post)
2691 | - [patch](dsl-ashjsonapi-domain.html#json_api-routes-base_route-patch)
2692 | - [delete](dsl-ashjsonapi-domain.html#json_api-routes-base_route-delete)
2693 | - [related](dsl-ashjsonapi-domain.html#json_api-routes-base_route-related)
2694 | - [relationship](dsl-ashjsonapi-domain.html#json_api-routes-base_route-relationship)
2695 | - [post\_to\_relationship](dsl-ashjsonapi-domain.html#json_api-routes-base_route-post_to_relationship)
2696 | - [patch\_relationship](dsl-ashjsonapi-domain.html#json_api-routes-base_route-patch_relationship)
2697 | - [delete\_from\_relationship](dsl-ashjsonapi-domain.html#json_api-routes-base_route-delete_from_relationship)
2698 | - [route](dsl-ashjsonapi-domain.html#json_api-routes-base_route-route)
2699 |
2700 | ### [](dsl-ashjsonapi-domain.html#examples-3)Examples
2701 |
2702 | ```
2703 | base_route "/posts" do
2704 | index :read
2705 | get :read
2706 | end
2707 |
2708 | base_route "/comments" do
2709 | index :read
2710 | end
2711 | ```
2712 |
2713 | ### [](dsl-ashjsonapi-domain.html#arguments)Arguments
2714 |
2715 | NameTypeDefaultDocs[`route`](dsl-ashjsonapi-domain.html#json_api-routes-base_route-route)`String.t`The route prefix to use for contained routes[`resource`](dsl-ashjsonapi-domain.html#json_api-routes-base_route-resource)`module`The resource that the contained routes will use by default
2716 |
2717 | ## [](dsl-ashjsonapi-domain.html#json_api-routes-base_route-get)json\_api.routes.base\_route.get
2718 |
2719 | ```
2720 | get resource \\ nil, action
2721 | ```
2722 |
2723 | A GET route to retrieve a single record
2724 |
2725 | ### [](dsl-ashjsonapi-domain.html#examples-4)Examples
2726 |
2727 | ```
2728 | get :read
2729 | ```
2730 |
2731 | ### [](dsl-ashjsonapi-domain.html#arguments-1)Arguments
2732 |
2733 | NameTypeDefaultDocs[`resource`](dsl-ashjsonapi-domain.html#json_api-routes-base_route-get-resource)`module`The resource that the route's action is defined on[`action`](dsl-ashjsonapi-domain.html#json_api-routes-base_route-get-action)`atom`The action to call when this route is hit
2734 |
2735 | ### [](dsl-ashjsonapi-domain.html#options-2)Options
2736 |
2737 | NameTypeDefaultDocs[`route`](dsl-ashjsonapi-domain.html#json_api-routes-base_route-get-route)`String.t``"/:id"`The path of the route[`default_fields`](dsl-ashjsonapi-domain.html#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?`](dsl-ashjsonapi-domain.html#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`](dsl-ashjsonapi-domain.html#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`](dsl-ashjsonapi-domain.html#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`[`name`](dsl-ashjsonapi-domain.html#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[`derive_sort?`](dsl-ashjsonapi-domain.html#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?`](dsl-ashjsonapi-domain.html#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
2738 |
2739 | ### [](dsl-ashjsonapi-domain.html#introspection)Introspection
2740 |
2741 | Target: [`AshJsonApi.Resource.Route`](AshJsonApi.Resource.Route.html)
2742 |
2743 | ## [](dsl-ashjsonapi-domain.html#json_api-routes-base_route-index)json\_api.routes.base\_route.index
2744 |
2745 | ```
2746 | index resource \\ nil, action
2747 | ```
2748 |
2749 | A GET route to retrieve a list of records
2750 |
2751 | ### [](dsl-ashjsonapi-domain.html#examples-5)Examples
2752 |
2753 | ```
2754 | index :read
2755 | ```
2756 |
2757 | ### [](dsl-ashjsonapi-domain.html#arguments-2)Arguments
2758 |
2759 | NameTypeDefaultDocs[`resource`](dsl-ashjsonapi-domain.html#json_api-routes-base_route-index-resource)`module`The resource that the route's action is defined on[`action`](dsl-ashjsonapi-domain.html#json_api-routes-base_route-index-action)`atom`The action to call when this route is hit
2760 |
2761 | ### [](dsl-ashjsonapi-domain.html#options-3)Options
2762 |
2763 | NameTypeDefaultDocs[`paginate?`](dsl-ashjsonapi-domain.html#json_api-routes-base_route-index-paginate?)`boolean``true`[`route`](dsl-ashjsonapi-domain.html#json_api-routes-base_route-index-route)`String.t``"/"`The path of the route[`default_fields`](dsl-ashjsonapi-domain.html#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?`](dsl-ashjsonapi-domain.html#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`](dsl-ashjsonapi-domain.html#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`](dsl-ashjsonapi-domain.html#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`[`name`](dsl-ashjsonapi-domain.html#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[`derive_sort?`](dsl-ashjsonapi-domain.html#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?`](dsl-ashjsonapi-domain.html#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
2764 |
2765 | ### [](dsl-ashjsonapi-domain.html#introspection-1)Introspection
2766 |
2767 | Target: [`AshJsonApi.Resource.Route`](AshJsonApi.Resource.Route.html)
2768 |
2769 | ## [](dsl-ashjsonapi-domain.html#json_api-routes-base_route-post)json\_api.routes.base\_route.post
2770 |
2771 | ```
2772 | post resource \\ nil, action
2773 | ```
2774 |
2775 | A POST route to create a record
2776 |
2777 | ### [](dsl-ashjsonapi-domain.html#examples-6)Examples
2778 |
2779 | ```
2780 | post :create
2781 | ```
2782 |
2783 | ### [](dsl-ashjsonapi-domain.html#arguments-3)Arguments
2784 |
2785 | NameTypeDefaultDocs[`resource`](dsl-ashjsonapi-domain.html#json_api-routes-base_route-post-resource)`module`The resource that the route's action is defined on[`action`](dsl-ashjsonapi-domain.html#json_api-routes-base_route-post-action)`atom`The action to call when this route is hit
2786 |
2787 | ### [](dsl-ashjsonapi-domain.html#options-4)Options
2788 |
2789 | NameTypeDefaultDocs[`route`](dsl-ashjsonapi-domain.html#json_api-routes-base_route-post-route)`String.t``"/"`The path of the route[`default_fields`](dsl-ashjsonapi-domain.html#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?`](dsl-ashjsonapi-domain.html#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`](dsl-ashjsonapi-domain.html#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`](dsl-ashjsonapi-domain.html#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`[`query_params`](dsl-ashjsonapi-domain.html#json_api-routes-base_route-post-query_params)`list(atom)``[]`A list of action inputs to accept as query parameters.[`name`](dsl-ashjsonapi-domain.html#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[`derive_sort?`](dsl-ashjsonapi-domain.html#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?`](dsl-ashjsonapi-domain.html#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[`relationship_arguments`](dsl-ashjsonapi-domain.html#json_api-routes-base_route-post-relationship_arguments)`list(atom | {:id, atom})``[]`Arguments to be used to edit relationships. See the [relationships guide](relationships.html) for more.[`upsert?`](dsl-ashjsonapi-domain.html#json_api-routes-base_route-post-upsert?)`boolean``false`Whether or not to use the `upsert?: true` option when calling [`Ash.create/2`](../ash/3.4.47/Ash.html#create/2).[`upsert_identity`](dsl-ashjsonapi-domain.html#json_api-routes-base_route-post-upsert_identity)`atom``false`Which identity to use for the upsert
2790 |
2791 | ### [](dsl-ashjsonapi-domain.html#introspection-2)Introspection
2792 |
2793 | Target: [`AshJsonApi.Resource.Route`](AshJsonApi.Resource.Route.html)
2794 |
2795 | ## [](dsl-ashjsonapi-domain.html#json_api-routes-base_route-patch)json\_api.routes.base\_route.patch
2796 |
2797 | ```
2798 | patch resource \\ nil, action
2799 | ```
2800 |
2801 | A PATCH route to update a record
2802 |
2803 | ### [](dsl-ashjsonapi-domain.html#examples-7)Examples
2804 |
2805 | ```
2806 | patch :update
2807 | ```
2808 |
2809 | ### [](dsl-ashjsonapi-domain.html#arguments-4)Arguments
2810 |
2811 | NameTypeDefaultDocs[`resource`](dsl-ashjsonapi-domain.html#json_api-routes-base_route-patch-resource)`module`The resource that the route's action is defined on[`action`](dsl-ashjsonapi-domain.html#json_api-routes-base_route-patch-action)`atom`The action to call when this route is hit
2812 |
2813 | ### [](dsl-ashjsonapi-domain.html#options-5)Options
2814 |
2815 | NameTypeDefaultDocs[`relationship_arguments`](dsl-ashjsonapi-domain.html#json_api-routes-base_route-patch-relationship_arguments)`any``[]`Arguments to be used to edit relationships. See the [relationships guide](relationships.html) for more.[`read_action`](dsl-ashjsonapi-domain.html#json_api-routes-base_route-patch-read_action)`atom`The read action to use to look the record up before updating[`route`](dsl-ashjsonapi-domain.html#json_api-routes-base_route-patch-route)`String.t``"/:id"`The path of the route[`default_fields`](dsl-ashjsonapi-domain.html#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?`](dsl-ashjsonapi-domain.html#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`](dsl-ashjsonapi-domain.html#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`](dsl-ashjsonapi-domain.html#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`[`query_params`](dsl-ashjsonapi-domain.html#json_api-routes-base_route-patch-query_params)`list(atom)``[]`A list of action inputs to accept as query parameters.[`name`](dsl-ashjsonapi-domain.html#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[`derive_sort?`](dsl-ashjsonapi-domain.html#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?`](dsl-ashjsonapi-domain.html#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
2816 |
2817 | ### [](dsl-ashjsonapi-domain.html#introspection-3)Introspection
2818 |
2819 | Target: [`AshJsonApi.Resource.Route`](AshJsonApi.Resource.Route.html)
2820 |
2821 | ## [](dsl-ashjsonapi-domain.html#json_api-routes-base_route-delete)json\_api.routes.base\_route.delete
2822 |
2823 | ```
2824 | delete resource \\ nil, action
2825 | ```
2826 |
2827 | A DELETE route to destroy a record
2828 |
2829 | ### [](dsl-ashjsonapi-domain.html#examples-8)Examples
2830 |
2831 | ```
2832 | delete :destroy
2833 | ```
2834 |
2835 | ### [](dsl-ashjsonapi-domain.html#arguments-5)Arguments
2836 |
2837 | NameTypeDefaultDocs[`resource`](dsl-ashjsonapi-domain.html#json_api-routes-base_route-delete-resource)`module`The resource that the route's action is defined on[`action`](dsl-ashjsonapi-domain.html#json_api-routes-base_route-delete-action)`atom`The action to call when this route is hit
2838 |
2839 | ### [](dsl-ashjsonapi-domain.html#options-6)Options
2840 |
2841 | NameTypeDefaultDocs[`read_action`](dsl-ashjsonapi-domain.html#json_api-routes-base_route-delete-read_action)`atom`The read action to use to look the record up before updating[`route`](dsl-ashjsonapi-domain.html#json_api-routes-base_route-delete-route)`String.t``"/:id"`The path of the route[`default_fields`](dsl-ashjsonapi-domain.html#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?`](dsl-ashjsonapi-domain.html#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`](dsl-ashjsonapi-domain.html#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`](dsl-ashjsonapi-domain.html#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`[`query_params`](dsl-ashjsonapi-domain.html#json_api-routes-base_route-delete-query_params)`list(atom)``[]`A list of action inputs to accept as query parameters.[`name`](dsl-ashjsonapi-domain.html#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[`derive_sort?`](dsl-ashjsonapi-domain.html#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?`](dsl-ashjsonapi-domain.html#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
2842 |
2843 | ### [](dsl-ashjsonapi-domain.html#introspection-4)Introspection
2844 |
2845 | Target: [`AshJsonApi.Resource.Route`](AshJsonApi.Resource.Route.html)
2846 |
2847 | ## [](dsl-ashjsonapi-domain.html#json_api-routes-base_route-related)json\_api.routes.base\_route.related
2848 |
2849 | ```
2850 | related resource \\ nil, relationship, action
2851 | ```
2852 |
2853 | A GET route to read the related resources of a relationship
2854 |
2855 | ### [](dsl-ashjsonapi-domain.html#examples-9)Examples
2856 |
2857 | ```
2858 | related :comments, :read
2859 | ```
2860 |
2861 | ### [](dsl-ashjsonapi-domain.html#arguments-6)Arguments
2862 |
2863 | NameTypeDefaultDocs[`resource`](dsl-ashjsonapi-domain.html#json_api-routes-base_route-related-resource)`module`The resource that the route's action is defined on[`relationship`](dsl-ashjsonapi-domain.html#json_api-routes-base_route-related-relationship)`atom`[`action`](dsl-ashjsonapi-domain.html#json_api-routes-base_route-related-action)`atom`The action to call when this route is hit
2864 |
2865 | ### [](dsl-ashjsonapi-domain.html#options-7)Options
2866 |
2867 | NameTypeDefaultDocs[`route`](dsl-ashjsonapi-domain.html#json_api-routes-base_route-related-route)`String.t`The path of the route - Defaults to /:id/\[relationship\_name][`default_fields`](dsl-ashjsonapi-domain.html#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?`](dsl-ashjsonapi-domain.html#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`](dsl-ashjsonapi-domain.html#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`](dsl-ashjsonapi-domain.html#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`[`query_params`](dsl-ashjsonapi-domain.html#json_api-routes-base_route-related-query_params)`list(atom)``[]`A list of action inputs to accept as query parameters.[`name`](dsl-ashjsonapi-domain.html#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[`derive_sort?`](dsl-ashjsonapi-domain.html#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?`](dsl-ashjsonapi-domain.html#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
2868 |
2869 | ### [](dsl-ashjsonapi-domain.html#introspection-5)Introspection
2870 |
2871 | Target: [`AshJsonApi.Resource.Route`](AshJsonApi.Resource.Route.html)
2872 |
2873 | ## [](dsl-ashjsonapi-domain.html#json_api-routes-base_route-relationship)json\_api.routes.base\_route.relationship
2874 |
2875 | ```
2876 | relationship resource \\ nil, relationship, action
2877 | ```
2878 |
2879 | A READ route to read the relationship, returns resource identifiers.
2880 |
2881 | ### [](dsl-ashjsonapi-domain.html#examples-10)Examples
2882 |
2883 | ```
2884 | relationship :comments, :read
2885 | ```
2886 |
2887 | ### [](dsl-ashjsonapi-domain.html#arguments-7)Arguments
2888 |
2889 | NameTypeDefaultDocs[`resource`](dsl-ashjsonapi-domain.html#json_api-routes-base_route-relationship-resource)`module`The resource that the route's action is defined on[`relationship`](dsl-ashjsonapi-domain.html#json_api-routes-base_route-relationship-relationship)`atom`[`action`](dsl-ashjsonapi-domain.html#json_api-routes-base_route-relationship-action)`atom`The action to call when this route is hit
2890 |
2891 | ### [](dsl-ashjsonapi-domain.html#options-8)Options
2892 |
2893 | NameTypeDefaultDocs[`route`](dsl-ashjsonapi-domain.html#json_api-routes-base_route-relationship-route)`String.t`The path of the route - Defaults to /:id/relationships/\[relationship\_name][`default_fields`](dsl-ashjsonapi-domain.html#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?`](dsl-ashjsonapi-domain.html#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`](dsl-ashjsonapi-domain.html#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`](dsl-ashjsonapi-domain.html#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`[`query_params`](dsl-ashjsonapi-domain.html#json_api-routes-base_route-relationship-query_params)`list(atom)``[]`A list of action inputs to accept as query parameters.[`name`](dsl-ashjsonapi-domain.html#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[`derive_sort?`](dsl-ashjsonapi-domain.html#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?`](dsl-ashjsonapi-domain.html#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
2894 |
2895 | ### [](dsl-ashjsonapi-domain.html#introspection-6)Introspection
2896 |
2897 | Target: [`AshJsonApi.Resource.Route`](AshJsonApi.Resource.Route.html)
2898 |
2899 | ## [](dsl-ashjsonapi-domain.html#json_api-routes-base_route-post_to_relationship)json\_api.routes.base\_route.post\_to\_relationship
2900 |
2901 | ```
2902 | post_to_relationship resource \\ nil, relationship
2903 | ```
2904 |
2905 | A POST route to create related entities using resource identifiers
2906 |
2907 | ### [](dsl-ashjsonapi-domain.html#examples-11)Examples
2908 |
2909 | ```
2910 | post_to_relationship :comments
2911 | ```
2912 |
2913 | ### [](dsl-ashjsonapi-domain.html#arguments-8)Arguments
2914 |
2915 | NameTypeDefaultDocs[`resource`](dsl-ashjsonapi-domain.html#json_api-routes-base_route-post_to_relationship-resource)`module`The resource that the route's action is defined on[`relationship`](dsl-ashjsonapi-domain.html#json_api-routes-base_route-post_to_relationship-relationship)`atom`
2916 |
2917 | ### [](dsl-ashjsonapi-domain.html#options-9)Options
2918 |
2919 | NameTypeDefaultDocs[`route`](dsl-ashjsonapi-domain.html#json_api-routes-base_route-post_to_relationship-route)`String.t`The path of the route - Defaults to /:id/relationships/\[relationship\_name][`default_fields`](dsl-ashjsonapi-domain.html#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?`](dsl-ashjsonapi-domain.html#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`](dsl-ashjsonapi-domain.html#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`](dsl-ashjsonapi-domain.html#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`[`query_params`](dsl-ashjsonapi-domain.html#json_api-routes-base_route-post_to_relationship-query_params)`list(atom)``[]`A list of action inputs to accept as query parameters.[`name`](dsl-ashjsonapi-domain.html#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[`derive_sort?`](dsl-ashjsonapi-domain.html#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?`](dsl-ashjsonapi-domain.html#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
2920 |
2921 | ### [](dsl-ashjsonapi-domain.html#introspection-7)Introspection
2922 |
2923 | Target: [`AshJsonApi.Resource.Route`](AshJsonApi.Resource.Route.html)
2924 |
2925 | ## [](dsl-ashjsonapi-domain.html#json_api-routes-base_route-patch_relationship)json\_api.routes.base\_route.patch\_relationship
2926 |
2927 | ```
2928 | patch_relationship resource \\ nil, relationship
2929 | ```
2930 |
2931 | A PATCH route to update a relationship using resource identifiers
2932 |
2933 | ### [](dsl-ashjsonapi-domain.html#examples-12)Examples
2934 |
2935 | ```
2936 | patch_relationship :comments
2937 | ```
2938 |
2939 | ### [](dsl-ashjsonapi-domain.html#arguments-9)Arguments
2940 |
2941 | NameTypeDefaultDocs[`resource`](dsl-ashjsonapi-domain.html#json_api-routes-base_route-patch_relationship-resource)`module`The resource that the route's action is defined on[`relationship`](dsl-ashjsonapi-domain.html#json_api-routes-base_route-patch_relationship-relationship)`atom`
2942 |
2943 | ### [](dsl-ashjsonapi-domain.html#options-10)Options
2944 |
2945 | NameTypeDefaultDocs[`route`](dsl-ashjsonapi-domain.html#json_api-routes-base_route-patch_relationship-route)`String.t`The path of the route - Defaults to /:id/relationships/\[relationship\_name][`default_fields`](dsl-ashjsonapi-domain.html#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?`](dsl-ashjsonapi-domain.html#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`](dsl-ashjsonapi-domain.html#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`](dsl-ashjsonapi-domain.html#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`[`query_params`](dsl-ashjsonapi-domain.html#json_api-routes-base_route-patch_relationship-query_params)`list(atom)``[]`A list of action inputs to accept as query parameters.[`name`](dsl-ashjsonapi-domain.html#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[`derive_sort?`](dsl-ashjsonapi-domain.html#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?`](dsl-ashjsonapi-domain.html#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
2946 |
2947 | ### [](dsl-ashjsonapi-domain.html#introspection-8)Introspection
2948 |
2949 | Target: [`AshJsonApi.Resource.Route`](AshJsonApi.Resource.Route.html)
2950 |
2951 | ## [](dsl-ashjsonapi-domain.html#json_api-routes-base_route-delete_from_relationship)json\_api.routes.base\_route.delete\_from\_relationship
2952 |
2953 | ```
2954 | delete_from_relationship resource \\ nil, relationship
2955 | ```
2956 |
2957 | A DELETE route to remove related entities using resource identifiers
2958 |
2959 | ### [](dsl-ashjsonapi-domain.html#examples-13)Examples
2960 |
2961 | ```
2962 | delete_from_relationship :comments
2963 | ```
2964 |
2965 | ### [](dsl-ashjsonapi-domain.html#arguments-10)Arguments
2966 |
2967 | NameTypeDefaultDocs[`resource`](dsl-ashjsonapi-domain.html#json_api-routes-base_route-delete_from_relationship-resource)`module`The resource that the route's action is defined on[`relationship`](dsl-ashjsonapi-domain.html#json_api-routes-base_route-delete_from_relationship-relationship)`atom`
2968 |
2969 | ### [](dsl-ashjsonapi-domain.html#options-11)Options
2970 |
2971 | NameTypeDefaultDocs[`route`](dsl-ashjsonapi-domain.html#json_api-routes-base_route-delete_from_relationship-route)`String.t`The path of the route - Defaults to /:id/relationships/\[relationship\_name][`default_fields`](dsl-ashjsonapi-domain.html#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?`](dsl-ashjsonapi-domain.html#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`](dsl-ashjsonapi-domain.html#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`](dsl-ashjsonapi-domain.html#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`[`query_params`](dsl-ashjsonapi-domain.html#json_api-routes-base_route-delete_from_relationship-query_params)`list(atom)``[]`A list of action inputs to accept as query parameters.[`name`](dsl-ashjsonapi-domain.html#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[`derive_sort?`](dsl-ashjsonapi-domain.html#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?`](dsl-ashjsonapi-domain.html#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
2972 |
2973 | ### [](dsl-ashjsonapi-domain.html#introspection-9)Introspection
2974 |
2975 | Target: [`AshJsonApi.Resource.Route`](AshJsonApi.Resource.Route.html)
2976 |
2977 | ## [](dsl-ashjsonapi-domain.html#json_api-routes-base_route-route)json\_api.routes.base\_route.route
2978 |
2979 | ```
2980 | route resource \\ nil, method, route, action
2981 | ```
2982 |
2983 | A route for a generic action.
2984 |
2985 | ### [](dsl-ashjsonapi-domain.html#examples-14)Examples
2986 |
2987 | ```
2988 | route :get, "say_hi/:name", :say_hello
2989 | ```
2990 |
2991 | ### [](dsl-ashjsonapi-domain.html#arguments-11)Arguments
2992 |
2993 | NameTypeDefaultDocs[`resource`](dsl-ashjsonapi-domain.html#json_api-routes-base_route-route-resource)`module`The resource that the route's action is defined on[`method`](dsl-ashjsonapi-domain.html#json_api-routes-base_route-route-method)`atom`The HTTP method for the route, e.g `:get`, or `:post`[`route`](dsl-ashjsonapi-domain.html#json_api-routes-base_route-route-route)`String.t`The path of the route[`action`](dsl-ashjsonapi-domain.html#json_api-routes-base_route-route-action)`atom`The action to call when this route is hit
2994 |
2995 | ### [](dsl-ashjsonapi-domain.html#options-12)Options
2996 |
2997 | NameTypeDefaultDocs[`wrap_in_result?`](dsl-ashjsonapi-domain.html#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`](dsl-ashjsonapi-domain.html#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?`](dsl-ashjsonapi-domain.html#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`](dsl-ashjsonapi-domain.html#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`](dsl-ashjsonapi-domain.html#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`[`query_params`](dsl-ashjsonapi-domain.html#json_api-routes-base_route-route-query_params)`list(atom)``[]`A list of action inputs to accept as query parameters.[`name`](dsl-ashjsonapi-domain.html#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[`derive_sort?`](dsl-ashjsonapi-domain.html#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?`](dsl-ashjsonapi-domain.html#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
2998 |
2999 | ### [](dsl-ashjsonapi-domain.html#introspection-10)Introspection
3000 |
3001 | Target: [`AshJsonApi.Resource.Route`](AshJsonApi.Resource.Route.html)
3002 |
3003 | ### [](dsl-ashjsonapi-domain.html#introspection-11)Introspection
3004 |
3005 | Target: [`AshJsonApi.Domain.BaseRoute`](AshJsonApi.Domain.BaseRoute.html)
3006 |
3007 | ## [](dsl-ashjsonapi-domain.html#json_api-routes-get)json\_api.routes.get
3008 |
3009 | ```
3010 | get resource, action
3011 | ```
3012 |
3013 | A GET route to retrieve a single record
3014 |
3015 | ### [](dsl-ashjsonapi-domain.html#examples-15)Examples
3016 |
3017 | ```
3018 | get :read
3019 | ```
3020 |
3021 | ### [](dsl-ashjsonapi-domain.html#arguments-12)Arguments
3022 |
3023 | NameTypeDefaultDocs[`resource`](dsl-ashjsonapi-domain.html#json_api-routes-get-resource)`module`The resource that the route's action is defined on[`action`](dsl-ashjsonapi-domain.html#json_api-routes-get-action)`atom`The action to call when this route is hit
3024 |
3025 | ### [](dsl-ashjsonapi-domain.html#options-13)Options
3026 |
3027 | NameTypeDefaultDocs[`route`](dsl-ashjsonapi-domain.html#json_api-routes-get-route)`String.t``"/:id"`The path of the route[`default_fields`](dsl-ashjsonapi-domain.html#json_api-routes-get-default_fields)`list(atom)`A list of fields to be shown in the attributes of the called route[`primary?`](dsl-ashjsonapi-domain.html#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`](dsl-ashjsonapi-domain.html#json_api-routes-get-metadata)`(any, any, any -> any)`A function to generate arbitrary top-level metadata for the JSON:API response[`modify_conn`](dsl-ashjsonapi-domain.html#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`[`name`](dsl-ashjsonapi-domain.html#json_api-routes-get-name)`String.t`A globally unique name for this route, to be used when generating docs and open api specifications[`derive_sort?`](dsl-ashjsonapi-domain.html#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?`](dsl-ashjsonapi-domain.html#json_api-routes-get-derive_filter?)`boolean``true`Whether or not to derive a filter parameter based on the sortable fields of the resource
3028 |
3029 | ### [](dsl-ashjsonapi-domain.html#introspection-12)Introspection
3030 |
3031 | Target: [`AshJsonApi.Resource.Route`](AshJsonApi.Resource.Route.html)
3032 |
3033 | ## [](dsl-ashjsonapi-domain.html#json_api-routes-index)json\_api.routes.index
3034 |
3035 | ```
3036 | index resource, action
3037 | ```
3038 |
3039 | A GET route to retrieve a list of records
3040 |
3041 | ### [](dsl-ashjsonapi-domain.html#examples-16)Examples
3042 |
3043 | ```
3044 | index :read
3045 | ```
3046 |
3047 | ### [](dsl-ashjsonapi-domain.html#arguments-13)Arguments
3048 |
3049 | NameTypeDefaultDocs[`resource`](dsl-ashjsonapi-domain.html#json_api-routes-index-resource)`module`The resource that the route's action is defined on[`action`](dsl-ashjsonapi-domain.html#json_api-routes-index-action)`atom`The action to call when this route is hit
3050 |
3051 | ### [](dsl-ashjsonapi-domain.html#options-14)Options
3052 |
3053 | NameTypeDefaultDocs[`paginate?`](dsl-ashjsonapi-domain.html#json_api-routes-index-paginate?)`boolean``true`[`route`](dsl-ashjsonapi-domain.html#json_api-routes-index-route)`String.t``"/"`The path of the route[`default_fields`](dsl-ashjsonapi-domain.html#json_api-routes-index-default_fields)`list(atom)`A list of fields to be shown in the attributes of the called route[`primary?`](dsl-ashjsonapi-domain.html#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`](dsl-ashjsonapi-domain.html#json_api-routes-index-metadata)`(any, any, any -> any)`A function to generate arbitrary top-level metadata for the JSON:API response[`modify_conn`](dsl-ashjsonapi-domain.html#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`[`name`](dsl-ashjsonapi-domain.html#json_api-routes-index-name)`String.t`A globally unique name for this route, to be used when generating docs and open api specifications[`derive_sort?`](dsl-ashjsonapi-domain.html#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?`](dsl-ashjsonapi-domain.html#json_api-routes-index-derive_filter?)`boolean``true`Whether or not to derive a filter parameter based on the sortable fields of the resource
3054 |
3055 | ### [](dsl-ashjsonapi-domain.html#introspection-13)Introspection
3056 |
3057 | Target: [`AshJsonApi.Resource.Route`](AshJsonApi.Resource.Route.html)
3058 |
3059 | ## [](dsl-ashjsonapi-domain.html#json_api-routes-post)json\_api.routes.post
3060 |
3061 | ```
3062 | post resource, action
3063 | ```
3064 |
3065 | A POST route to create a record
3066 |
3067 | ### [](dsl-ashjsonapi-domain.html#examples-17)Examples
3068 |
3069 | ```
3070 | post :create
3071 | ```
3072 |
3073 | ### [](dsl-ashjsonapi-domain.html#arguments-14)Arguments
3074 |
3075 | NameTypeDefaultDocs[`resource`](dsl-ashjsonapi-domain.html#json_api-routes-post-resource)`module`The resource that the route's action is defined on[`action`](dsl-ashjsonapi-domain.html#json_api-routes-post-action)`atom`The action to call when this route is hit
3076 |
3077 | ### [](dsl-ashjsonapi-domain.html#options-15)Options
3078 |
3079 | NameTypeDefaultDocs[`route`](dsl-ashjsonapi-domain.html#json_api-routes-post-route)`String.t``"/"`The path of the route[`default_fields`](dsl-ashjsonapi-domain.html#json_api-routes-post-default_fields)`list(atom)`A list of fields to be shown in the attributes of the called route[`primary?`](dsl-ashjsonapi-domain.html#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`](dsl-ashjsonapi-domain.html#json_api-routes-post-metadata)`(any, any, any -> any)`A function to generate arbitrary top-level metadata for the JSON:API response[`modify_conn`](dsl-ashjsonapi-domain.html#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`[`query_params`](dsl-ashjsonapi-domain.html#json_api-routes-post-query_params)`list(atom)``[]`A list of action inputs to accept as query parameters.[`name`](dsl-ashjsonapi-domain.html#json_api-routes-post-name)`String.t`A globally unique name for this route, to be used when generating docs and open api specifications[`derive_sort?`](dsl-ashjsonapi-domain.html#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?`](dsl-ashjsonapi-domain.html#json_api-routes-post-derive_filter?)`boolean``true`Whether or not to derive a filter parameter based on the sortable fields of the resource[`relationship_arguments`](dsl-ashjsonapi-domain.html#json_api-routes-post-relationship_arguments)`list(atom | {:id, atom})``[]`Arguments to be used to edit relationships. See the [relationships guide](relationships.html) for more.[`upsert?`](dsl-ashjsonapi-domain.html#json_api-routes-post-upsert?)`boolean``false`Whether or not to use the `upsert?: true` option when calling [`Ash.create/2`](../ash/3.4.47/Ash.html#create/2).[`upsert_identity`](dsl-ashjsonapi-domain.html#json_api-routes-post-upsert_identity)`atom``false`Which identity to use for the upsert
3080 |
3081 | ### [](dsl-ashjsonapi-domain.html#introspection-14)Introspection
3082 |
3083 | Target: [`AshJsonApi.Resource.Route`](AshJsonApi.Resource.Route.html)
3084 |
3085 | ## [](dsl-ashjsonapi-domain.html#json_api-routes-patch)json\_api.routes.patch
3086 |
3087 | ```
3088 | patch resource, action
3089 | ```
3090 |
3091 | A PATCH route to update a record
3092 |
3093 | ### [](dsl-ashjsonapi-domain.html#examples-18)Examples
3094 |
3095 | ```
3096 | patch :update
3097 | ```
3098 |
3099 | ### [](dsl-ashjsonapi-domain.html#arguments-15)Arguments
3100 |
3101 | NameTypeDefaultDocs[`resource`](dsl-ashjsonapi-domain.html#json_api-routes-patch-resource)`module`The resource that the route's action is defined on[`action`](dsl-ashjsonapi-domain.html#json_api-routes-patch-action)`atom`The action to call when this route is hit
3102 |
3103 | ### [](dsl-ashjsonapi-domain.html#options-16)Options
3104 |
3105 | NameTypeDefaultDocs[`relationship_arguments`](dsl-ashjsonapi-domain.html#json_api-routes-patch-relationship_arguments)`any``[]`Arguments to be used to edit relationships. See the [relationships guide](relationships.html) for more.[`read_action`](dsl-ashjsonapi-domain.html#json_api-routes-patch-read_action)`atom`The read action to use to look the record up before updating[`route`](dsl-ashjsonapi-domain.html#json_api-routes-patch-route)`String.t``"/:id"`The path of the route[`default_fields`](dsl-ashjsonapi-domain.html#json_api-routes-patch-default_fields)`list(atom)`A list of fields to be shown in the attributes of the called route[`primary?`](dsl-ashjsonapi-domain.html#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`](dsl-ashjsonapi-domain.html#json_api-routes-patch-metadata)`(any, any, any -> any)`A function to generate arbitrary top-level metadata for the JSON:API response[`modify_conn`](dsl-ashjsonapi-domain.html#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`[`query_params`](dsl-ashjsonapi-domain.html#json_api-routes-patch-query_params)`list(atom)``[]`A list of action inputs to accept as query parameters.[`name`](dsl-ashjsonapi-domain.html#json_api-routes-patch-name)`String.t`A globally unique name for this route, to be used when generating docs and open api specifications[`derive_sort?`](dsl-ashjsonapi-domain.html#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?`](dsl-ashjsonapi-domain.html#json_api-routes-patch-derive_filter?)`boolean``true`Whether or not to derive a filter parameter based on the sortable fields of the resource
3106 |
3107 | ### [](dsl-ashjsonapi-domain.html#introspection-15)Introspection
3108 |
3109 | Target: [`AshJsonApi.Resource.Route`](AshJsonApi.Resource.Route.html)
3110 |
3111 | ## [](dsl-ashjsonapi-domain.html#json_api-routes-delete)json\_api.routes.delete
3112 |
3113 | ```
3114 | delete resource, action
3115 | ```
3116 |
3117 | A DELETE route to destroy a record
3118 |
3119 | ### [](dsl-ashjsonapi-domain.html#examples-19)Examples
3120 |
3121 | ```
3122 | delete :destroy
3123 | ```
3124 |
3125 | ### [](dsl-ashjsonapi-domain.html#arguments-16)Arguments
3126 |
3127 | NameTypeDefaultDocs[`resource`](dsl-ashjsonapi-domain.html#json_api-routes-delete-resource)`module`The resource that the route's action is defined on[`action`](dsl-ashjsonapi-domain.html#json_api-routes-delete-action)`atom`The action to call when this route is hit
3128 |
3129 | ### [](dsl-ashjsonapi-domain.html#options-17)Options
3130 |
3131 | NameTypeDefaultDocs[`read_action`](dsl-ashjsonapi-domain.html#json_api-routes-delete-read_action)`atom`The read action to use to look the record up before updating[`route`](dsl-ashjsonapi-domain.html#json_api-routes-delete-route)`String.t``"/:id"`The path of the route[`default_fields`](dsl-ashjsonapi-domain.html#json_api-routes-delete-default_fields)`list(atom)`A list of fields to be shown in the attributes of the called route[`primary?`](dsl-ashjsonapi-domain.html#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`](dsl-ashjsonapi-domain.html#json_api-routes-delete-metadata)`(any, any, any -> any)`A function to generate arbitrary top-level metadata for the JSON:API response[`modify_conn`](dsl-ashjsonapi-domain.html#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`[`query_params`](dsl-ashjsonapi-domain.html#json_api-routes-delete-query_params)`list(atom)``[]`A list of action inputs to accept as query parameters.[`name`](dsl-ashjsonapi-domain.html#json_api-routes-delete-name)`String.t`A globally unique name for this route, to be used when generating docs and open api specifications[`derive_sort?`](dsl-ashjsonapi-domain.html#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?`](dsl-ashjsonapi-domain.html#json_api-routes-delete-derive_filter?)`boolean``true`Whether or not to derive a filter parameter based on the sortable fields of the resource
3132 |
3133 | ### [](dsl-ashjsonapi-domain.html#introspection-16)Introspection
3134 |
3135 | Target: [`AshJsonApi.Resource.Route`](AshJsonApi.Resource.Route.html)
3136 |
3137 | ## [](dsl-ashjsonapi-domain.html#json_api-routes-related)json\_api.routes.related
3138 |
3139 | ```
3140 | related resource, relationship, action
3141 | ```
3142 |
3143 | A GET route to read the related resources of a relationship
3144 |
3145 | ### [](dsl-ashjsonapi-domain.html#examples-20)Examples
3146 |
3147 | ```
3148 | related :comments, :read
3149 | ```
3150 |
3151 | ### [](dsl-ashjsonapi-domain.html#arguments-17)Arguments
3152 |
3153 | NameTypeDefaultDocs[`resource`](dsl-ashjsonapi-domain.html#json_api-routes-related-resource)`module`The resource that the route's action is defined on[`relationship`](dsl-ashjsonapi-domain.html#json_api-routes-related-relationship)`atom`[`action`](dsl-ashjsonapi-domain.html#json_api-routes-related-action)`atom`The action to call when this route is hit
3154 |
3155 | ### [](dsl-ashjsonapi-domain.html#options-18)Options
3156 |
3157 | NameTypeDefaultDocs[`route`](dsl-ashjsonapi-domain.html#json_api-routes-related-route)`String.t`The path of the route - Defaults to /:id/\[relationship\_name][`default_fields`](dsl-ashjsonapi-domain.html#json_api-routes-related-default_fields)`list(atom)`A list of fields to be shown in the attributes of the called route[`primary?`](dsl-ashjsonapi-domain.html#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`](dsl-ashjsonapi-domain.html#json_api-routes-related-metadata)`(any, any, any -> any)`A function to generate arbitrary top-level metadata for the JSON:API response[`modify_conn`](dsl-ashjsonapi-domain.html#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`[`query_params`](dsl-ashjsonapi-domain.html#json_api-routes-related-query_params)`list(atom)``[]`A list of action inputs to accept as query parameters.[`name`](dsl-ashjsonapi-domain.html#json_api-routes-related-name)`String.t`A globally unique name for this route, to be used when generating docs and open api specifications[`derive_sort?`](dsl-ashjsonapi-domain.html#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?`](dsl-ashjsonapi-domain.html#json_api-routes-related-derive_filter?)`boolean``true`Whether or not to derive a filter parameter based on the sortable fields of the resource
3158 |
3159 | ### [](dsl-ashjsonapi-domain.html#introspection-17)Introspection
3160 |
3161 | Target: [`AshJsonApi.Resource.Route`](AshJsonApi.Resource.Route.html)
3162 |
3163 | ## [](dsl-ashjsonapi-domain.html#json_api-routes-relationship)json\_api.routes.relationship
3164 |
3165 | ```
3166 | relationship resource, relationship, action
3167 | ```
3168 |
3169 | A READ route to read the relationship, returns resource identifiers.
3170 |
3171 | ### [](dsl-ashjsonapi-domain.html#examples-21)Examples
3172 |
3173 | ```
3174 | relationship :comments, :read
3175 | ```
3176 |
3177 | ### [](dsl-ashjsonapi-domain.html#arguments-18)Arguments
3178 |
3179 | NameTypeDefaultDocs[`resource`](dsl-ashjsonapi-domain.html#json_api-routes-relationship-resource)`module`The resource that the route's action is defined on[`relationship`](dsl-ashjsonapi-domain.html#json_api-routes-relationship-relationship)`atom`[`action`](dsl-ashjsonapi-domain.html#json_api-routes-relationship-action)`atom`The action to call when this route is hit
3180 |
3181 | ### [](dsl-ashjsonapi-domain.html#options-19)Options
3182 |
3183 | NameTypeDefaultDocs[`route`](dsl-ashjsonapi-domain.html#json_api-routes-relationship-route)`String.t`The path of the route - Defaults to /:id/relationships/\[relationship\_name][`default_fields`](dsl-ashjsonapi-domain.html#json_api-routes-relationship-default_fields)`list(atom)`A list of fields to be shown in the attributes of the called route[`primary?`](dsl-ashjsonapi-domain.html#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`](dsl-ashjsonapi-domain.html#json_api-routes-relationship-metadata)`(any, any, any -> any)`A function to generate arbitrary top-level metadata for the JSON:API response[`modify_conn`](dsl-ashjsonapi-domain.html#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`[`query_params`](dsl-ashjsonapi-domain.html#json_api-routes-relationship-query_params)`list(atom)``[]`A list of action inputs to accept as query parameters.[`name`](dsl-ashjsonapi-domain.html#json_api-routes-relationship-name)`String.t`A globally unique name for this route, to be used when generating docs and open api specifications[`derive_sort?`](dsl-ashjsonapi-domain.html#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?`](dsl-ashjsonapi-domain.html#json_api-routes-relationship-derive_filter?)`boolean``true`Whether or not to derive a filter parameter based on the sortable fields of the resource
3184 |
3185 | ### [](dsl-ashjsonapi-domain.html#introspection-18)Introspection
3186 |
3187 | Target: [`AshJsonApi.Resource.Route`](AshJsonApi.Resource.Route.html)
3188 |
3189 | ## [](dsl-ashjsonapi-domain.html#json_api-routes-post_to_relationship)json\_api.routes.post\_to\_relationship
3190 |
3191 | ```
3192 | post_to_relationship resource, relationship
3193 | ```
3194 |
3195 | A POST route to create related entities using resource identifiers
3196 |
3197 | ### [](dsl-ashjsonapi-domain.html#examples-22)Examples
3198 |
3199 | ```
3200 | post_to_relationship :comments
3201 | ```
3202 |
3203 | ### [](dsl-ashjsonapi-domain.html#arguments-19)Arguments
3204 |
3205 | NameTypeDefaultDocs[`resource`](dsl-ashjsonapi-domain.html#json_api-routes-post_to_relationship-resource)`module`The resource that the route's action is defined on[`relationship`](dsl-ashjsonapi-domain.html#json_api-routes-post_to_relationship-relationship)`atom`
3206 |
3207 | ### [](dsl-ashjsonapi-domain.html#options-20)Options
3208 |
3209 | NameTypeDefaultDocs[`route`](dsl-ashjsonapi-domain.html#json_api-routes-post_to_relationship-route)`String.t`The path of the route - Defaults to /:id/relationships/\[relationship\_name][`default_fields`](dsl-ashjsonapi-domain.html#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?`](dsl-ashjsonapi-domain.html#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`](dsl-ashjsonapi-domain.html#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`](dsl-ashjsonapi-domain.html#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`[`query_params`](dsl-ashjsonapi-domain.html#json_api-routes-post_to_relationship-query_params)`list(atom)``[]`A list of action inputs to accept as query parameters.[`name`](dsl-ashjsonapi-domain.html#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[`derive_sort?`](dsl-ashjsonapi-domain.html#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?`](dsl-ashjsonapi-domain.html#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
3210 |
3211 | ### [](dsl-ashjsonapi-domain.html#introspection-19)Introspection
3212 |
3213 | Target: [`AshJsonApi.Resource.Route`](AshJsonApi.Resource.Route.html)
3214 |
3215 | ## [](dsl-ashjsonapi-domain.html#json_api-routes-patch_relationship)json\_api.routes.patch\_relationship
3216 |
3217 | ```
3218 | patch_relationship resource, relationship
3219 | ```
3220 |
3221 | A PATCH route to update a relationship using resource identifiers
3222 |
3223 | ### [](dsl-ashjsonapi-domain.html#examples-23)Examples
3224 |
3225 | ```
3226 | patch_relationship :comments
3227 | ```
3228 |
3229 | ### [](dsl-ashjsonapi-domain.html#arguments-20)Arguments
3230 |
3231 | NameTypeDefaultDocs[`resource`](dsl-ashjsonapi-domain.html#json_api-routes-patch_relationship-resource)`module`The resource that the route's action is defined on[`relationship`](dsl-ashjsonapi-domain.html#json_api-routes-patch_relationship-relationship)`atom`
3232 |
3233 | ### [](dsl-ashjsonapi-domain.html#options-21)Options
3234 |
3235 | NameTypeDefaultDocs[`route`](dsl-ashjsonapi-domain.html#json_api-routes-patch_relationship-route)`String.t`The path of the route - Defaults to /:id/relationships/\[relationship\_name][`default_fields`](dsl-ashjsonapi-domain.html#json_api-routes-patch_relationship-default_fields)`list(atom)`A list of fields to be shown in the attributes of the called route[`primary?`](dsl-ashjsonapi-domain.html#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`](dsl-ashjsonapi-domain.html#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`](dsl-ashjsonapi-domain.html#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`[`query_params`](dsl-ashjsonapi-domain.html#json_api-routes-patch_relationship-query_params)`list(atom)``[]`A list of action inputs to accept as query parameters.[`name`](dsl-ashjsonapi-domain.html#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[`derive_sort?`](dsl-ashjsonapi-domain.html#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?`](dsl-ashjsonapi-domain.html#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
3236 |
3237 | ### [](dsl-ashjsonapi-domain.html#introspection-20)Introspection
3238 |
3239 | Target: [`AshJsonApi.Resource.Route`](AshJsonApi.Resource.Route.html)
3240 |
3241 | ## [](dsl-ashjsonapi-domain.html#json_api-routes-delete_from_relationship)json\_api.routes.delete\_from\_relationship
3242 |
3243 | ```
3244 | delete_from_relationship resource, relationship
3245 | ```
3246 |
3247 | A DELETE route to remove related entities using resource identifiers
3248 |
3249 | ### [](dsl-ashjsonapi-domain.html#examples-24)Examples
3250 |
3251 | ```
3252 | delete_from_relationship :comments
3253 | ```
3254 |
3255 | ### [](dsl-ashjsonapi-domain.html#arguments-21)Arguments
3256 |
3257 | NameTypeDefaultDocs[`resource`](dsl-ashjsonapi-domain.html#json_api-routes-delete_from_relationship-resource)`module`The resource that the route's action is defined on[`relationship`](dsl-ashjsonapi-domain.html#json_api-routes-delete_from_relationship-relationship)`atom`
3258 |
3259 | ### [](dsl-ashjsonapi-domain.html#options-22)Options
3260 |
3261 | NameTypeDefaultDocs[`route`](dsl-ashjsonapi-domain.html#json_api-routes-delete_from_relationship-route)`String.t`The path of the route - Defaults to /:id/relationships/\[relationship\_name][`default_fields`](dsl-ashjsonapi-domain.html#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?`](dsl-ashjsonapi-domain.html#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`](dsl-ashjsonapi-domain.html#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`](dsl-ashjsonapi-domain.html#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`[`query_params`](dsl-ashjsonapi-domain.html#json_api-routes-delete_from_relationship-query_params)`list(atom)``[]`A list of action inputs to accept as query parameters.[`name`](dsl-ashjsonapi-domain.html#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[`derive_sort?`](dsl-ashjsonapi-domain.html#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?`](dsl-ashjsonapi-domain.html#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
3262 |
3263 | ### [](dsl-ashjsonapi-domain.html#introspection-21)Introspection
3264 |
3265 | Target: [`AshJsonApi.Resource.Route`](AshJsonApi.Resource.Route.html)
3266 |
3267 | ## [](dsl-ashjsonapi-domain.html#json_api-routes-route)json\_api.routes.route
3268 |
3269 | ```
3270 | route resource, method, route, action
3271 | ```
3272 |
3273 | A route for a generic action.
3274 |
3275 | ### [](dsl-ashjsonapi-domain.html#examples-25)Examples
3276 |
3277 | ```
3278 | route :get, "say_hi/:name", :say_hello
3279 | ```
3280 |
3281 | ### [](dsl-ashjsonapi-domain.html#arguments-22)Arguments
3282 |
3283 | NameTypeDefaultDocs[`resource`](dsl-ashjsonapi-domain.html#json_api-routes-route-resource)`module`The resource that the route's action is defined on[`method`](dsl-ashjsonapi-domain.html#json_api-routes-route-method)`atom`The HTTP method for the route, e.g `:get`, or `:post`[`route`](dsl-ashjsonapi-domain.html#json_api-routes-route-route)`String.t`The path of the route[`action`](dsl-ashjsonapi-domain.html#json_api-routes-route-action)`atom`The action to call when this route is hit
3284 |
3285 | ### [](dsl-ashjsonapi-domain.html#options-23)Options
3286 |
3287 | NameTypeDefaultDocs[`wrap_in_result?`](dsl-ashjsonapi-domain.html#json_api-routes-route-wrap_in_result?)`boolean``false`Whether or not the action result should be wrapped in `{result: <result>}`[`default_fields`](dsl-ashjsonapi-domain.html#json_api-routes-route-default_fields)`list(atom)`A list of fields to be shown in the attributes of the called route[`primary?`](dsl-ashjsonapi-domain.html#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`](dsl-ashjsonapi-domain.html#json_api-routes-route-metadata)`(any, any, any -> any)`A function to generate arbitrary top-level metadata for the JSON:API response[`modify_conn`](dsl-ashjsonapi-domain.html#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`[`query_params`](dsl-ashjsonapi-domain.html#json_api-routes-route-query_params)`list(atom)``[]`A list of action inputs to accept as query parameters.[`name`](dsl-ashjsonapi-domain.html#json_api-routes-route-name)`String.t`A globally unique name for this route, to be used when generating docs and open api specifications[`derive_sort?`](dsl-ashjsonapi-domain.html#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?`](dsl-ashjsonapi-domain.html#json_api-routes-route-derive_filter?)`boolean``true`Whether or not to derive a filter parameter based on the sortable fields of the resource
3288 |
3289 | ### [](dsl-ashjsonapi-domain.html#introspection-22)Introspection
3290 |
3291 | Target: [`AshJsonApi.Resource.Route`](AshJsonApi.Resource.Route.html)
3292 |
3293 | [← Previous Page DSL: AshJsonApi.Resource](dsl-ashjsonapi-resource.html)
3294 |
3295 | [Next Page → Change Log](changelog.html)
3296 |
3297 | [Hex Package](https://hex.pm/packages/ash_json_api/1.4.16) [Hex Preview](https://preview.hex.pm/preview/ash_json_api/1.4.16) ([current file](https://preview.hex.pm/preview/ash_json_api/1.4.16/show/documentation/dsls/DSL-AshJsonApi.Domain.md)) Search HexDocs [Download ePub version](ash_json_api.epub "ePub version")
3298 |
3299 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.31.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
3300 | [](https://github.com/ash-project/ash_json_api)
3301 |
3302 | [ash\_json\_api](https://github.com/ash-project/ash_json_api)
3303 |
3304 | v1.4.16
3305 |
3306 | - Pages
3307 | - Modules
3308 | - Mix Tasks
3309 |
3310 | <!--THE END-->
3311 |
3312 | <!--THE END-->
3313 |
3314 | <!--THE END-->
3315 |
3316 | Search documentation of ash\_json\_api
3317 |
3318 | Settings
3319 |
3320 | # [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/documentation/dsls/DSL-AshJsonApi.Resource.md#L1 "View Source") DSL: AshJsonApi.Resource
3321 |
3322 | The entrypoint for adding JSON:API behavior to a resource"
3323 |
3324 | ## [](dsl-ashjsonapi-resource.html#json_api)json\_api
3325 |
3326 | Configure the resource's behavior in the JSON:API
3327 |
3328 | ### [](dsl-ashjsonapi-resource.html#nested-dsls)Nested DSLs
3329 |
3330 | - [routes](dsl-ashjsonapi-resource.html#json_api-routes)
3331 |
3332 | - get
3333 | - index
3334 | - post
3335 | - patch
3336 | - delete
3337 | - related
3338 | - relationship
3339 | - post\_to\_relationship
3340 | - patch\_relationship
3341 | - delete\_from\_relationship
3342 | - route
3343 | - [primary\_key](dsl-ashjsonapi-resource.html#json_api-primary_key)
3344 |
3345 | ### [](dsl-ashjsonapi-resource.html#examples)Examples
3346 |
3347 | ```
3348 | json_api do
3349 | type "post"
3350 | includes [
3351 | friends: [
3352 | :comments
3353 | ],
3354 | comments: []
3355 | ]
3356 |
3357 | routes do
3358 | base "/posts"
3359 |
3360 | get :read
3361 | get :me, route: "/me"
3362 | index :read
3363 | post :confirm_name, route: "/confirm_name"
3364 | patch :update
3365 | related :comments, :read
3366 | relationship :comments, :read
3367 | post_to_relationship :comments
3368 | patch_relationship :comments
3369 | delete_from_relationship :comments
3370 | end
3371 | end
3372 | ```
3373 |
3374 | ### [](dsl-ashjsonapi-resource.html#options)Options
3375 |
3376 | NameTypeDefaultDocs[`type`](dsl-ashjsonapi-resource.html#json_api-type)`String.t`The resource identifier type of this resource in JSON:API[`includes`](dsl-ashjsonapi-resource.html#json_api-includes)`any``[]`A keyword list of all paths that are includable from this resource[`include_nil_values?`](dsl-ashjsonapi-resource.html#json_api-include_nil_values?)`any`Whether or not to include properties for values that are nil in the JSON output[`default_fields`](dsl-ashjsonapi-resource.html#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[`derive_sort?`](dsl-ashjsonapi-resource.html#json_api-derive_sort?)`boolean``true`Whether or not to derive a sort parameter based on the sortable fields of the resource[`derive_filter?`](dsl-ashjsonapi-resource.html#json_api-derive_filter?)`boolean``true`Whether or not to derive a filter parameter based on the sortable fields of the resource
3377 |
3378 | ## [](dsl-ashjsonapi-resource.html#json_api-routes)json\_api.routes
3379 |
3380 | Configure the routes that will be exposed via the JSON:API
3381 |
3382 | ### [](dsl-ashjsonapi-resource.html#nested-dsls-1)Nested DSLs
3383 |
3384 | - [get](dsl-ashjsonapi-resource.html#json_api-routes-get)
3385 | - [index](dsl-ashjsonapi-resource.html#json_api-routes-index)
3386 | - [post](dsl-ashjsonapi-resource.html#json_api-routes-post)
3387 | - [patch](dsl-ashjsonapi-resource.html#json_api-routes-patch)
3388 | - [delete](dsl-ashjsonapi-resource.html#json_api-routes-delete)
3389 | - [related](dsl-ashjsonapi-resource.html#json_api-routes-related)
3390 | - [relationship](dsl-ashjsonapi-resource.html#json_api-routes-relationship)
3391 | - [post\_to\_relationship](dsl-ashjsonapi-resource.html#json_api-routes-post_to_relationship)
3392 | - [patch\_relationship](dsl-ashjsonapi-resource.html#json_api-routes-patch_relationship)
3393 | - [delete\_from\_relationship](dsl-ashjsonapi-resource.html#json_api-routes-delete_from_relationship)
3394 | - [route](dsl-ashjsonapi-resource.html#json_api-routes-route)
3395 |
3396 | ### [](dsl-ashjsonapi-resource.html#examples-1)Examples
3397 |
3398 | ```
3399 | routes do
3400 | base "/posts"
3401 |
3402 | get :read
3403 | get :me, route: "/me"
3404 | index :read
3405 | post :confirm_name, route: "/confirm_name"
3406 | patch :update
3407 | related :comments, :read
3408 | relationship :comments, :read
3409 | post_to_relationship :comments
3410 | patch_relationship :comments
3411 | delete_from_relationship :comments
3412 | end
3413 | ```
3414 |
3415 | ### [](dsl-ashjsonapi-resource.html#options-1)Options
3416 |
3417 | NameTypeDefaultDocs[`base`](dsl-ashjsonapi-resource.html#json_api-routes-base)`String.t`A base route for the resource, e.g `"/users"`
3418 |
3419 | ## [](dsl-ashjsonapi-resource.html#json_api-routes-get)json\_api.routes.get
3420 |
3421 | ```
3422 | get action
3423 | ```
3424 |
3425 | A GET route to retrieve a single record
3426 |
3427 | ### [](dsl-ashjsonapi-resource.html#examples-2)Examples
3428 |
3429 | ```
3430 | get :read
3431 | ```
3432 |
3433 | ### [](dsl-ashjsonapi-resource.html#arguments)Arguments
3434 |
3435 | NameTypeDefaultDocs[`action`](dsl-ashjsonapi-resource.html#json_api-routes-get-action)`atom`The action to call when this route is hit
3436 |
3437 | ### [](dsl-ashjsonapi-resource.html#options-2)Options
3438 |
3439 | NameTypeDefaultDocs[`route`](dsl-ashjsonapi-resource.html#json_api-routes-get-route)`String.t``"/:id"`The path of the route[`default_fields`](dsl-ashjsonapi-resource.html#json_api-routes-get-default_fields)`list(atom)`A list of fields to be shown in the attributes of the called route[`primary?`](dsl-ashjsonapi-resource.html#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`](dsl-ashjsonapi-resource.html#json_api-routes-get-metadata)`(any, any, any -> any)`A function to generate arbitrary top-level metadata for the JSON:API response[`modify_conn`](dsl-ashjsonapi-resource.html#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`[`name`](dsl-ashjsonapi-resource.html#json_api-routes-get-name)`String.t`A globally unique name for this route, to be used when generating docs and open api specifications[`derive_sort?`](dsl-ashjsonapi-resource.html#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?`](dsl-ashjsonapi-resource.html#json_api-routes-get-derive_filter?)`boolean``true`Whether or not to derive a filter parameter based on the sortable fields of the resource
3440 |
3441 | ### [](dsl-ashjsonapi-resource.html#introspection)Introspection
3442 |
3443 | Target: [`AshJsonApi.Resource.Route`](AshJsonApi.Resource.Route.html)
3444 |
3445 | ## [](dsl-ashjsonapi-resource.html#json_api-routes-index)json\_api.routes.index
3446 |
3447 | ```
3448 | index action
3449 | ```
3450 |
3451 | A GET route to retrieve a list of records
3452 |
3453 | ### [](dsl-ashjsonapi-resource.html#examples-3)Examples
3454 |
3455 | ```
3456 | index :read
3457 | ```
3458 |
3459 | ### [](dsl-ashjsonapi-resource.html#arguments-1)Arguments
3460 |
3461 | NameTypeDefaultDocs[`action`](dsl-ashjsonapi-resource.html#json_api-routes-index-action)`atom`The action to call when this route is hit
3462 |
3463 | ### [](dsl-ashjsonapi-resource.html#options-3)Options
3464 |
3465 | NameTypeDefaultDocs[`paginate?`](dsl-ashjsonapi-resource.html#json_api-routes-index-paginate?)`boolean``true`[`route`](dsl-ashjsonapi-resource.html#json_api-routes-index-route)`String.t``"/"`The path of the route[`default_fields`](dsl-ashjsonapi-resource.html#json_api-routes-index-default_fields)`list(atom)`A list of fields to be shown in the attributes of the called route[`primary?`](dsl-ashjsonapi-resource.html#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`](dsl-ashjsonapi-resource.html#json_api-routes-index-metadata)`(any, any, any -> any)`A function to generate arbitrary top-level metadata for the JSON:API response[`modify_conn`](dsl-ashjsonapi-resource.html#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`[`name`](dsl-ashjsonapi-resource.html#json_api-routes-index-name)`String.t`A globally unique name for this route, to be used when generating docs and open api specifications[`derive_sort?`](dsl-ashjsonapi-resource.html#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?`](dsl-ashjsonapi-resource.html#json_api-routes-index-derive_filter?)`boolean``true`Whether or not to derive a filter parameter based on the sortable fields of the resource
3466 |
3467 | ### [](dsl-ashjsonapi-resource.html#introspection-1)Introspection
3468 |
3469 | Target: [`AshJsonApi.Resource.Route`](AshJsonApi.Resource.Route.html)
3470 |
3471 | ## [](dsl-ashjsonapi-resource.html#json_api-routes-post)json\_api.routes.post
3472 |
3473 | ```
3474 | post action
3475 | ```
3476 |
3477 | A POST route to create a record
3478 |
3479 | ### [](dsl-ashjsonapi-resource.html#examples-4)Examples
3480 |
3481 | ```
3482 | post :create
3483 | ```
3484 |
3485 | ### [](dsl-ashjsonapi-resource.html#arguments-2)Arguments
3486 |
3487 | NameTypeDefaultDocs[`action`](dsl-ashjsonapi-resource.html#json_api-routes-post-action)`atom`The action to call when this route is hit
3488 |
3489 | ### [](dsl-ashjsonapi-resource.html#options-4)Options
3490 |
3491 | NameTypeDefaultDocs[`route`](dsl-ashjsonapi-resource.html#json_api-routes-post-route)`String.t``"/"`The path of the route[`default_fields`](dsl-ashjsonapi-resource.html#json_api-routes-post-default_fields)`list(atom)`A list of fields to be shown in the attributes of the called route[`primary?`](dsl-ashjsonapi-resource.html#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`](dsl-ashjsonapi-resource.html#json_api-routes-post-metadata)`(any, any, any -> any)`A function to generate arbitrary top-level metadata for the JSON:API response[`modify_conn`](dsl-ashjsonapi-resource.html#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`[`query_params`](dsl-ashjsonapi-resource.html#json_api-routes-post-query_params)`list(atom)``[]`A list of action inputs to accept as query parameters.[`name`](dsl-ashjsonapi-resource.html#json_api-routes-post-name)`String.t`A globally unique name for this route, to be used when generating docs and open api specifications[`derive_sort?`](dsl-ashjsonapi-resource.html#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?`](dsl-ashjsonapi-resource.html#json_api-routes-post-derive_filter?)`boolean``true`Whether or not to derive a filter parameter based on the sortable fields of the resource[`relationship_arguments`](dsl-ashjsonapi-resource.html#json_api-routes-post-relationship_arguments)`list(atom | {:id, atom})``[]`Arguments to be used to edit relationships. See the [relationships guide](relationships.html) for more.[`upsert?`](dsl-ashjsonapi-resource.html#json_api-routes-post-upsert?)`boolean``false`Whether or not to use the `upsert?: true` option when calling [`Ash.create/2`](../ash/3.4.47/Ash.html#create/2).[`upsert_identity`](dsl-ashjsonapi-resource.html#json_api-routes-post-upsert_identity)`atom``false`Which identity to use for the upsert
3492 |
3493 | ### [](dsl-ashjsonapi-resource.html#introspection-2)Introspection
3494 |
3495 | Target: [`AshJsonApi.Resource.Route`](AshJsonApi.Resource.Route.html)
3496 |
3497 | ## [](dsl-ashjsonapi-resource.html#json_api-routes-patch)json\_api.routes.patch
3498 |
3499 | ```
3500 | patch action
3501 | ```
3502 |
3503 | A PATCH route to update a record
3504 |
3505 | ### [](dsl-ashjsonapi-resource.html#examples-5)Examples
3506 |
3507 | ```
3508 | patch :update
3509 | ```
3510 |
3511 | ### [](dsl-ashjsonapi-resource.html#arguments-3)Arguments
3512 |
3513 | NameTypeDefaultDocs[`action`](dsl-ashjsonapi-resource.html#json_api-routes-patch-action)`atom`The action to call when this route is hit
3514 |
3515 | ### [](dsl-ashjsonapi-resource.html#options-5)Options
3516 |
3517 | NameTypeDefaultDocs[`relationship_arguments`](dsl-ashjsonapi-resource.html#json_api-routes-patch-relationship_arguments)`any``[]`Arguments to be used to edit relationships. See the [relationships guide](relationships.html) for more.[`read_action`](dsl-ashjsonapi-resource.html#json_api-routes-patch-read_action)`atom`The read action to use to look the record up before updating[`route`](dsl-ashjsonapi-resource.html#json_api-routes-patch-route)`String.t``"/:id"`The path of the route[`default_fields`](dsl-ashjsonapi-resource.html#json_api-routes-patch-default_fields)`list(atom)`A list of fields to be shown in the attributes of the called route[`primary?`](dsl-ashjsonapi-resource.html#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`](dsl-ashjsonapi-resource.html#json_api-routes-patch-metadata)`(any, any, any -> any)`A function to generate arbitrary top-level metadata for the JSON:API response[`modify_conn`](dsl-ashjsonapi-resource.html#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`[`query_params`](dsl-ashjsonapi-resource.html#json_api-routes-patch-query_params)`list(atom)``[]`A list of action inputs to accept as query parameters.[`name`](dsl-ashjsonapi-resource.html#json_api-routes-patch-name)`String.t`A globally unique name for this route, to be used when generating docs and open api specifications[`derive_sort?`](dsl-ashjsonapi-resource.html#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?`](dsl-ashjsonapi-resource.html#json_api-routes-patch-derive_filter?)`boolean``true`Whether or not to derive a filter parameter based on the sortable fields of the resource
3518 |
3519 | ### [](dsl-ashjsonapi-resource.html#introspection-3)Introspection
3520 |
3521 | Target: [`AshJsonApi.Resource.Route`](AshJsonApi.Resource.Route.html)
3522 |
3523 | ## [](dsl-ashjsonapi-resource.html#json_api-routes-delete)json\_api.routes.delete
3524 |
3525 | ```
3526 | delete action
3527 | ```
3528 |
3529 | A DELETE route to destroy a record
3530 |
3531 | ### [](dsl-ashjsonapi-resource.html#examples-6)Examples
3532 |
3533 | ```
3534 | delete :destroy
3535 | ```
3536 |
3537 | ### [](dsl-ashjsonapi-resource.html#arguments-4)Arguments
3538 |
3539 | NameTypeDefaultDocs[`action`](dsl-ashjsonapi-resource.html#json_api-routes-delete-action)`atom`The action to call when this route is hit
3540 |
3541 | ### [](dsl-ashjsonapi-resource.html#options-6)Options
3542 |
3543 | NameTypeDefaultDocs[`read_action`](dsl-ashjsonapi-resource.html#json_api-routes-delete-read_action)`atom`The read action to use to look the record up before updating[`route`](dsl-ashjsonapi-resource.html#json_api-routes-delete-route)`String.t``"/:id"`The path of the route[`default_fields`](dsl-ashjsonapi-resource.html#json_api-routes-delete-default_fields)`list(atom)`A list of fields to be shown in the attributes of the called route[`primary?`](dsl-ashjsonapi-resource.html#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`](dsl-ashjsonapi-resource.html#json_api-routes-delete-metadata)`(any, any, any -> any)`A function to generate arbitrary top-level metadata for the JSON:API response[`modify_conn`](dsl-ashjsonapi-resource.html#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`[`query_params`](dsl-ashjsonapi-resource.html#json_api-routes-delete-query_params)`list(atom)``[]`A list of action inputs to accept as query parameters.[`name`](dsl-ashjsonapi-resource.html#json_api-routes-delete-name)`String.t`A globally unique name for this route, to be used when generating docs and open api specifications[`derive_sort?`](dsl-ashjsonapi-resource.html#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?`](dsl-ashjsonapi-resource.html#json_api-routes-delete-derive_filter?)`boolean``true`Whether or not to derive a filter parameter based on the sortable fields of the resource
3544 |
3545 | ### [](dsl-ashjsonapi-resource.html#introspection-4)Introspection
3546 |
3547 | Target: [`AshJsonApi.Resource.Route`](AshJsonApi.Resource.Route.html)
3548 |
3549 | ## [](dsl-ashjsonapi-resource.html#json_api-routes-related)json\_api.routes.related
3550 |
3551 | ```
3552 | related relationship, action
3553 | ```
3554 |
3555 | A GET route to read the related resources of a relationship
3556 |
3557 | ### [](dsl-ashjsonapi-resource.html#examples-7)Examples
3558 |
3559 | ```
3560 | related :comments, :read
3561 | ```
3562 |
3563 | ### [](dsl-ashjsonapi-resource.html#arguments-5)Arguments
3564 |
3565 | NameTypeDefaultDocs[`relationship`](dsl-ashjsonapi-resource.html#json_api-routes-related-relationship)`atom`[`action`](dsl-ashjsonapi-resource.html#json_api-routes-related-action)`atom`The action to call when this route is hit
3566 |
3567 | ### [](dsl-ashjsonapi-resource.html#options-7)Options
3568 |
3569 | NameTypeDefaultDocs[`route`](dsl-ashjsonapi-resource.html#json_api-routes-related-route)`String.t`The path of the route - Defaults to /:id/\[relationship\_name][`default_fields`](dsl-ashjsonapi-resource.html#json_api-routes-related-default_fields)`list(atom)`A list of fields to be shown in the attributes of the called route[`primary?`](dsl-ashjsonapi-resource.html#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`](dsl-ashjsonapi-resource.html#json_api-routes-related-metadata)`(any, any, any -> any)`A function to generate arbitrary top-level metadata for the JSON:API response[`modify_conn`](dsl-ashjsonapi-resource.html#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`[`query_params`](dsl-ashjsonapi-resource.html#json_api-routes-related-query_params)`list(atom)``[]`A list of action inputs to accept as query parameters.[`name`](dsl-ashjsonapi-resource.html#json_api-routes-related-name)`String.t`A globally unique name for this route, to be used when generating docs and open api specifications[`derive_sort?`](dsl-ashjsonapi-resource.html#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?`](dsl-ashjsonapi-resource.html#json_api-routes-related-derive_filter?)`boolean``true`Whether or not to derive a filter parameter based on the sortable fields of the resource
3570 |
3571 | ### [](dsl-ashjsonapi-resource.html#introspection-5)Introspection
3572 |
3573 | Target: [`AshJsonApi.Resource.Route`](AshJsonApi.Resource.Route.html)
3574 |
3575 | ## [](dsl-ashjsonapi-resource.html#json_api-routes-relationship)json\_api.routes.relationship
3576 |
3577 | ```
3578 | relationship relationship, action
3579 | ```
3580 |
3581 | A READ route to read the relationship, returns resource identifiers.
3582 |
3583 | ### [](dsl-ashjsonapi-resource.html#examples-8)Examples
3584 |
3585 | ```
3586 | relationship :comments, :read
3587 | ```
3588 |
3589 | ### [](dsl-ashjsonapi-resource.html#arguments-6)Arguments
3590 |
3591 | NameTypeDefaultDocs[`relationship`](dsl-ashjsonapi-resource.html#json_api-routes-relationship-relationship)`atom`[`action`](dsl-ashjsonapi-resource.html#json_api-routes-relationship-action)`atom`The action to call when this route is hit
3592 |
3593 | ### [](dsl-ashjsonapi-resource.html#options-8)Options
3594 |
3595 | NameTypeDefaultDocs[`route`](dsl-ashjsonapi-resource.html#json_api-routes-relationship-route)`String.t`The path of the route - Defaults to /:id/relationships/\[relationship\_name][`default_fields`](dsl-ashjsonapi-resource.html#json_api-routes-relationship-default_fields)`list(atom)`A list of fields to be shown in the attributes of the called route[`primary?`](dsl-ashjsonapi-resource.html#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`](dsl-ashjsonapi-resource.html#json_api-routes-relationship-metadata)`(any, any, any -> any)`A function to generate arbitrary top-level metadata for the JSON:API response[`modify_conn`](dsl-ashjsonapi-resource.html#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`[`query_params`](dsl-ashjsonapi-resource.html#json_api-routes-relationship-query_params)`list(atom)``[]`A list of action inputs to accept as query parameters.[`name`](dsl-ashjsonapi-resource.html#json_api-routes-relationship-name)`String.t`A globally unique name for this route, to be used when generating docs and open api specifications[`derive_sort?`](dsl-ashjsonapi-resource.html#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?`](dsl-ashjsonapi-resource.html#json_api-routes-relationship-derive_filter?)`boolean``true`Whether or not to derive a filter parameter based on the sortable fields of the resource
3596 |
3597 | ### [](dsl-ashjsonapi-resource.html#introspection-6)Introspection
3598 |
3599 | Target: [`AshJsonApi.Resource.Route`](AshJsonApi.Resource.Route.html)
3600 |
3601 | ## [](dsl-ashjsonapi-resource.html#json_api-routes-post_to_relationship)json\_api.routes.post\_to\_relationship
3602 |
3603 | ```
3604 | post_to_relationship relationship
3605 | ```
3606 |
3607 | A POST route to create related entities using resource identifiers
3608 |
3609 | ### [](dsl-ashjsonapi-resource.html#examples-9)Examples
3610 |
3611 | ```
3612 | post_to_relationship :comments
3613 | ```
3614 |
3615 | ### [](dsl-ashjsonapi-resource.html#arguments-7)Arguments
3616 |
3617 | NameTypeDefaultDocs[`relationship`](dsl-ashjsonapi-resource.html#json_api-routes-post_to_relationship-relationship)`atom`
3618 |
3619 | ### [](dsl-ashjsonapi-resource.html#options-9)Options
3620 |
3621 | NameTypeDefaultDocs[`route`](dsl-ashjsonapi-resource.html#json_api-routes-post_to_relationship-route)`String.t`The path of the route - Defaults to /:id/relationships/\[relationship\_name][`default_fields`](dsl-ashjsonapi-resource.html#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?`](dsl-ashjsonapi-resource.html#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`](dsl-ashjsonapi-resource.html#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`](dsl-ashjsonapi-resource.html#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`[`query_params`](dsl-ashjsonapi-resource.html#json_api-routes-post_to_relationship-query_params)`list(atom)``[]`A list of action inputs to accept as query parameters.[`name`](dsl-ashjsonapi-resource.html#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[`derive_sort?`](dsl-ashjsonapi-resource.html#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?`](dsl-ashjsonapi-resource.html#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
3622 |
3623 | ### [](dsl-ashjsonapi-resource.html#introspection-7)Introspection
3624 |
3625 | Target: [`AshJsonApi.Resource.Route`](AshJsonApi.Resource.Route.html)
3626 |
3627 | ## [](dsl-ashjsonapi-resource.html#json_api-routes-patch_relationship)json\_api.routes.patch\_relationship
3628 |
3629 | ```
3630 | patch_relationship relationship
3631 | ```
3632 |
3633 | A PATCH route to update a relationship using resource identifiers
3634 |
3635 | ### [](dsl-ashjsonapi-resource.html#examples-10)Examples
3636 |
3637 | ```
3638 | patch_relationship :comments
3639 | ```
3640 |
3641 | ### [](dsl-ashjsonapi-resource.html#arguments-8)Arguments
3642 |
3643 | NameTypeDefaultDocs[`relationship`](dsl-ashjsonapi-resource.html#json_api-routes-patch_relationship-relationship)`atom`
3644 |
3645 | ### [](dsl-ashjsonapi-resource.html#options-10)Options
3646 |
3647 | NameTypeDefaultDocs[`route`](dsl-ashjsonapi-resource.html#json_api-routes-patch_relationship-route)`String.t`The path of the route - Defaults to /:id/relationships/\[relationship\_name][`default_fields`](dsl-ashjsonapi-resource.html#json_api-routes-patch_relationship-default_fields)`list(atom)`A list of fields to be shown in the attributes of the called route[`primary?`](dsl-ashjsonapi-resource.html#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`](dsl-ashjsonapi-resource.html#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`](dsl-ashjsonapi-resource.html#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`[`query_params`](dsl-ashjsonapi-resource.html#json_api-routes-patch_relationship-query_params)`list(atom)``[]`A list of action inputs to accept as query parameters.[`name`](dsl-ashjsonapi-resource.html#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[`derive_sort?`](dsl-ashjsonapi-resource.html#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?`](dsl-ashjsonapi-resource.html#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
3648 |
3649 | ### [](dsl-ashjsonapi-resource.html#introspection-8)Introspection
3650 |
3651 | Target: [`AshJsonApi.Resource.Route`](AshJsonApi.Resource.Route.html)
3652 |
3653 | ## [](dsl-ashjsonapi-resource.html#json_api-routes-delete_from_relationship)json\_api.routes.delete\_from\_relationship
3654 |
3655 | ```
3656 | delete_from_relationship relationship
3657 | ```
3658 |
3659 | A DELETE route to remove related entities using resource identifiers
3660 |
3661 | ### [](dsl-ashjsonapi-resource.html#examples-11)Examples
3662 |
3663 | ```
3664 | delete_from_relationship :comments
3665 | ```
3666 |
3667 | ### [](dsl-ashjsonapi-resource.html#arguments-9)Arguments
3668 |
3669 | NameTypeDefaultDocs[`relationship`](dsl-ashjsonapi-resource.html#json_api-routes-delete_from_relationship-relationship)`atom`
3670 |
3671 | ### [](dsl-ashjsonapi-resource.html#options-11)Options
3672 |
3673 | NameTypeDefaultDocs[`route`](dsl-ashjsonapi-resource.html#json_api-routes-delete_from_relationship-route)`String.t`The path of the route - Defaults to /:id/relationships/\[relationship\_name][`default_fields`](dsl-ashjsonapi-resource.html#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?`](dsl-ashjsonapi-resource.html#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`](dsl-ashjsonapi-resource.html#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`](dsl-ashjsonapi-resource.html#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`[`query_params`](dsl-ashjsonapi-resource.html#json_api-routes-delete_from_relationship-query_params)`list(atom)``[]`A list of action inputs to accept as query parameters.[`name`](dsl-ashjsonapi-resource.html#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[`derive_sort?`](dsl-ashjsonapi-resource.html#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?`](dsl-ashjsonapi-resource.html#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
3674 |
3675 | ### [](dsl-ashjsonapi-resource.html#introspection-9)Introspection
3676 |
3677 | Target: [`AshJsonApi.Resource.Route`](AshJsonApi.Resource.Route.html)
3678 |
3679 | ## [](dsl-ashjsonapi-resource.html#json_api-routes-route)json\_api.routes.route
3680 |
3681 | ```
3682 | route method, route, action
3683 | ```
3684 |
3685 | A route for a generic action.
3686 |
3687 | ### [](dsl-ashjsonapi-resource.html#examples-12)Examples
3688 |
3689 | ```
3690 | route :get, "say_hi/:name", :say_hello
3691 | ```
3692 |
3693 | ### [](dsl-ashjsonapi-resource.html#arguments-10)Arguments
3694 |
3695 | NameTypeDefaultDocs[`method`](dsl-ashjsonapi-resource.html#json_api-routes-route-method)`atom`The HTTP method for the route, e.g `:get`, or `:post`[`route`](dsl-ashjsonapi-resource.html#json_api-routes-route-route)`String.t`The path of the route[`action`](dsl-ashjsonapi-resource.html#json_api-routes-route-action)`atom`The action to call when this route is hit
3696 |
3697 | ### [](dsl-ashjsonapi-resource.html#options-12)Options
3698 |
3699 | NameTypeDefaultDocs[`wrap_in_result?`](dsl-ashjsonapi-resource.html#json_api-routes-route-wrap_in_result?)`boolean``false`Whether or not the action result should be wrapped in `{result: <result>}`[`default_fields`](dsl-ashjsonapi-resource.html#json_api-routes-route-default_fields)`list(atom)`A list of fields to be shown in the attributes of the called route[`primary?`](dsl-ashjsonapi-resource.html#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`](dsl-ashjsonapi-resource.html#json_api-routes-route-metadata)`(any, any, any -> any)`A function to generate arbitrary top-level metadata for the JSON:API response[`modify_conn`](dsl-ashjsonapi-resource.html#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`[`query_params`](dsl-ashjsonapi-resource.html#json_api-routes-route-query_params)`list(atom)``[]`A list of action inputs to accept as query parameters.[`name`](dsl-ashjsonapi-resource.html#json_api-routes-route-name)`String.t`A globally unique name for this route, to be used when generating docs and open api specifications[`derive_sort?`](dsl-ashjsonapi-resource.html#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?`](dsl-ashjsonapi-resource.html#json_api-routes-route-derive_filter?)`boolean``true`Whether or not to derive a filter parameter based on the sortable fields of the resource
3700 |
3701 | ### [](dsl-ashjsonapi-resource.html#introspection-10)Introspection
3702 |
3703 | Target: [`AshJsonApi.Resource.Route`](AshJsonApi.Resource.Route.html)
3704 |
3705 | ## [](dsl-ashjsonapi-resource.html#json_api-primary_key)json\_api.primary\_key
3706 |
3707 | Encode the id of the JSON API response from selected attributes of a resource
3708 |
3709 | ### [](dsl-ashjsonapi-resource.html#examples-13)Examples
3710 |
3711 | ```
3712 | primary_key do
3713 | keys [:first_name, :last_name]
3714 | delimiter "~"
3715 | end
3716 | ```
3717 |
3718 | ### [](dsl-ashjsonapi-resource.html#options-13)Options
3719 |
3720 | NameTypeDefaultDocs[`keys`](dsl-ashjsonapi-resource.html#json_api-primary_key-keys)`atom | list(atom)`the list of attributes to encode JSON API primary key[`delimiter`](dsl-ashjsonapi-resource.html#json_api-primary_key-delimiter)`String.t``"-"`The delimiter to concatenate the primary key values. Default to be '-'
3721 |
3722 | [← Previous Page Authenticating with AshJsonApi](authenticate-with-json-api.html)
3723 |
3724 | [Next Page → DSL: AshJsonApi.Domain](dsl-ashjsonapi-domain.html)
3725 |
3726 | [Hex Package](https://hex.pm/packages/ash_json_api/1.4.16) [Hex Preview](https://preview.hex.pm/preview/ash_json_api/1.4.16) ([current file](https://preview.hex.pm/preview/ash_json_api/1.4.16/show/documentation/dsls/DSL-AshJsonApi.Resource.md)) Search HexDocs [Download ePub version](ash_json_api.epub "ePub version")
3727 |
3728 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.31.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
3729 | [](https://github.com/ash-project/ash_json_api)
3730 |
3731 | [ash\_json\_api](https://github.com/ash-project/ash_json_api)
3732 |
3733 | v1.4.16
3734 |
3735 | - Pages
3736 | - Modules
3737 | - Mix Tasks
3738 |
3739 | <!--THE END-->
3740 |
3741 | <!--THE END-->
3742 |
3743 | <!--THE END-->
3744 |
3745 | Search documentation of ash\_json\_api
3746 |
3747 | Settings
3748 |
3749 | # [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/documentation/tutorials/getting-started-with-ash-json-api.md#L1 "View Source") Getting started with AshJsonApi
3750 |
3751 | ## [](getting-started-with-ash-json-api.html#installing-ashjsonapi)Installing AshJsonApi
3752 |
3753 | ### [](getting-started-with-ash-json-api.html#using-igniter-recommended)Using Igniter (recommended)
3754 |
3755 | ```
3756 | mix igniter.install ash_json_api
3757 | ```
3758 |
3759 | ### [](getting-started-with-ash-json-api.html#manually)Manually
3760 |
3761 | This manual setup branches off from the [Getting Started with Ash](../ash/get-started.html) guide. If you aren't starting from there, replace the application name, `Helpdesk`, with your application name, and replace the [`Ash.Domain`](../ash/3.4.47/Ash.Domain.html) name, `Helpdesk.Support` with a domain or domains from your own application.
3762 |
3763 | #### Add the ash\_json\_api dependency
3764 |
3765 | In your mix.exs, add the Ash JSON API dependency:
3766 |
3767 | ```
3768 | defp deps do
3769 | [
3770 | # .. other dependencies
3771 | {:ash_json_api, "~> 1.0"},
3772 | ]
3773 | end
3774 | ```
3775 |
3776 | #### Accept json\_api content type
3777 |
3778 | Add the following to your `config/config.exs`.
3779 |
3780 | ```
3781 | # config/config.exs
3782 | config :mime,
3783 | extensions: %{"json" => "application/vnd.api+json"},
3784 | types: %{"application/vnd.api+json" => ["json"]}
3785 | ```
3786 |
3787 | This configuration is required to support working with the JSON:API custom mime type.
3788 |
3789 | After adding the configuration above, compiling the project might throw an error:
3790 |
3791 | ```
3792 | ERROR! the application :mime has a different value set for key :types during runtime compared to compile time.
3793 | ```
3794 |
3795 | This can happen if `:mime` was already compiled before the configuration was changed and can be fixed by running
3796 |
3797 | ```
3798 | mix deps.compile mime --force
3799 | ```
3800 |
3801 | #### Create a router
3802 |
3803 | Create a separate Router Module to work with your Domains. It will generate the routes for your Resources and provide the functions you would usually have in a Controller.
3804 |
3805 | We will later forward requests from your Applications primary (Phoenix) Router to you Ash JSON API Router.
3806 |
3807 | ```
3808 | defmodule HelpdeskWeb.JsonApiRouter do
3809 | use AshJsonApi.Router,
3810 | # The api modules you want to serve
3811 | domains: [Module.concat(["Helpdesk.Support"])],
3812 | # optionally an open_api route
3813 | open_api: "/open_api"
3814 | end
3815 | ```
3816 |
3817 | > ### [](getting-started-with-ash-json-api.html#whats-up-with-module-concat-1)Whats up with [`Module.concat/1`](../elixir/Module.html#concat/1)?
3818 | >
3819 | > This [`Module.concat/1`](../elixir/Module.html#concat/1) prevents a [compile-time dependency](https://dashbit.co/blog/speeding-up-re-compilation-of-elixir-projects) from this router module to the domain modules. It is an implementation detail of how `forward/2` works that you end up with a compile-time dependency on the schema, but there is no need for this dependency, and that dependency can have *drastic* impacts on your compile times in certain scenarios.
3820 |
3821 | Additionally, your Resource requires a type, a base route and a set of allowed HTTP methods and what action they will trigger.
3822 |
3823 | #### Add [`AshJsonApi.Plug.Parser`](AshJsonApi.Plug.Parser.html) to your endpoint
3824 |
3825 | This handles any file uploads, if you have resource actions with the `:file` type.
3826 |
3827 | ```
3828 | plug Plug.Parsers,
3829 | parsers: [:urlencoded, :multipart, :json, AshJsonApi.Plug.Parser], # <- add it to this list.
3830 | pass: ["*/*"],
3831 | json_decoder: Jason
3832 | ```
3833 |
3834 | You don't have to add this if you don't plan on doing any file uploads, but there is no cost to adding it, even if you don't use it.
3835 |
3836 | #### Add the routes from your domain module(s)
3837 |
3838 | To make your Resources accessible to the outside world, forward requests from your Phoenix router to the router you created for your domains.
3839 |
3840 | For example:
3841 |
3842 | ```
3843 | scope "/api/json" do
3844 | pipe_through(:api)
3845 |
3846 | forward "/helpdesk", HelpdeskWeb.JsonApiRouter
3847 | end
3848 | ```
3849 |
3850 | ## [](getting-started-with-ash-json-api.html#configure-your-resources-and-domain-and-expose-actions)Configure your Resources and Domain and expose actions
3851 |
3852 | These examples are based off of the [Getting Started with Ash](../ash/get-started.html) guide.
3853 |
3854 | ### [](getting-started-with-ash-json-api.html#add-the-ashjsonapi-extension-to-your-domain-and-resource)Add the AshJsonApi extension to your domain and resource
3855 |
3856 | ### [](getting-started-with-ash-json-api.html#using-igniter-recommended-1)Using Igniter (recommended)
3857 |
3858 | To set up an existing resource of your own with [`AshJsonApi`](AshJsonApi.html), run:
3859 |
3860 | ```
3861 | mix ash.patch.extend Your.Resource.Name json_api
3862 | ```
3863 |
3864 | ### [](getting-started-with-ash-json-api.html#manually-1)Manually
3865 |
3866 | Add to your domain:
3867 |
3868 | ```
3869 | defmodule Helpdesk.Support do
3870 | use Ash.Domain, extensions: [AshJsonApi.Domain]
3871 | ...
3872 | ```
3873 |
3874 | And to your resource:
3875 |
3876 | ```
3877 | defmodule Helpdesk.Support.Ticket do
3878 | use Ash.Resource, extensions: [AshJsonApi.Resource]
3879 | # ...
3880 | json_api do
3881 | type "ticket"
3882 | end
3883 | end
3884 | ```
3885 |
3886 | ## [](getting-started-with-ash-json-api.html#define-routes)Define Routes
3887 |
3888 | Routes can be defined on the resource or the domain. If you define them on the domain (which is our default recommendation), the resource in question must still use the [`AshJsonApi.Resource`](AshJsonApi.Resource.html) extension, and define its own type.
3889 |
3890 | ### [](getting-started-with-ash-json-api.html#defining-routes-on-the-domain)Defining routes on the domain
3891 |
3892 | ```
3893 | defmodule Helpdesk.Support do
3894 | use Ash.Domain, extensions: [AshJsonApi.Domain]
3895 |
3896 | json_api do
3897 | routes do
3898 | # in the domain `base_route` acts like a scope
3899 | base_route "/tickets", Helpdesk.Support.Ticket do
3900 | get :read
3901 | index :read
3902 | post :open
3903 | end
3904 | end
3905 | end
3906 | end
3907 | ```
3908 |
3909 | And then add the extension and type to the resource:
3910 |
3911 | ```
3912 | defmodule Helpdesk.Support.Ticket do
3913 | use Ash.Resource, extensions: [AshJsonApi.Resource]
3914 | # ...
3915 | json_api do
3916 | type "ticket"
3917 | end
3918 | end
3919 | ```
3920 |
3921 | ### [](getting-started-with-ash-json-api.html#defining-routes-on-the-resource)Defining routes on the resource
3922 |
3923 | Here we show an example of defining routes on the resource.
3924 |
3925 | ```
3926 | defmodule Helpdesk.Support.Ticket do
3927 | use Ash.Resource, extensions: [AshJsonApi.Resource]
3928 | # ...
3929 | json_api do
3930 | type "ticket"
3931 |
3932 | routes do
3933 | # on the resource, the `base` applies to all routes
3934 | base "/tickets"
3935 |
3936 | get :read
3937 | index :read
3938 | post :open
3939 | # ...
3940 | end
3941 | end
3942 | end
3943 | ```
3944 |
3945 | Check out the [AshJsonApi.Resource documentation on Hex](AshJsonApi.Resource.html) for more information.
3946 |
3947 | ## [](getting-started-with-ash-json-api.html#run-your-api)Run your API
3948 |
3949 | From here on out its the standard Phoenix behavior. Start your application with `mix phx.server` and your API should be ready to try out. Should you be wondering what routes are available, you can print all available routes for each Resource:
3950 |
3951 | ```
3952 | Helpdesk.Support.Ticket
3953 | |> AshJsonApi.Resource.Info.routes(Helpdesk.Support)
3954 | ```
3955 |
3956 | Make sure that all requests you make to the API use the `application/vnd.api+json` type in both the `Accept` and `Content-Type` (where applicable) headers. The `Accept` header may be omitted.
3957 |
3958 | Examples:
3959 |
3960 | 1. Create a ticket
3961 |
3962 | ```
3963 | curl -X POST 'localhost:4000/api/json/helpdesk/tickets' \
3964 | --header 'Accept: application/vnd.api+json' \
3965 | --header 'Content-Type: application/vnd.api+json' \
3966 | --data-raw '{
3967 | "data": {
3968 | "type": "ticket",
3969 | "attributes": {
3970 | "subject": "This ticket was created through the JSON API"
3971 | }
3972 | }
3973 | }'
3974 | ```
3975 | 2. Get all tickets
3976 |
3977 | ```
3978 | curl 'localhost:4000/api/json/helpdesk/tickets'
3979 | ```
3980 | 3. Get a specific ticket
3981 |
3982 | ```
3983 | # Add the uuid of a Ticket you created earlier
3984 | curl 'localhost:4000/api/json/helpdesk/tickets/<uuid>'
3985 | ```
3986 |
3987 | ## [](getting-started-with-ash-json-api.html#open-api)Open API
3988 |
3989 | If you want to expose your API via Swagger UI or Redoc, see [the open api documentation](open-api.html).
3990 |
3991 | [← Previous Page Home](readme.html)
3992 |
3993 | [Next Page → What is AshJsonApi](what-is-ash-json-api.html)
3994 |
3995 | [Hex Package](https://hex.pm/packages/ash_json_api/1.4.16) [Hex Preview](https://preview.hex.pm/preview/ash_json_api/1.4.16) ([current file](https://preview.hex.pm/preview/ash_json_api/1.4.16/show/documentation/tutorials/getting-started-with-ash-json-api.md)) Search HexDocs [Download ePub version](ash_json_api.epub "ePub version")
3996 |
3997 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.31.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
3998 | [](https://github.com/ash-project/ash_json_api)
3999 |
4000 | [ash\_json\_api](https://github.com/ash-project/ash_json_api)
4001 |
4002 | v1.4.16
4003 |
4004 | - Pages
4005 | - Modules
4006 | - Mix Tasks
4007 |
4008 | <!--THE END-->
4009 |
4010 | <!--THE END-->
4011 |
4012 | <!--THE END-->
4013 |
4014 | Search documentation of ash\_json\_api
4015 |
4016 | Settings
4017 |
4018 | # [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/documentation/topics/links.md#L1 "View Source") Links
4019 |
4020 | In JSON:API, there are various pre-specified links.
4021 |
4022 | ## [](links.html#self-links-to-routes)Self links to routes
4023 |
4024 | Whenever you hit a route, there will be a `self` link in the top-level `links` object that points to the current request url.
4025 |
4026 | ## [](links.html#pagination-links-on-index-routes)Pagination links on index routes
4027 |
4028 | There will be `first`, `last`, `prev`, and `next` links on paginatable index routes, allowing clients to navigate through the pages of results.
4029 |
4030 | ## [](links.html#self-links-on-individual-entities)Self links on individual entities
4031 |
4032 | In order to get a self link generated for an individual entity, you must designate one of your `get` routes as `primary? true`. For example:
4033 |
4034 | ```
4035 | get :read, primary?: true
4036 | ```
4037 |
4038 | Then, each entity will have a `self` link in its `links` key.
4039 |
4040 | ## [](links.html#related-links)Related links
4041 |
4042 | ### [](links.html#relationship-self-links)Relationship Self Links
4043 |
4044 | Relationship self links are links to endpoints that return only the linkage, *not* the actual data of the related entities. To generate a relationship self link for a relationship, mark one of your `relationship` routes as `primary? true`. For example:
4045 |
4046 | ```
4047 | relationship :comments, :read, primary?: true
4048 | ```
4049 |
4050 | ### [](links.html#relationship-related-links)Relationship Related Links
4051 |
4052 | Relationship *related* links, on the other hand, are endpoints that return the related entities themselves, acting as modified index routes over the destination of the relationship. To generate one of these, mark one of your `related` routes as `primary? true`. For example:
4053 |
4054 | ```
4055 | related :comments, :read, primary?: true
4056 | ```
4057 |
4058 | [← Previous Page Relationships](relationships.html)
4059 |
4060 | [Next Page → Upgrading to AshJsonApi to 1.0](upgrade.html)
4061 |
4062 | [Hex Package](https://hex.pm/packages/ash_json_api/1.4.16) [Hex Preview](https://preview.hex.pm/preview/ash_json_api/1.4.16) ([current file](https://preview.hex.pm/preview/ash_json_api/1.4.16/show/documentation/topics/links.md)) Search HexDocs [Download ePub version](ash_json_api.epub "ePub version")
4063 |
4064 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.31.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
4065 | [](https://github.com/ash-project/ash_json_api)
4066 |
4067 | [ash\_json\_api](https://github.com/ash-project/ash_json_api)
4068 |
4069 | v1.4.16
4070 |
4071 | - Pages
4072 | - Modules
4073 | - Mix Tasks
4074 |
4075 | <!--THE END-->
4076 |
4077 | <!--THE END-->
4078 |
4079 | <!--THE END-->
4080 |
4081 | Search documentation of ash\_json\_api
4082 |
4083 | Settings
4084 |
4085 | # [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/mix/tasks/ash_json_api.install.ex#L2 "View Source") mix ash\_json\_api.install (ash\_json\_api v1.4.16)
4086 |
4087 | Installs AshJsonApi. Should be run with `mix igniter.install ash_json_api`
4088 |
4089 | # [](Mix.Tasks.AshJsonApi.Install.html#summary)Summary
4090 |
4091 | ## [Functions](Mix.Tasks.AshJsonApi.Install.html#functions)
4092 |
4093 | [igniter(igniter, argv)](Mix.Tasks.AshJsonApi.Install.html#igniter/2)
4094 |
4095 | Callback implementation for [`Igniter.Mix.Task.igniter/2`](../igniter/0.4.8/Igniter.Mix.Task.html#c:igniter/2).
4096 |
4097 | # [](Mix.Tasks.AshJsonApi.Install.html#functions)Functions
4098 |
4099 | [Link to this function](Mix.Tasks.AshJsonApi.Install.html#igniter/2 "Link to this function")
4100 |
4101 | # igniter(igniter, argv)
4102 |
4103 | [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/lib/mix/tasks/ash_json_api.install.ex#L14 "View Source")
4104 |
4105 | Callback implementation for [`Igniter.Mix.Task.igniter/2`](../igniter/0.4.8/Igniter.Mix.Task.html#c:igniter/2).
4106 |
4107 | [Hex Package](https://hex.pm/packages/ash_json_api/1.4.16) [Hex Preview](https://preview.hex.pm/preview/ash_json_api/1.4.16) Search HexDocs [Download ePub version](ash_json_api.epub "ePub version")
4108 |
4109 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.31.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
4110 | [](https://github.com/ash-project/ash_json_api)
4111 |
4112 | [ash\_json\_api](https://github.com/ash-project/ash_json_api)
4113 |
4114 | v1.4.16
4115 |
4116 | - Pages
4117 | - Modules
4118 | - Mix Tasks
4119 |
4120 | <!--THE END-->
4121 |
4122 | <!--THE END-->
4123 |
4124 | <!--THE END-->
4125 |
4126 | Search documentation of ash\_json\_api
4127 |
4128 | Settings
4129 |
4130 | # [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/documentation/topics/non-spec-query-parameters.md#L1 "View Source") Non-Spec query parameters
4131 |
4132 | AshJsonApi supports a few non-spec query parameters that enhance the capabilities of your API.
4133 |
4134 | These are currently not exposed in the generated OpenAPI spec. PRs welcome!
4135 |
4136 | ## [](non-spec-query-parameters.html#filter_included)`filter_included`
4137 |
4138 | Includes can be filtered via the `filter_included` query parameter. To do this, you provide the path to the included resource and the filter to apply.
4139 |
4140 | Example:
4141 |
4142 | `posts?include=comments&filter_included[comments][author_id]=1`
4143 |
4144 | ## [](non-spec-query-parameters.html#sort_included)`sort_included`
4145 |
4146 | Includes can be sorted via the `sort_included` query parameter. To do this, you provide the path to the included resource and the sort to apply.
4147 |
4148 | Example:
4149 |
4150 | `posts?include=comments&sort_included[comments]=author.username,-created_at`
4151 |
4152 | > ### [](non-spec-query-parameters.html#included-is-unsorted)included is unsorted!
4153 | >
4154 | > Keep in mind that the records in the top level `included` key will not be reliably sorted. This is because multiple relationships could include the same record. When sorting includes, look at the `data.relationships.name` key for the order instead.
4155 |
4156 | [← Previous Page What is AshJsonApi](what-is-ash-json-api.html)
4157 |
4158 | [Next Page → Open API](open-api.html)
4159 |
4160 | [Hex Package](https://hex.pm/packages/ash_json_api/1.4.16) [Hex Preview](https://preview.hex.pm/preview/ash_json_api/1.4.16) ([current file](https://preview.hex.pm/preview/ash_json_api/1.4.16/show/documentation/topics/non-spec-query-parameters.md)) Search HexDocs [Download ePub version](ash_json_api.epub "ePub version")
4161 |
4162 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.31.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
4163 | [](https://github.com/ash-project/ash_json_api)
4164 |
4165 | [ash\_json\_api](https://github.com/ash-project/ash_json_api)
4166 |
4167 | v1.4.16
4168 |
4169 | - Pages
4170 | - Modules
4171 | - Mix Tasks
4172 |
4173 | <!--THE END-->
4174 |
4175 | <!--THE END-->
4176 |
4177 | <!--THE END-->
4178 |
4179 | Search documentation of ash\_json\_api
4180 |
4181 | Settings
4182 |
4183 | # [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/documentation/topics/open-api.md#L1 "View Source") Open API
4184 |
4185 | ## [](open-api.html#use-with-phoenix)Use with Phoenix
4186 |
4187 | To set up the Open API endpoints for your application, first include the `:open_api_spex` dependency:
4188 |
4189 | ```
4190 | {:open_api_spex, "~> 3.16"},
4191 | ```
4192 |
4193 | Then in the module where you call `use AshJsonApi.Router` add the following option:
4194 |
4195 | ```
4196 | use AshJsonApi.Router, domains: [...], open_api: "/open_api"
4197 | ```
4198 |
4199 | Finally, you can use utilities provided by `open_api_spex` to show UIs for your API. Be sure to put your `forward` call last, if you are putting your API at a sub-path.
4200 |
4201 | ```
4202 | forward "/api/swaggerui",
4203 | OpenApiSpex.Plug.SwaggerUI,
4204 | path: "/api/open_api",
4205 | default_model_expand_depth: 4
4206 |
4207 | forward "/api/redoc",
4208 | Redoc.Plug.RedocUI,
4209 | spec_url: "/api/open_api"
4210 |
4211 | forward "/api", YourApp.YourApiRouter
4212 | ```
4213 |
4214 | Now you can go to `/api/swaggerui` and `/api/redoc`!
4215 |
4216 | ## [](open-api.html#use-with-plug)Use with Plug
4217 |
4218 | To set up the open API endpoints for your application, first include the `:open_api_spex` and `:redoc_ui_plug` dependency:
4219 |
4220 | ```
4221 | {:open_api_spex, "~> 3.16"},
4222 | {:redoc_ui_plug, "~> 0.2.1"},
4223 | ```
4224 |
4225 | Then in the module where you call `use AshJsonApi.Router` add the following option:
4226 |
4227 | ```
4228 | use AshJsonApi.Router, domains: [...], open_api: "/open_api"
4229 | ```
4230 |
4231 | Finally, you can use utilities provided by `open_api_spex` to show UIs for your API. Be sure to put your `forward` call last, if you are putting your API at a sub-path.
4232 |
4233 | ```
4234 | forward "/api/swaggerui",
4235 | to: OpenApiSpex.Plug.SwaggerUI,
4236 | init_opts: [
4237 | path: "/api/open_api",
4238 | default_model_expand_depth: 4
4239 | ]
4240 |
4241 | forward "/api/redoc",
4242 | to: Redoc.Plug.RedocUI,
4243 | init_opts: [
4244 | spec_url: "/api/open_api"
4245 | ]
4246 |
4247 | forward "/api", YourApp.YourApiRouter
4248 | ```
4249 |
4250 | Now you can go to `/api/swaggerui` and `/api/redoc`!
4251 |
4252 | ## [](open-api.html#customize-values-in-the-openapi-documentation)Customize values in the OpenAPI documentation
4253 |
4254 | To customize the main values of the OpenAPI spec, a few options are available:
4255 |
4256 | ```
4257 | use AshJsonApi.Router,
4258 | domains: [...],
4259 | open_api: "/open_api",
4260 | open_api_title: "Title",
4261 | open_api_version: "1.0.0",
4262 | open_api_servers: ["http://domain.com/api/v1"]
4263 | ```
4264 |
4265 | If `:open_api_servers` is not specified, a default server is automatically derived from your app's Phoenix endpoint, as retrieved from inbound connections on the `open_api` HTTP route.
4266 |
4267 | In case an active connection is not available, for example when generating the OpenAPI spec via CLI, you can explicitely specify a reference to the Phoenix endpoint:
4268 |
4269 | ```
4270 | use AshJsonApi.Router,
4271 | domains: [...],
4272 | open_api: "/open_api",
4273 | phoenix_endpoint: MyAppWeb.Endpoint
4274 | ```
4275 |
4276 | To override any value in the OpenApi documentation you can use the `:modify_open_api` options key:
4277 |
4278 | ```
4279 | use AshJsonApi.Router,
4280 | domains: [...],
4281 | open_api: "/open_api",
4282 | modify_open_api: {__MODULE__, :modify_open_api, []}
4283 |
4284 | def modify_open_api(spec, _, _) do
4285 | %{
4286 | spec
4287 | | info: %{spec.info | title: "MyApp Title JSON API", version: Application.spec(:my_app, :vsn) |> to_string()}
4288 | }
4289 | end
4290 | ```
4291 |
4292 | ## [](open-api.html#generate-spec-files-via-cli)Generate spec files via CLI
4293 |
4294 | You can write the OpenAPI spec file to disk using the Mix tasks provided by [OpenApiSpex](https://github.com/open-api-spex/open_api_spex).
4295 |
4296 | Supposing you have setup AshJsonApi as:
4297 |
4298 | ```
4299 | defmodule MyAppWeb.AshJsonApi
4300 | use AshJsonApi.Router, domains: [...], open_api: "/open_api"
4301 | end
4302 | ```
4303 |
4304 | you can generate the files with:
4305 |
4306 | ```
4307 | mix openapi.spec.json --spec MyAppWeb.AshJsonApi
4308 | mix openapi.spec.yaml --spec MyAppWeb.AshJsonApi
4309 | ```
4310 |
4311 | > ### [](open-api.html#setting-a-route-prefix-for-generated-files)Setting a route prefix for generated files
4312 | >
4313 | > The route prefix in normal usage is automatically inferred, but when generating files we will use the `prefix` option set in the `json_api` section of the relevant [`Ash.Domain`](../ash/3.4.47/Ash.Domain.html) module.
4314 |
4315 | To generate the YAML file you need to add the ymlr dependency.
4316 |
4317 | ```
4318 | def deps do
4319 | [
4320 | {:ymlr, "~> 2.0"}
4321 | ]
4322 | end
4323 | ```
4324 |
4325 | You can also use the `--check` option to confirm that your checked in spec file(s) match.
4326 |
4327 | ```
4328 | mix openapi.spec.json --spec MyAppWeb.AshJsonApiRouter --check
4329 | mix openapi.spec.yaml --spec MyAppWeb.AshJsonApiRouter --check
4330 | ```
4331 |
4332 | ## [](open-api.html#using-this-file-in-production)Using this file in production
4333 |
4334 | To avoid generating the spec every time your open\_api endpoint is hit, you can use the `open_api_file` option. Ensure that it points to an existing `.json` file. You will almost certainly want to do this only for production so that the schema is generated dynamically in dev, but served statically in production.
4335 |
4336 | ```
4337 | open_api_file =
4338 | if Mix.env() == :prod do
4339 | "priv/static/open_api.json"
4340 | else
4341 | nil
4342 | end
4343 |
4344 | use AshJsonApi.Router,
4345 | domains: [...],
4346 | open_api: "/open_api",
4347 | modify_open_api: {__MODULE__, :modify_open_api, []},
4348 | open_api_file: open_api_file
4349 | ```
4350 |
4351 | ## [](open-api.html#known-issues-limitations)Known issues/limitations
4352 |
4353 | ### [](open-api.html#swagger-ui)Swagger UI
4354 |
4355 | SwaggerUI does not properly render recursive types. This affects the examples and type documentation for the `filter` parameter especially.
4356 |
4357 | ### [](open-api.html#redoc)Redoc
4358 |
4359 | Redoc does not show all available schemas in the sidebar. This means that some schemas that are referenced only but have no endpoints that refer to them are effectively un-discoverable without downloading the spec and hunting them down yourself.
4360 |
4361 | [← Previous Page Non-Spec query parameters](non-spec-query-parameters.html)
4362 |
4363 | [Next Page → Relationships](relationships.html)
4364 |
4365 | [Hex Package](https://hex.pm/packages/ash_json_api/1.4.16) [Hex Preview](https://preview.hex.pm/preview/ash_json_api/1.4.16) ([current file](https://preview.hex.pm/preview/ash_json_api/1.4.16/show/documentation/topics/open-api.md)) Search HexDocs [Download ePub version](ash_json_api.epub "ePub version")
4366 |
4367 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.31.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
4368 | [](https://github.com/ash-project/ash_json_api)
4369 |
4370 | [ash\_json\_api](https://github.com/ash-project/ash_json_api)
4371 |
4372 | v1.4.16
4373 |
4374 | - Pages
4375 | - Modules
4376 | - Mix Tasks
4377 |
4378 | <!--THE END-->
4379 |
4380 | <!--THE END-->
4381 |
4382 | <!--THE END-->
4383 |
4384 | Search documentation of ash\_json\_api
4385 |
4386 | Settings
4387 |
4388 | # [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/README.md#L1 "View Source") Home
4389 |
4390 |  
4391 |
4392 |  [](https://opensource.org/licenses/MIT) [](https://hex.pm/packages/ash_json_api) [](../ash_json_api.html)
4393 |
4394 | # AshJsonApi
4395 |
4396 | Welcome! This is the extension for building [JSON:API](https://jsonapi.org) spec compliant APIs with [Ash](../ash.html). Generate a powerful JSON API in minutes!
4397 |
4398 | ## [](readme.html#tutorials)Tutorials
4399 |
4400 | - [Getting Started with AshJsonApi](getting-started-with-ash-json-api.html)
4401 |
4402 | ## [](readme.html#topics)Topics
4403 |
4404 | - [What is AshJsonApi?](what-is-ash-json-api.html)
4405 | - [Non-Spec Query Parameters](non-spec-query-parameters.html)
4406 | - [OpenAPI](open-api.html)
4407 | - [Relationships](relationships.html)
4408 | - [Authorize With AshJsonApi](authorize-with-json-api.html)
4409 | - [Upgrading to 1.0](upgrade.html)
4410 |
4411 | ## [](readme.html#reference)Reference
4412 |
4413 | - [AshJsonApi.Resource DSL](dsl-ashjsonapi-resource.html)
4414 | - [AshJsonApi.Domain DSL](dsl-ashjsonapi-domain.html)
4415 |
4416 | [← Previous Page API Reference](api-reference.html)
4417 |
4418 | [Next Page → Getting started with AshJsonApi](getting-started-with-ash-json-api.html)
4419 |
4420 | [Hex Package](https://hex.pm/packages/ash_json_api/1.4.16) [Hex Preview](https://preview.hex.pm/preview/ash_json_api/1.4.16) ([current file](https://preview.hex.pm/preview/ash_json_api/1.4.16/show/README.md)) Search HexDocs [Download ePub version](ash_json_api.epub "ePub version")
4421 |
4422 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.31.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
4423 | [](https://github.com/ash-project/ash_json_api)
4424 |
4425 | [ash\_json\_api](https://github.com/ash-project/ash_json_api)
4426 |
4427 | v1.4.16
4428 |
4429 | - Pages
4430 | - Modules
4431 | - Mix Tasks
4432 |
4433 | <!--THE END-->
4434 |
4435 | <!--THE END-->
4436 |
4437 | <!--THE END-->
4438 |
4439 | Search documentation of ash\_json\_api
4440 |
4441 | Settings
4442 |
4443 | # [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/documentation/topics/relationships.md#L1 "View Source") Relationships
4444 |
4445 | You can specify which arguments will modify relationships using `relationship_arguments`, but there are some things to keep in mind.
4446 |
4447 | `relationship_arguments` is a list of arguments that can be edited in the `data.relationships` input.
4448 |
4449 | This is primarily useful for those who want to keep their relationship changes in compliance with the `JSON:API` spec. If you are not focused on building a fully compliant JSON:API, it is likely far simpler to simply accept arguments in the `attributes` key and ignore the `data.relationships` input.
4450 |
4451 | If the argument's type is `{:array, _}`, a list of data will be expected. Otherwise, it will expect a single item.
4452 |
4453 | Everything in this guide applies to routs defined on the domain as well.
4454 |
4455 | For example:
4456 |
4457 | ```
4458 | # On a tweets resource
4459 |
4460 | # With a patch route that references the `authors` argument
4461 | json_api do
4462 | routes do
4463 | patch :update, relationship_arguments: [:authors]
4464 | end
4465 | end
4466 |
4467 | # And an argument by that name in the action
4468 | actions do
4469 | update :update do
4470 | argument :authors, {:array, :map}, allow_nil?: false
4471 |
4472 | change manage_relationship(:authors, type: :append_and_remove) # Use the authors argument to allow changing the related authors on update
4473 | end
4474 | end
4475 | ```
4476 |
4477 | You can then send the value for `authors` in the relationships key, e.g
4478 |
4479 | ```
4480 | {
4481 | data: {
4482 | attributes: {
4483 | ...
4484 | },
4485 | relationships: {
4486 | authors: {
4487 | data: [
4488 | {type: "author", id: 1}, // the `type` key is removed when the value is placed into the action, so this input would be `%{"id" => 1}` (`type` is required by `JSON:API` specification)
4489 | {type: "author", id: 2, meta: {arbitrary: 1, keys: 2}}, <- `meta` is JSON:API spec freeform data, so this input would be `%{"id" => 2, "arbitrary" => 1, "keys" => 2}`
4490 | ]
4491 | }
4492 | }
4493 | }
4494 | }
4495 | ```
4496 |
4497 | If you do not include `:authors` in the `relationship_arguments` key, you would supply its value in `attributes`, e.g:
4498 |
4499 | ```
4500 | {
4501 | data: {
4502 | attributes: {
4503 | authors: {
4504 | {id: 1},
4505 | {id: 2, arbitrary: 1, keys: 2},
4506 | }
4507 | }
4508 | }
4509 | }
4510 | ```
4511 |
4512 | Non-map argument types, e.g `argument :author, :integer` (expecting an author id) work with `manage_relationship`, but not with JSON:API, because it expects `{"type": _type, "id" => id}` for relationship values. To support non-map arguments in `relationship_arguments`, instead of `:author`, use `{:id, :author}`. This works for `{:array, _}` type arguments as well, so the value would be a list of ids.
4513 |
4514 | ## [](relationships.html#relationship-manipulation-routes)Relationship Manipulation Routes
4515 |
4516 | You can also specify routes that are dedicated to manipulating relationships. We generally suggest the above approach, but JSON:API spec also allows for dedicated relationship routes. For example:
4517 |
4518 | ```
4519 | routes do
4520 | ...
4521 | # use `post_to_relationship` when the operation is additive
4522 | post_to_relationship :add_author, action: :add_author
4523 | # use `patch_relationship` when the operation is both additive and subtractive
4524 | # use `delete_from_relationship` when the operation is subtractive
4525 | end
4526 | ```
4527 |
4528 | This will use an action on the source resource, (by default the primary update), and expects it to take an argument with the corresponding name. Additionally, it must have a `change manage_relationship` that uses that attribute. For example:
4529 |
4530 | ```
4531 | update :add_author do
4532 | argument :author, :map
4533 |
4534 | change manage_relationship(:author, type: :append)
4535 | end
4536 | ```
4537 |
4538 | [← Previous Page Open API](open-api.html)
4539 |
4540 | [Next Page → Links](links.html)
4541 |
4542 | [Hex Package](https://hex.pm/packages/ash_json_api/1.4.16) [Hex Preview](https://preview.hex.pm/preview/ash_json_api/1.4.16) ([current file](https://preview.hex.pm/preview/ash_json_api/1.4.16/show/documentation/topics/relationships.md)) Search HexDocs [Download ePub version](ash_json_api.epub "ePub version")
4543 |
4544 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.31.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
4545 | [](https://github.com/ash-project/ash_json_api)
4546 |
4547 | [ash\_json\_api](https://github.com/ash-project/ash_json_api)
4548 |
4549 | v1.4.16
4550 |
4551 | - Pages
4552 | - Modules
4553 | - Mix Tasks
4554 |
4555 | <!--THE END-->
4556 |
4557 | <!--THE END-->
4558 |
4559 | <!--THE END-->
4560 |
4561 | Search documentation of ash\_json\_api
4562 |
4563 | Settings
4564 |
4565 | # [View Source](https://github.com/ash-project/ash_json_api/blob/v1.4.16/documentation/topics/what-is-ash-json-api.md#L1 "View Source") What is AshJsonApi
4566 |
4567 | AshJsonApi allows you to expose your resource actions over a (JSON:API)\[[https://jsonapi.org\]](https://jsonapi.org%5D). This API supports all of the features of JSON:API and Ash, like sorting, filtering, pagination, and side loading.
4568 |
4569 | The kinds of thing this extension handles:
4570 |
4571 | 1. Route Creation: AshJsonApi defines routes and actions in your app based on resource configurations
4572 | 2. Deserialization: When an incoming HTTP request hits a AshJsonApi defined route/action, AshJsonApi will parse it from `/api/users?filter[admin]=true` into a call to ash
4573 | 3. Query Execution: AshJsonApi then executes the parsed Ash Action (this is the integration point between AshJsonApi and Ash Core, where Ash Actions are defined)
4574 | 4. Serialization: AshJsonApi then serializes the result of the Ash Action into JSON API objects.
4575 | 5. Response: AshJsonApi then sends this JSON back to the client
4576 | 6. Schema Generation: AshJsonApi generates a machine-readable JSON Schema of your entire API and a route/action that can serve it
4577 | 7. OpenAPI generation: AshJsonApi generates an OpenAPI spec for your API, which provides *human* readable documentation effortlessly.
4578 |
4579 | > ### [](what-is-ash-json-api.html#ash-does-the-work)Ash does the work
4580 | >
4581 | > Ash takes care of all of the data related work for a request (CRUD, Sorting, Filtering, Pagination, Side Loading, and Authorization) while AshJsonApi more or less replaces controllers and serializers.
4582 | >
4583 | > The beauty of putting all of that data functionality into a non-web layer (Ash) is that it can be used in many contexts. A JSON:API is one context - but there are others such as GraphQL or just using an Ash Resource from other code within an Application.
4584 |
4585 | [← Previous Page Getting started with AshJsonApi](getting-started-with-ash-json-api.html)
4586 |
4587 | [Next Page → Non-Spec query parameters](non-spec-query-parameters.html)
4588 |
4589 | [Hex Package](https://hex.pm/packages/ash_json_api/1.4.16) [Hex Preview](https://preview.hex.pm/preview/ash_json_api/1.4.16) ([current file](https://preview.hex.pm/preview/ash_json_api/1.4.16/show/documentation/topics/what-is-ash-json-api.md)) Search HexDocs [Download ePub version](ash_json_api.epub "ePub version")
4590 |
4591 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.31.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
4592 |
```