Description
Version
4.26.1
Description
Consider the following definition:
<?php
namespace App\Model\EApi\Equipment;
use JMS\Serializer\Annotation\Type;
use Nelmio\ApiDocBundle\Annotation\Model;
use OpenApi\Attributes\Property;
use OpenApi\Attributes\Schema;
readonly class EquipmentReservation
{
private function __construct(
#[Property(description: 'The parent reservation, if any. Will be false to break loops.',
nullable: true,
oneOf: [
new Schema(ref: new Model(type: self::class)),
new Schema(type: 'false'),
]
)]
public self|false|null $parent)
{
}
}
With this definition, the property is excluded from the OpenAPI documentation, which is due to the following branch:
I can add a type: object
to the Property attribute to force the property to be added, but that includes the type
field which should not be there:
"parent": {
"description": "The parent reservation, if any. Will be false to break loops.",
"type": "object",
"nullable": true,
"oneOf": [
{
"$ref": "#/components/schemas/EquipmentReservation"
},
{
"type": "false"
}
]
},
I can also add a #[JMS\Type('object')]
(or one with the class name) attribute to the property itself, but that ignores the oneOf specification I manually supplied:
"parent": {
"description": "The parent reservation, if any. Will be false to break loops.",
"nullable": true,
"oneOf": [
{
"$ref": "#/components/schemas/object"
}
]
},
Note that this is a serialization object only, so there is no need to deserialize: which means I do not necessarily want to define the JMS type, without it it should work just fine.
I tried adding an exclusion to the referenced implementation, but that would only throw further in the code due to the type being null.
Is there anything that can be done here, or do I want something that is too complex? 😄
Additional context
No response