Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Serializer] allow ObjectNormalizer to provide ConstraintViolationListInterface from ExtraAttributesException #25729

Closed
@dkarlovi

Description

@dkarlovi
QA
Bug report?no
Feature request?yes
BC Break report?no
RFC?yes
Symfony version3.3

Currently, I'm using API platform with the Symfony serializer andALLOW_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:

  1. there is noviolations
  2. the attribute name is not in the correct context (it should beextendedAttributes.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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp