Back to list
forest

ash-json-api

by forest

I ❤️ dotfiles

4🍴 0📅 Jan 3, 2026

SKILL.md


name: ash-json-api description: AshJsonApi guidelines for exposing Ash resources as JSON:API compliant REST endpoints. Use when adding JSON:API extensions to domains/resources, configuring routes, or implementing filtering, sorting, pagination, and includes. Supports full JSON:API specification.

AshJsonApi Guidelines

AshJsonApi generates JSON:API compliant endpoints from Ash resources, supporting filtering, sorting, pagination, includes, and relationships.

Domain Configuration

Add the AshJsonApi.Domain extension and define routes:

defmodule MyApp.Blog do
  use Ash.Domain,
    extensions: [AshJsonApi.Domain]

  json_api do
    authorize? true

    routes do
      base_route "/posts", MyApp.Blog.Post do
        get :read
        index :read
        post :create
        patch :update
        delete :destroy
      end
    end
  end

  resources do
    resource MyApp.Blog.Post
    resource MyApp.Blog.Comment
  end
end

Resource Configuration

Add the AshJsonApi.Resource extension and specify the type:

defmodule MyApp.Blog.Post do
  use Ash.Resource,
    domain: MyApp.Blog,
    extensions: [AshJsonApi.Resource]

  attributes do
    uuid_primary_key :id
    attribute :title, :string
    attribute :body, :string
    attribute :published, :boolean
  end

  relationships do
    belongs_to :author, MyApp.Accounts.User
    has_many :comments, MyApp.Blog.Comment
  end

  json_api do
    type "post"  # Required: JSON:API type name
  end

  actions do
    defaults [:create, :read, :update, :destroy]

    read :list_published do
      filter expr(published == true)
    end

    update :publish do
      accept []
      change set_attribute(:published, true)
    end
  end
end

Route Types

RouteHTTPPathDescription
getGET/posts/:idFetch single resource
indexGET/postsList resources (filter/sort/paginate)
postPOST/postsCreate resource
patchPATCH/posts/:idUpdate resource
deleteDELETE/posts/:idDestroy resource
relatedGET/posts/:id/commentsFetch related resources
relationshipGET/posts/:id/relationships/commentsFetch relationship data
post_to_relationshipPOST/posts/:id/relationships/commentsAdd to relationship
patch_relationshipPATCH/posts/:id/relationships/commentsReplace relationship
delete_from_relationshipDELETE/posts/:id/relationships/commentsRemove from relationship

Query Parameters

Standard JSON:API query parameters:

# Filter
?filter[attribute]=value

# Sort (descending with -)
?sort=attribute,-other_attribute

# Pagination
?page[number]=2&page[size]=10

# Includes (sideload related resources)
?include=author,comments.author

Score

Total Score

50/100

Based on repository quality metrics

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

0/10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

Reviews

💬

Reviews coming soon