diff --git a/src/Metadata/Extractor/YamlResourceExtractor.php b/src/Metadata/Extractor/YamlResourceExtractor.php
index 8bbb03bed69..30838186580 100644
--- a/src/Metadata/Extractor/YamlResourceExtractor.php
+++ b/src/Metadata/Extractor/YamlResourceExtractor.php
@@ -471,7 +471,7 @@ private function buildParameters(array $resource): ?array
$parameters[$key] = new $cl(
key: $key,
required: $this->phpize($parameter, 'required', 'bool'),
- schema: $parameter['schema'],
+ schema: $parameter['schema'] ?? null,
openApi: ($parameter['openapi'] ?? null) ? new Parameter(
name: $parameter['openapi']['name'],
in: $parameter['in'] ?? 'query',
diff --git a/src/Metadata/Tests/Extractor/Adapter/XmlResourceAdapter.php b/src/Metadata/Tests/Extractor/Adapter/XmlResourceAdapter.php
index 4a2acbbb069..0b302606fa5 100644
--- a/src/Metadata/Tests/Extractor/Adapter/XmlResourceAdapter.php
+++ b/src/Metadata/Tests/Extractor/Adapter/XmlResourceAdapter.php
@@ -533,8 +533,14 @@ private function buildParameters(\SimpleXMLElement $resource, ?array $values = n
$childNode = $node->addChild('parameter');
$childNode->addAttribute('in', 'query');
$childNode->addAttribute('key', $key);
- $childNode->addAttribute('required', $this->parse($value['required']));
- $this->buildValues($childNode->addChild('schema'), $value['schema']);
+
+ if (\array_key_exists('required', $value)) {
+ $childNode->addAttribute('required', $this->parse($value['required']));
+ }
+
+ if (\array_key_exists('schema', $value)) {
+ $this->buildValues($childNode->addChild('schema'), $value['schema']);
+ }
}
}
diff --git a/src/Metadata/Tests/Extractor/Adapter/resources.xml b/src/Metadata/Tests/Extractor/Adapter/resources.xml
index 45b012242b2..65eebd8c971 100644
--- a/src/Metadata/Tests/Extractor/Adapter/resources.xml
+++ b/src/Metadata/Tests/Extractor/Adapter/resources.xml
@@ -1,3 +1,3 @@
-
+
diff --git a/src/Metadata/Tests/Extractor/Adapter/resources.yaml b/src/Metadata/Tests/Extractor/Adapter/resources.yaml
index 2c9e21b1c5f..08dbaa80827 100644
--- a/src/Metadata/Tests/Extractor/Adapter/resources.yaml
+++ b/src/Metadata/Tests/Extractor/Adapter/resources.yaml
@@ -139,6 +139,9 @@ resources:
-
rel: 'http://www.w3.org/ns/json-ld#error'
href: 'http://www.w3.org/ns/hydra/error'
+ parameters:
+ date:
+ key: date
formats:
json: null
jsonld: null
diff --git a/src/Metadata/Tests/Extractor/ResourceMetadataCompatibilityTest.php b/src/Metadata/Tests/Extractor/ResourceMetadataCompatibilityTest.php
index 030f754e90c..fd16dac7b8e 100644
--- a/src/Metadata/Tests/Extractor/ResourceMetadataCompatibilityTest.php
+++ b/src/Metadata/Tests/Extractor/ResourceMetadataCompatibilityTest.php
@@ -442,6 +442,9 @@ final class ResourceMetadataCompatibilityTest extends TestCase
'links' => [
['rel' => 'http://www.w3.org/ns/json-ld#error', 'href' => 'http://www.w3.org/ns/hydra/error'],
],
+ 'parameters' => [
+ 'date' => ['key' => 'date'],
+ ],
],
],
],
@@ -761,7 +764,7 @@ private function withParameters(array $values): ?array
$parameters = [];
foreach ($values as $k => $value) {
- $parameters[$k] = new QueryParameter(key: $value['key'], required: $value['required'], schema: $value['schema']);
+ $parameters[$k] = new QueryParameter(key: $value['key'] ?? null, required: $value['required'] ?? null, schema: $value['schema'] ?? null);
}
return $parameters;