You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
final readonly classSomeObject
{
publicfunction__construct(
public ?int$number,
) {}
}
The OpenAPI spec is generated correctly with nullable set to true:
"number": {
"type": "integer",
"nullable": true
}
However, when the number property has an attribute that is derived from the OpenAPI OpenApi\Attributes\Property class (where CustomOpenApiProperty is defined as final class CustomOpenApiProperty extends \OpenApi\Attributes\Property):
final readonly classSomeObject
{
publicfunction__construct(
#[CustomOpenApiProperty()]
public ?int$number,
) {}
}
As I'm unfamiliar with the internals of this bundle, this might be a more general issue not specific to nullable.
Update: this issue also applies to the the property being required since #2111 was fixed.
The text was updated successfully, but these errors were encountered:
egonolieux
changed the title
Nullability of a property gets ignored when using the App\OpenApi\Attribute\Property attribute
Nullability of a property gets ignored when using an attribute derived from App\OpenApi\Attribute\Property
Aug 16, 2023
egonolieux
changed the title
Nullability of a property gets ignored when using an attribute derived from App\OpenApi\Attribute\Property
Nullability of a property gets ignored when using an attribute derived from \OpenApi\Attributes\Property
Aug 16, 2023
This might be more likely an issue in the underlying swagger-php library.
I think not, because using the OpenApi\Attributes\Property directly does not reproduce the issue. I suspect this might be caused by the merging logic of the describers somehow.
Historically there have been cases in the library where code was checking for specific class types, but I think those should be all gone by now.
egonolieux
changed the title
Nullability of a property gets ignored when using an attribute derived from \OpenApi\Attributes\Property
Nullability and requiredness of a property gets ignored when using an attribute derived from \OpenApi\Attributes\Property
Jan 4, 2024
If a class has a nullable property:
The OpenAPI spec is generated correctly with
nullable
set totrue
:However, when the
number
property has an attribute that is derived from the OpenAPIOpenApi\Attributes\Property
class (whereCustomOpenApiProperty
is defined asfinal class CustomOpenApiProperty extends \OpenApi\Attributes\Property
):The OpenAPI spec is generated without
nullable
:As I'm unfamiliar with the internals of this bundle, this might be a more general issue not specific to
nullable
.Update: this issue also applies to the the property being required since #2111 was fixed.
The text was updated successfully, but these errors were encountered: