docs
docs copied to clipboard
Missing doc: how to add pagination_items_per_page using yaml instead of annotation
I use yaml for api platform configuration .
For Project resource i created project.yaml inside /config/api_platform/resources/project.yaml
How can i set items per page to 10 ?
I tried this and it doesn't work :
# /config/api_platform/resources/project.yaml
App\Entity\Project:
paginationItemsPerPage: 10 <--- it doesn't work for me
attributes:
normalization_context:
groups: ["project:read"]
denormalization_context:
groups: ["project:read"]
itemOperations:
get: ~
put: ~
delete: ~
patch: ~
calcul_score_projet:
method: PATCH
path: /projects/{id}/score
controller: App\Action\ScoreAction
openapi_context:
summary: Modifier et calculer le score d'un projet
description: >
# Modifier et calculer le score d'un projet
collectionOperations:
get:
filters: ["project.search"]
post:
calcul_score_projet:
method: POST
validation_groups: ["Default"]
path: /projects/score
controller: App\Action\ScoreAction
openapi_context:
summary: Ajouter et calculer le score d'un projet
description: >
# Ajouter et calculer le score d'un projet
Whast version of api platform do you use? If is older I think that you need to add pagination_items_per_page (snake_case) unde attributes. Something like this:
# /config/api_platform/resources/project.yaml
App\Entity\Project:
attributes:
pagination_items_per_page : 10 <-- think will work here
normalization_context:
groups: ["project:read"]
denormalization_context:
groups: ["project:read"]
itemOperations:
get: ~
put: ~
delete: ~
patch: ~
calcul_score_projet:
method: PATCH
path: /projects/{id}/score
controller: App\Action\ScoreAction
openapi_context:
summary: Modifier et calculer le score d'un projet
description: >
# Modifier et calculer le score d'un projet
collectionOperations:
get:
filters: ["project.search"]
post:
calcul_score_projet:
method: POST
validation_groups: ["Default"]
path: /projects/score
controller: App\Action\ScoreAction
openapi_context:
summary: Ajouter et calculer le score d'un projet
description: >
# Ajouter et calculer le score d'un projet
if you use newer version of api-platform, then all your ressource is invalid (no more attributes
, collectionOperations
and itemOperations
merge in one single operations:
, and more ... see docs page for operations.)
I cannot test this solution but i think there is your problem.