Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for JMS discriminator map (#2247)
- Loading branch information
1 parent
7f46161
commit 4ff744f
Showing
8 changed files
with
186 additions
and
1 deletion.
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
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
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
41 changes: 41 additions & 0 deletions
41
tests/Functional/Entity/DiscriminatorMap/JMSAbstractUser.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,41 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the NelmioApiDocBundle package. | ||
* | ||
* (c) Nelmio | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Nelmio\ApiDocBundle\Tests\Functional\Entity\DiscriminatorMap; | ||
|
||
use JMS\Serializer\Annotation as Serializer; | ||
use Nelmio\ApiDocBundle\Tests\Functional\TestKernel; | ||
|
||
if (TestKernel::isAnnotationsAvailable()) { | ||
/** | ||
* @Serializer\Discriminator(map={ | ||
* "manager" = JMSManager::class, | ||
* "administrator" = JMSAdministrator::class, | ||
* }, groups={"Default"}) | ||
*/ | ||
abstract class JMSAbstractUser | ||
{ | ||
/** | ||
* @Serializer\Type("string") | ||
* | ||
* @Serializer\Groups({"Default"}) | ||
*/ | ||
public $username; | ||
} | ||
} else { | ||
#[Serializer\Discriminator(map: ['manager' => JMSManager::class, 'administrator' => JMSAdministrator::class], groups: ['Default'])] | ||
abstract class JMSAbstractUser | ||
{ | ||
#[Serializer\Type('string')] | ||
#[Serializer\Groups(['Default'])] | ||
public $username; | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
tests/Functional/Entity/DiscriminatorMap/JMSAdministrator.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,34 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the NelmioApiDocBundle package. | ||
* | ||
* (c) Nelmio | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Nelmio\ApiDocBundle\Tests\Functional\Entity\DiscriminatorMap; | ||
|
||
use JMS\Serializer\Annotation as Serializer; | ||
use Nelmio\ApiDocBundle\Tests\Functional\TestKernel; | ||
|
||
if (TestKernel::isAnnotationsAvailable()) { | ||
class JMSAdministrator extends JMSAbstractUser | ||
{ | ||
/** | ||
* @Serializer\Type("string") | ||
* | ||
* @Serializer\Groups({"Default"}) | ||
*/ | ||
public $adminTitle; | ||
} | ||
} else { | ||
class JMSAdministrator extends JMSAbstractUser | ||
{ | ||
#[Serializer\Type('string')] | ||
#[Serializer\Groups(['Default'])] | ||
public $adminTitle; | ||
} | ||
} |
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,16 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the NelmioApiDocBundle package. | ||
* | ||
* (c) Nelmio | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Nelmio\ApiDocBundle\Tests\Functional\Entity\DiscriminatorMap; | ||
|
||
class JMSManager extends JMSAbstractUser | ||
{ | ||
} |
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