-
-
Notifications
You must be signed in to change notification settings - Fork 853
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
[Bug]: MapRequestPayload doesn't handle type with scalar values #2462
Comments
@Arkounay I am pretty sure that this has nothing to do with the bundle but is an error message directly from Symfony. |
Hmm I don't think so? if you send a payload in my example with an array |
Interesting did not know that works. And doku does not mention it. Even the exception message I made a reproducer. @DjordyKoert what would be a good way to check that so we don't try to create a Model from scalar types. |
Thanks for the reproducer @mario-fehr 👍 If this can help some people, a quick workaround I did for now is this and it seems to be working in my case #[AutoconfigureTag('nelmio_api_doc.model_describer')]
class NativeTypeDescriber implements ModelDescriberInterface
{
public function describe(Model $model, \OpenApi\Annotations\Schema $schema): void
{
$type = $model->getType()->getClassName();
if ($type === 'int') {
$type = 'integer';
}
$schema->type = $type;
}
public function supports(Model $model): bool
{
return $model->getType()->getClassName() === 'int' || $model->getType()->getClassName() === 'string';
}
} |
Nelmio does not yet support this, I made a draft PR #2467 with a semi-functional fix. |
Wow cool, thank you @DjordyKoert |
Version
5.0.0
Description
Hi,
When using MapRequestPayload with a scalar type value, for example "int"
it triggers the following exception:
in
src/Model/ModelRegistry.php (line 131)
JSON OpenApi
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: