NelmioApiDocBundle
NelmioApiDocBundle copied to clipboard
[RFC] [3.x] Allow `FosRestDescriber` to extract the serialization groups from `FOS\RestBundle\Controller\Annotations\View` annotation
The @View annotation from FOSRestBundle allows to define the serialization groups in its serializerGroups attribute. It controls how the returned response will be serialized based on the configured groups.
This proposal is to leverage that definition for the API documentation, in order to avoid writing twice the same groups in the groups attribute at Nelmio\ApiDocBundle\Annotation\Model.
Before:
use FOS\RestBundle\Controller\Annotations\View;
use Nelmio\ApiDocBundle\Annotation\Model;
use Nelmio\ApiDocBundle\Annotation\Operation;
use Swagger\Annotations as SWG;
/**
* @View(
* serializerGroups={"internal"}
* )
*
* @Operation(
* @SWG\Response(
* response="200",
* @SWG\Schema(ref=@Model(type=MyModel::class, groups={"internal"}))
* )
* )
*/
After:
use FOS\RestBundle\Controller\Annotations\View;
use Nelmio\ApiDocBundle\Annotation\Model;
use Nelmio\ApiDocBundle\Annotation\Operation;
use Swagger\Annotations as SWG;
/**
* @View(
* serializerGroups={"internal"}
* )
*
* @Operation(
* @SWG\Response(
* response="200",
* @SWG\Schema(ref=@Model(type=MyModel::class))
* )
* )
*/