Skip to content

Commit

Permalink
TASK: Remove the '[]' postfix from collection parameters as those wil…
Browse files Browse the repository at this point in the history
…l use deepObject style now
  • Loading branch information
mficzel committed Jun 14, 2024
1 parent 074774e commit 6d31435
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Classes/Domain/Path/OpenApiParameter.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public static function fromReflectionParameter(\ReflectionParameter $reflectionP
$parameterSchema = OpenApiSchema::fromReflectionClass($reflectionClass);

return new self(
name: $reflectionParameter->name . (($parameterAttribute->in === ParameterLocation::LOCATION_QUERY && $parameterSchema->type === 'array') ? '[]' : ''),
name: $reflectionParameter->name,
in: $parameterAttribute->in,
description: $parameterAttribute->description ?: $schemaAttribute->description,
required: !$reflectionParameter->isDefaultValueAvailable(),
Expand Down
7 changes: 4 additions & 3 deletions Tests/Unit/Application/ParameterFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,12 @@ public static function parameterProvider(): iterable
new Uri('https://acme.site/de/')
))->withQueryParams(
[
'endpointQuery' => ['language' => 'de'],
'anotherEndpointQuery' => '{"pleaseFail":"true"}'
]
)
);
$multipleParametersRequest->setArgument('endpointQuery', ['language' => 'de']);

yield 'withMultipleParameters' => [
'request' => $multipleParametersRequest,
'className' => PathController::class,
Expand All @@ -118,9 +119,9 @@ public static function parameterProvider(): iterable
$collectionParametersRequest = ActionRequest::fromHttpRequest(
(new ServerRequest(
HttpMethod::METHOD_GET->value,
new Uri('https://acme.site/?identifierCollection[]=foo&identifierCollection[]=bar&identifier=baz')
new Uri('https://acme.site/?identifierCollection=foo&identifierCollection=bar&identifier=baz')
))->withQueryParams([
'identifierCollection' => ['foo','bar'],
'identifierCollection' => '["foo","bar"]',
'identifier' => 'baz'
])
);
Expand Down
2 changes: 1 addition & 1 deletion Tests/Unit/Domain/OpenApiDocumentFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ public function testFromClassNameCreatesDefinitionsForValidClasses(): void
style: ParameterStyle::STYLE_FORM
),
new OpenApiParameter(
name: 'identifierCollection[]',
name: 'identifierCollection',
description: '',
in: ParameterLocation::LOCATION_QUERY,
required: true,
Expand Down

0 comments on commit 6d31435

Please sign in to comment.