Skip to content

ValidationException::getConstraintViolationList schema is wrongly documented #7659

@VincentLanglet

Description

@VincentLanglet

API Platform version(s) affected: 4.2

Again, not fully sure about it @soyuka since the whole schema things is new to me...

Description
Looking at ValidationException::getConstraintViolationList

#[SerializedName('violations')]
#[Groups(['json', 'jsonld'])]
#[ApiProperty(
jsonldContext: ['@type' => 'ConstraintViolationList'],
schema: [
'type' => 'array',
'items' => [
'type' => 'object',
'properties' => [
'propertyPath' => ['type' => 'string', 'description' => 'The property path of the violation'],
'message' => ['type' => 'string', 'description' => 'The message associated with the violation'],
],
],
]
)]
public function getConstraintViolationList(): ConstraintViolationListInterface
{
return $this->constraintViolationList;
}

the violations is described as an array of

'propertyPath' => ['type' => 'string', 'description' => 'The property path of the violation'],
'message' => ['type' => 'string', 'description' => 'The message associated with the violation'],

but, when dumping value on my side and according to the AbstractConstraintViolationListNormalizer I see more fields.

Possible Solution
If I am right, something like

'propertyPath' => ['type' => 'string', 'description' => 'The property path of the violation'],
'message' => ['type' => 'string', 'description' => 'The message associated with the violation'],
'code' => ['type' => 'string', 'description' => 'The code of the violation'],
'hint' => ['type' => 'string', 'description' => '...'],
'payload' => ['type' => 'array', 'description' => '...'],

but I'm not fully sure how code/hint/payload are optional

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions