I use Nelmio to generate automatically my api doc. I would like to return an object in responseMap which is a simple class (entity without a database associated) like this :
/**
* @ApiDoc(
* description = "Get informations from user.",
* responseMap = {
* 200 = { "\AppBundle\Entity\MyUserInfos" },
* },
* )
*
* @Rest\View(statusCode=Response::HTTP_OK)
* @Rest\Get("/my_user_infos")
*/
public function getMyUserInfosAction(Request $request) {
...
}
namespace AppBundle\Entity;
/**
* MyUserInfos
*/
class MyUserInfos
{
/**
* @var string
*/
private $username;
/**
* @var string
*/
private $email;
+getters and setters
}
But response object is not displayed in my api doc. Can anyone help me ? Thanks.
Remove the leading backslash on you class name
/**
* @ApiDoc(
* description = "Get informations from user.",
* responseMap = {
* 200 = { "AppBundle\Entity\MyUserInfos" },
* },
* )
*
* @Rest\View(statusCode=Response::HTTP_OK)
* @Rest\Get("/my_user_infos")
*/
public function getMyUserInfosAction(Request $request) {
...
}