Merge fixes

This commit is contained in:
Guilhem Niot 2018-01-13 13:37:17 +01:00
commit b5fb133533
2 changed files with 27 additions and 34 deletions

View File

@ -36,11 +36,8 @@ class PhpdocPropertyAnnotationReader
/** /**
* Update the Swagger information with information from the DocBlock comment. * Update the Swagger information with information from the DocBlock comment.
*
* @param \ReflectionProperty $reflectionProperty
* @param Items|Schema $property
*/ */
public function updateWithPhpdoc(\ReflectionProperty $reflectionProperty, $property) public function updateWithPhpdoc(\ReflectionProperty $reflectionProperty, Schema $property)
{ {
try { try {
$docBlock = $this->docBlockFactory->create($reflectionProperty); $docBlock = $this->docBlockFactory->create($reflectionProperty);

View File

@ -29,37 +29,33 @@ class SwaggerPropertyAnnotationReader
$this->annotationsReader = $annotationsReader; $this->annotationsReader = $annotationsReader;
} }
/** public function updateWithSwaggerPropertyAnnotation(\ReflectionProperty $reflectionProperty, Schema $property)
* @param \ReflectionProperty $reflectionProperty
* @param Items|Schema $property
*/
public function updateWithSwaggerPropertyAnnotation(\ReflectionProperty $reflectionProperty, $property)
{ {
$swgProperty = $this->annotationsReader->getPropertyAnnotation($reflectionProperty, SwgProperty::class); if (!$swgProperty = $this->annotationsReader->getPropertyAnnotation($reflectionProperty, SwgProperty::class)) {
if ($swgProperty instanceof SwgProperty) { return;
if (null !== $swgProperty->type) { }
$property->setType($swgProperty->type);
} if (null !== $swgProperty->type) {
if (UNDEFINED !== $swgProperty->default) { $property->setType($swgProperty->type);
$property->setDefault($swgProperty->default); }
} if (UNDEFINED !== $swgProperty->default) {
if (null !== $swgProperty->enum) { $property->setDefault($swgProperty->default);
$property->setEnum($swgProperty->enum); }
} if (null !== $swgProperty->enum) {
if ($property instanceof Schema) { $property->setEnum($swgProperty->enum);
if (null !== $swgProperty->description) { }
$property->setDescription($swgProperty->description);
} if (null !== $swgProperty->description) {
if (null !== $swgProperty->title) { $property->setDescription($swgProperty->description);
$property->setTitle($swgProperty->title); }
} if (null !== $swgProperty->title) {
if (null !== $swgProperty->example) { $property->setTitle($swgProperty->title);
$property->setExample($swgProperty->example); }
} if (null !== $swgProperty->example) {
if (null !== $swgProperty->readOnly) { $property->setExample($swgProperty->example);
$property->setReadOnly($swgProperty->readOnly); }
} if (null !== $swgProperty->readOnly) {
} $property->setReadOnly($swgProperty->readOnly);
} }
} }
} }