简体   繁体   English

显示实体属性描述的注释-使用nelmioapidocbundle

[英]Annotation to show Entity's property description - using nelmioapidocbundle

I am using nelmioapidocbundle in order to documents my Rest API built on the top of symfony-2.x. 我正在使用nelmioapidocbundle来记录建立在symfony-2.x顶部的Rest API。

I can't found the right annotation to use to show each Entity's property description on the return section (Please see bellow attached image). 我找不到用于在返回部分显示每个实体的属性描述的正确注释(请参见下面的附加图像)。

My Entity : 我的实体:

/**
 * Checkins
 *
 * @ORM\Table(name="CheckIns")
 * @ORM\Entity(repositoryClass="Project1\ApiBundle\Entity\CheckinsRepository")
 *
 * @ExclusionPolicy("none")
 */
class Checkins
{
    /**
     * @var integer
     *
     * @ORM\Column(name="id", type="bigint", nullable=false)
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     *
     * @Groups({"checkin"})
     * @
     */
    private $id;

My Controller : 我的控制器:

 class CheckinController extends BaseRestController
 {
    /**
     * @ApiDoc(
     *  resource=true,
     *  description="Find checkin by ID",
     *
     * parameters={
     *      {"name"="categoryId", "dataType"="integer", "required"=true, "description"="checkin id"}
     *  }
     *
     *  output={
     *      "class"="Project1\ApiBundle\Entity\Checkins",
     *      "groups"={"checkin"}
     *  },
     *  statusCodes={
     *      200="Checkin found",
     *      400="ID is required",
     *      404="Checkin not found"
     *  }
     * )
     *
     * @Rest\View()
     */
    public function getAction(Request $request)
    {}

Result ( Description column is empty ) : 结果(“描述”列为空): 在此处输入图片说明

There's a description in doc section of the bundle: 捆绑软件的doc部分中有一个描述:

For classes parsed with JMS metadata, description will be taken from the properties doc comment, if available. 对于使用JMS元数据解析的类,将从属性doc注释(如果有)中进行描述。 For Form Types, you can add an extra option named description on each field 对于表单类型,您可以在每个字段上添加一个名为description的附加选项。

Please visit the following link for more instructions(info at the bottom of the section): 请访问以下链接以获取更多说明(本节底部的信息):

https://github.com/nelmio/NelmioApiDocBundle/blob/master/Resources/doc/index.md#the-apidoc-annotation https://github.com/nelmio/NelmioApiDocBundle/blob/master/Resources/doc/index.md#the-apidoc-annotation

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Symfony-NelmioApiDocBundle:显示从类导入的参数描述 - Symfony - NelmioApiDocBundle: Show parameter description imported from class 在NelmioApiDocBundle中设置“参数”注释 - Set 'parameters' annotation in NelmioApiDocBundle NelmioApiDocBundle根据输入注释生成一个额外的参数 - NelmioApiDocBundle generates an extra parameter based on input annotation Symfony2:为什么NelmioApiDocBundle中的视图注释不起作用? - Symfony2: Why is the view annotation in NelmioApiDocBundle not working? 如何使NelmioApiDocBundle与Symfony的FormType一起使用 - How to make NelmioApiDocBundle work with Symfony's FormType NelmioApiDocBundle如何在@ApiDoc(输入)注释中将参数传递给表单类型类? - NelmioApiDocBundle how to pass a parameter to a form type classe in @ApiDoc (input) annotation? 如何使用NelmioApiDocBundle在POST请求中包含查询参数? - How do I include a query parameter in a POST request using NelmioApiDocBundle? Symfony 2:在属性AppBundle \\ Entity \\ Genre :: $ movie上声明的注释@ORM \\ OneToMany没有名为“ onDelete”的属性 - Symfony 2: The annotation @ORM\OneToMany declared on property AppBundle\Entity\Genre::$movie does not have a property named “onDelete” 具有描述的Symfony2实体 - Symfony2 Entity with description Symfony 4,将实体的属性作为数组键的findAll - Symfony 4, findAll with entity's property as array key
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM