mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-09 02:59:27 +03:00
Always provide a context to swagger-php (#1860)
The next swagger-php release will make `context` a required parameter for `Analysis` and adding annotations to it.
This commit is contained in:
parent
985b43fb60
commit
74a440a2b1
@ -17,6 +17,7 @@ use Nelmio\ApiDocBundle\Model\ModelRegistry;
|
||||
use Nelmio\ApiDocBundle\ModelDescriber\ModelDescriberInterface;
|
||||
use Nelmio\ApiDocBundle\OpenApiPhp\DefaultOperationId;
|
||||
use Nelmio\ApiDocBundle\OpenApiPhp\ModelRegister;
|
||||
use Nelmio\ApiDocBundle\OpenApiPhp\Util;
|
||||
use OpenApi\Analysis;
|
||||
use OpenApi\Annotations\OpenApi;
|
||||
use Psr\Cache\CacheItemPoolInterface;
|
||||
@ -95,8 +96,9 @@ final class ApiDocGenerator
|
||||
$describer->describe($this->openApi);
|
||||
}
|
||||
|
||||
$analysis = new Analysis();
|
||||
$analysis->addAnnotation($this->openApi, null);
|
||||
$context = Util::createContext();
|
||||
$analysis = new Analysis([], $context);
|
||||
$analysis->addAnnotation($this->openApi, $context);
|
||||
|
||||
// Register model annotations
|
||||
$modelRegister = new ModelRegister($modelRegistry, $this->mediaTypes);
|
||||
|
@ -14,6 +14,7 @@ namespace Nelmio\ApiDocBundle\ModelDescriber\Annotations;
|
||||
use Doctrine\Common\Annotations\Reader;
|
||||
use Nelmio\ApiDocBundle\Model\ModelRegistry;
|
||||
use Nelmio\ApiDocBundle\OpenApiPhp\ModelRegister;
|
||||
use Nelmio\ApiDocBundle\OpenApiPhp\Util;
|
||||
use OpenApi\Analyser;
|
||||
use OpenApi\Analysis;
|
||||
use OpenApi\Annotations as OA;
|
||||
@ -41,7 +42,7 @@ class OpenApiAnnotationsReader
|
||||
}
|
||||
|
||||
// Read @Model annotations
|
||||
$this->modelRegister->__invoke(new Analysis([$oaSchema]));
|
||||
$this->modelRegister->__invoke(new Analysis([$oaSchema], Util::createContext()));
|
||||
|
||||
if (!$oaSchema->validate()) {
|
||||
return;
|
||||
@ -82,7 +83,7 @@ class OpenApiAnnotationsReader
|
||||
Analyser::$context = null;
|
||||
|
||||
// Read @Model annotations
|
||||
$this->modelRegister->__invoke(new Analysis([$oaProperty]), $serializationGroups);
|
||||
$this->modelRegister->__invoke(new Analysis([$oaProperty], Util::createContext()), $serializationGroups);
|
||||
|
||||
if (!$oaProperty->validate()) {
|
||||
return;
|
||||
|
@ -166,6 +166,6 @@ final class ModelRegister
|
||||
}
|
||||
|
||||
$annotation->merge([$modelAnnotation]);
|
||||
$analysis->addAnnotation($modelAnnotation, null);
|
||||
$analysis->addAnnotation($modelAnnotation, $properties['_context']);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user