core icon indicating copy to clipboard operation
core copied to clipboard

Adding configuration directly under the resource config in a yaml file gives an error

Open hafkenscheid opened this issue 1 year ago • 5 comments

API Platform version(s) affected: 4.0.17 (symfony)

Description
Adding configuration directly under the resource config (like described in the documentation) does result in an error.

How to reproduce
https://api-platform.com/docs/core/pagination/#disabling-the-pagination-for-a-specific-resource

# api/config/api_platform/resources.yaml
# The YAML syntax is only supported for Symfony
resources:
  App\ApiResource\Book:
    paginationEnabled: false

https://api-platform.com/docs/symfony/security/

# api/config/api_platform/resources.yaml
resources:
  App\Entity\Book:
    security: 'is_granted("ROLE_USER")'

Both result in their corresponding errors:

"paginationEnabled" setting is expected to be null or an array, string given

"security" setting is expected to be null or an array, string given

hafkenscheid avatar Feb 20 '25 18:02 hafkenscheid

version of symfony ?

soyuka avatar Feb 28 '25 22:02 soyuka

encountered the same issue with api-platform v4.1.4 and Symfony 6.4

morrisGrunerYoc avatar Apr 03 '25 09:04 morrisGrunerYoc

Here also Symfony 6.4

hafkenscheid avatar Apr 03 '25 20:04 hafkenscheid

Not sure why we'd need some stack trace or a reproducer. Why wouldn't you use the PHP format?

soyuka avatar Apr 07 '25 14:04 soyuka

We want to separate api-configuration and entity. I did not find a proper way yet, to use the ApiResource / ApiFilter, etc. attributes on non-entity classes, so the only (supported) way to split logic is yaml.

hafkenscheid avatar May 26 '25 21:05 hafkenscheid