core icon indicating copy to clipboard operation
core copied to clipboard

OpenApi Schemas for errors/violations do not match actual response

Open BernardA opened this issue 7 months ago • 1 comments

API Platform version(s) affected: 4.1.1

Description

I found that two new schemas were added: Error and ConstraintViolation. The actual errors do not seem to match:

ConstraintViolation: The property "instance" exists on OpenApi but not on the actual violation, while "code" and "hint" exist on the actual "violations" but not on OpenApi.

OpenApi:

Image

Actual:

 `{
 "status": 422,
  "violations": [
  {
      "propertyPath": "societe",
      "message": "This value should be of type App\\Entity\\Societe.",
      "code": "ba785a8c-82cb-4283-967c-3cf342181b40",
     "hint": "Item not found for \"/api/lecture/societes/038757282\"."
    }
  ],
  "detail": "societe: This value should be of type App\\Entity\\Societe.",
  "type": "/validation_errors/ba785a8c-82cb-4283-967c-3cf342181b40",
  "title": "An error occurred"
  }`

Error

On error the property "instance" exists on OpenApi but not on the actual response:

OpenApi:

Image

Actual:

 `{
  "title": "An error occurred",
  "detail": "Societe inexistante.",
  "status": 400,
  "type": "/errors/400"
 }`

How to reproduce

Possible Solution

Additional Context

BernardA avatar Apr 11 '25 08:04 BernardA

https://github.com/api-platform/core/pull/6960

soyuka avatar May 05 '25 13:05 soyuka