Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
soyuka committed Sep 16, 2024
1 parent 78cea1a commit 64351f8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ private function addSchemaValidation(Parameter $parameter): Parameter
$maxLength = isset($schema['maxLength']);

if ($minLength && $maxLength) {
$assertions[] = sprintf('between:%s,%s', $schema['minLength'], $schema['maxLength']);
$assertions[] = \sprintf('between:%s,%s', $schema['minLength'], $schema['maxLength']);
} elseif ($minLength) {
$assertions[] = 'min:'.$schema['minLength'];
} elseif ($maxLength) {
Expand All @@ -125,7 +125,7 @@ private function addSchemaValidation(Parameter $parameter): Parameter
$maxItems = isset($schema['maxItems']);

if ($minItems && $maxItems) {
$assertions[] = sprintf('between:%s,%s', $schema['minItems'], $schema['maxItems']);
$assertions[] = \sprintf('between:%s,%s', $schema['minItems'], $schema['maxItems']);
} elseif ($minItems) {
$assertions[] = 'min:'.$schema['minItems'];
} elseif ($maxItems) {
Expand Down
4 changes: 4 additions & 0 deletions src/State/Util/ParameterParserTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ private function extractParameterValues(Parameter $parameter, array $values): st
{
$accessors = null;
$key = $parameter->getKey();
if (null === $key) {
throw new \RuntimeException('A Parameter should have a key.');
}

$parsedKey = explode('[:property]', $key);
if (isset($parsedKey[0]) && isset($values[$parsedKey[0]])) {
$key = $parsedKey[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</service>

<service id="api_platform.validator.metadata.resource.metadata_collection_factory.parameter" class="ApiPlatform\Validator\Metadata\Resource\Factory\ParameterValidationResourceMetadataCollectionFactory" decorates="api_platform.metadata.resource.metadata_collection_factory" public="false" decoration-priority="1000">
<argument type="service" id="api_platform.metadata.resource.metadata_collection_factory.parameter.inner" />
<argument type="service" id="api_platform.validator.metadata.resource.metadata_collection_factory.parameter.inner" />
<argument type="service" id="api_platform.filter_locator" />
</service>

Expand Down

0 comments on commit 64351f8

Please sign in to comment.