-
-
Notifications
You must be signed in to change notification settings - Fork 836
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(#2297): (Symfony 7.1) Add MapRequestPayload array parameter hand…
…ling (#2298) | Q | A | |---------------|---------------------------------------------------------------------------------------------------------------------------| | Bug fix? | no | | New feature? | yes <!-- please update src/**/CHANGELOG.md files --> | | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | | Issues | Fix #2297 <!-- prefix each issue number with "Fix #", no need to create an issue if none exists, explain below instead --> | With Symfony 7.1, a new `type` parameter has been introduced for `MapRequestPayload` that allows array Controller parameters to be resolved. This currently leads to an error when the Describer tries to register a new Model, because the parameter type `array` is used in this case. To resolve the issue, the given `type` parameter form the `MapRequestPayload` should be used instead. I tried to test this as gracefully as possible. Any more elegant suggestions are welcome! --------- Co-authored-by: Maximilian Zumbansen <[email protected]> Co-authored-by: djordy <[email protected]>
- Loading branch information
1 parent
d590880
commit 684391a
Showing
16 changed files
with
925 additions
and
5,261 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
tests/Functional/Controller/MapQueryParameterController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the NelmioApiDocBundle package. | ||
* | ||
* (c) Nelmio | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Nelmio\ApiDocBundle\Tests\Functional\Controller; | ||
|
||
use Symfony\Component\HttpKernel\Attribute\MapQueryParameter; | ||
use Symfony\Component\Routing\Annotation\Route; | ||
|
||
class MapQueryParameterController | ||
{ | ||
#[Route('/article_map_query_parameter', methods: ['GET'])] | ||
#[OA\Response(response: '200', description: '')] | ||
public function fetchArticleFromMapQueryParameter( | ||
#[MapQueryParameter] int $someInt, | ||
#[MapQueryParameter] float $someFloat, | ||
#[MapQueryParameter] bool $someBool, | ||
#[MapQueryParameter] string $someString, | ||
#[MapQueryParameter] array $someArray, | ||
) { | ||
} | ||
|
||
#[Route('/article_map_query_parameter_validate_filters', methods: ['GET'])] | ||
#[OA\Response(response: '200', description: '')] | ||
public function fetchArticleFromMapQueryParameterValidateFilters( | ||
#[MapQueryParameter(options: ['min_range' => 2, 'max_range' => 1234])] int $minMaxInt, | ||
#[MapQueryParameter(filter: FILTER_VALIDATE_DOMAIN)] string $domain, | ||
#[MapQueryParameter(filter: FILTER_VALIDATE_EMAIL)] string $email, | ||
#[MapQueryParameter(filter: FILTER_VALIDATE_IP)] string $ip, | ||
#[MapQueryParameter(filter: FILTER_VALIDATE_IP, flags: FILTER_FLAG_IPV4)] string $ipv4, | ||
#[MapQueryParameter(filter: FILTER_VALIDATE_IP, flags: FILTER_FLAG_IPV6)] string $ipv6, | ||
#[MapQueryParameter(filter: FILTER_VALIDATE_MAC)] string $macAddress, | ||
#[MapQueryParameter(filter: FILTER_VALIDATE_REGEXP, options: ['regexp' => '/^test/'])] string $regexp, | ||
#[MapQueryParameter(filter: FILTER_VALIDATE_URL)] string $url, | ||
) { | ||
} | ||
|
||
#[Route('/article_map_query_parameter_nullable', methods: ['GET'])] | ||
#[OA\Response(response: '200', description: '')] | ||
public function fetchArticleFromMapQueryParameterNullable( | ||
#[MapQueryParameter] ?int $id, | ||
) { | ||
} | ||
|
||
#[Route('/article_map_query_parameter_default', methods: ['GET'])] | ||
#[OA\Response(response: '200', description: '')] | ||
public function fetchArticleFromMapQueryParameterDefault( | ||
#[MapQueryParameter] int $id = 123, | ||
) { | ||
} | ||
|
||
#[Route('/article_map_query_parameter_overwrite_parameters', methods: ['GET'])] | ||
#[OA\Parameter( | ||
name: 'id', | ||
in: 'query', | ||
description: 'Query parameter id description', | ||
example: 123, | ||
)] | ||
#[OA\Parameter( | ||
name: 'changedType', | ||
in: 'query', | ||
schema: new OA\Schema(type: 'int', nullable: false), | ||
description: 'Incorrectly described query parameter', | ||
example: 123, | ||
)] | ||
#[OA\Response(response: '200', description: '')] | ||
public function fetchArticleFromMapQueryParameterOverwriteParameters( | ||
#[MapQueryParameter] ?int $id, | ||
#[MapQueryParameter] ?string $changedType, | ||
) { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.