首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用phoenix_api_docs

使用phoenix_api_docs
EN

Stack Overflow用户
提问于 2017-07-26 23:32:41
回答 1查看 35关注 0票数 1

我想使用https://github.com/smoku/phoenix_api_docs来制作一个doc api,但我有一个问题,正如文档中所指出的,我在test_helper.exs中放入了以下内容:

代码语言:javascript
复制
PhoenixApiDocs.start ExUnit.start(formatters: [ExUnit.CLIFormatter, PhoenixApiDocs.Formatter])

当我运行mix测试时,控制台显示如下:

代码语言:javascript
复制
09:22:51.173 [error] GenEvent handler PhoenixApiDocs.Formatter
                     installed in #PID<0.323.0> terminating
  ** (UndefinedFunctionError) function
    WhitespaceEx.Application.Router.__routes__/0 is undefined (module 
    WhitespaceEx.Application.Router is not available)
    WhitespaceEx.Application.Router.__routes__() (phoenix_api_docs)
  lib/phoenix_api_docs/generator.ex:26: 
    PhoenixApiDocs.Generator.routes_docs/2 (phoenix_api_docs) 
  lib/phoenix_api_docs/generator.ex:12:
    PhoenixApiDocs.Generator.run/0 (phoenix_api_docs) 
  lib/phoenix_api_docs/formatter.ex:22: 
    PhoenixApiDocs.Formatter.save_blueprint_file/0 (phoenix_api_docs) 
  lib/phoenix_api_docs/formatter.ex:9: 
    PhoenixApiDocs.Formatter.handle_event/2 (stdlib) 
  gen_event.erl:573: :gen_event.server_update/4 (stdlib) 
  gen_event.erl:555: :gen_event.server_notify/4 (stdlib) 
  gen_event.erl:296: :gen_event.handle_msg/6 (stdlib) 
  proc_lib.erl:247: :proc_lib.init_p_do_apply/3 Last message: 
    {:suite_finished, 6679713, nil}

并且不生成文件api.apib中的文档。项目配置有erlang 19.2elixir 1.4.2Phoenix v1.2.4nodejs 7.4.0Erlang/OTP 20

在这种情况下我需要一些帮助

EN

回答 1

Stack Overflow用户

发布于 2017-07-29 12:44:40

phoenix_api_docsmix.exs中指定的应用程序模块推断出路由器模块的名称

代码语言:javascript
复制
  def run do
    test_conns = PhoenixApiDocs.ConnLogger.conns
    app_module = Mix.Project.get.application |> Keyword.get(:mod) |> elem(0)
    router_module = Module.concat([app_module, :Router])

    %{
      host: Keyword.get(api_docs_info, :host, "http://localhost"),
      title: Keyword.get(api_docs_info, :title, "API Documentation"),
      description: Keyword.get(api_docs_info, :description, "Enter API description in mix.exs - api_docs_info"),
      routes: routes_docs(router_module, test_conns)
    }
  end 

从您的错误消息看,您的应用程序模块名称似乎是WhitespaceEx.Application,但我猜您的路由器模块是WhitespaceEx.Router

使用当前phoenix_api_docs实现的一种方法是将应用程序模块重命名为WhitespaceEx

有一个开放的PR,允许您配置路由器名称,并支持phoenix 1.3约定Support for Phoenix 1.3 #9

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45331452

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档