Skip to content

Commit cb64a61

Browse files
authored
Add global resources defaults entry (#1287)
1 parent ddee00d commit cb64a61

File tree

3 files changed

+175
-67
lines changed

3 files changed

+175
-67
lines changed

core/configuration.md

Lines changed: 156 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ api_platform:
1515
# The version of the API.
1616
version: '0.0.0'
1717

18-
# Return IRIs as Absolute Urls.
19-
# ex. http://example.com/authors/1
18+
# Return IRIs as Absolute URLs.
19+
# ex: http://example.com/authors/1
2020
absolute_url: false
2121

2222
# Set this to false if you want Webby to disappear.
@@ -31,12 +31,12 @@ api_platform:
3131
# Specify a path name generator to use.
3232
path_segment_name_generator: 'api_platform.path_segment_name_generator.underscore'
3333

34-
# Allow using plain IDs for JSON format
34+
# Allow using plain IDs for JSON format.
3535
allow_plain_identifiers: false
3636

3737
validator:
38-
# Enable the serialization of payload fields when a validation error is thrown
39-
# If you want to serialize only some payload fields, define them like this [ severity, anotherPayloadField ]
38+
# Enable the serialization of payload fields when a validation error is thrown.
39+
# If you want to serialize only some payload fields, define them like this: [ severity, anotherPayloadField ]
4040
serialize_payload_fields: []
4141

4242
eager_loading:
@@ -54,17 +54,18 @@ api_platform:
5454
# If disabled, it will only join relations having the EAGER fetch mode.
5555
force_eager: true
5656

57+
# Enabling the FOSUserBundle integration has been deprecated in 2.5 and will be removed in 3.0.
5758
# Enable the FOSUserBundle integration.
5859
enable_fos_user: false
5960

6061
# Enabling the NelmioApiDocBundle integration has been deprecated in 2.2 and will be removed in 3.0.
61-
# NelmioApiDocBundle 3 has native support for API Platform
62+
# NelmioApiDocBundle 3 has native support for API Platform.
6263
enable_nelmio_api_doc: false
6364

6465
# Enable the Swagger documentation and export.
6566
enable_swagger: true
6667

67-
# Enable Swagger ui.
68+
# Enable Swagger UI.
6869
enable_swagger_ui: true
6970

7071
# Enable ReDoc.
@@ -90,40 +91,47 @@ api_platform:
9091
order_parameter_name: 'order'
9192

9293
pagination:
94+
# The default name of the parameter handling the page number.
95+
page_parameter_name: 'page'
96+
97+
# The name of the query parameter to enable or disable pagination.
98+
enabled_parameter_name: 'pagination'
99+
100+
# The name of the query parameter to set the number of items per page.
101+
items_per_page_parameter_name: 'itemsPerPage'
102+
103+
# The name of the query parameter to enable or disable the partial pagination.
104+
partial_parameter_name: 'partial'
105+
93106
# To enable or disable pagination for all resource collections by default.
107+
# Deprecated since 2.6 and will be removed in 3.0, use defaults.pagination_enabled instead.
94108
enabled: true
95109

96110
# To allow partial pagination for all resource collections.
97111
# This improves performances by skipping the `COUNT` query.
112+
# Deprecated since 2.6 and will be removed in 3.0, use defaults.pagination_partial instead.
98113
partial: false
99114

100115
# To allow the client to enable or disable the pagination.
116+
# Deprecated since 2.6 and will be removed in 3.0, use defaults.pagination_client_enabled instead.
101117
client_enabled: false
102118

103119
# To allow the client to set the number of items per page.
120+
# Deprecated since 2.6 and will be removed in 3.0, use defaults.pagination_client_items_per_page instead.
104121
client_items_per_page: false
105122

106123
# To allow the client to enable or disable the partial pagination.
124+
# Deprecated since 2.6 and will be removed in 3.0, use defaults.pagination_client_partial instead.
107125
client_partial: false
108126

109127
# The default number of items per page.
128+
# Deprecated since 2.6 and will be removed in 3.0, use defaults.pagination_items_per_page instead.
110129
items_per_page: 30
111130

112131
# The maximum number of items per page.
132+
# Deprecated since 2.6 and will be removed in 3.0, use defaults.pagination_maximum_items_per_page instead.
113133
maximum_items_per_page: ~
114134

115-
# The default name of the parameter handling the page number.
116-
page_parameter_name: 'page'
117-
118-
# The name of the query parameter to enable or disable pagination.
119-
enabled_parameter_name: 'pagination'
120-
121-
# The name of the query parameter to set the number of items per page.
122-
items_per_page_parameter_name: 'itemsPerPage'
123-
124-
# The name of the query parameter to enable or disable the partial pagination.
125-
partial_parameter_name: 'partial'
126-
127135
mapping:
128136
# The list of paths with files or directories where the bundle will look for additional resource files.
129137
paths: []
@@ -141,43 +149,43 @@ api_platform:
141149
enabled: false
142150

143151
oauth:
144-
# To enable or disable oauth.
152+
# To enable or disable OAuth.
145153
enabled: false
146154

147-
# The oauth client id.
155+
# The OAuth client ID.
148156
clientId: ''
149157

150-
# The oauth client secret.
158+
# The OAuth client secret.
151159
clientSecret: ''
152160

153-
# The oauth type.
161+
# The OAuth type.
154162
type: 'oauth2'
155163

156-
# The oauth flow grant type.
164+
# The OAuth flow grant type.
157165
flow: 'application'
158166

159-
# The oauth token url.
167+
# The OAuth token URL.
160168
tokenUrl: '/oauth/v2/token'
161169

162-
# The oauth authentication url.
170+
# The OAuth authentication URL.
163171
authorizationUrl: '/oauth/v2/auth'
164172

165-
# The oauth scopes.
173+
# The OAuth scopes.
166174
scopes: []
167175

168176
graphql:
169-
# Enabled by default with installed GraphQL
177+
# Enabled by default with installed webonyx/graphql-php.
170178
enabled: false
171179

172180
# The default IDE (graphiql or graphql-playground) used when going to the GraphQL endpoint. False to disable.
173181
default_ide: 'graphiql'
174182

175183
graphiql:
176-
# Enabled by default with installed GraphQL and Twig
184+
# Enabled by default with installed webonyx/graphql-php and Twig.
177185
enabled: false
178186

179187
graphql_playground:
180-
# Enabled by default with installed GraphQL and Twig
188+
# Enabled by default with installed webonyx/graphql-php and Twig.
181189
enabled: false
182190

183191
# The nesting separator used in the filter names.
@@ -191,12 +199,12 @@ api_platform:
191199
# The active versions of OpenAPI to be exported or used in the swagger_ui. The first value is the default.
192200
versions: [2, 3]
193201

194-
# The swagger api keys.
202+
# The swagger API keys.
195203
api_keys: []
196-
# The name of the header or query parameter containing the api key.
204+
# The name of the header or query parameter containing the API key.
197205
# name: ''
198206

199-
# Whether the api key should be a query parameter or a header.
207+
# Whether the API key should be a query parameter or a header.
200208
# type: 'query' or 'header'
201209

202210
openapi:
@@ -218,40 +226,44 @@ api_platform:
218226
url:
219227

220228
http_cache:
229+
# To make all responses public by default.
230+
public: ~
231+
232+
invalidation:
233+
# To enable the tags-based cache invalidation system.
234+
enabled: false
235+
236+
# URLs of the Varnish servers to purge using cache tags when a resource is updated.
237+
varnish_urls: []
238+
239+
# To pass options to the client charged with the request.
240+
request_options: []
241+
221242
# Automatically generate etags for API responses.
243+
# Deprecated since 2.6 and will be removed in 3.0, use defaults.cache_headers.etag instead.
222244
etag: true
223245

224246
# Default value for the response max age.
247+
# Deprecated since 2.6 and will be removed in 3.0, use defaults.cache_headers.max_age instead.
225248
max_age: 3600
226249

227250
# Default value for the response shared (proxy) max age.
251+
# Deprecated since 2.6 and will be removed in 3.0, use defaults.cache_headers.shared_max_age instead.
228252
shared_max_age: 3600
229253

230254
# Default values of the "Vary" HTTP header.
255+
# Deprecated since 2.6 and will be removed in 3.0, use defaults.cache_headers.vary instead.
231256
vary: ['Accept']
232257

233-
# To make all responses public by default.
234-
public: ~
235-
236-
invalidation:
237-
# To enable the tags-based cache invalidation system.
238-
enabled: false
239-
240-
# URLs of the Varnish servers to purge using cache tags when a resource is updated.
241-
varnish_urls: []
242-
243-
# To pass options to the client charged with the request.
244-
request_options: []
245-
246258
mercure:
247-
# Enabled by default with installed symfony/mercure-bundle
259+
# Enabled by default with installed symfony/mercure-bundle.
248260
enabled: false
249261

250262
# The URL sent in the Link HTTP header. If not set, will default to MercureBundle's default hub URL.
251263
hub_url: null
252264

253265
messenger:
254-
# Enabled by default with installed symfony/messenger and not installed symfony/symfony
266+
# Enabled by default with installed symfony/messenger and not installed symfony/symfony.
255267
enabled: false
256268

257269
elasticsearch:
@@ -303,4 +315,100 @@ api_platform:
303315
mime_types: ['application/ld+json']
304316

305317
# ...
318+
319+
# Global resources defaults, see in the next section.
320+
defaults:
321+
# ...
322+
```
323+
324+
## Global Resources Defaults
325+
326+
If you need to globally configure all the resources instead of adding configuration in each one, it's possible to do so with the `defaults` key:
327+
328+
```yaml
329+
# api/config/packages/api_platform.yaml
330+
api_platform:
331+
332+
defaults:
333+
description: ~
334+
iri: ~
335+
short_name: ~
336+
item_operations: ~
337+
collection_operations: ~
338+
339+
graphql: ~
340+
341+
elasticsearch: ~
342+
343+
security: ~
344+
security_message: ~
345+
security_post_denormalize: ~
346+
security_post_denormalize_message: ~
347+
348+
cache_headers:
349+
# Automatically generate etags for API responses.
350+
etag: true
351+
352+
# Default value for the response max age.
353+
max_age: 3600
354+
355+
# Default value for the response shared (proxy) max age.
356+
shared_max_age: 3600
357+
358+
# Default values of the "Vary" HTTP header.
359+
vary: ['Accept']
360+
361+
normalization_context: ~
362+
denormalization_context: ~
363+
swagger_context: ~
364+
openapi_context: ~
365+
deprecation_reason: ~
366+
fetch_partial: ~
367+
force_eager: ~
368+
formats: ~
369+
filters: ~
370+
hydra_context: ~
371+
mercure: ~
372+
messenger: ~
373+
order: ~
374+
375+
# To enable or disable pagination for all resource collections.
376+
pagination_enabled: true
377+
378+
# To allow the client to enable or disable the pagination.
379+
pagination_client_enabled: false
380+
381+
# To allow the client to set the number of items per page.
382+
pagination_client_items_per_page: false
383+
384+
# To allow the client to enable or disable the partial pagination.
385+
pagination_client_partial: false
386+
387+
# The default number of items per page.
388+
pagination_items_per_page: 30
389+
390+
# The maximum number of items per page.
391+
pagination_maximum_items_per_page: ~
392+
393+
# To allow partial pagination for all resource collections.
394+
# This improves performances by skipping the `COUNT` query.
395+
pagination_partial: false
396+
397+
# To use cursor-based pagination.
398+
pagination_via_cursor: ~
399+
400+
pagination_fetch_join_collection: ~
401+
402+
route_prefix: ~
403+
validation_groups: ~
404+
sunset: ~
405+
input: ~
406+
output: ~
407+
stateless: ~
408+
409+
# The URL generation strategy to use for IRIs
410+
# Use values from UrlGeneratorInterface
411+
url_generation_strategy: ~
412+
413+
# ...
306414
```

0 commit comments

Comments
 (0)