Alternera.Resource.Transformers.AddJsonApi (alternera_resource_sdk v0.9.0)

Copy Markdown View Source

Writes the resource's json_api section from expose api:: the type "<package id>.<resource id>", the base /tenants/:tenant_id/resources/<package id>/<resource id> and one route per exposed kind on the primary action of its type. With nothing exposed the section stays empty and the proxy serves no route for the resource.

AshJsonApi turns each path parameter into an argument of the route's read action or, failing that, a filter on a public attribute. tenant_id is private (the tenant comes from the path through the proxy's router), so the routes read through :alternera_json_api_read, a read action this transformer adds with a tenant_id argument that nothing uses: the index and get routes run it, and the patch and delete routes fetch their record with it. It reads like a plain read; a filter or preparation on the resource's own primary read does not apply to the API.

Summary

Functions

The read action the JSON:API routes run.

Functions

after_compile?()

Callback implementation for Spark.Dsl.Transformer.after_compile?/0.

read_action()

@spec read_action() :: atom()

The read action the JSON:API routes run.