Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OpenAPI/Hydra] Validation error schema should be generated #4480

Open
alanpoulain opened this issue Sep 30, 2021 · 1 comment
Open

[OpenAPI/Hydra] Validation error schema should be generated #4480

alanpoulain opened this issue Sep 30, 2021 · 1 comment

Comments

@alanpoulain
Copy link
Member

Description

In OpenApiFactory, the schema is not generated for the validation error (422):

$responses['422'] = new Model\Response('Unprocessable entity');

It would be nice to add it at least for Hydra.
Hydra normalizes the validation error like this:

'@context' => $this->urlGenerator->generate('api_jsonld_context', ['shortName' => 'ConstraintViolationList']),
'@type' => 'ConstraintViolationList',
'hydra:title' => $context['title'] ?? 'An error occurred',
'hydra:description' => $messages ? implode("\n", $messages) : (string) $object,
'violations' => $violations,

One way to implement it would be to add a new schema type, like TYPE_VALIDATION_ERROR here:

public const TYPE_INPUT = 'input';
public const TYPE_OUTPUT = 'output';

And handle this new type in this method:

public function buildSchema(string $className, string $format = 'jsonld', string $type = Schema::TYPE_OUTPUT, ?string $operationType = null, ?string $operationName = null, ?Schema $schema = null, ?array $serializerContext = null, bool $forceCollection = false): Schema

@stale
Copy link

stale bot commented Nov 4, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Nov 4, 2022
@stale stale bot removed the wontfix label Nov 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants