NelmioApiDoc模型定义/如何忽略其他名称的现有属性的getter或别名?

时间:2018-05-17 15:07:59

标签: swagger openapi swagger-php nelmioapidocbundle

我们可以覆盖模型访问者属性名称还是忽略它?

这里是我的User::getUsername函数,它是电子邮件属性的getter(我需要这个函数来命名,以实现接口):

class User extends AbstractDocument implements AdvancedUserInterface, EquatableInterface
{
    /**
     * @var string
     * @Assert\NotBlank()
     * @Assert\Email()
     * @SWG\Property(
     *     description="The email of the user",
     *     example="example@company.com"
     * )
     */
    private $email;

    //...

    /**
     * Returns the username used to authenticate the user.
     * @return string The user email
     * @SWG\Property(property="email")
     */
    public function getUsername()
    {
        return $this->email;
    }
}

生成的文档仍显示:

{
  "User": {
    "properties":{
      "email":{  
        "description":"The email of the user",
        "example":"example@company.com",
        "type":"string"
      },
      "username":{  
        "type":"string"
      }
    }
  }
}

你能帮帮我吗?

0 个答案:

没有答案