The open_api API documentation library is giving "internal server error"

I am trying to create an API documentation site for my API using the open_api library in my project. However, I am encountering an “Internal Server Error.”

I have created a GitHub repo to replicate the error:
GitHub repo: GitHub - sangeethailango/project_management

After cloning the repo, go to http://localhost:4000/api/redoc to find the page where the error occurs.

The page loads fine if I remove the related(:users, :read) line in the accounts.ex domain file. However, the page fails to load when this line is present. For your information, I did not encounter any errors while creating the APIs, but the issue only occurs here.

1 Like

It looks your user resource is two things:

  1. missing json_api declaration
  json_api do
    type("user")
  end
  1. and the use of extensions: [AshJsonApi.Resource]
  use Ash.Resource,
    domain: ProjectManagement.Account,
    data_layer: AshPostgres.DataLayer,
    extensions: [AshJsonApi.Resource]

Adding both should fix the error.

1 Like