我想使用NelmioApiDocBundle自动生成文档。我允许标准的Symfony文档安装和配置它:https://symfony.com/doc/current/bundles/NelmioApiDocBundle/index.html。不幸的是,当我转到/api/doc时,我的doc是空的。
我在3.2.0中使用了Symfony 3.4和NelmioApiDocBundle。
这是我的配置:
nelmio_api_doc:
areas:
path_patterns: # an array of regexps
- ^/api(?!/doc$)
host_patterns:
- ^api\.
documentation:
host: 127.0.0.1
schemes: [http, https]
info:
title: Thanatos API
description: This is documentation of Thanatos
version: 1.0.0
security:
- Bearer: []以及控制器中的注释(首先,我希望在文档中看到任何数据):
/**
* @Route(
* "/",
* name="thanatos_dashboard_index",
* )
*
* @SWG\Response(
* response=200,
* description="Returns the rewards of an user",
* @SWG\Schema(
* type="array",
* @SWG\Items(ref=@Model(type=Reward::class, groups={"full"}))
* )
* )
* @SWG\Parameter(
* name="order",
* in="query",
* type="string",
* description="The field used to order rewards"
* )
* @SWG\Tag(name="rewards")
* @NelmioSecurity(name="Bearer")
*/
public function indexAction()
{
return $this->render("@AppThanatos/Dashboard/index.html.twig");
}在/api/doc中,我看到“没有在spec中定义的操作!”。我做错了什么?
@更新
我刚开始使用萨米语:http://symfony.com/projects/sami
发布于 2018-06-05 09:17:06
我也有同样的问题。在我的Mac上工作,我总是使用ERR_EMPTY_RESPONSE (使用Chrome),但是在生产环境中,同样的配置工作得很好。
唯一的区别是Xdebug,我尝试过禁用模块,现在一切都正常了。
发布于 2018-09-07 01:24:09
如果任何命令事件(通常是post-install-cmd或post-update-cmd)触发ScriptHandler::installAssets脚本,则通常由composer安装资产。如果尚未设置此脚本,则可以手动执行以下命令:
php bin/console assets:install --symlink发布于 2018-06-01 15:27:29
试试这个:
替换
* @Route(
* "/",
* name="thanatos_dashboard_index",
* )通过
@Rest\Get("/getVehicles")在操作控制器中,返回数组或对象,如下所示:
$em = $this->getDoctrine();
return $em->getRepository('AppBundle:Vehicle')->findAll();https://stackoverflow.com/questions/50644906
复制相似问题