mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-09 02:59:27 +03:00
do not fail if phpdocumentor is not available
This commit is contained in:
parent
ccf7a75ec5
commit
f4a9ad7ef7
@ -88,14 +88,18 @@ final class NelmioApiDocExtension extends Extension implements PrependExtensionI
|
||||
|
||||
// JMS metadata support
|
||||
if ($config['models']['use_jms']) {
|
||||
$arguments = [
|
||||
new Reference('jms_serializer.metadata_factory'),
|
||||
new Reference('jms_serializer.naming_strategy'),
|
||||
new Reference('nelmio_api_doc.model_describers.swagger_property_annotation_reader'),
|
||||
];
|
||||
// phpdocumentor is not a hard requirement, only use if available
|
||||
if (class_exists(DocBlockFactory::class)) {
|
||||
$arguments[] = new Reference('nelmio_api_doc.model_describers.phpdoc_property_annotation_reader');
|
||||
}
|
||||
$container->register('nelmio_api_doc.model_describers.jms', JMSModelDescriber::class)
|
||||
->setPublic(false)
|
||||
->setArguments([
|
||||
new Reference('jms_serializer.metadata_factory'),
|
||||
new Reference('jms_serializer.naming_strategy'),
|
||||
new Reference('nelmio_api_doc.model_describers.swagger_property_annotation_reader'),
|
||||
new Reference('nelmio_api_doc.model_describers.phpdoc_property_annotation_reader'),
|
||||
])
|
||||
->setArguments($arguments)
|
||||
->addTag('nelmio_api_doc.model_describer', ['priority' => 50]);
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ class JMSModelDescriber implements ModelDescriberInterface, ModelRegistryAwareIn
|
||||
MetadataFactoryInterface $factory,
|
||||
PropertyNamingStrategyInterface $namingStrategy,
|
||||
SwaggerPropertyAnnotationReader $swaggerPropertyAnnotationReader,
|
||||
PhpdocPropertyAnnotationReader $phpdocPropertyAnnotationReader
|
||||
PhpdocPropertyAnnotationReader $phpdocPropertyAnnotationReader = null
|
||||
) {
|
||||
$this->factory = $factory;
|
||||
$this->namingStrategy = $namingStrategy;
|
||||
@ -107,7 +107,9 @@ class JMSModelDescriber implements ModelDescriberInterface, ModelRegistryAwareIn
|
||||
|
||||
// read property options from Swagger Property annotation if it exists
|
||||
if (null !== $item->reflection) {
|
||||
$this->phpdocPropertyAnnotationsReader->updateWithPhpdoc($item->reflection, $realProp);
|
||||
if ($this->phpdocPropertyAnnotationsReader) {
|
||||
$this->phpdocPropertyAnnotationsReader->updateWithPhpdoc($item->reflection, $realProp);
|
||||
}
|
||||
$this->swaggerPropertyAnnotationReader->updateWithSwaggerPropertyAnnotation($item->reflection, $realProp);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user