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

Property metadata and normalization context for custom resource #1718

Closed
mykbas opened this issue Dec 13, 2020 · 2 comments
Closed

Property metadata and normalization context for custom resource #1718

mykbas opened this issue Dec 13, 2020 · 2 comments

Comments

@mykbas
Copy link

mykbas commented Dec 13, 2020

API Platform version(s) affected: 2.6.0-alpha.1 + Symfony 5.2

Description
Following this tutorial with Symfony5.2 and latest APIPlatform 2.6.0-alpha.1 setting normalization context with custom data provider returns empty data for the fields marked with appropriate groups.

UPD: clearing cache didn't help

UPD 2
Somehow it does not react to manual setting normalizationContext groups either in camelcase "dailyStats:read" or with dash "daily-stats:read", or "dummystats:read".
But the data is displayed correctly only with default groups `"dailystats:read"``

For class defined like below I see only `totalVisitors`

/**
* @ApiResource(
*     normalizationContext={"groups"={"dummystats:read"}},
*     itemOperations={"get"},
*     collectionOperations={"get"}
* )
*/
class DailyStats
{
    /**
    * @Groups({"dummystats:read"})
    */
    public $date;
    
    /**
    * @Groups({"dailystats:read"})
    */
    public $totalVisitors;
}
@mykbas mykbas changed the title Property Metadata and normalizationContext for Property metadata and normalization context for custom resource Dec 13, 2020
@tpharaoh
Copy link

tpharaoh commented Dec 13, 2020 via email

@mykbas
Copy link
Author

mykbas commented Dec 16, 2020

found my mistake

@mykbas mykbas closed this as completed Dec 16, 2020
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

2 participants