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

GenId in yaml not working? #2632

Open
alexz707 opened this issue Feb 8, 2024 · 0 comments
Open

GenId in yaml not working? #2632

alexz707 opened this issue Feb 8, 2024 · 0 comments

Comments

@alexz707
Copy link

alexz707 commented Feb 8, 2024

API Platform version(s) affected: v3.2.13
Description
I'm trying to use the genId: false on a property of an asset object. (specifically on a method)
When I configure it via attributes it is working. However I cannot get it to work via YAML.

class Asset
{
    public function __construct(private AssetEntity $asset)
    {
    }

    #[ApiProperty(genId: false)]
    public function getDependencies(): Dependency
    {
        return $this->asset->getDependencies();
    }
}

If I remove the ApiProperty and use the following Yaml config it is not working:
As I wasn't sure if it is making a differnence I tried it with the properties section of a resource as well as with the
"standalone" properties section at the bottom. Ofc I have removed the other section while testing, both are only in there as demonstration purpose)

resources:
   ApiBundle\Dto\Asset:
        operations:
            ApiPlatform\Metadata\GetCollection:
                filters: [ ApiBundle\Filter\AssetParentIdFilter ]
                paginationClientItemsPerPage: true
            ApiPlatform\Metadata\Get:
                normalizationContext:
                    groups: [ 'asset:read', 'asset:item:get', 'dependency:read', 'property:read']
            ApiPlatform\Metadata\Put:
            ApiPlatform\Metadata\Post:
            ApiPlatform\Metadata\Delete:
            ApiPlatform\Metadata\Patch:
        provider: ApiBundle\State\AssetProvider
        normalizationContext:
            groups: ['asset:read', 'dependency:read', 'property:read']
        denormalizationContext:
            groups: ['asset:write']
        properties:
            id:
                identifier: true
           dependencies:
               genId: false

properties:
    ApiBundle\Dto\Asset:
        dependencies:
            genId: false

Partial output with attribute:

  "dependencies": {
    "@type": "Dependency",
    "sourceId": 109,
    "sourceType": "asset",
}

Partial output without attribute:

  "dependencies": {
    "@type": "Dependency",
    "@id": "/api/.well-known/genid/2d585464da3ebbbd870c",
    "sourceId": 109,
    "sourceType": "asset",
}

I searched various forums/ docs / examples but could not find a working example to achive the result with yaml.
Is this a bug or am I doing something wrong?
Thanks a lot!
BR
Alex

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant