mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-02 15:51:48 +03:00
Merge pull request #868 from dpcat237/502_hide-requirement-when-empty
#502 hide requirement when empty
This commit is contained in:
commit
e6ea85157e
@ -56,11 +56,15 @@ class FosRestHandler implements HandlerInterface
|
|||||||
'description' => $annot->description,
|
'description' => $annot->description,
|
||||||
'default' => $annot->default,
|
'default' => $annot->default,
|
||||||
));
|
));
|
||||||
} else {
|
} elseif ($annot->requirements !== null) {
|
||||||
$annotation->addFilter($annot->name, array(
|
$annotation->addFilter($annot->name, array(
|
||||||
'requirement' => $this->handleRequirements($annot->requirements).((property_exists($annot, 'map') ? $annot->map : $annot->array) ? '[]' : ''),
|
'requirement' => $this->handleRequirements($annot->requirements).((property_exists($annot, 'map') ? $annot->map : $annot->array) ? '[]' : ''),
|
||||||
'description' => $annot->description,
|
'description' => $annot->description,
|
||||||
));
|
));
|
||||||
|
} else {
|
||||||
|
$annotation->addFilter($annot->name, array(
|
||||||
|
'description' => $annot->description,
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -203,4 +203,22 @@ class FosRestHandlerTest extends WebTestCase
|
|||||||
$this->assertArrayHasKey('requirement', $filters['param1']);
|
$this->assertArrayHasKey('requirement', $filters['param1']);
|
||||||
$this->assertEquals('NotNull, NotBlank', $filters['param1']['requirement']);
|
$this->assertEquals('NotNull, NotBlank', $filters['param1']['requirement']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testWithRequirementParamNotSet()
|
||||||
|
{
|
||||||
|
$container = $this->getContainer();
|
||||||
|
$extractor = $container->get('nelmio_api_doc.extractor.api_doc_extractor');
|
||||||
|
$annotation = $extractor->get('Nelmio\ApiDocBundle\Tests\Fixtures\Controller\TestController::zActionWithRequirementParamNotSet', 'test_route_31');
|
||||||
|
|
||||||
|
$this->assertNotNull($annotation);
|
||||||
|
|
||||||
|
$filters = $annotation->getFilters();
|
||||||
|
$this->assertCount(1, $filters);
|
||||||
|
$this->assertArrayHasKey('param1', $filters);
|
||||||
|
$filter = $filters['param1'];
|
||||||
|
|
||||||
|
$this->assertArrayNotHasKey('requirement', $filter);
|
||||||
|
$this->assertArrayHasKey('description', $filter);
|
||||||
|
$this->assertEquals($filter['description'], 'Param1 description.');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -414,4 +414,12 @@ class TestController
|
|||||||
public function routeWithQueryParamPlainArrayRequirementsAction()
|
public function routeWithQueryParamPlainArrayRequirementsAction()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ApiDoc()
|
||||||
|
* @QueryParam(name="param1", description="Param1 description.")
|
||||||
|
*/
|
||||||
|
public function zActionWithRequirementParamNotSet()
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -248,3 +248,8 @@ test_route_30:
|
|||||||
path: /z-query-param-plain-array-requirements
|
path: /z-query-param-plain-array-requirements
|
||||||
methods: [GET]
|
methods: [GET]
|
||||||
defaults: { _controller: NelmioApiDocTestBundle:Test:routeWithQueryParamPlainArrayRequirementsAction }
|
defaults: { _controller: NelmioApiDocTestBundle:Test:routeWithQueryParamPlainArrayRequirementsAction }
|
||||||
|
|
||||||
|
test_route_31:
|
||||||
|
path: /z-query-requirement-param-not-set
|
||||||
|
methods: [GET]
|
||||||
|
defaults: { _controller: NelmioApiDocTestBundle:Test:zActionWithRequirementParamNotSet }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user