Symfony - NelmioApiDocBundle: show parameter description, imported from the class

I use NelmioApiDocBundle with PHP Symfony3 infrastructure for API REST. I want to show my description of the parameters on the page / api / doc. Is this possible without the addition of manual settings? I want to import it from an I / O class.

Here is my documentation:

Screenshot

Here is my @ApiDoc controller action (/ api / user / login) , which generates the documentation:

* @ApiDoc( * section = "user", * resource = true, * description = "Checks the user credentials and returns an authentication & refresh token if they are correct", * input = { "class" = "AppBundle\Libraries\Core\User\LoginRequest", "name" = "" }, * output = { "class" = "AppBundle\Libraries\Core\User\LoginResponse", "name" = "" }, * statusCodes = { * 200 = "Returned when successful", * 400 = "Returned when request syntax is incorrect", * 404 = "Returned when the page is not found", * 429 = "Returned when the client sent too many requests during a time period", * 500 = "Returned when an internal server error occured", * 501 = "Returned when an unavailable request method is user (GET, POST, DELETE, PUT, ...)", * 503 = "Returned when the service is unavailable at the moment eg. due to maintenance or overload" * }, * * ) 

AppBundle \ Libraries \ Core \ User \ LoginRequest class:

 class LoginRequest implements JsonSerializable { /** * The username. * * @var string * * @Assert\NotBlank() * @Assert\Type("string") */ public $username; /** * The password. * * @var string * * @Assert\NotBlank() * @Assert\Type("string") */ public $password; /** * Defines whether or not to save the refresh token as cooke. * * @var bool * * @Assert\NotBlank() * @Assert\Type("bool") */ public $rememberPassword; public function getUsername() { return $this->username; } public function setUsername($username) { $this->username = $username; } public function getPassword() { return $this->password; } public function setPassword($password) { $this->password = $password; } public function getRememberPassword() { return $this->rememberPassword; } public function setRememberPassword($rememberPassword) { $this->rememberPassword = $rememberPassword; } public function jsonSerialize() { return [ 'username' => $this->username, 'password' => $this->password, 'rememberPassword' => $this->rememberPassword ]; } } ) class LoginRequest implements JsonSerializable { /** * The username. * * @var string * * @Assert\NotBlank() * @Assert\Type("string") */ public $username; /** * The password. * * @var string * * @Assert\NotBlank() * @Assert\Type("string") */ public $password; /** * Defines whether or not to save the refresh token as cooke. * * @var bool * * @Assert\NotBlank() * @Assert\Type("bool") */ public $rememberPassword; public function getUsername() { return $this->username; } public function setUsername($username) { $this->username = $username; } public function getPassword() { return $this->password; } public function setPassword($password) { $this->password = $password; } public function getRememberPassword() { return $this->rememberPassword; } public function setRememberPassword($rememberPassword) { $this->rememberPassword = $rememberPassword; } public function jsonSerialize() { return [ 'username' => $this->username, 'password' => $this->password, 'rememberPassword' => $this->rememberPassword ]; } } ) class LoginRequest implements JsonSerializable { /** * The username. * * @var string * * @Assert\NotBlank() * @Assert\Type("string") */ public $username; /** * The password. * * @var string * * @Assert\NotBlank() * @Assert\Type("string") */ public $password; /** * Defines whether or not to save the refresh token as cooke. * * @var bool * * @Assert\NotBlank() * @Assert\Type("bool") */ public $rememberPassword; public function getUsername() { return $this->username; } public function setUsername($username) { $this->username = $username; } public function getPassword() { return $this->password; } public function setPassword($password) { $this->password = $password; } public function getRememberPassword() { return $this->rememberPassword; } public function setRememberPassword($rememberPassword) { $this->rememberPassword = $rememberPassword; } public function jsonSerialize() { return [ 'username' => $this->username, 'password' => $this->password, 'rememberPassword' => $this->rememberPassword ]; } } refresh token as cooke. class LoginRequest implements JsonSerializable { /** * The username. * * @var string * * @Assert\NotBlank() * @Assert\Type("string") */ public $username; /** * The password. * * @var string * * @Assert\NotBlank() * @Assert\Type("string") */ public $password; /** * Defines whether or not to save the refresh token as cooke. * * @var bool * * @Assert\NotBlank() * @Assert\Type("bool") */ public $rememberPassword; public function getUsername() { return $this->username; } public function setUsername($username) { $this->username = $username; } public function getPassword() { return $this->password; } public function setPassword($password) { $this->password = $password; } public function getRememberPassword() { return $this->rememberPassword; } public function setRememberPassword($rememberPassword) { $this->rememberPassword = $rememberPassword; } public function jsonSerialize() { return [ 'username' => $this->username, 'password' => $this->password, 'rememberPassword' => $this->rememberPassword ]; } } ) class LoginRequest implements JsonSerializable { /** * The username. * * @var string * * @Assert\NotBlank() * @Assert\Type("string") */ public $username; /** * The password. * * @var string * * @Assert\NotBlank() * @Assert\Type("string") */ public $password; /** * Defines whether or not to save the refresh token as cooke. * * @var bool * * @Assert\NotBlank() * @Assert\Type("bool") */ public $rememberPassword; public function getUsername() { return $this->username; } public function setUsername($username) { $this->username = $username; } public function getPassword() { return $this->password; } public function setPassword($password) { $this->password = $password; } public function getRememberPassword() { return $this->rememberPassword; } public function setRememberPassword($rememberPassword) { $this->rememberPassword = $rememberPassword; } public function jsonSerialize() { return [ 'username' => $this->username, 'password' => $this->password, 'rememberPassword' => $this->rememberPassword ]; } } username, class LoginRequest implements JsonSerializable { /** * The username. * * @var string * * @Assert\NotBlank() * @Assert\Type("string") */ public $username; /** * The password. * * @var string * * @Assert\NotBlank() * @Assert\Type("string") */ public $password; /** * Defines whether or not to save the refresh token as cooke. * * @var bool * * @Assert\NotBlank() * @Assert\Type("bool") */ public $rememberPassword; public function getUsername() { return $this->username; } public function setUsername($username) { $this->username = $username; } public function getPassword() { return $this->password; } public function setPassword($password) { $this->password = $password; } public function getRememberPassword() { return $this->rememberPassword; } public function setRememberPassword($rememberPassword) { $this->rememberPassword = $rememberPassword; } public function jsonSerialize() { return [ 'username' => $this->username, 'password' => $this->password, 'rememberPassword' => $this->rememberPassword ]; } } password, class LoginRequest implements JsonSerializable { /** * The username. * * @var string * * @Assert\NotBlank() * @Assert\Type("string") */ public $username; /** * The password. * * @var string * * @Assert\NotBlank() * @Assert\Type("string") */ public $password; /** * Defines whether or not to save the refresh token as cooke. * * @var bool * * @Assert\NotBlank() * @Assert\Type("bool") */ public $rememberPassword; public function getUsername() { return $this->username; } public function setUsername($username) { $this->username = $username; } public function getPassword() { return $this->password; } public function setPassword($password) { $this->password = $password; } public function getRememberPassword() { return $this->rememberPassword; } public function setRememberPassword($rememberPassword) { $this->rememberPassword = $rememberPassword; } public function jsonSerialize() { return [ 'username' => $this->username, 'password' => $this->password, 'rememberPassword' => $this->rememberPassword ]; } } rememberPassword class LoginRequest implements JsonSerializable { /** * The username. * * @var string * * @Assert\NotBlank() * @Assert\Type("string") */ public $username; /** * The password. * * @var string * * @Assert\NotBlank() * @Assert\Type("string") */ public $password; /** * Defines whether or not to save the refresh token as cooke. * * @var bool * * @Assert\NotBlank() * @Assert\Type("bool") */ public $rememberPassword; public function getUsername() { return $this->username; } public function setUsername($username) { $this->username = $username; } public function getPassword() { return $this->password; } public function setPassword($password) { $this->password = $password; } public function getRememberPassword() { return $this->rememberPassword; } public function setRememberPassword($rememberPassword) { $this->rememberPassword = $rememberPassword; } public function jsonSerialize() { return [ 'username' => $this->username, 'password' => $this->password, 'rememberPassword' => $this->rememberPassword ]; } } 

I would use to describe this class, for example. User name: "Username", password:. "Password". and rememberPassword: "Determines save or not save the refresh token as a cooke".

Thanks for the help.

Hi Orlando

+5
source share

All Articles