Gets the primary key field name(s) for a resource.
Parameters
resource- The Ash resource module
Returns
List of primary key field names (as atoms).
Examples
iex> Config.primary_key(MyApp.Post)
[:id]
Retrieves and normalizes configuration from AshJsonApi DSL.
This module provides a unified interface for accessing configuration options defined in Ash domains and resources through the AshJsonApi DSL.
Domain-level configuration is retrieved via AshJsonApi.Domain.Info:
tag/1 - Custom OpenAPI tag for the domaingroup_by/1 - How operations should be grouped (e.g., by resource)prefix/1 - Route prefix for all resources in the domainResource-level configuration is retrieved via AshJsonApi.Resource.Info:
type/1 - JSON:API type name (defaults to underscored resource name)derive_filter?/1 - Whether to auto-generate filter schemasderive_sort?/1 - Whether to auto-generate sort schemasdefault_fields/1 - Default fields to include in responsesincludes/1 - Available relationship includes# Get the JSON:API type for a resource
type = Config.resource_type(MyApp.Post)
# => "post"
# Check if filtering should be derived
if Config.derive_filter?(MyApp.Post) do
# Generate filter schema
end
# Get route prefix for a domain
prefix = Config.route_prefix(MyApp.Blog)
# => "/api/v1"Functions in this module follow the "let it crash" philosophy. If called with an invalid module (not an Ash resource or domain), they will raise an error. This is intentional - configuration errors should fail loudly rather than silently returning defaults.
Gets the default fields to include in responses for a resource.
Checks whether filter schemas should be auto-derived for a resource.
Checks whether sort schemas should be auto-derived for a resource.
Gets all resources in a domain.
Gets the JSON:API routes for a domain.
Gets the OpenAPI tag for a domain.
Gets the operation grouping strategy for a domain.
Gets the available relationship includes for a resource.
Gets the primary key field name(s) for a resource.
Gets the public attributes for a resource.
Gets a specific relationship for a resource by name.
Gets the relationships for a resource.
Gets a specific action for a resource by name.
Gets the actions for a resource.
Gets the JSON:API type name for a resource.
Gets the route prefix for a domain.
Gets the default fields to include in responses for a resource.
If configured, responses will only include the specified fields unless the client requests additional fields via sparse fieldsets.
resource - The Ash resource module List of field names (as atoms) or nil for all fields.
iex> Config.default_fields(MyApp.Post)
[:id, :title, :body]
iex> Config.default_fields(MyApp.Comment)
nil
Checks whether filter schemas should be auto-derived for a resource.
When enabled, the OpenAPI generator will create detailed filter parameter schemas based on the resource's attributes.
resource - The Ash resource moduleBoolean indicating if filter derivation is enabled.
iex> Config.derive_filter?(MyApp.Post)
true
Checks whether sort schemas should be auto-derived for a resource.
When enabled, the OpenAPI generator will create sort parameter schemas listing all sortable fields.
resource - The Ash resource moduleBoolean indicating if sort derivation is enabled.
iex> Config.derive_sort?(MyApp.Post)
true
Gets all resources in a domain.
domain - The Ash domain moduleList of resource modules.
iex> Config.domain_resources(MyApp.Blog)
[MyApp.Post, MyApp.Comment, MyApp.Author]
Gets the JSON:API routes for a domain.
domain - The Ash domain moduleList of route structs.
Config.domain_routes(MyApp.Blog)
# => [%{type: :index, ...}, %{type: :get, ...}, ...]
Gets the OpenAPI tag for a domain.
Tags are used to group operations in OpenAPI documentation tools like Swagger UI.
domain - The Ash domain module The tag name as a string, or nil if not configured.
iex> Config.domain_tag(MyApp.Blog)
"Blog"
Gets the operation grouping strategy for a domain.
Determines how operations are grouped in the OpenAPI spec.
domain - The Ash domain module The grouping strategy atom (e.g., :resource, :domain), or nil.
iex> Config.group_by(MyApp.Blog)
:resource
Gets the available relationship includes for a resource.
Defines which relationships can be included via the include
query parameter. Returns nil if not configured.
resource - The Ash resource module List of includable relationship paths, or nil if not configured.
iex> Config.includes(MyApp.Post)
[:author, :comments, "comments.author"]
Gets the primary key field name(s) for a resource.
resource - The Ash resource moduleList of primary key field names (as atoms).
iex> Config.primary_key(MyApp.Post)
[:id]
Gets the public attributes for a resource.
Returns only attributes marked public? true, which are the ones
that belong in OpenAPI schemas.
resource - The Ash resource moduleList of attribute structs.
Gets a specific relationship for a resource by name.
resource - The Ash resource modulename - The relationship name (atom) The relationship struct or nil if not found.
Gets the relationships for a resource.
resource - The Ash resource moduleList of relationship structs.
Gets a specific action for a resource by name.
resource - The Ash resource moduleaction_name - The action name (atom) The action struct or nil if not found.
Gets the actions for a resource.
resource - The Ash resource moduleList of action structs.
Gets the JSON:API type name for a resource.
The type is used in JSON:API responses as the type field and in
route generation. If not explicitly configured, defaults to the
underscored resource module name.
resource - The Ash resource moduleThe JSON:API type as a string.
iex> Config.resource_type(MyApp.BlogPost)
"blog_post"
iex> Config.resource_type(MyApp.User)
"user"
Gets the route prefix for a domain.
The prefix is prepended to all resource routes in the domain.
domain - The Ash domain moduleThe route prefix as a string (empty string if not configured).
iex> Config.route_prefix(MyApp.Blog)
"/api/v1"
iex> Config.route_prefix(MyApp.Admin)
"/admin"