Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add missing trigger_deprecation calls to deprecated classes, methods #2265

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
15 changes: 14 additions & 1 deletion CHANGELOG.md
Expand Up @@ -15,6 +15,10 @@ nelmio_api_doc:
deepLinking: true
```

4.25.3
-----
* Calling `DocumentationExtension::getExtendedType()` has been deprecated in favor of `DocumentationExtension::getExtendedTypes()` to align with the deprecation introduced with `symfony/symfony` version `4.2`.

4.25.0
-----
* Added support for [JMS @Discriminator](https://jmsyst.com/libs/serializer/master/reference/annotations#discriminator) annotation/attribute
Expand Down Expand Up @@ -135,6 +139,15 @@ doc-api:
* Added Redocly as an alternative to Swagger UI. https://github.com/Redocly/redoc.
* Added support for describing dictionary types in OpenAPI 3.0.

4.17.0
-----
* Passing groups to `PropertyDescriberInterface::describe()` via the `$groups` parameter is deprecated, the parameter will get removed in a future version. Pass groups via `$context['groups']` instead.
* `UndocumentedArrayItemsException::class` has been marked as deprecated and will be removed in a future version.

4.15.0
-----
* Passing `null` to the `$schema` parameter of `PropertyDescriberInterface::describe()` is deprecated. In future versions, the `$schema` parameter will be made non-nullable and will require a `OA\Schema` instance.

4.0.0
-----
* Added support of OpenAPI 3.0. The internals were completely reworked and this version introduces BC breaks.
Expand Down Expand Up @@ -162,7 +175,7 @@ doc-api:

* Add a documentation form extension. Use the ``documentation`` option to define how a form field is documented.
* Allow references to config definitions in controllers.
* Using `@Model` implicitely in `@SWG\Schema`, `@SWG\Items` and `@SWG\Property` is deprecated. Use `ref=@Model()` instead.
* Using `@Model` implicitly in `@SWG\Schema`, `@SWG\Items` and `@SWG\Property` is deprecated. Use `ref=@Model()` instead.

Before:
```php
Expand Down
7,366 changes: 253 additions & 7,113 deletions phpunit-baseline.json

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions src/Exception/UndocumentedArrayItemsException.php
Expand Up @@ -11,6 +11,13 @@

namespace Nelmio\ApiDocBundle\Exception;

trigger_deprecation(
'nelmio/api-doc-bundle',
'4.17.0',
'The "%s" class is deprecated and will be removed in a future version',
UndocumentedArrayItemsException::class,
);

/**
* @deprecated since 4.17, this exception is not used anymore
*/
Expand Down
8 changes: 8 additions & 0 deletions src/Form/Extension/DocumentationExtension.php
Expand Up @@ -39,6 +39,14 @@ public function configureOptions(OptionsResolver $resolver): void
*/
public function getExtendedType()
{
trigger_deprecation(
'nelmio/api-doc-bundle',
'4.25.3',
'Calling %s is deprecated since Symfony 4.2, call %s instead',
__METHOD__,
'DocumentationExtension::getExtendedTypes()',
);

return self::getExtendedTypes()[0];
}

