我想为symfony-project使用nelmio,但它不起作用。
它总是说:规范中没有定义任何操作!
我还在https://symfony.com/doc/current/bundles/NelmioApiDocBundle/index.html上尝试了这个示例
怎么了?有什么想法吗?
routing.yml
app.swagger_ui:
path: /api/doc
methods: GET
defaults: { _controller: nelmio_api_doc.controller.swagger_ui }config.yml
nelmio_api_doc:
areas:
path_patterns: # an array of regexps
- ^/api(?!/doc$)
host_patterns:
- ^api\.控制器
/**
* @Route("/api/test", methods={"GET"})
* @SWG\Response(
* response=200,
* description="Returns the rewards of an user"
* )
* @SWG\Parameter(
* name="order",
* in="query",
* type="string",
* description="The field used to order rewards"
* )
*/
public function testAction()
{
} composer.json
"symfony/symfony": "3.4.*",
"nelmio/api-doc-bundle": "3.2.1",发布于 2018-09-07 08:06:08
如果任何命令事件(通常是post-install-cmd或post-update-cmd)触发ScriptHandler::installAssets脚本,则通常由composer安装资产。如果您尚未设置此脚本,则可以手动执行此命令:
php bin/控制台资源:install --symlink
发布于 2020-03-26 00:38:16
只需移除
host_patterns:
- ^api\.并将虚拟主机设置为
documentation:
host: symfony.localhost发布于 2018-11-06 20:20:03
问题出在config.yml路径模式中。如果您删除配置(所有nelmio_api_doc)或更改路径,模式将起作用。示例:
nelmio_api_doc:
areas:
default:
path_patterns: [ /api/ ]https://stackoverflow.com/questions/52180056
复制相似问题