mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-02 15:51:48 +03:00
Make Model Attachable (#2025)
* Make Model Attachable * fix cs * Drop zircote/swagger-php < 4.2 support
This commit is contained in:
parent
a17ad38cc8
commit
766ed898cf
@ -11,15 +11,15 @@
|
|||||||
|
|
||||||
namespace Nelmio\ApiDocBundle\Annotation;
|
namespace Nelmio\ApiDocBundle\Annotation;
|
||||||
|
|
||||||
use OpenApi\Annotations\AbstractAnnotation;
|
|
||||||
use OpenApi\Annotations\Parameter;
|
use OpenApi\Annotations\Parameter;
|
||||||
|
use OpenApi\Attributes\Attachable;
|
||||||
use OpenApi\Generator;
|
use OpenApi\Generator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Annotation
|
* @Annotation
|
||||||
*/
|
*/
|
||||||
#[\Attribute(\Attribute::TARGET_METHOD)]
|
#[\Attribute(\Attribute::TARGET_METHOD)]
|
||||||
final class Model extends AbstractAnnotation
|
final class Model extends Attachable
|
||||||
{
|
{
|
||||||
/** {@inheritdoc} */
|
/** {@inheritdoc} */
|
||||||
public static $_types = [
|
public static $_types = [
|
||||||
|
@ -16,6 +16,7 @@ use Nelmio\ApiDocBundle\Model\Model;
|
|||||||
use Nelmio\ApiDocBundle\Model\ModelRegistry;
|
use Nelmio\ApiDocBundle\Model\ModelRegistry;
|
||||||
use OpenApi\Analysis;
|
use OpenApi\Analysis;
|
||||||
use OpenApi\Annotations as OA;
|
use OpenApi\Annotations as OA;
|
||||||
|
use OpenApi\Generator;
|
||||||
use Symfony\Component\PropertyInfo\Type;
|
use Symfony\Component\PropertyInfo\Type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -116,13 +117,16 @@ final class ModelRegister
|
|||||||
|
|
||||||
private function detach(ModelAnnotation $model, OA\AbstractAnnotation $annotation, Analysis $analysis): void
|
private function detach(ModelAnnotation $model, OA\AbstractAnnotation $annotation, Analysis $analysis): void
|
||||||
{
|
{
|
||||||
foreach ($annotation->_unmerged as $key => $unmerged) {
|
if (Generator::UNDEFINED !== $annotation->attachables) {
|
||||||
if ($unmerged === $model) {
|
foreach ($annotation->attachables as $key => $attachable) {
|
||||||
unset($annotation->_unmerged[$key]);
|
if ($attachable === $model) {
|
||||||
|
unset($annotation->attachables[$key]);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$analysis->annotations->detach($model);
|
$analysis->annotations->detach($model);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,9 +141,11 @@ final class ModelRegister
|
|||||||
|
|
||||||
private function getModel(OA\AbstractAnnotation $annotation): ?ModelAnnotation
|
private function getModel(OA\AbstractAnnotation $annotation): ?ModelAnnotation
|
||||||
{
|
{
|
||||||
foreach ($annotation->_unmerged as $unmerged) {
|
if (Generator::UNDEFINED !== $annotation->attachables) {
|
||||||
if ($unmerged instanceof ModelAnnotation) {
|
foreach ($annotation->attachables as $attachable) {
|
||||||
return $unmerged;
|
if ($attachable instanceof ModelAnnotation) {
|
||||||
|
return $attachable;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,12 +11,12 @@
|
|||||||
|
|
||||||
namespace Nelmio\ApiDocBundle\Tests\Functional\Controller;
|
namespace Nelmio\ApiDocBundle\Tests\Functional\Controller;
|
||||||
|
|
||||||
use Functional\Entity\ArticleInterface;
|
|
||||||
use Nelmio\ApiDocBundle\Annotation\Areas;
|
use Nelmio\ApiDocBundle\Annotation\Areas;
|
||||||
use Nelmio\ApiDocBundle\Annotation\Model;
|
use Nelmio\ApiDocBundle\Annotation\Model;
|
||||||
use Nelmio\ApiDocBundle\Annotation\Operation;
|
use Nelmio\ApiDocBundle\Annotation\Operation;
|
||||||
use Nelmio\ApiDocBundle\Annotation\Security;
|
use Nelmio\ApiDocBundle\Annotation\Security;
|
||||||
use Nelmio\ApiDocBundle\Tests\Functional\Entity\Article;
|
use Nelmio\ApiDocBundle\Tests\Functional\Entity\Article;
|
||||||
|
use Nelmio\ApiDocBundle\Tests\Functional\Entity\ArticleInterface;
|
||||||
use Nelmio\ApiDocBundle\Tests\Functional\Entity\CompoundEntity;
|
use Nelmio\ApiDocBundle\Tests\Functional\Entity\CompoundEntity;
|
||||||
use Nelmio\ApiDocBundle\Tests\Functional\Entity\EntityWithAlternateType;
|
use Nelmio\ApiDocBundle\Tests\Functional\Entity\EntityWithAlternateType;
|
||||||
use Nelmio\ApiDocBundle\Tests\Functional\Entity\EntityWithObjectType;
|
use Nelmio\ApiDocBundle\Tests\Functional\Entity\EntityWithObjectType;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Functional\Entity;
|
namespace Nelmio\ApiDocBundle\Tests\Functional\Entity;
|
||||||
|
|
||||||
interface ArticleInterface
|
interface ArticleInterface
|
||||||
{
|
{
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
"symfony/options-resolver": "^4.4|^5.0|^6.0",
|
"symfony/options-resolver": "^4.4|^5.0|^6.0",
|
||||||
"symfony/property-info": "^4.4|^5.0|^6.0",
|
"symfony/property-info": "^4.4|^5.0|^6.0",
|
||||||
"symfony/routing": "^4.4|^5.0|^6.0",
|
"symfony/routing": "^4.4|^5.0|^6.0",
|
||||||
"zircote/swagger-php": "^3.2|^4.0",
|
"zircote/swagger-php": "^4.2.0",
|
||||||
"phpdocumentor/reflection-docblock": "^3.1|^4.0|^5.0"
|
"phpdocumentor/reflection-docblock": "^3.1|^4.0|^5.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
<php>
|
<php>
|
||||||
<env name="SHELL_VERBOSITY" value="-1" />
|
<env name="SHELL_VERBOSITY" value="-1" />
|
||||||
<ini name="error_reporting" value="-1" />
|
<ini name="error_reporting" value="-1" />
|
||||||
|
<ini name="memory_limit" value="512M" />
|
||||||
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[self]=0" />
|
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[self]=0" />
|
||||||
</php>
|
</php>
|
||||||
|
|
||||||
@ -21,18 +22,4 @@
|
|||||||
<directory>Tests</directory>
|
<directory>Tests</directory>
|
||||||
</testsuite>
|
</testsuite>
|
||||||
</testsuites>
|
</testsuites>
|
||||||
|
|
||||||
<filter>
|
|
||||||
<whitelist>
|
|
||||||
<directory>.</directory>
|
|
||||||
<exclude>
|
|
||||||
<directory>Tests</directory>
|
|
||||||
<directory>vendor</directory>
|
|
||||||
</exclude>
|
|
||||||
</whitelist>
|
|
||||||
</filter>
|
|
||||||
|
|
||||||
<php>
|
|
||||||
<ini name="memory_limit" value="512M" />
|
|
||||||
</php>
|
|
||||||
</phpunit>
|
</phpunit>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user