Expand Down
16 changes: 16 additions & 0 deletions src/PropertyDescriber/ArrayPropertyDescriber.php
Expand Up @@ -27,6 +27,22 @@ class ArrayPropertyDescriber implements PropertyDescriberInterface, ModelRegistr
*/
public function describe(array $types, OA\Schema $property, ?array $groups = null, ?OA\Schema $schema = null, array $context = [])
DominicLuidold marked this conversation as resolved.
Show resolved Hide resolved
{
if (null === $schema) {
trigger_deprecation(
'nelmio/api-doc-bundle',
'4.15.0',
'Passing null for the $schema parameter of "PropertyDescriberInterface::describe()" is deprecated. In future versions, the $schema parameter will be made non-nullable',
);
}

if (null !== $groups) {
trigger_deprecation(
'nelmio/api-doc-bundle',
'4.17.0',
'Using the $groups parameter of "PropertyDescriberInterface::describe()" is deprecated and will be removed in a future version. Pass groups via $context[\'groups\']',
);
}
Comment on lines +30 to +44
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this way of checking the parameter be better for triggering deprecations?

Suggested change
if (null === $schema) {
trigger_deprecation(
'nelmio/api-doc-bundle',
'4.15.0',
'Passing null for the $schema parameter of "PropertyDescriberInterface::describe()" is deprecated. In future versions, the $schema parameter will be made non-nullable',
);
}
if (null !== $groups) {
trigger_deprecation(
'nelmio/api-doc-bundle',
'4.17.0',
'Using the $groups parameter of "PropertyDescriberInterface::describe()" is deprecated and will be removed in a future version. Pass groups via $context[\'groups\']',
);
}
if (null !== $groups || func_num_args() >= 3) {
trigger_deprecation(
'nelmio/api-doc-bundle',
'4.17.0',
'Using the $groups parameter of "%s" is deprecated and will be removed in a future version. Pass groups via $context[\'groups\'].', __METHOD__
);
}
if (\func_num_args() < 4 || null === $schema) {
trigger_deprecation(
'nelmio/api-doc-bundle',
'4.15.0',
'The "%s()" method will have a new "OA\Schema $schema" arument not defining it is deprecated.', __METHOD__
);
$schema = null;
} else {
$schema = func_get_arg(3);
}


$property->type = 'array';
/** @var OA\Items $property */
$property = Util::getChild($property, OA\Items::class);
Expand Down
16 changes: 16 additions & 0 deletions src/PropertyDescriber/BooleanPropertyDescriber.php
Expand Up @@ -21,6 +21,22 @@ class BooleanPropertyDescriber implements PropertyDescriberInterface
*/
public function describe(array $types, OA\Schema $property, ?array $groups = null, ?OA\Schema $schema = null, array $context = [])
{
if (null === $schema) {
trigger_deprecation(
'nelmio/api-doc-bundle',
'4.15.0',
'Passing null for the $schema parameter of "PropertyDescriberInterface::describe()" is deprecated. In future versions, the $schema parameter will be made non-nullable',
);
}

if (null !== $groups) {
trigger_deprecation(
'nelmio/api-doc-bundle',
'4.17.0',
'Using the $groups parameter of "PropertyDescriberInterface::describe()" is deprecated and will be removed in a future version. Pass groups via $context[\'groups\']',
);
}

$property->type = 'boolean';
}

Expand Down
16 changes: 16 additions & 0 deletions src/PropertyDescriber/CompoundPropertyDescriber.php
Expand Up @@ -27,6 +27,22 @@ class CompoundPropertyDescriber implements PropertyDescriberInterface, ModelRegi
*/
public function describe(array $types, OA\Schema $property, ?array $groups = null, ?OA\Schema $schema = null, array $context = [])
{
if (null === $schema) {
trigger_deprecation(
'nelmio/api-doc-bundle',
'4.15.0',
'Passing null for the $schema parameter of "PropertyDescriberInterface::describe()" is deprecated. In future versions, the $schema parameter will be made non-nullable',
);
}

if (null !== $groups) {
trigger_deprecation(
'nelmio/api-doc-bundle',
'4.17.0',
'Using the $groups parameter of "PropertyDescriberInterface::describe()" is deprecated and will be removed in a future version. Pass groups via $context[\'groups\']',
);
}

$property->oneOf = Generator::UNDEFINED !== $property->oneOf ? $property->oneOf : [];

foreach ($types as $type) {
Expand Down
16 changes: 16 additions & 0 deletions src/PropertyDescriber/DateTimePropertyDescriber.php
Expand Up @@ -21,6 +21,22 @@ class DateTimePropertyDescriber implements PropertyDescriberInterface
*/
public function describe(array $types, OA\Schema $property, ?array $groups = null, ?OA\Schema $schema = null, array $context = [])
{
if (null === $schema) {
trigger_deprecation(
'nelmio/api-doc-bundle',
'4.15.0',
'Passing null for the $schema parameter of "PropertyDescriberInterface::describe()" is deprecated. In future versions, the $schema parameter will be made non-nullable',
);
}

if (null !== $groups) {
trigger_deprecation(
'nelmio/api-doc-bundle',
'4.17.0',
'Using the $groups parameter of "PropertyDescriberInterface::describe()" is deprecated and will be removed in a future version. Pass groups via $context[\'groups\']',
);
}

$property->type = 'string';
$property->format = 'date-time';
}
Expand Down
16 changes: 16 additions & 0 deletions src/PropertyDescriber/DictionaryPropertyDescriber.php
Expand Up @@ -27,6 +27,22 @@ final class DictionaryPropertyDescriber implements PropertyDescriberInterface, M
*/
public function describe(array $types, OA\Schema $property, ?array $groups = null, ?OA\Schema $schema = null, array $context = [])
{
if (null === $schema) {
trigger_deprecation(
'nelmio/api-doc-bundle',
'4.15.0',
'Passing null for the $schema parameter of "PropertyDescriberInterface::describe()" is deprecated. In future versions, the $schema parameter will be made non-nullable',
);
}

if (null !== $groups) {
trigger_deprecation(
'nelmio/api-doc-bundle',
'4.17.0',
'Using the $groups parameter of "PropertyDescriberInterface::describe()" is deprecated and will be removed in a future version. Pass groups via $context[\'groups\']',
);
}

$property->type = 'object';
/** @var OA\AdditionalProperties $additionalProperties */
$additionalProperties = Util::getChild($property, OA\AdditionalProperties::class);
Expand Down
16 changes: 16 additions & 0 deletions src/PropertyDescriber/FloatPropertyDescriber.php
Expand Up @@ -21,6 +21,22 @@ class FloatPropertyDescriber implements PropertyDescriberInterface
*/
public function describe(array $types, OA\Schema $property, ?array $groups = null, ?OA\Schema $schema = null, array $context = [])
{
if (null === $schema) {
trigger_deprecation(
'nelmio/api-doc-bundle',
'4.15.0',
'Passing null for the $schema parameter of "PropertyDescriberInterface::describe()" is deprecated. In future versions, the $schema parameter will be made non-nullable',
);
}

if (null !== $groups) {
trigger_deprecation(
'nelmio/api-doc-bundle',
'4.17.0',
'Using the $groups parameter of "PropertyDescriberInterface::describe()" is deprecated and will be removed in a future version. Pass groups via $context[\'groups\']',
);
}

$property->type = 'number';
$property->format = 'float';
}
Expand Down
16 changes: 16 additions & 0 deletions src/PropertyDescriber/IntegerPropertyDescriber.php
Expand Up @@ -21,6 +21,22 @@ class IntegerPropertyDescriber implements PropertyDescriberInterface
*/
public function describe(array $types, OA\Schema $property, ?array $groups = null, ?OA\Schema $schema = null, array $context = [])
{
if (null === $schema) {
trigger_deprecation(
'nelmio/api-doc-bundle',
'4.15.0',
'Passing null for the $schema parameter of "PropertyDescriberInterface::describe()" is deprecated. In future versions, the $schema parameter will be made non-nullable',
);
}

if (null !== $groups) {
trigger_deprecation(
'nelmio/api-doc-bundle',
'4.17.0',
'Using the $groups parameter of "PropertyDescriberInterface::describe()" is deprecated and will be removed in a future version. Pass groups via $context[\'groups\']',
);
}

$property->type = 'integer';
}

Expand Down
16 changes: 16 additions & 0 deletions src/PropertyDescriber/NullablePropertyDescriber.php
Expand Up @@ -23,6 +23,22 @@ final class NullablePropertyDescriber implements PropertyDescriberInterface, Pro
*/
public function describe(array $types, OA\Schema $property, ?array $groups = null, ?OA\Schema $schema = null, array $context = [])
{
if (null === $schema) {
trigger_deprecation(
'nelmio/api-doc-bundle',
'4.15.0',
'Passing null for the $schema parameter of "PropertyDescriberInterface::describe()" is deprecated. In future versions, the $schema parameter will be made non-nullable',
);
}

if (null !== $groups) {
trigger_deprecation(
'nelmio/api-doc-bundle',
'4.17.0',
'Using the $groups parameter of "PropertyDescriberInterface::describe()" is deprecated and will be removed in a future version. Pass groups via $context[\'groups\']',
);
}

if (Generator::UNDEFINED === $property->nullable) {
$property->nullable = true;
}
Expand Down
7 changes: 7 additions & 0 deletions src/PropertyDescriber/NullablePropertyTrait.php
Expand Up @@ -23,6 +23,13 @@ trait NullablePropertyTrait
{
protected function setNullableProperty(Type $type, OA\Schema $property, ?OA\Schema $schema, array $context = []): void
{
trigger_deprecation(
'nelmio/api-doc-bundle',
'4.17',
'Use %s instead',
NullablePropertyDescriber::class,
);

if (Generator::UNDEFINED !== $property->nullable) {
if (!$property->nullable) {
// if already false mark it as undefined (so it does not show up as `nullable: false`)
Expand Down
16 changes: 16 additions & 0 deletions src/PropertyDescriber/ObjectPropertyDescriber.php
Expand Up @@ -27,6 +27,22 @@ class ObjectPropertyDescriber implements PropertyDescriberInterface, ModelRegist
*/
public function describe(array $types, OA\Schema $property, ?array $groups = null, ?OA\Schema $schema = null, array $context = [])
{
if (null === $schema) {
trigger_deprecation(
'nelmio/api-doc-bundle',
'4.15.0',
'Passing null for the $schema parameter of "PropertyDescriberInterface::describe()" is deprecated. In future versions, the $schema parameter will be made non-nullable',
);
}

if (null !== $groups) {
trigger_deprecation(
'nelmio/api-doc-bundle',
'4.17.0',
'Using the $groups parameter of "PropertyDescriberInterface::describe()" is deprecated and will be removed in a future version. Pass groups via $context[\'groups\']',
);
}

$type = new Type(
$types[0]->getBuiltinType(),
false,
Expand Down
16 changes: 16 additions & 0 deletions src/PropertyDescriber/PropertyDescriber.php
Expand Up @@ -42,6 +42,22 @@ public function __construct(
*/
public function describe(array $types, OA\Schema $property, ?array $groups = null, ?OA\Schema $schema = null, array $context = []): void
{
if (null === $schema) {
trigger_deprecation(
'nelmio/api-doc-bundle',
'4.15.0',
'Passing null for the $schema parameter of "PropertyDescriberInterface::describe()" is deprecated. In future versions, the $schema parameter will be made non-nullable',
);
}

if (null !== $groups) {
trigger_deprecation(
'nelmio/api-doc-bundle',
'4.17.0',
'Using the $groups parameter of "PropertyDescriberInterface::describe()" is deprecated and will be removed in a future version. Pass groups via $context[\'groups\']',
);
}

if (null === $propertyDescriber = $this->getPropertyDescriber($types)) {
return;
}
Expand Down
16 changes: 16 additions & 0 deletions src/PropertyDescriber/RequiredPropertyDescriber.php
Expand Up @@ -26,6 +26,22 @@ final class RequiredPropertyDescriber implements PropertyDescriberInterface, Pro
*/
public function describe(array $types, OA\Schema $property, ?array $groups = null, ?OA\Schema $schema = null, array $context = [])
{
if (null === $schema) {
trigger_deprecation(
'nelmio/api-doc-bundle',
'4.15.0',
'Passing null for the $schema parameter of "PropertyDescriberInterface::describe()" is deprecated. In future versions, the $schema parameter will be made non-nullable',
);
}

if (null !== $groups) {
trigger_deprecation(
'nelmio/api-doc-bundle',
'4.17.0',
'Using the $groups parameter of "PropertyDescriberInterface::describe()" is deprecated and will be removed in a future version. Pass groups via $context[\'groups\']',
);
}

$this->propertyDescriber->describe($types, $property, $groups, $schema, $context);

if (!$property instanceof OA\Property) {
Expand Down
16 changes: 16 additions & 0 deletions src/PropertyDescriber/StringPropertyDescriber.php
Expand Up @@ -21,6 +21,22 @@ class StringPropertyDescriber implements PropertyDescriberInterface
*/
public function describe(array $types, OA\Schema $property, ?array $groups = null, ?OA\Schema $schema = null, array $context = [])
{
if (null === $schema) {
trigger_deprecation(
'nelmio/api-doc-bundle',
'4.15.0',
'Passing null for the $schema parameter of "PropertyDescriberInterface::describe()" is deprecated. In future versions, the $schema parameter will be made non-nullable',
);
}

if (null !== $groups) {
trigger_deprecation(
'nelmio/api-doc-bundle',
'4.17.0',
'Using the $groups parameter of "PropertyDescriberInterface::describe()" is deprecated and will be removed in a future version. Pass groups via $context[\'groups\']',
);
}

$property->type = 'string';
}

Expand Down