2016-07-12 00:33:55 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
2016-12-29 12:09:26 +01:00
|
|
|
* This file is part of the NelmioApiDocBundle package.
|
2016-07-12 00:33:55 +02:00
|
|
|
*
|
2016-12-29 12:09:26 +01:00
|
|
|
* (c) Nelmio
|
2016-07-12 00:33:55 +02:00
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*/
|
|
|
|
|
2016-12-29 12:09:26 +01:00
|
|
|
namespace Nelmio\ApiDocBundle\Tests\Functional\Controller;
|
2016-07-12 00:33:55 +02:00
|
|
|
|
2016-11-30 16:21:03 +01:00
|
|
|
use FOS\RestBundle\Controller\Annotations\QueryParam;
|
|
|
|
use FOS\RestBundle\Controller\Annotations\RequestParam;
|
2017-01-14 17:36:56 +01:00
|
|
|
use Nelmio\ApiDocBundle\Annotation\Model;
|
2017-03-16 19:35:04 +01:00
|
|
|
use Nelmio\ApiDocBundle\Annotation\Operation;
|
2018-01-25 21:11:34 +01:00
|
|
|
use Nelmio\ApiDocBundle\Annotation\Security;
|
2017-06-13 13:34:26 +02:00
|
|
|
use Nelmio\ApiDocBundle\Tests\Functional\Entity\Article;
|
2018-02-05 18:39:58 +01:00
|
|
|
use Nelmio\ApiDocBundle\Tests\Functional\Entity\SymfonyConstraints;
|
2017-06-26 10:34:42 +02:00
|
|
|
use Nelmio\ApiDocBundle\Tests\Functional\Entity\User;
|
2017-06-24 17:49:00 +02:00
|
|
|
use Nelmio\ApiDocBundle\Tests\Functional\Form\DummyType;
|
2017-09-20 08:18:58 +03:00
|
|
|
use Nelmio\ApiDocBundle\Tests\Functional\Form\UserType;
|
2016-07-12 00:33:55 +02:00
|
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
2016-12-30 13:37:02 +01:00
|
|
|
use Swagger\Annotations as SWG;
|
2018-03-23 19:46:54 +01:00
|
|
|
use Symfony\Component\Validator\Constraints\IsTrue;
|
2018-03-15 19:09:51 +01:00
|
|
|
use Symfony\Component\Validator\Constraints\Regex;
|
2016-07-12 00:33:55 +02:00
|
|
|
|
2016-11-30 14:08:10 +01:00
|
|
|
/**
|
2018-03-13 12:40:36 -03:00
|
|
|
* @Route("/api", host="api.example.com")
|
2016-11-30 14:08:10 +01:00
|
|
|
*/
|
2016-07-12 00:33:55 +02:00
|
|
|
class ApiController
|
|
|
|
{
|
2017-06-13 13:34:26 +02:00
|
|
|
/**
|
|
|
|
* @SWG\Response(
|
|
|
|
* response="200",
|
|
|
|
* description="Success",
|
2018-03-17 14:36:57 +01:00
|
|
|
* @SWG\Schema(ref=@Model(type=Article::class, groups={"light"}))
|
2017-06-13 13:34:26 +02:00
|
|
|
* )
|
|
|
|
* @Route("/article/{id}", methods={"GET"})
|
|
|
|
*/
|
|
|
|
public function fetchArticleAction()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-12-30 13:37:02 +01:00
|
|
|
/**
|
2018-04-20 10:34:55 +02:00
|
|
|
* The method LINK is not supported by OpenAPI so the method will be ignored.
|
|
|
|
*
|
|
|
|
* @Route("/swagger", methods={"GET", "LINK"})
|
2016-12-30 13:37:02 +01:00
|
|
|
* @Route("/swagger2", methods={"GET"})
|
2017-03-16 19:35:04 +01:00
|
|
|
* @Operation(
|
2016-12-30 13:37:02 +01:00
|
|
|
* @SWG\Response(response="201", description="An example resource")
|
|
|
|
* )
|
|
|
|
*/
|
|
|
|
public function swaggerAction()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @Route("/swagger/implicit", methods={"GET", "POST"})
|
2017-01-14 17:36:56 +01:00
|
|
|
* @SWG\Response(
|
|
|
|
* response="201",
|
|
|
|
* description="Operation automatically detected",
|
2017-01-23 19:46:38 +01:00
|
|
|
* @Model(type=User::class)
|
2017-01-14 17:36:56 +01:00
|
|
|
* )
|
2016-12-30 13:37:02 +01:00
|
|
|
* @SWG\Parameter(
|
|
|
|
* name="foo",
|
2017-01-14 17:36:56 +01:00
|
|
|
* in="body",
|
|
|
|
* description="This is a parameter",
|
|
|
|
* @SWG\Schema(
|
|
|
|
* type="array",
|
2018-03-17 14:36:57 +01:00
|
|
|
* @SWG\Items(ref=@Model(type=User::class))
|
2017-01-14 17:36:56 +01:00
|
|
|
* )
|
2016-12-30 13:37:02 +01:00
|
|
|
* )
|
2017-03-17 19:45:46 +01:00
|
|
|
* @SWG\Tag(name="implicit")
|
2016-12-30 13:37:02 +01:00
|
|
|
*/
|
|
|
|
public function implicitSwaggerAction()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-09-20 08:18:58 +03:00
|
|
|
/**
|
|
|
|
* @Route("/test/users/{user}", methods={"POST"}, schemes={"https"}, requirements={"user"="/foo/"})
|
|
|
|
* @SWG\Response(
|
|
|
|
* response="201",
|
|
|
|
* description="Operation automatically detected",
|
|
|
|
* @Model(type=User::class)
|
|
|
|
* )
|
|
|
|
* @SWG\Parameter(
|
|
|
|
* name="foo",
|
|
|
|
* in="body",
|
|
|
|
* description="This is a parameter",
|
2018-03-17 14:36:57 +01:00
|
|
|
* @SWG\Schema(ref=@Model(type=UserType::class))
|
2017-09-20 08:18:58 +03:00
|
|
|
* )
|
|
|
|
*/
|
|
|
|
public function submitUserTypeAction()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-07-12 00:33:55 +02:00
|
|
|
/**
|
|
|
|
* @Route("/test/{user}", methods={"GET"}, schemes={"https"}, requirements={"user"="/foo/"})
|
2017-06-02 21:30:31 +02:00
|
|
|
* @Operation(
|
|
|
|
* @SWG\Response(response=200, description="sucessful")
|
|
|
|
* )
|
2016-07-12 00:33:55 +02:00
|
|
|
*/
|
|
|
|
public function userAction()
|
|
|
|
{
|
|
|
|
}
|
2016-07-13 23:05:14 +02:00
|
|
|
|
2016-11-30 16:21:03 +01:00
|
|
|
/**
|
2016-11-30 16:52:13 +01:00
|
|
|
* @Route("/fosrest.{_format}", methods={"POST"})
|
2018-03-15 19:09:51 +01:00
|
|
|
* @QueryParam(name="foo", requirements=@Regex("/^\d+$/"))
|
2018-02-27 15:42:40 +01:00
|
|
|
* @RequestParam(name="bar", requirements="\d+")
|
2018-03-23 19:46:54 +01:00
|
|
|
* @RequestParam(name="baz", requirements=@IsTrue)
|
2016-11-30 16:21:03 +01:00
|
|
|
*/
|
|
|
|
public function fosrestAction()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-07-13 23:05:14 +02:00
|
|
|
/**
|
|
|
|
* This action is deprecated.
|
|
|
|
*
|
|
|
|
* Please do not use this action.
|
|
|
|
*
|
|
|
|
* @Route("/deprecated", methods={"GET"})
|
2016-07-14 23:52:01 +02:00
|
|
|
*
|
2016-07-13 23:05:14 +02:00
|
|
|
* @deprecated
|
|
|
|
*/
|
|
|
|
public function deprecatedAction()
|
|
|
|
{
|
|
|
|
}
|
2016-11-30 14:08:10 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This action is not documented. It is excluded by the config.
|
|
|
|
*
|
|
|
|
* @Route("/admin", methods={"GET"})
|
|
|
|
*/
|
|
|
|
public function adminAction()
|
|
|
|
{
|
|
|
|
}
|
2017-03-16 19:35:04 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @SWG\Get(
|
|
|
|
* path="/filtered",
|
|
|
|
* @SWG\Response(response="201", description="")
|
|
|
|
* )
|
|
|
|
*/
|
|
|
|
public function filteredAction()
|
|
|
|
{
|
|
|
|
}
|
2017-06-24 17:49:00 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @Route("/form", methods={"POST"})
|
|
|
|
* @SWG\Parameter(
|
|
|
|
* name="form",
|
|
|
|
* in="body",
|
|
|
|
* description="Request content",
|
2018-03-17 14:36:57 +01:00
|
|
|
* @SWG\Schema(ref=@Model(type=DummyType::class))
|
2017-06-24 17:49:00 +02:00
|
|
|
* )
|
|
|
|
* @SWG\Response(response="201", description="")
|
|
|
|
*/
|
|
|
|
public function formAction()
|
|
|
|
{
|
|
|
|
}
|
2018-01-25 21:11:34 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @Route("/security")
|
|
|
|
* @SWG\Response(response="201", description="")
|
|
|
|
* @Security(name="api_key")
|
|
|
|
* @Security(name="basic")
|
|
|
|
*/
|
|
|
|
public function securityAction()
|
|
|
|
{
|
|
|
|
}
|
2018-02-05 18:39:58 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @Route("/swagger/symfonyConstraints", methods={"GET"})
|
|
|
|
* @SWG\Response(
|
|
|
|
* response="201",
|
|
|
|
* description="Used for symfony constraints test",
|
2018-03-17 14:36:57 +01:00
|
|
|
* @SWG\Schema(ref=@Model(type=SymfonyConstraints::class))
|
2018-02-05 18:39:58 +01:00
|
|
|
* )
|
|
|
|
*/
|
|
|
|
public function symfonyConstraintsAction()
|
|
|
|
{
|
|
|
|
}
|
2018-02-19 10:49:52 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @SWG\Response(
|
|
|
|
* response="200",
|
|
|
|
* description="Success",
|
|
|
|
* @SWG\Schema(ref="#/definitions/Test")
|
|
|
|
* )
|
|
|
|
* @Route("/configReference", methods={"GET"})
|
|
|
|
*/
|
|
|
|
public function configReferenceAction()
|
|
|
|
{
|
|
|
|
}
|
2016-07-12 00:33:55 +02:00
|
|
|
}
|