Skip to content

OpenApi Schemas for errors/violations do not match actual response #7080

Open
@BernardA

Description

@BernardA

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions