gpt4 book ai didi

php - NelmioApiDocBundle 不生成文档

转载 作者:行者123 更新时间:2023-12-05 08:11:48 24 4
gpt4 key购买 nike

我想使用 NelmioApiDocBundle 自动生成文档。我使用标准 Symfony 文档来安装和配置它:https://symfony.com/doc/current/bundles/NelmioApiDocBundle/index.html .不幸的是,当我转到/api/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: []

以及我的 Controller 中的注释(一开始我想在我的文档中看到任何数据):

/**
* @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 中,我看到“没有在规范中定义操作!”。我做错了什么?


@更新

我刚开始使用 Sami:http://symfony.com/projects/sami

最佳答案

我也遇到了同样的问题。在我的 Mac 上工作时,我总是ERR_EMPTY_RESPONSE(使用 Chrome),但在生产环境中,相同的配置工作正常。

唯一的区别是 Xdebug,我试过禁用该模块,现在一切正常。

关于php - NelmioApiDocBundle 不生成文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50644906/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com