use serializer naming strategy for parameter names

This commit is contained in:
Jordan Stout 2013-02-14 12:20:13 -08:00
parent a9087994da
commit d099ffa40f
2 changed files with 14 additions and 3 deletions

View File

@ -15,6 +15,7 @@ use Metadata\MetadataFactoryInterface;
use Nelmio\ApiDocBundle\Util\DocCommentExtractor;
use JMS\Serializer\Metadata\PropertyMetadata;
use JMS\Serializer\Metadata\VirtualPropertyMetadata;
use JMS\Serializer\Naming\PropertyNamingStrategyInterface;
/**
* Uses the JMS metadata factory to extract input/output model information
@ -27,6 +28,11 @@ class JmsMetadataParser implements ParserInterface
*/
private $factory;
/**
* @var PropertyNamingStrategyInterface
*/
private $namingStrategy;
/**
* @var \Nelmio\ApiDocBundle\Util\DocCommentExtractor
*/
@ -35,9 +41,13 @@ class JmsMetadataParser implements ParserInterface
/**
* Constructor, requires JMS Metadata factory
*/
public function __construct(MetadataFactoryInterface $factory, DocCommentExtractor $commentExtractor)
{
public function __construct(
MetadataFactoryInterface $factory,
PropertyNamingStrategyInterface $namingStrategy,
DocCommentExtractor $commentExtractor
) {
$this->factory = $factory;
$this->namingStrategy = $namingStrategy;
$this->commentExtractor = $commentExtractor;
}
@ -85,7 +95,7 @@ class JmsMetadataParser implements ParserInterface
// iterate over property metadata
foreach ($meta->propertyMetadata as $item) {
if (!is_null($item->type)) {
$name = isset($item->serializedName) ? $item->serializedName : $item->name;
$name = $this->namingStrategy->translateName($item);
$dataType = $this->processDataType($item);

View File

@ -10,6 +10,7 @@
<services>
<service id="nelmio_api_doc.parser.jms_metadata_parser" class="%nelmio_api_doc.parser.jms_metadata_parser.class%">
<argument type="service" id="jms_serializer.metadata_factory" />
<argument type="service" id="jms_serializer.naming_strategy" />
<argument type="service" id="nelmio_api_doc.doc_comment_extractor" />
<tag name="nelmio_api_doc.extractor.parser" />
</service>