mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-09 02:59:27 +03:00
Merge pull request #2011 from magnetik/interfaces
The ObjectModelDescriber can support interfaces
This commit is contained in:
commit
27ed1cc28e
@ -215,6 +215,7 @@ class ObjectModelDescriber implements ModelDescriberInterface, ModelRegistryAwar
|
||||
|
||||
public function supports(Model $model): bool
|
||||
{
|
||||
return Type::BUILTIN_TYPE_OBJECT === $model->getType()->getBuiltinType() && class_exists($model->getType()->getClassName());
|
||||
return Type::BUILTIN_TYPE_OBJECT === $model->getType()->getBuiltinType()
|
||||
&& (class_exists($model->getType()->getClassName()) || interface_exists($model->getType()->getClassName()));
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Nelmio\ApiDocBundle\Tests\Functional\Controller;
|
||||
|
||||
use Functional\Entity\ArticleInterface;
|
||||
use Nelmio\ApiDocBundle\Annotation\Areas;
|
||||
use Nelmio\ApiDocBundle\Annotation\Model;
|
||||
use Nelmio\ApiDocBundle\Annotation\Operation;
|
||||
@ -51,6 +52,23 @@ class ApiController80
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @OA\Get(
|
||||
* @OA\Response(
|
||||
* response="200",
|
||||
* description="Success",
|
||||
* @Model(type=ArticleInterface::class, groups={"light"}))
|
||||
* )
|
||||
* )
|
||||
* @OA\Parameter(ref="#/components/parameters/test")
|
||||
* @Route("/article-interface/{id}", methods={"GET"})
|
||||
* @OA\Parameter(name="Accept-Version", in="header", @OA\Schema(type="string"))
|
||||
* @OA\Parameter(name="Application-Name", in="header", @OA\Schema(type="string"))
|
||||
*/
|
||||
public function fetchArticleInterfaceAction()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* The method LINK is not supported by OpenAPI so the method will be ignored.
|
||||
*
|
||||
|
8
Tests/Functional/Entity/ArticleInterface.php
Normal file
8
Tests/Functional/Entity/ArticleInterface.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Functional\Entity;
|
||||
|
||||
interface ArticleInterface
|
||||
{
|
||||
public function getAuthor(): string;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user