forked from api-platform/core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(metadata): get method metadata for BackedEnums
- Loading branch information
1 parent
73adbdb
commit 4c3253f
Showing
4 changed files
with
94 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
tests/Fixtures/TestBundle/ApiResource/Issue6317/Issue6317.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the API Platform project. | ||
* | ||
* (c) Kévin Dunglas <dunglas@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ApiPlatform\Tests\Fixtures\TestBundle\ApiResource\Issue6317; | ||
|
||
use ApiPlatform\Metadata\ApiProperty; | ||
use ApiPlatform\Metadata\ApiResource; | ||
|
||
#[ApiResource] | ||
enum Issue6317: int | ||
{ | ||
case First = 1; | ||
case Second = 2; | ||
|
||
#[ApiProperty(identifier: true, example: 'An example of an ID')] | ||
public function getId(): int | ||
{ | ||
return $this->value; | ||
} | ||
|
||
#[ApiProperty(jsonSchemaContext: ['example' => '/lisa/mary'])] | ||
public function getName(): string | ||
{ | ||
return $this->name; | ||
} | ||
|
||
#[ApiProperty(jsonldContext: ['example' => '24'])] | ||
public function getOrdinal(): string | ||
{ | ||
return 1 === $this->value ? '1st' : '2nd'; | ||
} | ||
|
||
#[ApiProperty(openapiContext: ['example' => '42'])] | ||
public function getCardinal(): int | ||
{ | ||
return $this->value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters