| 1 |
<?php declare(strict_types=1); |
| 2 |
|
| 3 |
/** |
| 4 |
* @license Apache 2.0 |
| 5 |
*/ |
| 6 |
|
| 7 |
namespace OpenApi\Annotations; |
| 8 |
|
| 9 |
use OpenApi\Generator; |
| 10 |
|
| 11 |
/** |
| 12 |
* The discriminator is a specific object in a schema which is used to inform the consumer of |
| 13 |
* the specification of an alternative schema based on the value associated with it. |
| 14 |
* |
| 15 |
* This object is based on the [JSON Schema Specification](http://json-schema.org) and uses a predefined subset of it. |
| 16 |
* On top of this subset, there are extensions provided by this specification to allow for more complete documentation. |
| 17 |
* |
| 18 |
* @see [Discriminator Object](https://spec.openapis.org/oas/v3.1.1.html#discriminator-object) |
| 19 |
* @see [JSON Schema](http://json-schema.org/) |
| 20 |
* |
| 21 |
* @Annotation |
| 22 |
*/ |
| 23 |
class Discriminator extends AbstractAnnotation |
| 24 |
{ |
| 25 |
/** |
| 26 |
* The name of the property in the payload that will hold the discriminator value. |
| 27 |
* |
| 28 |
* @var string |
| 29 |
*/ |
| 30 |
public $propertyName = Generator::UNDEFINED; |
| 31 |
|
| 32 |
/** |
| 33 |
* An object to hold mappings between payload values and schema names or references. |
| 34 |
* |
| 35 |
* @var array<string,string> |
| 36 |
*/ |
| 37 |
public $mapping = Generator::UNDEFINED; |
| 38 |
|
| 39 |
/** |
| 40 |
* @inheritdoc |
| 41 |
*/ |
| 42 |
public static $_required = ['propertyName']; |
| 43 |
|
| 44 |
/** |
| 45 |
* @inheritdoc |
| 46 |
*/ |
| 47 |
public static $_types = [ |
| 48 |
'propertyName' => 'string', |
| 49 |
]; |
| 50 |
|
| 51 |
/** |
| 52 |
* @inheritdoc |
| 53 |
*/ |
| 54 |
public static $_parents = [ |
| 55 |
Schema::class, |
| 56 |
Property::class, |
| 57 |
AdditionalProperties::class, |
| 58 |
Items::class, |
| 59 |
JsonContent::class, |
| 60 |
XmlContent::class, |
| 61 |
]; |
| 62 |
|
| 63 |
/** |
| 64 |
* @inheritdoc |
| 65 |
*/ |
| 66 |
public static $_nested = [ |
| 67 |
Attachable::class => ['attachables'], |
| 68 |
]; |
| 69 |
} |