【问题标题】:How to remove _format URL suffix from documentation generated by NelmioApiDocBundle?如何从 NelmioApiDocBundle 生成的文档中删除 _format URL 后缀?
【发布时间】:2015-11-27 13:48:39
【问题描述】:

我已经为我在 Symfony 中面向 API 的新项目安装了 NelmioApiDocBundle,但我无法摆脱这个捆绑包添加到我所有端点 URL 的 .{_format} 后缀。

看起来是这样的:

我的 API 不支持 _format 作为后缀。它确实支持它作为查询参数或请求标头。因此,如果我尝试从 NelmioApiDocBundle 沙箱向此端点发出请求,它会收到 404 错误响应。

这是我当前关于 nelmio 的 config.yml 部分:

yml nelmio_api_doc: name: My API doc sandbox: enabled: true endpoint: null accept_type: application/json body_format: formats: null default_format: json request_format: formats: json: application/json xml: null method: accept_header default_format: json authentication: name: bearer delivery: query cache: enabled: false file: '%kernel.cache_dir%/api-doc.cache'

【问题讨论】:

    标签: symfony nelmioapidocbundle


    【解决方案1】:

    我已经在 stackoverflow 的其他地方找到了它。看来我的问题与 NelmioApiDocBundle 无关,而是与 FOSRestBundle 相关。我只需要更改config.yml 中的一个 FOSRest 设置:

    fos_rest:
        routing_loader:
            include_format: false
    

    我找到了解决方案here

    【讨论】:

      猜你喜欢
      • 2018-11-11
      • 2015-10-25
      • 1970-01-01
      • 2012-04-21
      • 1970-01-01
      • 2018-08-27
      • 1970-01-01
      • 1970-01-01
      • 2019-03-01
      相关资源
      最近更新 更多