Symfony 设置Nelmio ApiDoc返回参数说明
在控制器的ApiDoc上,我们已经指定了输出响应对象,现在我们看到了返回的所有参数的列表。 如何在此列表中为版本和/或描述字段提供值 我已经尝试将Symfony 设置Nelmio ApiDoc返回参数说明,symfony,nelmioapidocbundle,Symfony,Nelmioapidocbundle,在控制器的ApiDoc上,我们已经指定了输出响应对象,现在我们看到了返回的所有参数的列表。 如何在此列表中为版本和/或描述字段提供值 我已经尝试将@ApiDoc(description=“text”)添加到响应对象的参数中,但似乎没有任何效果 提前感谢。我没有使用nelmioApiDoc,但在注释部分使用description=“text”查看文档似乎是正确的。您是否尝试过清除缓存: php bin/console cache:clear --env=prod 不确定是否相关 在JMSSeri
@ApiDoc(description=“text”)
添加到响应对象的参数中,但似乎没有任何效果
提前感谢。我没有使用nelmioApiDoc,但在注释部分使用
description=“text”
查看文档似乎是正确的。您是否尝试过清除缓存:
php bin/console cache:clear --env=prod
不确定是否相关
在JMSSerializerBundle类中使用了此选项,看起来您必须使用
@Until(“x.x.x”)
和@Since(“x.x”)
这是我的一个项目中的一个有效API方法:
/**
* Get an extended FB token given a normal access_token
*
* @ApiDoc(
* resource=true,
* requirements={
* {
* "name"="access_token",
* "dataType"="string",
* "description"="The FB access token",
* "version" = "1.0"
* }
* },
* views = { "facebook" }
* )
* @Get("/extend/token/{access_token}", name="get_extend_fb_token", options={ "method_prefix" = false }, defaults={"_format"="json"})
*/
public function getExtendTokenAction(Request $request, $access_token)
{
//...
}
返回的所有APIDoc参数都分组在“需求”下。我今天浏览了ApiDocBundle,看到的描述来自对带有@VirtualProperty的模型属性或方法的注释 例如:
/**
* This text will be displayed as the response property's description
*
* @var \DateTime
* @JMS\Type("DateTime<'Y-m-d\TH:i:sO'>")
*/
protected $dateTimeProperty;
这同样适用于控制器方法上的所有注释
您知道如何将
version
添加到单独的属性中了吗?
/**
* VirtualProperty comment
*
* @JMS\Type("integer")
* @JMS\VirtualProperty()
* @return integer
*/
public function getVirtualProperty()
{
return $this->someFunc();
}