Skip to content

Commit

Permalink
Merge pull request #792 from rodrigm/master
Browse files Browse the repository at this point in the history
Fix #565
  • Loading branch information
willdurand committed Feb 24, 2016
2 parents 4381f06 + 89f459d commit 2a0f95e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Extractor/ApiDocExtractor.php
Expand Up @@ -322,8 +322,8 @@ protected function extractData(ApiDoc $annotation, Route $route, \ReflectionMeth
$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;
});
Expand Down
4 changes: 2 additions & 2 deletions Tests/Extractor/ApiDocExtractorTest.php
Expand Up @@ -286,13 +286,13 @@ public function testPostRequestDoesRequireParametersWhenMarkedAsSuch()
$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']);
Expand Down
4 changes: 2 additions & 2 deletions Tests/Fixtures/app/config/routing.yml
Expand Up @@ -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
Expand Down

0 comments on commit 2a0f95e

Please sign in to comment.