{"id":13507816,"url":"https://github.com/smoku/phoenix_api_docs","last_synced_at":"2026-02-22T10:33:46.280Z","repository":{"id":57531689,"uuid":"67257583","full_name":"smoku/phoenix_api_docs","owner":"smoku","description":"Phoenix API Docs","archived":false,"fork":false,"pushed_at":"2018-09-05T10:41:59.000Z","size":14,"stargazers_count":26,"open_issues_count":9,"forks_count":10,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-11-01T07:33:18.529Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/smoku.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-09-02T21:58:38.000Z","updated_at":"2023-04-28T08:58:14.000Z","dependencies_parsed_at":"2022-09-06T16:20:11.856Z","dependency_job_id":null,"html_url":"https://github.com/smoku/phoenix_api_docs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smoku%2Fphoenix_api_docs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smoku%2Fphoenix_api_docs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smoku%2Fphoenix_api_docs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smoku%2Fphoenix_api_docs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/smoku","download_url":"https://codeload.github.com/smoku/phoenix_api_docs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246301963,"owners_count":20755512,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T02:00:40.034Z","updated_at":"2025-10-21T15:07:58.531Z","avatar_url":"https://github.com/smoku.png","language":"Elixir","funding_links":[],"categories":["Documentation"],"sub_categories":[],"readme":"# Phoenix Api Docs\n\n`PhoenixApiDocs` is a library written in the `Elixir` for the [Phoenix framework](http://www.phoenixframework.org/). It lets you generate API documentation in the [API Blueprint](https://apiblueprint.org/) format from annotations in controllers and automated tests.\n\n\n## Installation\n\nAdd PhoenixApiDocs to your mix.exs dependencies:\n\n```elixir\ndefp deps do\n  [{:phoenix_api_docs, \"~\u003e 0.1.0\"}]\nend\n```\n\nRun `mix deps.get` to fetch the dependencies:\n\n```\n$ mix deps.get\n```\n\nIn your `test/test_helper.exs` start gen server `PhoenixApiDocs.start` for logging requests and configure `ExUnit` to use `PhoenixApiDocs.Formatter`:\n\n```elixir\nPhoenixApiDocs.start\nExUnit.start(formatters: [ExUnit.CLIFormatter, PhoenixApiDocs.Formatter])\n```\n\n\n## Usage\n\nAdd `api_docs_info` to your `mix.exs`:\n\n```elixir\ndef api_docs_info do\n  [\n    host: \"https://api.acme.com\",\n    title: \"ACME API\",\n    description: \"API requires authorization. All requests must have valid `auth_token`\"\n  ]\nend\n```\n\nOptions:\n* `host`: API host.\n* `title`: Documentation title (can use Blueprint format).\n* `description`: Documentation description (can use Blueprint format).\n\nAdd `PhoenixApiDocs.Controller` to your `phoenix` controller and use `api\\3` macro to generate specification for the controller action:\n\n```elixir\ndefmodule App.CommentController do\n  use App.Web, :controller\n  use PhoenixApiDocs.Controller\n\n  api :GET, \"/posts/:post_id/comments\" do\n    group \"Comment\" # If not provided, it will be guessed from the controller name (resource name)\n    title \"List comments for specific docs\"\n    description \"Optiona description that will be displayed in the documentation\"\n    note \"Optional note that will be displayed in the documentation\"\n    parameter :post_id, :integer, :required, \"Post ID or slug\"\n  end\n  def index(conn, %{\"post_id\" =\u003e post_id}) do\n    ...\n  end\n\n  api :PUT, \"/posts/:post_id/comments\" do\n    title \"Update comment\"\n    parameter :post_id, :integer, :required, \"Post ID or slug\"\n  end\n  def update(conn, %{\"comment\" =\u003e comment_params}) do\n    ...\n  end\n\nend\n```\n\nAPI specification options:\n\n* `method`: HTTP method - GET, POST, PUT, PATCH, DELETE\n* `url`: URL route from `phoenix router``\n* `group`: Documentation routes are grouped by a group name (defaults to resource name guessed from the controller name)\n* `title`: Title (can use Blueprint format)\n* `description`: Description (optional, can use Blueprint format)\n* `note`: Note (optional, can use Blueprint format)\n* `parameter`: `name, type, required/optional, description`\n  * required - `parameter :post_id, :integer, :required, \"Post ID\"`\n  * optional - `parameter :post_id, :integer, \"Post ID\"`\n\n\nIn your tests select what requests and responses you want to include in the documentation by saving `conn` to `PhoenixApiDocs.ConnLogger`:\n\n```elixir\n  test \"list comments for post\", %{conn: conn} do\n    post = insert(:post)\n    insert_list(5, :comment, post: post)\n\n    conn = get(\n      conn,\n      comments_path(conn, :index, post)\n    )\n\n    assert json_response(conn, 200)\n\n    PhoenixApiDocs.ConnLogger.save(conn)\n  end\n```\n\n`PhoenixApiDocs.ConnLogger.save` can be also piped:\n\n```elixir\n    conn = get(\n      conn,\n      comments_path(conn, :index, post)\n    ) |\u003e PhoenixApiDocs.ConnLogger.save\n  end\n```\n\nAfter you run your tests, documentation in an API Blueprint format will be generate in a file `api.apib`\n\n```\n$ mix test\n```\n\nTo generate the documentation in a HTML format use [Aglio renderer](https://github.com/danielgtaylor/aglio)\n\n```\n$ npm install aglio -g\n\n$ mix phoenix.api_docs\n```\n\n\n## Configuration\n\nThe configuration options can be setup in `config.exs`:\n\n```elixir\nconfig :phoenix_api_docs,\n  docs_path: \"priv/static/docs\",\n  theme: \"triple\"\n```\n\nConfig options:\n* `docs_path`: Specify the path where the documentation will be generated. If you want to serve the documentation directly from the `phoenix` you can specify `priv/static/docs`.\n* `theme`: HTML theme is generated using the [Aglio renderer](https://github.com/danielgtaylor/aglio).\n\n\n## Common problems\n\n#### Route is not generated after adding api annotation in the controller\n\nPlease make sure that the route you are using in the annotation matches exactly the route from the `phoenix router` (including params). Run `mix phoenix.routes` and compare the routes.\n\n## Tasks to do\n\n* `raise error` when route that is used in the annotation is not available in the `phoenix router`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmoku%2Fphoenix_api_docs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmoku%2Fphoenix_api_docs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmoku%2Fphoenix_api_docs/lists"}