Closed
Description
Q | A |
---|---|
Bug report? | no |
Feature request? | yes |
BC Break report? | no |
RFC? | yes |
Symfony version | 3.3 |
Currently, I'm using API platform with the Symfony serializer and ALLOW_EXTRA_ATTRIBUTES=false
If my request produces a constraint violation, the error looks like:
{
"type": "https://tools.ietf.org/html/rfc2616#section-10",
"title": "An error occurred",
"detail": "extendedAttributes.foo: This value should not be blank.",
"violations": [
{
"propertyPath": "extendedAttributes.foo",
"message": "This value should not be blank."
}
]
}
But, if I provide an invalid attribute, the message looks like:
{
"type": "https://tools.ietf.org/html/rfc2616#section-10",
"title": "An error occurred",
"detail": "Extra attributes are not allowed (\"foo2\" are unknown)."
}
Two things to note:
- there is no
violations
- the attribute name is not in the correct context (it should be
extendedAttributes.foo2
)
both of which would be solved with this, if I understand correctly.
(there's also the issue of property names in errors not being normalized too, but that's outside of scope here, might even be API Platform specific)
Having the normalizer be able to provide a compatible violation list would allow API platform to render this case regardless what subsystem produced the error (serializer or validator).
WDYT? /cc @dunglas