Skip to content

Commit e0e639e

Browse files
authored
Support the "deprecationReason" attribute in the ApiProperty annotation (#1983)
* Fix ApiProperty annot, support deprecationReason attr * Remove useless use
1 parent 9a3e6e2 commit e0e639e

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

src/Annotation/ApiProperty.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
namespace ApiPlatform\Core\Annotation;
1515

1616
use ApiPlatform\Core\Exception\InvalidArgumentException;
17-
use Doctrine\Common\Annotations\Annotation\Attribute;
1817

1918
/**
2019
* ApiProperty annotation.
@@ -24,6 +23,7 @@
2423
* @Annotation
2524
* @Target({"METHOD", "PROPERTY"})
2625
* @Attributes(
26+
* @Attribute("deprecationReason", type="string"),
2727
* @Attribute("fetchable", type="bool"),
2828
* @Attribute("fetchEager", type="bool"),
2929
* @Attribute("jsonldContext", type="array"),
@@ -74,6 +74,13 @@ final class ApiProperty
7474
*/
7575
public $identifier;
7676

77+
/**
78+
* @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
79+
*
80+
* @var string
81+
*/
82+
private $deprecationReason;
83+
7784
/**
7885
* @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
7986
*

src/Annotation/ApiResource.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
namespace ApiPlatform\Core\Annotation;
1515

1616
use ApiPlatform\Core\Exception\InvalidArgumentException;
17-
use Doctrine\Common\Annotations\Annotation\Attribute;
1817

1918
/**
2019
* ApiResource annotation.

tests/Annotation/ApiPropertyTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,15 @@ public function testAssignation()
4848
public function testConstruct()
4949
{
5050
$property = new ApiProperty([
51+
'deprecationReason' => 'this field is deprecated',
5152
'fetchable' => true,
5253
'fetchEager' => false,
5354
'jsonldContext' => ['foo' => 'bar'],
5455
'swaggerContext' => ['foo' => 'baz'],
5556
'attributes' => ['unknown' => 'unknown', 'fetchable' => false],
5657
]);
5758
$this->assertEquals([
59+
'deprecation_reason' => 'this field is deprecated',
5860
'fetchable' => false,
5961
'fetch_eager' => false,
6062
'jsonld_context' => ['foo' => 'bar'],

0 commit comments

Comments
 (0)