Skip to content

Commit

Permalink
Support the "deprecationReason" attribute in the ApiProperty annotati…
Browse files Browse the repository at this point in the history
…on (#1983)

* Fix ApiProperty annot, support deprecationReason attr

* Remove useless use
  • Loading branch information
dunglas committed May 29, 2018
1 parent 9a3e6e2 commit e0e639e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/Annotation/ApiProperty.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
namespace ApiPlatform\Core\Annotation;

use ApiPlatform\Core\Exception\InvalidArgumentException;
use Doctrine\Common\Annotations\Annotation\Attribute;

/**
* ApiProperty annotation.
Expand All @@ -24,6 +23,7 @@
* @Annotation
* @Target({"METHOD", "PROPERTY"})
* @Attributes(
* @Attribute("deprecationReason", type="string"),
* @Attribute("fetchable", type="bool"),
* @Attribute("fetchEager", type="bool"),
* @Attribute("jsonldContext", type="array"),
Expand Down Expand Up @@ -74,6 +74,13 @@ final class ApiProperty
*/
public $identifier;

/**
* @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
*
* @var string
*/
private $deprecationReason;

/**
* @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
*
Expand Down
1 change: 0 additions & 1 deletion src/Annotation/ApiResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
namespace ApiPlatform\Core\Annotation;

use ApiPlatform\Core\Exception\InvalidArgumentException;
use Doctrine\Common\Annotations\Annotation\Attribute;

/**
* ApiResource annotation.
Expand Down
2 changes: 2 additions & 0 deletions tests/Annotation/ApiPropertyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,15 @@ public function testAssignation()
public function testConstruct()
{
$property = new ApiProperty([
'deprecationReason' => 'this field is deprecated',
'fetchable' => true,
'fetchEager' => false,
'jsonldContext' => ['foo' => 'bar'],
'swaggerContext' => ['foo' => 'baz'],
'attributes' => ['unknown' => 'unknown', 'fetchable' => false],
]);
$this->assertEquals([
'deprecation_reason' => 'this field is deprecated',
'fetchable' => false,
'fetch_eager' => false,
'jsonld_context' => ['foo' => 'bar'],
Expand Down

0 comments on commit e0e639e

Please sign in to comment.