Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #565 #792

Merged
merged 1 commit into from Feb 24, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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