mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-02 15:51:48 +03:00
commit
2a0f95eac0
@ -322,8 +322,8 @@ class ApiDocExtractor
|
||||
$parameters = $this->clearClasses($parameters);
|
||||
$parameters = $this->generateHumanReadableTypes($parameters);
|
||||
|
||||
if ('PUT' === $annotation->getMethod()) {
|
||||
// All parameters are optional with PUT (update)
|
||||
if ('PATCH' === $annotation->getMethod()) {
|
||||
// All parameters are optional with PATCH (update)
|
||||
array_walk($parameters, function ($val, $key) use (&$parameters) {
|
||||
$parameters[$key]['required'] = false;
|
||||
});
|
||||
|
@ -286,13 +286,13 @@ class ApiDocExtractorTest extends WebTestCase
|
||||
$this->assertTrue($parameters['required_field']['required']);
|
||||
}
|
||||
|
||||
public function testPutRequestDoesNeverRequireParameters()
|
||||
public function testPatchRequestDoesNeverRequireParameters()
|
||||
{
|
||||
$container = $this->getContainer();
|
||||
/** @var ApiDocExtractor $extractor */
|
||||
$extractor = $container->get('nelmio_api_doc.extractor.api_doc_extractor');
|
||||
/** @var ApiDoc $annotation */
|
||||
$annotation = $extractor->get('Nelmio\ApiDocBundle\Tests\Fixtures\Controller\TestController::requiredParametersAction', 'test_put_disables_required_parameters');
|
||||
$annotation = $extractor->get('Nelmio\ApiDocBundle\Tests\Fixtures\Controller\TestController::requiredParametersAction', 'test_patch_disables_required_parameters');
|
||||
|
||||
$parameters = $annotation->getParameters();
|
||||
$this->assertFalse($parameters['required_field']['required']);
|
||||
|
@ -209,9 +209,9 @@ test_required_parameters:
|
||||
requirements:
|
||||
_format: json|xml|html
|
||||
|
||||
test_put_disables_required_parameters:
|
||||
test_patch_disables_required_parameters:
|
||||
path: /api/other-resources/{id}.{_format}
|
||||
methods: [PUT]
|
||||
methods: [PATCH]
|
||||
defaults: { _controller: NelmioApiDocTestBundle:Resource:requiredParametersAction, _format: json }
|
||||
requirements:
|
||||
_format: json|xml|html
|
||||
|
Loading…
x
Reference in New Issue
Block a user