@@ -68,6 +68,54 @@ a new instance:
6868> [ !TIP] Always check the specific documentation for your persistence layer (Doctrine ORM, MongoDB
6969> ODM, Laravel Eloquent) to see the exact namespace and available options for these filters.
7070
71+ ### Global Default Parameters
72+
73+ Instead of repeating the same parameter configuration on every resource, you can define global
74+ default parameters that are automatically applied to all resources. This is done via the ` defaults `
75+ key in your API Platform configuration.
76+
77+ Add a ` parameters ` map under ` defaults ` in your API Platform configuration. Each entry maps a
78+ fully-qualified parameter class name to its options.
79+
80+ ``` yaml
81+ # Symfony: api/config/packages/api_platform.yaml
82+ api_platform :
83+ defaults :
84+ parameters :
85+ ApiPlatform\Metadata\HeaderParameter :
86+ key : " API-Token"
87+ required : true
88+ description : " API authentication token"
89+
90+ ApiPlatform\Metadata\QueryParameter :
91+ key : " api_version"
92+ required : false
93+ description : " API version"
94+ ` ` `
95+
96+ ` ` ` php
97+ <?php
98+ // Laravel : config/api-platform.php
99+ return [
100+ ' defaults' => [
101+ ' parameters' => [
102+ \ApiPlatform\Metadata\HeaderParameter::class => [
103+ ' key' => 'API-Token',
104+ ' required' => true,
105+ ' description' => 'API authentication token',
106+ ],
107+ \ApiPlatform\Metadata\QueryParameter::class => [
108+ ' key' => 'api_version',
109+ ' required' => false,
110+ ' description' => 'API version',
111+ ],
112+ ],
113+ ],
114+ ];
115+ ```
116+
117+ Every resource will automatically expose these parameters on all their operations.
118+
71119You can declare a parameter on the resource class to make it available for all its operations:
72120
73121``` php
0 commit comments