diff --git a/.symfony.bundle.yaml b/.symfony.bundle.yaml index bcd0936cd..020e80c34 100644 --- a/.symfony.bundle.yaml +++ b/.symfony.bundle.yaml @@ -1,6 +1,5 @@ -branches: ["2.x", "3.x", "master"] -maintained_branches: ["3.x", "master"] -current_branch: "master" -dev_branch: "master" -dev_branch_alias: "4.x" -doc_dir: { "3.x": "Resources/doc/", "master": "docs/" } +branches: ["2.x", "3.x", "master", "5.x"] +maintained_branches: ["master", "5.x"] +current_branch: "5.x" +dev_branch: "5.x" +doc_dir: { "3.x": "Resources/doc/", "master": "docs/", "5.x": "docs/" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f1a002d3..70dc95021 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,21 @@ # CHANGELOG +## 4.32.3 + +* Deprecated `Nelmio\ApiDocBundle\Annotation` namespace in favor of `Nelmio\ApiDocBundle\Attribute` namespace in preparation for 5.x. Consider upgrading to the new attribute syntax. +```diff +- use Nelmio\ApiDocBundle\Annotation\Areas; +- use Nelmio\ApiDocBundle\Annotation\Model; +- use Nelmio\ApiDocBundle\Annotation\Operation; +- use Nelmio\ApiDocBundle\Annotation\Security; + ++ use Nelmio\ApiDocBundle\Attribute\Areas; ++ use Nelmio\ApiDocBundle\Attribute\Model; ++ use Nelmio\ApiDocBundle\Attribute\Operation; ++ use Nelmio\ApiDocBundle\Attribute\Security; +``` + + ## 4.32.0 * Added support to configure `options` and `serializationContext` via `nelmio_api_doc.models.names`. diff --git a/UPGRADE-3.0.md b/UPGRADE-3.0.md index f720e2737..07d643764 100644 --- a/UPGRADE-3.0.md +++ b/UPGRADE-3.0.md @@ -17,7 +17,7 @@ First, copy this command in ``src/AppBundle/Command/SwaggerDocblockConvertComman // src/AppBundle/Command/SwaggerDocblockConvertCommand.php namespace AppBundle\Command; -use Nelmio\ApiDocBundle\Annotation\ApiDoc; +use Nelmio\ApiDocBundle\Attribute\ApiDoc; use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; diff --git a/UPGRADE-5.0.md b/UPGRADE-5.0.md index fe5e4a57f..8f132674a 100644 --- a/UPGRADE-5.0.md +++ b/UPGRADE-5.0.md @@ -25,3 +25,15 @@ This causes the following breaking changes in classes that used annotations: - BC BREAK: Removed 2nd parameter `?Reader $annotationReader` from `Nelmio\ApiDocBundle\ModelDescriber\ObjectModelDescriber::__construct()` - BC BREAK: Removed 1st parameter `?Reader $annotationReader` from `Nelmio\ApiDocBundle\RouteDescriber\FosRestDescriber::__construct()` - BC BREAK: Removed 1st parameter `?Reader $annotationReader` from `Nelmio\ApiDocBundle\Routing\FilteredRouteCollectionBuilder::__construct()` + +## BC BREAK: `Nelmio\ApiDocBundle\Annotation` namespace has been remove in favor of `Nelmio\ApiDocBundle\Attribute` + +## BC BREAK: Configuration option `with_annotation` has been renamed to `with_attribute` +```diff +nelmio_api_doc: + areas: + path_patterns: + - ^/api/foo +- with_annotation: true ++ with_attribute: true +``` \ No newline at end of file diff --git a/composer.json b/composer.json index 8884af483..809244d41 100644 --- a/composer.json +++ b/composer.json @@ -92,7 +92,8 @@ }, "extra": { "branch-alias": { - "dev-master": "4.x-dev" + "dev-master": "4.x-dev", + "dev-5.x": "5.x-dev" } }, "scripts-descriptions": { diff --git a/docs/alternative_names.rst b/docs/alternative_names.rst index 6e1f4903d..89be057dd 100644 --- a/docs/alternative_names.rst +++ b/docs/alternative_names.rst @@ -29,7 +29,7 @@ In this case the class ``App\Entity\User`` will be aliased into: .. tip:: - This allows to use normal references instead of ``@Model``. Notably, you can specify + This allows to use normal references instead of ``#[Model]``. Notably, you can specify the groups used for a model once in config and then refer to its alternative name: .. code-block:: yaml @@ -38,14 +38,14 @@ In this case the class ``App\Entity\User`` will be aliased into: models: names: [ { alias: MyModel, type: App\MyModel, groups: [light] }] - .. code-block:: php + .. configuration-block:: - class HomeController - { - /** - * @OA\Response(response=200, @OA\JsonContent(ref="#/components/schemas/MyModel")) - */ - public function indexAction() + .. code-block:: php-attributes + + class HomeController { - } - } + #[OA\Response(response: 200, content: new OA\JsonContent(ref: "#/components/schemas/MyModel"))] + public function indexAction() + { + } + } \ No newline at end of file diff --git a/docs/areas.rst b/docs/areas.rst index fa2705c8f..e0369f1bb 100644 --- a/docs/areas.rst +++ b/docs/areas.rst @@ -62,12 +62,12 @@ Then update your routing to be able to access your different documentations: That's all! You can now access ``/api/doc/internal``, ``/api/doc/commercial`` and ``/api/doc/store``. -Use annotations to filter documented routes in each area +Use attributes to filter documented routes in each area -------------------------------------------------------- -You can use the `@Areas` annotation inside your controllers to define your routes' areas. +You can use the ``#[Areas]`` attribute inside your controllers to define your routes' areas. -First, you need to define which areas will use the`@Areas` annotations to filter +First, you need to define which areas will use the`#[Areas]` attributes to filter the routes that should be documented: .. code-block:: yaml @@ -77,22 +77,29 @@ the routes that should be documented: default: path_patterns: [ ^/api ] internal: - with_annotation: true + with_attribute: true -Then add the annotation before your controller or action:: +Then add the attribute before your controller or action:: - use Nelmio\Annotations as Nelmio; +.. configuration-block:: + + .. code-block:: php-attributes + + use Nelmio\Attribute as Nelmio; - /** - * @Nelmio\Areas({"internal"}) => All actions in this controller are documented under the 'internal' area - */ - class MyController - { /** - * @Nelmio\Areas({"internal"}) => This action is documented under the 'internal' area + * All actions in this controller are documented under the 'internal' area */ - public function index() + #[Nelmio\Areas(["internal"])] + class MyController { - ... + /** + * This action is documented under the 'internal' area + */ + #[Nelmio\Areas(["internal"])] + public function index() + { + ... + } } - } + diff --git a/docs/faq.rst b/docs/faq.rst index f3558634c..d44fa97c1 100644 --- a/docs/faq.rst +++ b/docs/faq.rst @@ -180,19 +180,21 @@ Endpoints grouping Q: Areas feature doesn't fit my needs. So how can I group similar endpoints of one or more controllers in a separate section in the documentation? -A: Use ``@OA\Tag`` annotation. +A: Use ``#[OA\Tag]`` attribute. -.. code-block:: php +.. configuration-block:: + + .. code-block:: php-attributes + + /** + * Class BookmarkController + */ + #[OA\Tag(name: "Bookmarks")] + class BookmarkController extends AbstractFOSRestController implements ContextPresetInterface + { + // ... + } - /** - * Class BookmarkController - * - * @OA\Tag(name="Bookmarks") - */ - class BookmarkController extends AbstractFOSRestController implements ContextPresetInterface - { - // ... - } Disable Default Section ----------------------- @@ -214,23 +216,22 @@ Overriding a Form or Plain PHP Object Schema Type Q: I'd like to define a PHP object or form with a type other any ``object``, how do I do that? -A: By using the ``@OA\Schema`` annotation or attribute with a ``type`` or ``ref``. +A: By using the ``#[OA\Schema]`` attribute with a ``type`` or ``ref``. Note, however, that a ``type="object"`` will still read all a models properties. -.. code-block:: php +.. configuration-block:: - false]))] @@ -524,45 +403,14 @@ General PHP objects When using the JMS serializer combined with `willdurand/Hateoas`_ (and the `BazingaHateoasBundle`_), HATEOAS metadata are automatically extracted -If you want to customize the documentation of an object's property, you can use ``@OA\Property``:: +If you want to customize the documentation of an object's property, you can use ``#[OA\Property]``:: .. configuration-block:: - .. code-block:: php-annotations - - use Nelmio\ApiDocBundle\Annotation\Model; - use OpenApi\Annotations as OA; - - class User - { - /** - * @var int - * @OA\Property(description="The unique identifier of the user.") - */ - public $id; - - /** - * @OA\Property(type="string", maxLength=255) - */ - public $username; - - /** - * @OA\Property(ref=@Model(type=User::class)) - */ - public $friend; - - /** - * @OA\Property(description="This is my coworker!") - */ - public setCoworker(User $coworker) { - // ... - } - } - .. code-block:: php-attributes - use Nelmio\ApiDocBundle\Annotation\Model; + use Nelmio\ApiDocBundle\Attribute\Model; use OpenApi\Attributes as OA; class User @@ -585,7 +433,7 @@ If you want to customize the documentation of an object's property, you can use } } -See the `OpenAPI 3.0 specification`__ to see all the available fields of ``@OA\Property``. +See the `OpenAPI 3.0 specification`__ to see all the available fields of ``#[@OA\Property]``. __ https://swagger.io/specification/ diff --git a/docs/security.rst b/docs/security.rst index ca8f915a2..34f774e57 100644 --- a/docs/security.rst +++ b/docs/security.rst @@ -24,32 +24,20 @@ This will add the Bearer security policy to all registered paths. Overriding Specific Paths ------------------------- -The security policy can be overridden for a path using the ``Security`` annotation/attribute. +The security policy can be overridden for a path using the ``Security`` attribute. .. configuration-block:: - .. code-block:: php-annotations - - /** - * @Security(name="ApiKeyAuth") - */ - .. code-block:: php-attributes #[Security(name: "ApiKeyAuth")] -Notice at the bottom of the docblock is a ``Security`` annotation/attribute with a name of `ApiKeyAuth`. This will override the global security policy to only accept the ``ApiKeyAuth`` policy for this path. +Notice at the bottom of the docblock is a ``Security`` attribute with a name of `ApiKeyAuth`. This will override the global security policy to only accept the ``ApiKeyAuth`` policy for this path. You can also completely remove security from a path by providing ``Security`` with a name of ``null``. .. configuration-block:: - .. code-block:: php-annotations - - /** - * @Security(name=null) - */ - .. code-block:: php-attributes #[Security(name: null)] diff --git a/src/ApiDocGenerator.php b/src/ApiDocGenerator.php index cedcd1614..e22c36106 100644 --- a/src/ApiDocGenerator.php +++ b/src/ApiDocGenerator.php @@ -123,7 +123,7 @@ public function generate(): OpenApi $analysis = new Analysis([], $context); $analysis->addAnnotation($this->openApi, $context); - // Register model annotations + // Register model attributes $modelRegister = new ModelRegister($modelRegistry, $this->mediaTypes); $modelRegister($analysis); @@ -152,7 +152,7 @@ private function getProcessors(Generator $generator): array // Get the standard processors from the generator. $processors = $generator->getProcessors(); - // Remove OperationId processor as we use a lot of generated annotations which do not have enough information in their context + // Remove OperationId processor as we use a lot of generated attributes which do not have enough information in their context // to generate these ids properly. // @see \Nelmio\ApiDocBundle\OpenApiPhp\Util::createContext foreach ($processors as $key => $processor) { diff --git a/src/Annotation/Areas.php b/src/Attribute/Areas.php similarity index 96% rename from src/Annotation/Areas.php rename to src/Attribute/Areas.php index f90983576..0d004c0e7 100644 --- a/src/Annotation/Areas.php +++ b/src/Attribute/Areas.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Nelmio\ApiDocBundle\Annotation; +namespace Nelmio\ApiDocBundle\Attribute; #[\Attribute(\Attribute::TARGET_CLASS | \Attribute::TARGET_METHOD)] final class Areas diff --git a/src/Annotation/Model.php b/src/Attribute/Model.php similarity index 97% rename from src/Annotation/Model.php rename to src/Attribute/Model.php index cbc610fad..57aaee5e3 100644 --- a/src/Annotation/Model.php +++ b/src/Attribute/Model.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Nelmio\ApiDocBundle\Annotation; +namespace Nelmio\ApiDocBundle\Attribute; use OpenApi\Annotations\Parameter; use OpenApi\Attributes\Attachable; diff --git a/src/Annotation/Operation.php b/src/Attribute/Operation.php similarity index 89% rename from src/Annotation/Operation.php rename to src/Attribute/Operation.php index ed153e539..092458fa2 100644 --- a/src/Annotation/Operation.php +++ b/src/Attribute/Operation.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Nelmio\ApiDocBundle\Annotation; +namespace Nelmio\ApiDocBundle\Attribute; use OpenApi\Annotations\Operation as BaseOperation; diff --git a/src/Annotation/Security.php b/src/Attribute/Security.php similarity index 95% rename from src/Annotation/Security.php rename to src/Attribute/Security.php index f057282f4..839fd7e7e 100644 --- a/src/Annotation/Security.php +++ b/src/Attribute/Security.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Nelmio\ApiDocBundle\Annotation; +namespace Nelmio\ApiDocBundle\Attribute; use OpenApi\Annotations\AbstractAnnotation; diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 0b2ec84fb..790f24587 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -26,7 +26,7 @@ public function getConfigTreeBuilder(): TreeBuilder $rootNode ->children() ->booleanNode('use_validation_groups') - ->info('If true, `groups` passed to @Model annotations will be used to limit validation constraints') + ->info('If true, `groups` passed to #[Model] attributes will be used to limit validation constraints') ->defaultFalse() ->end() ->arrayNode('cache') @@ -86,7 +86,7 @@ public function getConfigTreeBuilder(): TreeBuilder 'default' => [ 'path_patterns' => [], 'host_patterns' => [], - 'with_annotation' => false, + 'with_attribute' => false, 'documentation' => [], 'name_patterns' => [], 'disable_default_routes' => false, @@ -127,13 +127,13 @@ public function getConfigTreeBuilder(): TreeBuilder ->example(['^api_v1']) ->prototype('scalar')->end() ->end() - ->booleanNode('with_annotation') + ->booleanNode('with_attribute') ->defaultFalse() - ->info('whether to filter by annotation') + ->info('whether to filter by attributes') ->end() ->booleanNode('disable_default_routes') ->defaultFalse() - ->info('if set disables default routes without annotations') + ->info('if set disables default routes without attributes') ->end() ->arrayNode('documentation') ->useAttributeAsKey('key') diff --git a/src/DependencyInjection/NelmioApiDocExtension.php b/src/DependencyInjection/NelmioApiDocExtension.php index 1995f2dc1..c699f6fa0 100644 --- a/src/DependencyInjection/NelmioApiDocExtension.php +++ b/src/DependencyInjection/NelmioApiDocExtension.php @@ -130,7 +130,7 @@ public function load(array $configs, ContainerBuilder $container): void if (0 === count($areaConfig['path_patterns']) && 0 === count($areaConfig['host_patterns']) && 0 === count($areaConfig['name_patterns']) - && false === $areaConfig['with_annotation'] + && false === $areaConfig['with_attribute'] && false === $areaConfig['disable_default_routes'] ) { $container->setDefinition(sprintf('nelmio_api_doc.routes.%s', $area), $routesDefinition) diff --git a/src/Describer/OpenApiPhpDescriber.php b/src/Describer/OpenApiPhpDescriber.php index 79a807c72..bec30c519 100644 --- a/src/Describer/OpenApiPhpDescriber.php +++ b/src/Describer/OpenApiPhpDescriber.php @@ -11,8 +11,8 @@ namespace Nelmio\ApiDocBundle\Describer; -use Nelmio\ApiDocBundle\Annotation\Operation; -use Nelmio\ApiDocBundle\Annotation\Security; +use Nelmio\ApiDocBundle\Attribute\Operation; +use Nelmio\ApiDocBundle\Attribute\Security; use Nelmio\ApiDocBundle\OpenApiPhp\Util; use Nelmio\ApiDocBundle\Util\ControllerReflector; use Nelmio\ApiDocBundle\Util\SetsContextTrait; diff --git a/src/Exception/UndocumentedArrayItemsException.php b/src/Exception/UndocumentedArrayItemsException.php index 2b2e812b5..f6cee4224 100644 --- a/src/Exception/UndocumentedArrayItemsException.php +++ b/src/Exception/UndocumentedArrayItemsException.php @@ -37,7 +37,7 @@ public function __construct(?string $class = null, string $path = '') } $propertyName .= $path; - parent::__construct(sprintf('Property "%s" is an array, but its items type isn\'t specified. You can specify that by using the type `string[]` for instance or `@OA\Property(type="array", @OA\Items(type="string"))`.', $propertyName)); + parent::__construct(sprintf('Property "%s" is an array, but its items type isn\'t specified. You can specify that by using the type `string[]` for instance or `#[OA\Property(type="array", new OA\Items(type="string"))]`.', $propertyName)); } /** diff --git a/src/ModelDescriber/Annotations/OpenApiAnnotationsReader.php b/src/ModelDescriber/Annotations/OpenApiAnnotationsReader.php index 8debfc04d..c61b0f201 100644 --- a/src/ModelDescriber/Annotations/OpenApiAnnotationsReader.php +++ b/src/ModelDescriber/Annotations/OpenApiAnnotationsReader.php @@ -39,11 +39,11 @@ public function __construct(ModelRegistry $modelRegistry, array $mediaTypes) public function updateSchema(\ReflectionClass $reflectionClass, OA\Schema $schema): void { - if (null === $oaSchema = $this->getAnnotation($schema->_context, $reflectionClass, OA\Schema::class)) { + if (null === $oaSchema = $this->getAttribute($schema->_context, $reflectionClass, OA\Schema::class)) { return; } - // Read @Model annotations + // Read #[Model] attributes $this->modelRegister->__invoke(new Analysis([$oaSchema], Util::createContext())); if (!$oaSchema->validate()) { @@ -58,7 +58,7 @@ public function updateSchema(\ReflectionClass $reflectionClass, OA\Schema $schem */ public function getPropertyName($reflection, string $default): string { - if (null === $oaProperty = $this->getAnnotation(new Context(), $reflection, OA\Property::class)) { + if (null === $oaProperty = $this->getAttribute(new Context(), $reflection, OA\Property::class)) { return $default; } @@ -71,11 +71,11 @@ public function getPropertyName($reflection, string $default): string */ public function updateProperty($reflection, OA\Property $property, ?array $serializationGroups = null): void { - if (null === $oaProperty = $this->getAnnotation($property->_context, $reflection, OA\Property::class)) { + if (null === $oaProperty = $this->getAttribute($property->_context, $reflection, OA\Property::class)) { return; } - // Read @Model annotations + // Read #[Model] attributes $this->modelRegister->__invoke(new Analysis([$oaProperty], Util::createContext()), $serializationGroups); if (!$oaProperty->validate()) { @@ -93,7 +93,7 @@ public function updateProperty($reflection, OA\Property $property, ?array $seria * * @return T|null */ - private function getAnnotation(Context $parentContext, $reflection, string $className) + private function getAttribute(Context $parentContext, $reflection, string $className) { $this->setContextFromReflection($parentContext, $reflection); diff --git a/src/ModelDescriber/Annotations/SymfonyConstraintAnnotationReader.php b/src/ModelDescriber/Annotations/SymfonyConstraintAnnotationReader.php index d6b88df39..1861ff90a 100644 --- a/src/ModelDescriber/Annotations/SymfonyConstraintAnnotationReader.php +++ b/src/ModelDescriber/Annotations/SymfonyConstraintAnnotationReader.php @@ -46,24 +46,24 @@ public function __construct(bool $useValidationGroups = false) */ public function updateProperty($reflection, OA\Property $property, ?array $validationGroups = null): void { - foreach ($this->getAnnotations($property->_context, $reflection, $validationGroups) as $outerAnnotation) { - $innerAnnotations = $outerAnnotation instanceof Assert\Compound || $outerAnnotation instanceof Assert\Sequentially - ? $outerAnnotation->constraints - : [$outerAnnotation]; + foreach ($this->getAttributes($property->_context, $reflection, $validationGroups) as $outerAttribute) { + $innerAttributes = $outerAttribute instanceof Assert\Compound || $outerAttribute instanceof Assert\Sequentially + ? $outerAttribute->constraints + : [$outerAttribute]; - $this->processPropertyAnnotations($reflection, $property, $innerAnnotations); + $this->processPropertyAttributes($reflection, $property, $innerAttributes); } } /** * @param \ReflectionProperty|\ReflectionMethod $reflection - * @param Constraint[] $annotations + * @param Constraint[] $attributes */ - private function processPropertyAnnotations($reflection, OA\Property $property, array $annotations): void + private function processPropertyAttributes($reflection, OA\Property $property, array $attributes): void { - foreach ($annotations as $annotation) { - if ($annotation instanceof Assert\NotBlank || $annotation instanceof Assert\NotNull) { - if ($annotation instanceof Assert\NotBlank && $annotation->allowNull) { + foreach ($attributes as $attribute) { + if ($attribute instanceof Assert\NotBlank || $attribute instanceof Assert\NotNull) { + if ($attribute instanceof Assert\NotBlank && $attribute->allowNull) { // The field is optional return; } @@ -87,48 +87,48 @@ private function processPropertyAnnotations($reflection, OA\Property $property, $this->schema->required = array_values(array_unique($existingRequiredFields)); $property->nullable = false; - } elseif ($annotation instanceof Assert\Length) { - if (isset($annotation->min)) { - $property->minLength = $annotation->min; + } elseif ($attribute instanceof Assert\Length) { + if (isset($attribute->min)) { + $property->minLength = $attribute->min; } - if (isset($annotation->max)) { - $property->maxLength = $annotation->max; + if (isset($attribute->max)) { + $property->maxLength = $attribute->max; } - } elseif ($annotation instanceof Assert\Regex) { - $this->appendPattern($property, $annotation->getHtmlPattern()); - } elseif ($annotation instanceof Assert\Count) { - if (isset($annotation->min)) { - $property->minItems = $annotation->min; + } elseif ($attribute instanceof Assert\Regex) { + $this->appendPattern($property, $attribute->getHtmlPattern()); + } elseif ($attribute instanceof Assert\Count) { + if (isset($attribute->min)) { + $property->minItems = $attribute->min; } - if (isset($annotation->max)) { - $property->maxItems = $annotation->max; + if (isset($attribute->max)) { + $property->maxItems = $attribute->max; } - } elseif ($annotation instanceof Assert\Choice) { - $this->applyEnumFromChoiceConstraint($property, $annotation, $reflection); - } elseif ($annotation instanceof Assert\Range) { - if (\is_int($annotation->min)) { - $property->minimum = $annotation->min; + } elseif ($attribute instanceof Assert\Choice) { + $this->applyEnumFromChoiceConstraint($property, $attribute, $reflection); + } elseif ($attribute instanceof Assert\Range) { + if (\is_int($attribute->min)) { + $property->minimum = $attribute->min; } - if (\is_int($annotation->max)) { - $property->maximum = $annotation->max; + if (\is_int($attribute->max)) { + $property->maximum = $attribute->max; } - } elseif ($annotation instanceof Assert\LessThan) { - if (\is_int($annotation->value)) { + } elseif ($attribute instanceof Assert\LessThan) { + if (\is_int($attribute->value)) { $property->exclusiveMaximum = true; - $property->maximum = $annotation->value; + $property->maximum = $attribute->value; } - } elseif ($annotation instanceof Assert\LessThanOrEqual) { - if (\is_int($annotation->value)) { - $property->maximum = $annotation->value; + } elseif ($attribute instanceof Assert\LessThanOrEqual) { + if (\is_int($attribute->value)) { + $property->maximum = $attribute->value; } - } elseif ($annotation instanceof Assert\GreaterThan) { - if (\is_int($annotation->value)) { + } elseif ($attribute instanceof Assert\GreaterThan) { + if (\is_int($attribute->value)) { $property->exclusiveMinimum = true; - $property->minimum = $annotation->value; + $property->minimum = $attribute->value; } - } elseif ($annotation instanceof Assert\GreaterThanOrEqual) { - if (\is_int($annotation->value)) { - $property->minimum = $annotation->value; + } elseif ($attribute instanceof Assert\GreaterThanOrEqual) { + if (\is_int($attribute->value)) { + $property->minimum = $attribute->value; } } } @@ -179,14 +179,14 @@ private function applyEnumFromChoiceConstraint(OA\Schema $property, Assert\Choic * * @return iterable */ - private function getAnnotations(Context $parentContext, $reflection, ?array $validationGroups): iterable + private function getAttributes(Context $parentContext, $reflection, ?array $validationGroups): iterable { - // To correctly load OA annotations + // To correctly load OA attributes $this->setContextFromReflection($parentContext, $reflection); - foreach ($this->locateAnnotations($reflection) as $annotation) { - if (!$this->useValidationGroups || $this->isConstraintInGroup($annotation, $validationGroups)) { - yield $annotation; + foreach ($this->locateAttributes($reflection) as $attribute) { + if (!$this->useValidationGroups || $this->isConstraintInGroup($attribute, $validationGroups)) { + yield $attribute; } } @@ -198,7 +198,7 @@ private function getAnnotations(Context $parentContext, $reflection, ?array $val * * @return \Traversable */ - private function locateAnnotations($reflection): \Traversable + private function locateAttributes($reflection): \Traversable { if (class_exists(Constraint::class)) { foreach ($reflection->getAttributes(Constraint::class, \ReflectionAttribute::IS_INSTANCEOF) as $attribute) { @@ -217,7 +217,7 @@ private function locateAnnotations($reflection): \Traversable * * @param string[]|null $validationGroups */ - private function isConstraintInGroup(Constraint $annotation, ?array $validationGroups): bool + private function isConstraintInGroup(Constraint $attribute, ?array $validationGroups): bool { if (null === $validationGroups) { $validationGroups = [Constraint::DEFAULT_GROUP]; @@ -225,7 +225,7 @@ private function isConstraintInGroup(Constraint $annotation, ?array $validationG return [] !== array_intersect( $validationGroups, - (array) $annotation->groups + (array) $attribute->groups ); } } diff --git a/src/ModelDescriber/FormModelDescriber.php b/src/ModelDescriber/FormModelDescriber.php index bd6e7f5a3..ee4a24398 100644 --- a/src/ModelDescriber/FormModelDescriber.php +++ b/src/ModelDescriber/FormModelDescriber.php @@ -122,7 +122,7 @@ private function parseForm(OA\Schema $schema, FormInterface $form): void if ($config->hasOption('documentation')) { $property->mergeProperties($config->getOption('documentation')); - // Parse inner @Model annotations + // Parse inner #[Model] attributes $modelRegister = new ModelRegister($this->modelRegistry, $this->mediaTypes); $modelRegister->__invoke(new Analysis([$property], Util::createContext())); } diff --git a/src/ModelDescriber/JMSModelDescriber.php b/src/ModelDescriber/JMSModelDescriber.php index f5497efa7..ca17b5a00 100644 --- a/src/ModelDescriber/JMSModelDescriber.php +++ b/src/ModelDescriber/JMSModelDescriber.php @@ -131,7 +131,7 @@ public function describe(Model $model, OA\Schema $schema) $context->pushPropertyMetadata($item); $name = true === $isJmsV1 ? $this->namingStrategy->translateName($item) : $item->serializedName; - // read property options from Swagger Property annotation if it exists + // read property options from Swagger Property attribute if it exists $reflections = []; if (true === $isJmsV1 && property_exists($item, 'reflection') && null !== $item->reflection) { diff --git a/src/ModelDescriber/ObjectModelDescriber.php b/src/ModelDescriber/ObjectModelDescriber.php index 0ff4effdd..b7b124074 100644 --- a/src/ModelDescriber/ObjectModelDescriber.php +++ b/src/ModelDescriber/ObjectModelDescriber.php @@ -172,7 +172,7 @@ public function describe(Model $model, OA\Schema $schema) $types = $this->propertyInfo->getTypes($class, $propertyName); if (null === $types || 0 === count($types)) { - throw new \LogicException(sprintf('The PropertyInfo component was not able to guess the type of %s::$%s. You may need to add a `@var` annotation or use `@OA\Property(type="")` to make its type explicit.', $class, $propertyName)); + throw new \LogicException(sprintf('The PropertyInfo component was not able to guess the type of %s::$%s. You may need to add a `@var` annotation or use `#[OA\Property(type="")]` to make its type explicit.', $class, $propertyName)); } $this->describeProperty($types, $model, $property, $propertyName, $schema); @@ -227,7 +227,7 @@ private function describeProperty(array $types, Model $model, OA\Schema $propert } } - throw new \Exception(sprintf('Type "%s" is not supported in %s::$%s. You may use the `@OA\Property(type="")` annotation to specify it manually.', $types[0]->getBuiltinType(), $model->getType()->getClassName(), $propertyName)); + throw new \Exception(sprintf('Type "%s" is not supported in %s::$%s. You may use the `#[OA\Property(type="")]` annotation to specify it manually.', $types[0]->getBuiltinType(), $model->getType()->getClassName(), $propertyName)); } /** diff --git a/src/OpenApiPhp/ModelRegister.php b/src/OpenApiPhp/ModelRegister.php index de20ee6bb..17d127057 100644 --- a/src/OpenApiPhp/ModelRegister.php +++ b/src/OpenApiPhp/ModelRegister.php @@ -11,7 +11,7 @@ namespace Nelmio\ApiDocBundle\OpenApiPhp; -use Nelmio\ApiDocBundle\Annotation\Model as ModelAnnotation; +use Nelmio\ApiDocBundle\Attribute\Model as ModelAnnotation; use Nelmio\ApiDocBundle\Model\Model; use Nelmio\ApiDocBundle\Model\ModelRegistry; use OpenApi\Analysis; @@ -46,7 +46,7 @@ public function __construct(ModelRegistry $modelRegistry, array $mediaTypes) public function __invoke(Analysis $analysis, ?array $parentGroups = null): void { foreach ($analysis->annotations as $annotation) { - // @Model using the ref field + // #[Model] using the ref field if ($annotation instanceof OA\Schema && $annotation->ref instanceof ModelAnnotation) { $model = $annotation->ref; @@ -60,15 +60,15 @@ public function __invoke(Analysis $analysis, ?array $parentGroups = null): void // Misusage of ::$ref if (($annotation instanceof OA\Response || $annotation instanceof OA\RequestBody) && $annotation->ref instanceof ModelAnnotation) { - throw new \InvalidArgumentException(sprintf('Using @Model inside @%s::$ref is not allowed. You should use ::$ref with @Property, @Parameter, @Schema, @Items but within @Response or @RequestBody you should put @Model directly at the root of the annotation : `@Response(..., @Model(...))`.', get_class($annotation))); + throw new \InvalidArgumentException(sprintf('Using #[Model] inside #[%s::$ref] is not allowed. You should use ::$ref with #[Property], #[Parameter], #[Schema], #[Items] but within #[Response] or #[RequestBody} You should use ::$content : `#[Response(..., content: new Model())]`.', get_class($annotation))); } // Implicit usages - // We don't use $ref for @Responses, @RequestBody and @Parameter to respect semantics - // We don't replace these objects with the @Model found (we inject it in a subfield) whereas we do for @Schemas + // We don't use $ref for #[Responses], #[RequestBody] and #[Parameter] to respect semantics + // We don't replace these objects with the #[Model] found (we inject it in a subfield) whereas we do for @Schemas - $model = $this->getModel($annotation); // We check whether there is a @Model annotation nested + $model = $this->getModel($annotation); // We check whether there is a #[Model] attribute nested if (null === $model) { continue; } @@ -88,7 +88,7 @@ public function __invoke(Analysis $analysis, ?array $parentGroups = null): void } if (!$annotation instanceof OA\Parameter) { - throw new \InvalidArgumentException(sprintf("@Model annotation can't be nested with an annotation of type @%s.", get_class($annotation))); + throw new \InvalidArgumentException(sprintf("#[Model] attribute can't be nested with an attribute of type @%s.", get_class($annotation))); } if ($annotation->schema instanceof OA\Schema && 'array' === $annotation->schema->type) { @@ -176,7 +176,7 @@ private function createContentForMediaType( break; default: - throw new \InvalidArgumentException(sprintf("@Model annotation is not compatible with the media types '%s'. It must be one of 'json' or 'xml'.", implode(',', $this->mediaTypes))); + throw new \InvalidArgumentException(sprintf("#[Model] attribute is not compatible with the media types '%s'. It must be one of 'json' or 'xml'.", implode(',', $this->mediaTypes))); } $annotation->merge([$modelAnnotation]); diff --git a/src/RouteDescriber/FosRestDescriber.php b/src/RouteDescriber/FosRestDescriber.php index 02655cc03..ee7ddbcd6 100644 --- a/src/RouteDescriber/FosRestDescriber.php +++ b/src/RouteDescriber/FosRestDescriber.php @@ -40,30 +40,30 @@ public function __construct(array $mediaTypes) public function describe(OA\OpenApi $api, Route $route, \ReflectionMethod $reflectionMethod): void { - $annotations = $this->getAttributesAsAnnotation($reflectionMethod, RequestParam::class); - $annotations = array_merge($annotations, $this->getAttributesAsAnnotation($reflectionMethod, QueryParam::class)); + $attributes = $this->getAttributes($reflectionMethod, RequestParam::class); + $attributes = array_merge($attributes, $this->getAttributes($reflectionMethod, QueryParam::class)); foreach ($this->getOperations($api, $route) as $operation) { - foreach ($annotations as $annotation) { - $parameterName = $annotation->key ?? $annotation->getName(); // the key used by fosrest + foreach ($attributes as $attribute) { + $parameterName = $attribute->key ?? $attribute->getName(); // the key used by fosrest - if ($annotation instanceof QueryParam) { - $name = $parameterName.($annotation->map ? '[]' : ''); + if ($attribute instanceof QueryParam) { + $name = $parameterName.($attribute->map ? '[]' : ''); $parameter = Util::getOperationParameter($operation, $name, 'query'); - $parameter->allowEmptyValue = $annotation->nullable && $annotation->allowBlank; + $parameter->allowEmptyValue = $attribute->nullable && $attribute->allowBlank; - $parameter->required = !$annotation->nullable && $annotation->strict; + $parameter->required = !$attribute->nullable && $attribute->strict; if (Generator::UNDEFINED === $parameter->description) { - $parameter->description = $annotation->description; + $parameter->description = $attribute->description; } - if ($annotation->map) { + if ($attribute->map) { $parameter->explode = true; } $schema = Util::getChild($parameter, OA\Schema::class); - $this->describeCommonSchemaFromAnnotation($schema, $annotation, $reflectionMethod); + $this->describeCommonSchemaFromAttribute($schema, $attribute, $reflectionMethod); } else { /** @var OA\RequestBody $requestBody */ $requestBody = Util::getChild($operation, OA\RequestBody::class); @@ -71,13 +71,13 @@ public function describe(OA\OpenApi $api, Route $route, \ReflectionMethod $refle $contentSchema = $this->getContentSchemaForType($requestBody, $mediaType); $schema = Util::getProperty($contentSchema, $parameterName); - if (!$annotation->nullable && $annotation->strict) { + if (!$attribute->nullable && $attribute->strict) { $requiredParameters = is_array($contentSchema->required) ? $contentSchema->required : []; $requiredParameters[] = $parameterName; $contentSchema->required = array_values(array_unique($requiredParameters)); } - $this->describeCommonSchemaFromAnnotation($schema, $annotation, $reflectionMethod); + $this->describeCommonSchemaFromAttribute($schema, $attribute, $reflectionMethod); } } } @@ -192,33 +192,33 @@ private function getContentSchemaForType(OA\RequestBody $requestBody, string $ty ); } - private function describeCommonSchemaFromAnnotation(OA\Schema $schema, AbstractScalarParam $annotation, \ReflectionMethod $reflectionMethod): void + private function describeCommonSchemaFromAttribute(OA\Schema $schema, AbstractScalarParam $attribute, \ReflectionMethod $reflectionMethod): void { - $schema->default = $annotation->getDefault(); + $schema->default = $attribute->getDefault(); if (Generator::UNDEFINED === $schema->type) { - $schema->type = $annotation->map ? 'array' : 'string'; + $schema->type = $attribute->map ? 'array' : 'string'; } - if ($annotation->map) { + if ($attribute->map) { $schema->type = 'array'; $schema->items = Util::getChild($schema, OA\Items::class); } - $pattern = $this->getPattern($annotation->requirements); + $pattern = $this->getPattern($attribute->requirements); if (null !== $pattern) { $schema->pattern = $pattern; } - $format = $this->getFormat($annotation->requirements); + $format = $this->getFormat($attribute->requirements); if (null !== $format) { $schema->format = $format; } - $enum = $this->getEnum($annotation->requirements, $reflectionMethod); + $enum = $this->getEnum($attribute->requirements, $reflectionMethod); if (null !== $enum) { - if ($annotation->requirements instanceof Choice) { - if ($annotation->requirements->multiple) { + if ($attribute->requirements instanceof Choice) { + if ($attribute->requirements->multiple) { $schema->type = 'array'; $schema->items = Util::createChild($schema, OA\Items::class, ['type' => 'string', 'enum' => $enum]); } else { @@ -235,13 +235,13 @@ private function describeCommonSchemaFromAnnotation(OA\Schema $schema, AbstractS * * @return T[] */ - private function getAttributesAsAnnotation(\ReflectionMethod $reflection, string $className): array + private function getAttributes(\ReflectionMethod $reflection, string $className): array { - $annotations = []; + $attributes = []; foreach ($reflection->getAttributes($className, \ReflectionAttribute::IS_INSTANCEOF) as $attribute) { - $annotations[] = $attribute->newInstance(); + $attributes[] = $attribute->newInstance(); } - return $annotations; + return $attributes; } } diff --git a/src/Routing/FilteredRouteCollectionBuilder.php b/src/Routing/FilteredRouteCollectionBuilder.php index a896466c9..02adde0f8 100644 --- a/src/Routing/FilteredRouteCollectionBuilder.php +++ b/src/Routing/FilteredRouteCollectionBuilder.php @@ -11,7 +11,7 @@ namespace Nelmio\ApiDocBundle\Routing; -use Nelmio\ApiDocBundle\Annotation\Areas; +use Nelmio\ApiDocBundle\Attribute\Areas; use Nelmio\ApiDocBundle\Util\ControllerReflector; use OpenApi\Annotations\AbstractAnnotation; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -43,13 +43,13 @@ public function __construct( 'path_patterns' => [], 'host_patterns' => [], 'name_patterns' => [], - 'with_annotation' => false, + 'with_attribute' => false, 'disable_default_routes' => false, ]) ->setAllowedTypes('path_patterns', 'string[]') ->setAllowedTypes('host_patterns', 'string[]') ->setAllowedTypes('name_patterns', 'string[]') - ->setAllowedTypes('with_annotation', 'boolean') + ->setAllowedTypes('with_attribute', 'boolean') ->setAllowedTypes('disable_default_routes', 'boolean') ; @@ -117,7 +117,7 @@ private function matchName(string $name): bool private function matchAnnotation(Route $route): bool { - if (false === $this->options['with_annotation']) { + if (false === $this->options['with_attribute']) { return true; } @@ -153,7 +153,7 @@ private function defaultRouteDisabled(Route $route): bool }, $method->getAttributes(AbstractAnnotation::class, \ReflectionAttribute::IS_INSTANCEOF)); foreach ($annotations as $annotation) { - if (false !== strpos(get_class($annotation), 'Nelmio\\ApiDocBundle\\Annotation') + if (false !== strpos(get_class($annotation), 'Nelmio\\ApiDocBundle\\Attribute') || false !== strpos(get_class($annotation), 'OpenApi\\Annotations') || false !== strpos(get_class($annotation), 'OpenApi\\Attributes') ) { diff --git a/tests/DependencyInjection/ConfigurationTest.php b/tests/DependencyInjection/ConfigurationTest.php index 0bca5e32c..9d0fe1f2f 100644 --- a/tests/DependencyInjection/ConfigurationTest.php +++ b/tests/DependencyInjection/ConfigurationTest.php @@ -38,7 +38,7 @@ public function testDefaultArea(): void 'path_patterns' => ['/foo'], 'host_patterns' => [], 'name_patterns' => [], - 'with_annotation' => false, + 'with_attribute' => false, 'disable_default_routes' => false, 'documentation' => [], ], @@ -53,7 +53,7 @@ public function testAreas(): void 'default' => [ 'path_patterns' => ['/foo'], 'host_patterns' => [], - 'with_annotation' => false, + 'with_attribute' => false, 'documentation' => [], 'name_patterns' => [], 'disable_default_routes' => false, @@ -61,7 +61,7 @@ public function testAreas(): void 'internal' => [ 'path_patterns' => ['/internal'], 'host_patterns' => ['^swagger\.'], - 'with_annotation' => false, + 'with_attribute' => false, 'documentation' => [], 'name_patterns' => [], 'disable_default_routes' => false, @@ -69,7 +69,7 @@ public function testAreas(): void 'commercial' => [ 'path_patterns' => ['/internal'], 'host_patterns' => [], - 'with_annotation' => false, + 'with_attribute' => false, 'documentation' => [], 'name_patterns' => [], 'disable_default_routes' => false, diff --git a/tests/Functional/Controller/ApiController.php b/tests/Functional/Controller/ApiController.php index 18d9e4775..a36d11382 100644 --- a/tests/Functional/Controller/ApiController.php +++ b/tests/Functional/Controller/ApiController.php @@ -11,10 +11,10 @@ namespace Nelmio\ApiDocBundle\Tests\Functional\Controller; -use Nelmio\ApiDocBundle\Annotation\Areas; -use Nelmio\ApiDocBundle\Annotation\Model; -use Nelmio\ApiDocBundle\Annotation\Operation; -use Nelmio\ApiDocBundle\Annotation\Security; +use Nelmio\ApiDocBundle\Attribute\Areas; +use Nelmio\ApiDocBundle\Attribute\Model; +use Nelmio\ApiDocBundle\Attribute\Operation; +use Nelmio\ApiDocBundle\Attribute\Security; use Nelmio\ApiDocBundle\Tests\Functional\Entity\ArrayItems\Dictionary; use Nelmio\ApiDocBundle\Tests\Functional\Entity\ArrayItems\Foo; use Nelmio\ApiDocBundle\Tests\Functional\Entity\Article; diff --git a/tests/Functional/Controller/BazingaController.php b/tests/Functional/Controller/BazingaController.php index f12aade51..726d4f7fb 100644 --- a/tests/Functional/Controller/BazingaController.php +++ b/tests/Functional/Controller/BazingaController.php @@ -11,7 +11,7 @@ namespace Nelmio\ApiDocBundle\Tests\Functional\Controller; -use Nelmio\ApiDocBundle\Annotation\Model; +use Nelmio\ApiDocBundle\Attribute\Model; use Nelmio\ApiDocBundle\Tests\Functional\Entity\BazingaUser; use OpenApi\Attributes as OA; use Symfony\Component\Routing\Annotation\Route; diff --git a/tests/Functional/Controller/BazingaTypedController.php b/tests/Functional/Controller/BazingaTypedController.php index a610fe634..04e652f45 100644 --- a/tests/Functional/Controller/BazingaTypedController.php +++ b/tests/Functional/Controller/BazingaTypedController.php @@ -11,7 +11,7 @@ namespace Nelmio\ApiDocBundle\Tests\Functional\Controller; -use Nelmio\ApiDocBundle\Annotation\Model; +use Nelmio\ApiDocBundle\Attribute\Model; use Nelmio\ApiDocBundle\Tests\Functional\EntityExcluded\BazingaUserTyped; use OpenApi\Attributes as OA; use Symfony\Component\Routing\Annotation\Route; diff --git a/tests/Functional/Controller/ClassApiController.php b/tests/Functional/Controller/ClassApiController.php index ac85ef9bc..fc2cf19ea 100644 --- a/tests/Functional/Controller/ClassApiController.php +++ b/tests/Functional/Controller/ClassApiController.php @@ -11,7 +11,7 @@ namespace Nelmio\ApiDocBundle\Tests\Functional\Controller; -use Nelmio\ApiDocBundle\Annotation\Security; +use Nelmio\ApiDocBundle\Attribute\Security; use OpenApi\Attributes as OAT; use Symfony\Component\Routing\Annotation\Route; diff --git a/tests/Functional/Controller/Controller2209.php b/tests/Functional/Controller/Controller2209.php index 7ea767869..dd22ad84e 100644 --- a/tests/Functional/Controller/Controller2209.php +++ b/tests/Functional/Controller/Controller2209.php @@ -13,7 +13,7 @@ namespace Nelmio\ApiDocBundle\Tests\Functional\Controller; -use Nelmio\ApiDocBundle\Annotation\Model; +use Nelmio\ApiDocBundle\Attribute\Model; use Nelmio\ApiDocBundle\Tests\Functional\Entity\Article81; use OpenApi\Attributes as OA; use Symfony\Component\HttpFoundation\JsonResponse; diff --git a/tests/Functional/Controller/JMSController.php b/tests/Functional/Controller/JMSController.php index b01243a61..4124f708b 100644 --- a/tests/Functional/Controller/JMSController.php +++ b/tests/Functional/Controller/JMSController.php @@ -11,7 +11,7 @@ namespace Nelmio\ApiDocBundle\Tests\Functional\Controller; -use Nelmio\ApiDocBundle\Annotation\Model; +use Nelmio\ApiDocBundle\Attribute\Model; use Nelmio\ApiDocBundle\Tests\Functional\Entity\Article81; use Nelmio\ApiDocBundle\Tests\Functional\Entity\DiscriminatorMap\JMSAbstractUser; use Nelmio\ApiDocBundle\Tests\Functional\Entity\JMSComplex; diff --git a/tests/Functional/Controller/JmsOptOutController.php b/tests/Functional/Controller/JmsOptOutController.php index a138e9748..997069fef 100644 --- a/tests/Functional/Controller/JmsOptOutController.php +++ b/tests/Functional/Controller/JmsOptOutController.php @@ -11,7 +11,7 @@ namespace Nelmio\ApiDocBundle\Tests\Functional\Controller; -use Nelmio\ApiDocBundle\Annotation\Model; +use Nelmio\ApiDocBundle\Attribute\Model; use Nelmio\ApiDocBundle\Tests\Functional\Entity\JMSUser; use OpenApi\Attributes as OA; use Symfony\Component\Routing\Annotation\Route; diff --git a/tests/Functional/Controller/MapRequestPayloadController.php b/tests/Functional/Controller/MapRequestPayloadController.php index 88921cb58..6d7f1047e 100644 --- a/tests/Functional/Controller/MapRequestPayloadController.php +++ b/tests/Functional/Controller/MapRequestPayloadController.php @@ -11,7 +11,7 @@ namespace Nelmio\ApiDocBundle\Tests\Functional\Controller; -use Nelmio\ApiDocBundle\Annotation\Model; +use Nelmio\ApiDocBundle\Attribute\Model; use Nelmio\ApiDocBundle\Tests\Functional\Entity\Article81; use Nelmio\ApiDocBundle\Tests\Functional\Entity\SymfonyConstraintsWithValidationGroups; use Symfony\Component\HttpKernel\Attribute\MapRequestPayload; diff --git a/tests/Functional/Controller/OperationIdController.php b/tests/Functional/Controller/OperationIdController.php index 45be34854..82b18704f 100644 --- a/tests/Functional/Controller/OperationIdController.php +++ b/tests/Functional/Controller/OperationIdController.php @@ -13,7 +13,7 @@ namespace Nelmio\ApiDocBundle\Tests\Functional\Controller; -use Nelmio\ApiDocBundle\Annotation\Security; +use Nelmio\ApiDocBundle\Attribute\Security; use OpenApi\Attributes as OA; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\Routing\Annotation\Route; diff --git a/tests/Functional/Controller/PromotedPropertiesController81.php b/tests/Functional/Controller/PromotedPropertiesController81.php index b12e4669f..080da7fef 100644 --- a/tests/Functional/Controller/PromotedPropertiesController81.php +++ b/tests/Functional/Controller/PromotedPropertiesController81.php @@ -13,7 +13,7 @@ namespace Nelmio\ApiDocBundle\Tests\Functional\Controller; -use Nelmio\ApiDocBundle\Annotation\Model; +use Nelmio\ApiDocBundle\Attribute\Model; use Nelmio\ApiDocBundle\Tests\Functional\Entity\EntityWithPromotedPropertiesWithDefaults; use OpenApi\Attributes as OA; use Symfony\Component\Routing\Annotation\Route; diff --git a/tests/Functional/Entity/JMSComplex.php b/tests/Functional/Entity/JMSComplex.php index a7dd564b2..0fb475224 100644 --- a/tests/Functional/Entity/JMSComplex.php +++ b/tests/Functional/Entity/JMSComplex.php @@ -12,7 +12,7 @@ namespace Nelmio\ApiDocBundle\Tests\Functional\Entity; use JMS\Serializer\Annotation as Serializer; -use Nelmio\ApiDocBundle\Annotation\Model; +use Nelmio\ApiDocBundle\Attribute\Model; use OpenApi\Attributes as OA; #[Serializer\ExclusionPolicy('all')] diff --git a/tests/Functional/Entity/JMSDualComplex.php b/tests/Functional/Entity/JMSDualComplex.php index 67cbefc03..ac1847d52 100644 --- a/tests/Functional/Entity/JMSDualComplex.php +++ b/tests/Functional/Entity/JMSDualComplex.php @@ -12,7 +12,7 @@ namespace Nelmio\ApiDocBundle\Tests\Functional\Entity; use JMS\Serializer\Annotation as Serializer; -use Nelmio\ApiDocBundle\Annotation\Model; +use Nelmio\ApiDocBundle\Attribute\Model; use OpenApi\Attributes as OA; class JMSDualComplex diff --git a/tests/Functional/Form/FormWithModel.php b/tests/Functional/Form/FormWithModel.php index 925eb5ee2..329fc5f3a 100644 --- a/tests/Functional/Form/FormWithModel.php +++ b/tests/Functional/Form/FormWithModel.php @@ -11,7 +11,7 @@ namespace Nelmio\ApiDocBundle\Tests\Functional\Form; -use Nelmio\ApiDocBundle\Annotation\Model; +use Nelmio\ApiDocBundle\Attribute\Model; use Nelmio\ApiDocBundle\Tests\Functional\Entity\User; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\TextType; diff --git a/tests/RouteDescriber/RouteArgumentDescriber/SymfonyMapRequestPayloadDescriberTest.php b/tests/RouteDescriber/RouteArgumentDescriber/SymfonyMapRequestPayloadDescriberTest.php index 613a2ea18..eedbe7c06 100644 --- a/tests/RouteDescriber/RouteArgumentDescriber/SymfonyMapRequestPayloadDescriberTest.php +++ b/tests/RouteDescriber/RouteArgumentDescriber/SymfonyMapRequestPayloadDescriberTest.php @@ -13,7 +13,7 @@ namespace Nelmio\ApiDocBundle\Tests\RouteDescriber\RouteArgumentDescriber; -use Nelmio\ApiDocBundle\Annotation\Operation; +use Nelmio\ApiDocBundle\Attribute\Operation; use Nelmio\ApiDocBundle\Model\ModelRegistry; use Nelmio\ApiDocBundle\ModelDescriber\ModelDescriberInterface; use Nelmio\ApiDocBundle\RouteDescriber\RouteArgumentDescriber\SymfonyMapRequestPayloadDescriber; diff --git a/tests/Routing/FilteredRouteCollectionBuilderTest.php b/tests/Routing/FilteredRouteCollectionBuilderTest.php index 3bb1900cc..6fd199baa 100644 --- a/tests/Routing/FilteredRouteCollectionBuilderTest.php +++ b/tests/Routing/FilteredRouteCollectionBuilderTest.php @@ -11,8 +11,8 @@ namespace Nelmio\ApiDocBundle\Tests\Routing; -use Nelmio\ApiDocBundle\Annotation\Areas; -use Nelmio\ApiDocBundle\Annotation\Operation; +use Nelmio\ApiDocBundle\Attribute\Areas; +use Nelmio\ApiDocBundle\Attribute\Operation; use Nelmio\ApiDocBundle\Routing\FilteredRouteCollectionBuilder; use Nelmio\ApiDocBundle\Util\ControllerReflector; use OpenApi\Attributes\Parameter; @@ -108,7 +108,7 @@ public static function getInvalidOptions(): \Generator yield [['path_patterns' => [null]]]; yield [['path_patterns' => [new \stdClass()]]]; yield [['path_patterns' => ['^/foo$', 1]]]; - yield [['with_annotation' => ['an array']]]; + yield [['with_attribute' => ['an array']]]; yield [['path_patterns' => 'a string']]; yield [['path_patterns' => 11]]; yield [['name_patterns' => 22]]; @@ -209,13 +209,13 @@ public function fooAction(): void 'r10', new Route('/api/areas_attributes/new', ['_controller' => 'ApiController::newAreaActionAttributes']), new \ReflectionMethod($apiController, 'fooAction'), - ['with_annotation' => true], + ['with_attribute' => true], ], 'with attribute and path patterns' => [ 'r10', new Route('/api/areas_attributes/new', ['_controller' => 'ApiController::newAreaActionAttributes']), new \ReflectionMethod($apiController, 'fooAction'), - ['path_patterns' => ['^/api'], 'with_annotation' => true], + ['path_patterns' => ['^/api'], 'with_attribute' => true], ], ]; @@ -229,7 +229,7 @@ public function fooAction(): void 'r10', new Route('/api/areas_attributes/new', ['_controller' => 'ApiController::newAreaActionAttributes']), new \ReflectionMethod($apiController, 'fooAction'), - ['with_annotation' => true], + ['with_attribute' => true], ]; } @@ -310,7 +310,7 @@ public function fooAction(): void 'r10', new Route('/api/foo', ['_controller' => 'ApiController::fooAction']), new \ReflectionMethod($apiController, 'fooAction'), - ['with_annotation' => true], + ['with_attribute' => true], 0, ]; @@ -387,7 +387,7 @@ public function testRoutesWithInvalidController(): void $routeBuilder = new FilteredRouteCollectionBuilder( $controllerReflectorStub, 'area', - ['with_annotation' => true], + ['with_attribute' => true], ); $filteredRoutes = $routeBuilder->filter($routes);