mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-03-12 10:36:09 +03:00
Fix the invalid reference notice
This commit is contained in:
parent
eeeab29ec9
commit
2fcce922d7
@ -15,6 +15,7 @@ use Nelmio\ApiDocBundle\Annotation\Model as ModelAnnotation;
|
|||||||
use Nelmio\ApiDocBundle\Model\Model;
|
use Nelmio\ApiDocBundle\Model\Model;
|
||||||
use Nelmio\ApiDocBundle\Model\ModelRegistry;
|
use Nelmio\ApiDocBundle\Model\ModelRegistry;
|
||||||
use Swagger\Analysis;
|
use Swagger\Analysis;
|
||||||
|
use Swagger\Annotations\Definition;
|
||||||
use Swagger\Annotations\Items;
|
use Swagger\Annotations\Items;
|
||||||
use Swagger\Annotations\Parameter;
|
use Swagger\Annotations\Parameter;
|
||||||
use Swagger\Annotations\Response;
|
use Swagger\Annotations\Response;
|
||||||
@ -37,6 +38,7 @@ final class ModelRegister
|
|||||||
|
|
||||||
public function __invoke(Analysis $analysis)
|
public function __invoke(Analysis $analysis)
|
||||||
{
|
{
|
||||||
|
$modelsRegistered = [];
|
||||||
foreach ($analysis->annotations as $annotation) {
|
foreach ($analysis->annotations as $annotation) {
|
||||||
if ($annotation instanceof Response) {
|
if ($annotation instanceof Response) {
|
||||||
$annotationClass = Schema::class;
|
$annotationClass = Schema::class;
|
||||||
@ -70,8 +72,12 @@ final class ModelRegister
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$ref = $this->modelRegistry->register(new Model($this->createType($model->type), $model->groups));
|
||||||
|
$parts = explode('/', $ref);
|
||||||
|
$modelsRegistered[end($parts)] = true;
|
||||||
|
|
||||||
$annotation->merge([new $annotationClass([
|
$annotation->merge([new $annotationClass([
|
||||||
'ref' => $this->modelRegistry->register(new Model($this->createType($model->type), $model->groups)),
|
'ref' => $ref,
|
||||||
])]);
|
])]);
|
||||||
|
|
||||||
// It is no longer an unmerged annotation
|
// It is no longer an unmerged annotation
|
||||||
@ -84,6 +90,10 @@ final class ModelRegister
|
|||||||
}
|
}
|
||||||
$analysis->annotations->detach($model);
|
$analysis->annotations->detach($model);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach ($modelsRegistered as $model => $v) {
|
||||||
|
$analysis->annotations->attach(new Definition(['definition' => $model]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function createType(string $type): Type
|
private function createType(string $type): Type
|
||||||
|
Loading…
x
Reference in New Issue
Block a user