Skip to content

Commit

Permalink
Merge e690ec8 into b73f9a7
Browse files Browse the repository at this point in the history
  • Loading branch information
phansys committed Jul 23, 2020
2 parents b73f9a7 + e690ec8 commit dfc0c31
Show file tree
Hide file tree
Showing 12 changed files with 984 additions and 122 deletions.
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"conflict": {
"friendsofsymfony/rest-bundle": "<2.1",
"jms/serializer": "<1.3 || >=4.0",
"nelmio/api-doc-bundle": "<2.4",
"nelmio/api-doc-bundle": "<2.4 || >=4.0",
"sonata-project/core-bundle": "<3.20",
"sonata-project/doctrine-orm-admin-bundle": "<3.0",
"sonata-project/google-authenticator": "<1.0"
Expand All @@ -57,12 +57,13 @@
"jms/serializer-bundle": "^1.0 || ^2.0 || ^3.0",
"matthiasnoback/symfony-config-test": "^4.0",
"matthiasnoback/symfony-dependency-injection-test": "^4.0",
"nelmio/api-doc-bundle": "^2.4",
"nelmio/api-doc-bundle": "^2.4 || ^3.6",
"sensio/framework-extra-bundle": "^5.5",
"sonata-project/doctrine-orm-admin-bundle": "^3.18",
"sonata-project/google-authenticator": "^1.0 || ^2.0",
"symfony/browser-kit": "^4.4 || ^5.1",
"symfony/phpunit-bridge": "^5.1"
"symfony/phpunit-bridge": "^5.1",
"symfony/swiftmailer-bundle": "^3.4"
},
"suggest": {
"friendsofsymfony/rest-bundle": "For using the public API methods.",
Expand Down
139 changes: 99 additions & 40 deletions src/Controller/Api/GroupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@
use FOS\RestBundle\Request\ParamFetcherInterface;
use FOS\RestBundle\View\View as FOSRestView;
use FOS\UserBundle\Model\GroupInterface;
use Nelmio\ApiDocBundle\Annotation\ApiDoc;
use Nelmio\ApiDocBundle\Annotation\Model;
use Nelmio\ApiDocBundle\Annotation\Operation;
use Sonata\DatagridBundle\Pager\PagerInterface;
use Sonata\UserBundle\Model\GroupManagerInterface;
use Swagger\Annotations as SWG;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\Request;
Expand Down Expand Up @@ -59,9 +61,14 @@ public function __construct(GroupManagerInterface $groupManager, FormFactoryInte
/**
* Returns a paginated list of groups.
*
* @ApiDoc(
* resource=true,
* output={"class"="Sonata\DatagridBundle\Pager\PagerInterface", "groups"={"sonata_api_read"}}
* @Operation(
* operationId="getGroups",
* summary="Returns a paginated list of groups.",
* @SWG\Response(
* description="Returned when successful",
* response="200",
* @SWG\Schema(ref=@Model(type=Sonata\DatagridBundle\Pager\PagerInterface::class, groups={"sonata_api_read"}))
* )
* )
*
* @Get("/groups", name="get_groups")
Expand Down Expand Up @@ -104,15 +111,25 @@ public function getGroupsAction(ParamFetcherInterface $paramFetcher)
/**
* Retrieves a specific group.
*
* @ApiDoc(
* requirements={
* {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="group id"}
* },
* output={"class"="FOS\UserBundle\Model\GroupInterface", "groups"={"sonata_api_read"}},
* statusCodes={
* 200="Returned when successful",
* 404="Returned when group is not found"
* }
* @Operation(
* operationId="getGroup",
* summary="Retrieves a specific group.",
* @SWG\Parameter(
* name="id",
* in="path",
* description="group id",
* required=true,
* type="integer"
* ),
* @SWG\Response(
* response="200",
* description="Returned when successful",
* @SWG\Schema(ref=@Model(type=Sonata\UserBundle\Model\GroupInterface::class, groups={"sonata_api_read"}))
* ),
* @SWG\Response(
* response="404",
* description="Returned when group is not found"
* )
* )
*
* @Get("/group/{id}", name="get_group")
Expand All @@ -131,13 +148,24 @@ public function getGroupAction($id)
/**
* Adds a group.
*
* @ApiDoc(
* input={"class"="sonata_user_api_form_group", "name"="", "groups"={"sonata_api_write"}},
* output={"class"="Sonata\UserBundle\Model\Group", "groups"={"sonata_api_read"}},
* statusCodes={
* 200="Returned when successful",
* 400="Returned when an error has occurred while group creation",
* }
* @Operation(
* operationId="postGroup",
* summary="Adds a group.",
* @SWG\Parameter(
* name="",
* in="body",
* required=true,
* @Model(type=Sonata\UserBundle\Form\Type\ApiGroupType::class, groups={"sonata_api_write"})
* ),
* @SWG\Response(
* response="200",
* description="Returned when successful",
* @SWG\Schema(ref=@Model(type=Sonata\UserBundle\Model\Group::class, groups={"sonata_api_read"}))
* ),
* @SWG\Response(
* response="400",
* description="Returned when an error has occurred while group creation"
* )
* )
*
* @Post("/group", name="post_group")
Expand All @@ -156,17 +184,35 @@ public function postGroupAction(Request $request)
/**
* Updates a group.
*
* @ApiDoc(
* requirements={
* {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="group identifier"}
* },
* input={"class"="sonata_user_api_form_group", "name"="", "groups"={"sonata_api_write"}},
* output={"class"="Sonata\UserBundle\Model\Group", "groups"={"sonata_api_read"}},
* statusCodes={
* 200="Returned when successful",
* 400="Returned when an error has occurred while group creation",
* 404="Returned when unable to find group"
* }
* @Operation(
* operationId="putGroup",
* summary="Updates an group.",
* @SWG\Parameter(
* name="id",
* in="path",
* description="group identifier",
* required=true,
* type="integer"
* ),
* @SWG\Parameter(
* name="",
* in="body",
* required=true,
* @Model(type=Sonata\UserBundle\Form\Type\ApiGroupType::class, groups={"sonata_api_write"})
* ),
* @SWG\Response(
* response="200",
* description="Returned when successful",
* @SWG\Schema(ref=@Model(type=Sonata\UserBundle\Model\Group::class, groups={"sonata_api_read"}))
* ),
* @SWG\Response(
* response="400",
* description="Returned when an error has occurred while group creation"
* ),
* @SWG\Response(
* response="404",
* description="Returned when unable to find group"
* )
* )
*
* @Put("/group/{id}", name="put_group")
Expand All @@ -186,15 +232,28 @@ public function putGroupAction($id, Request $request)
/**
* Deletes a group.
*
* @ApiDoc(
* requirements={
* {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="group identifier"}
* },
* statusCodes={
* 200="Returned when group is successfully deleted",
* 400="Returned when an error has occurred while group deletion",
* 404="Returned when unable to find group"
* }
* @Operation(
* operationId="deleteGroup",
* summary="Deletes a group.",
* @SWG\Parameter(
* name="id",
* in="path",
* description="group identifier",
* required=true,
* type="integer"
* ),
* @SWG\Response(
* response="200",
* description="Returned when group is successfully deleted"
* ),
* @SWG\Response(
* response="400",
* description="Returned when an error has occurred while group deletion"
* ),
* @SWG\Response(
* response="404",
* description="Returned when unable to find group"
* )
* )
*
* @Delete("/group/{id}", name="delete_group")
Expand Down

0 comments on commit dfc0c31

Please sign in to comment.