api-platform / api-platform/core

[OpenAPI/Hydra] Validation error schema should be generated

Open
#4,480 1 comment 5 reactions 0 assignees View on GitHub
Hacktoberfest OpenAPI
Dominant language
PHP
Stars
2.6k
Forks
980
Avg merge
2d 4h
Merged PRs (30d)
49

Description

**Description**

In `OpenApiFactory`, the schema is not generated for the validation error (422):
https://github.com/api-platform/core/blob/e649fa1507963102fddb339458a82c426240553b/src/OpenApi/Factory/OpenApiFactory.php#L227

It would be nice to add it at least for Hydra.
Hydra normalizes the validation error like this:
https://github.com/api-platform/core/blob/e649fa1507963102fddb339458a82c426240553b/src/Core/Hydra/Serializer/ConstraintViolationListNormalizer.php#L46-L50

One way to implement it would be to add a new schema type, like `TYPE_VALIDATION_ERROR` here:
https://github.com/api-platform/core/blob/e649fa1507963102fddb339458a82c426240553b/src/Core/JsonSchema/Schema.php#L30-L31

And handle this new type in this method:
https://github.com/api-platform/core/blob/e649fa1507963102fddb339458a82c426240553b/src/Core/Hydra/JsonSchema/SchemaFactory.php#L73

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.