Skip to content

Property metadata and normalization context for custom resource #1718

@mykbas

Description

@mykbas

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;
}

Activity

changed the title [-]Property Metadata and normalizationContext for [/-] [+]Property metadata and normalization context for custom resource[/+] on Dec 13, 2020
tpharaoh

tpharaoh commented on Dec 13, 2020

@tpharaoh
mykbas

mykbas commented on Dec 16, 2020

@mykbas
Author

found my mistake

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @tpharaoh@mykbas

        Issue actions

          Property metadata and normalization context for custom resource · Issue #1718 · api-platform/api-platform