api-platform / api-platform/admin

Using serialization group for LIST, but not for SHOW results in empty columns instead of non existent columns

Open
#111 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
516
Forks
134
PR merge metrics
No merged PRs in 30d

Description

Hi,

When I'm using serialization groups for `collectionOperations/get`, I'm expecting those fields not to appear in the view, instead I'm getting this fields with empty values.

Screenshot should illustrate the issue, empty columns are not really empty, but filtered with serialization group.
![screen shot 2018-08-04 at 11 18 57](https://user-images.githubusercontent.com/870747/43672447-4f353514-97d8-11e8-9d9c-d5f980a40f71.png)

my resource configuration
```yaml
App\Entity\Restaurant:
collectionOperations:
get:
filters: ['restaurant.search_filter']
normalization_context:
groups: ['restaurant:list']
denormalization_context:
groups: ['restaurant:list']
post: ~
attributes:
normalization_context:
groups: ['restaurant']
denormalization_context:
groups: ['restaurant']
```

Serialization configuration

```yaml
App\Entity\Restaurant:
attributes:
owner:
groups: ['restaurant', 'restaurant:list']
city:
groups: ['restaurant', 'restaurant:list']
specialities:
groups: ['restaurant']
...

name:
groups: ['restaurant']
...
```

If I will change entity global `normalization_context` to `restaurant:list`, then I will get only owner and city everywhere and it's not possible to extend list of fields per operation with `restaurant` group.

Is it bug or misconfiguration? What can be done to render only specific fields at resources listing page?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.