|
13 | 13 |
|
14 | 14 | namespace ApiPlatform\Validator\Metadata\Resource\Factory; |
15 | 15 |
|
16 | | -use ApiPlatform\Metadata\HttpOperation; |
17 | 16 | use ApiPlatform\Metadata\Parameter; |
18 | 17 | use ApiPlatform\Metadata\Parameters; |
19 | | -use ApiPlatform\Metadata\QueryParameter; |
20 | 18 | use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface; |
21 | 19 | use ApiPlatform\Metadata\Resource\ResourceMetadataCollection; |
22 | 20 | use ApiPlatform\OpenApi\Model\Parameter as OpenApiParameter; |
@@ -52,15 +50,10 @@ public function create(string $resourceClass): ResourceMetadataCollection |
52 | 50 |
|
53 | 51 | foreach ($operations as $operationName => $operation) { |
54 | 52 | $parameters = $operation->getParameters() ?? new Parameters(); |
55 | | - foreach ($parameters as $key => $parameter) { |
| 53 | + foreach ($operation->getParameters() ?? [] as $key => $parameter) { |
56 | 54 | $parameters->add($key, $this->addSchemaValidation($parameter)); |
57 | 55 | } |
58 | 56 |
|
59 | | - // As we deprecate the parameter validator, we declare a parameter for each filter transfering validation to the new system |
60 | | - if ($operation->getFilters() && 0 === $parameters->count()) { |
61 | | - $parameters = $this->addFilterValidation($operation); |
62 | | - } |
63 | | - |
64 | 57 | if (\count($parameters) > 0) { |
65 | 58 | $operations->add($operationName, $operation->withParameters($parameters)); |
66 | 59 | } |
@@ -167,43 +160,4 @@ private function addSchemaValidation(Parameter $parameter, ?array $schema = null |
167 | 160 |
|
168 | 161 | return $parameter->withConstraints($assertions); |
169 | 162 | } |
170 | | - |
171 | | - private function addFilterValidation(HttpOperation $operation): Parameters |
172 | | - { |
173 | | - $parameters = new Parameters(); |
174 | | - $internalPriority = -1; |
175 | | - |
176 | | - foreach ($operation->getFilters() as $filter) { |
177 | | - if (!$this->filterLocator->has($filter)) { |
178 | | - continue; |
179 | | - } |
180 | | - |
181 | | - $filter = $this->filterLocator->get($filter); |
182 | | - foreach ($filter->getDescription($operation->getClass()) as $parameterName => $definition) { |
183 | | - $key = $parameterName; |
184 | | - $required = $definition['required'] ?? false; |
185 | | - $schema = $definition['schema'] ?? null; |
186 | | - |
187 | | - $openApi = null; |
188 | | - if (isset($definition['openapi']) && $definition['openapi'] instanceof OpenApiParameter) { |
189 | | - $openApi = $definition['openapi']; |
190 | | - } |
191 | | - |
192 | | - // The query parameter validator forced this, lets maintain BC on filters |
193 | | - if (true === $required && !$openApi) { |
194 | | - $openApi = new OpenApiParameter(name: $key, in: 'query', allowEmptyValue: false); |
195 | | - } |
196 | | - |
197 | | - $parameters->add($key, $this->addSchemaValidation( |
198 | | - // we disable openapi and hydra on purpose as their docs comes from filters see the condition for addFilterValidation above |
199 | | - new QueryParameter(key: $key, property: $definition['property'] ?? null, priority: $internalPriority--, schema: $schema, openApi: false, hydra: false), |
200 | | - $schema, |
201 | | - $required, |
202 | | - $openApi |
203 | | - )); |
204 | | - } |
205 | | - } |
206 | | - |
207 | | - return $parameters; |
208 | | - } |
209 | 163 | } |
0 commit comments