This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
defmodule DecentralisedBookIndex.Metadata do
|
||||
use Ash.Domain,
|
||||
otp_app: :decentralised_book_index
|
||||
use Ash.Domain, otp_app: :decentralised_book_index, extensions: [AshJsonApi.Domain, AshPhoenix]
|
||||
|
||||
alias DecentralisedBookIndex.Metadata
|
||||
|
||||
@@ -64,4 +63,13 @@ defmodule DecentralisedBookIndex.Metadata do
|
||||
|
||||
resource DecentralisedBookIndex.Metadata.AuthorRole
|
||||
end
|
||||
|
||||
json_api do
|
||||
routes do
|
||||
base_route "/author", Metadata.Author do
|
||||
get :read
|
||||
index :search
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,11 +2,16 @@ defmodule DecentralisedBookIndex.Metadata.Author do
|
||||
use Ash.Resource,
|
||||
otp_app: :decentralised_book_index,
|
||||
domain: DecentralisedBookIndex.Metadata,
|
||||
data_layer: AshPostgres.DataLayer
|
||||
data_layer: AshPostgres.DataLayer,
|
||||
extensions: [AshJsonApi.Resource]
|
||||
|
||||
require Ash.Query
|
||||
alias DecentralisedBookIndex.Metadata
|
||||
|
||||
json_api do
|
||||
type "author"
|
||||
end
|
||||
|
||||
postgres do
|
||||
table "authors"
|
||||
repo DecentralisedBookIndex.Repo
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
defmodule DecentralisedBookIndexWeb.AshJsonApiRouter do
|
||||
use AshJsonApi.Router,
|
||||
domains: [],
|
||||
domains: [Module.concat(["DecentralisedBookIndex.Metadata"])],
|
||||
open_api: "/open_api"
|
||||
end
|
||||
|
||||
@@ -21,12 +21,12 @@ defmodule DecentralisedBookIndexWeb.Router do
|
||||
plug :set_actor, :user
|
||||
end
|
||||
|
||||
scope "/api/json" do
|
||||
scope "/api/v1/json" do
|
||||
pipe_through [:api]
|
||||
|
||||
forward "/swaggerui",
|
||||
OpenApiSpex.Plug.SwaggerUI,
|
||||
path: "/api/json/open_api",
|
||||
path: "/api/v1/json/open_api",
|
||||
default_model_expand_depth: 4
|
||||
|
||||
forward "/", DecentralisedBookIndexWeb.AshJsonApiRouter
|
||||
|
||||
Reference in New Issue
Block a user