AshPhoenixGenApi.Verifiers.VerifyActionConfigs (ash_phoenix_gen_api v1.0.3)

Copy Markdown View Source

Verifier for the gen_api section of AshPhoenixGenApi.Resource.

This verifier performs compile-time validation of the PhoenixGenApi action configurations defined in an Ash resource's DSL. It checks:

  1. Action existence — Every action entity references an Ash action that actually exists on the resource.

  2. Request type uniqueness — No two actions in the same resource share the same request_type (either explicit or auto-derived).

  3. Arg consistency — When both arg_types and arg_orders are explicitly provided, their keys must match exactly.

  4. Permission arg existence — When check_permission is set to {:arg, "arg_name"}, the argument must exist in either the explicit arg_types or the Ash action's accepted attributes/arguments.

  5. MFA validity — When an explicit mfa is provided, the module must be loaded (or the function must exist if the module is loaded).

  6. Permission callback validity — When permission_callback is provided, it must be a valid MFA tuple {module, function, args} where module and function are atoms and args is a list, or nil.

Error Messages

The verifier raises Spark.Error.DslError with descriptive messages and the path to the offending configuration, making it easy to locate and fix issues.