mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-02 15:51:48 +03:00
Fix CS
This commit is contained in:
parent
a07e3bfe75
commit
a4fe1f8078
@ -168,7 +168,7 @@ final class SwaggerPhpDescriber extends ExternalDocDescriber implements ModelReg
|
|||||||
|
|
||||||
private function normalizePath(string $path): string
|
private function normalizePath(string $path): string
|
||||||
{
|
{
|
||||||
if (substr($path, -10) === '.{_format}') {
|
if ('.{_format}' === substr($path, -10)) {
|
||||||
$path = substr($path, 0, -10);
|
$path = substr($path, 0, -10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,8 +39,7 @@ class JMSModelDescriber implements ModelDescriberInterface, ModelRegistryAwareIn
|
|||||||
MetadataFactoryInterface $factory,
|
MetadataFactoryInterface $factory,
|
||||||
PropertyNamingStrategyInterface $namingStrategy,
|
PropertyNamingStrategyInterface $namingStrategy,
|
||||||
SwaggerPropertyAnnotationReader $swaggerPropertyAnnotationReader
|
SwaggerPropertyAnnotationReader $swaggerPropertyAnnotationReader
|
||||||
)
|
) {
|
||||||
{
|
|
||||||
$this->factory = $factory;
|
$this->factory = $factory;
|
||||||
$this->namingStrategy = $namingStrategy;
|
$this->namingStrategy = $namingStrategy;
|
||||||
$this->swaggerPropertyAnnotationReader = $swaggerPropertyAnnotationReader;
|
$this->swaggerPropertyAnnotationReader = $swaggerPropertyAnnotationReader;
|
||||||
@ -101,8 +100,9 @@ class JMSModelDescriber implements ModelDescriberInterface, ModelRegistryAwareIn
|
|||||||
}
|
}
|
||||||
|
|
||||||
// read property options from Swagger Property annotation if it exists
|
// read property options from Swagger Property annotation if it exists
|
||||||
if($item->reflection !== null)
|
if (null !== $item->reflection) {
|
||||||
$this->swaggerPropertyAnnotationReader->updateWithSwaggerPropertyAnnotation($item->reflection, $realProp);
|
$this->swaggerPropertyAnnotationReader->updateWithSwaggerPropertyAnnotation($item->reflection, $realProp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,8 +29,7 @@ class ObjectModelDescriber implements ModelDescriberInterface, ModelRegistryAwar
|
|||||||
public function __construct(
|
public function __construct(
|
||||||
PropertyInfoExtractorInterface $propertyInfo,
|
PropertyInfoExtractorInterface $propertyInfo,
|
||||||
SwaggerPropertyAnnotationReader $swaggerPropertyAnnotationReader
|
SwaggerPropertyAnnotationReader $swaggerPropertyAnnotationReader
|
||||||
)
|
) {
|
||||||
{
|
|
||||||
$this->propertyInfo = $propertyInfo;
|
$this->propertyInfo = $propertyInfo;
|
||||||
$this->swaggerPropertyAnnotationReader = $swaggerPropertyAnnotationReader;
|
$this->swaggerPropertyAnnotationReader = $swaggerPropertyAnnotationReader;
|
||||||
}
|
}
|
||||||
@ -69,16 +68,16 @@ class ObjectModelDescriber implements ModelDescriberInterface, ModelRegistryAwar
|
|||||||
$property = $property->getItems();
|
$property = $property->getItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($type->getBuiltinType() === Type::BUILTIN_TYPE_STRING) {
|
if (Type::BUILTIN_TYPE_STRING === $type->getBuiltinType()) {
|
||||||
$property->setType('string');
|
$property->setType('string');
|
||||||
} elseif ($type->getBuiltinType() === Type::BUILTIN_TYPE_BOOL) {
|
} elseif (Type::BUILTIN_TYPE_BOOL === $type->getBuiltinType()) {
|
||||||
$property->setType('boolean');
|
$property->setType('boolean');
|
||||||
} elseif ($type->getBuiltinType() === Type::BUILTIN_TYPE_INT) {
|
} elseif (Type::BUILTIN_TYPE_INT === $type->getBuiltinType()) {
|
||||||
$property->setType('integer');
|
$property->setType('integer');
|
||||||
} elseif ($type->getBuiltinType() === Type::BUILTIN_TYPE_FLOAT) {
|
} elseif (Type::BUILTIN_TYPE_FLOAT === $type->getBuiltinType()) {
|
||||||
$property->setType('number');
|
$property->setType('number');
|
||||||
$property->setFormat('float');
|
$property->setFormat('float');
|
||||||
} elseif ($type->getBuiltinType() === Type::BUILTIN_TYPE_OBJECT) {
|
} elseif (Type::BUILTIN_TYPE_OBJECT === $type->getBuiltinType()) {
|
||||||
if (in_array($type->getClassName(), ['DateTime', 'DateTimeImmutable'])) {
|
if (in_array($type->getClassName(), ['DateTime', 'DateTimeImmutable'])) {
|
||||||
$property->setType('string');
|
$property->setType('string');
|
||||||
$property->setFormat('date-time');
|
$property->setFormat('date-time');
|
||||||
@ -88,7 +87,7 @@ class ObjectModelDescriber implements ModelDescriberInterface, ModelRegistryAwar
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new \Exception(sprintf("Unknown type: %s", $type->getBuiltinType()));
|
throw new \Exception(sprintf('Unknown type: %s', $type->getBuiltinType()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// read property options from Swagger Property annotation if it exists
|
// read property options from Swagger Property annotation if it exists
|
||||||
|
@ -11,10 +11,10 @@
|
|||||||
|
|
||||||
namespace Nelmio\ApiDocBundle\ModelDescriber;
|
namespace Nelmio\ApiDocBundle\ModelDescriber;
|
||||||
|
|
||||||
use EXSyst\Component\Swagger\Schema;
|
|
||||||
use EXSyst\Component\Swagger\Items;
|
|
||||||
use Swagger\Annotations\Property as SwgProperty;
|
|
||||||
use Doctrine\Common\Annotations\Reader;
|
use Doctrine\Common\Annotations\Reader;
|
||||||
|
use EXSyst\Component\Swagger\Items;
|
||||||
|
use EXSyst\Component\Swagger\Schema;
|
||||||
|
use Swagger\Annotations\Property as SwgProperty;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
@ -36,20 +36,20 @@ class SwaggerPropertyAnnotationReader
|
|||||||
{
|
{
|
||||||
$swgProperty = $this->annotationsReader->getPropertyAnnotation($reflectionProperty, SwgProperty::class);
|
$swgProperty = $this->annotationsReader->getPropertyAnnotation($reflectionProperty, SwgProperty::class);
|
||||||
if ($swgProperty instanceof SwgProperty) {
|
if ($swgProperty instanceof SwgProperty) {
|
||||||
if ($swgProperty->type !== null) {
|
if (null !== $swgProperty->type) {
|
||||||
$property->setType($swgProperty->type);
|
$property->setType($swgProperty->type);
|
||||||
}
|
}
|
||||||
if ($swgProperty->readOnly !== null) {
|
if (null !== $swgProperty->readOnly) {
|
||||||
$property->setReadOnly($swgProperty->readOnly);
|
$property->setReadOnly($swgProperty->readOnly);
|
||||||
}
|
}
|
||||||
if ($property instanceof Schema) {
|
if ($property instanceof Schema) {
|
||||||
if ($swgProperty->description !== null) {
|
if (null !== $swgProperty->description) {
|
||||||
$property->setDescription($swgProperty->description);
|
$property->setDescription($swgProperty->description);
|
||||||
}
|
}
|
||||||
if ($swgProperty->title !== null) {
|
if (null !== $swgProperty->title) {
|
||||||
$property->setTitle($swgProperty->title);
|
$property->setTitle($swgProperty->title);
|
||||||
}
|
}
|
||||||
if ($swgProperty->example !== null) {
|
if (null !== $swgProperty->example) {
|
||||||
$property->setExample((string) $swgProperty->example);
|
$property->setExample((string) $swgProperty->example);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ trait RouteDescriberTrait
|
|||||||
|
|
||||||
private function normalizePath(string $path): string
|
private function normalizePath(string $path): string
|
||||||
{
|
{
|
||||||
if (substr($path, -10) === '.{_format}') {
|
if ('.{_format}' === substr($path, -10)) {
|
||||||
$path = substr($path, 0, -10);
|
$path = substr($path, 0, -10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,6 +41,5 @@ class JMSController
|
|||||||
*/
|
*/
|
||||||
public function yamlAction()
|
public function yamlAction()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ use Swagger\Annotations as SWG;
|
|||||||
class User
|
class User
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var integer
|
* @var int
|
||||||
*
|
*
|
||||||
* @SWG\Property(description = "User id", required = true, readOnly = true, title = "userid", example=1)
|
* @SWG\Property(description = "User id", required = true, readOnly = true, title = "userid", example=1)
|
||||||
*/
|
*/
|
||||||
|
@ -1,13 +1,20 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the NelmioApiDocBundle package.
|
||||||
|
*
|
||||||
|
* (c) Nelmio
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
namespace Nelmio\ApiDocBundle\Tests\Functional\Entity;
|
namespace Nelmio\ApiDocBundle\Tests\Functional\Entity;
|
||||||
|
|
||||||
use JMS\Serializer\Annotation as Serializer;
|
use JMS\Serializer\Annotation as Serializer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class VirtualProperty
|
* Class VirtualProperty.
|
||||||
* @package Nelmio\ApiDocBundle\Tests\Functional\Entity
|
|
||||||
*
|
*
|
||||||
* @Serializer\ExclusionPolicy("all")
|
* @Serializer\ExclusionPolicy("all")
|
||||||
* @Serializer\VirtualProperty(
|
* @Serializer\VirtualProperty(
|
||||||
@ -18,7 +25,6 @@ use JMS\Serializer\Annotation as Serializer;
|
|||||||
*/
|
*/
|
||||||
class VirtualProperty
|
class VirtualProperty
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var int
|
* @var int
|
||||||
* @Serializer\Type("integer")
|
* @Serializer\Type("integer")
|
||||||
@ -34,6 +40,6 @@ class VirtualProperty
|
|||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->user = new User();
|
$this->user = new User();
|
||||||
$this->user->setEmail("dummy@test.com");
|
$this->user->setEmail('dummy@test.com');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,8 +12,8 @@
|
|||||||
namespace Nelmio\ApiDocBundle\Tests\Functional\Form;
|
namespace Nelmio\ApiDocBundle\Tests\Functional\Form;
|
||||||
|
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
|
||||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ class UserType extends AbstractType
|
|||||||
$builder
|
$builder
|
||||||
->add('dummy', DummyType::class)
|
->add('dummy', DummyType::class)
|
||||||
->add('dummies', CollectionType::class, [
|
->add('dummies', CollectionType::class, [
|
||||||
'entry_type' => DummyType::class
|
'entry_type' => DummyType::class,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,9 +159,9 @@ class FunctionalTest extends WebTestCase
|
|||||||
],
|
],
|
||||||
'id' => [
|
'id' => [
|
||||||
'type' => 'integer',
|
'type' => 'integer',
|
||||||
'description' => "User id",
|
'description' => 'User id',
|
||||||
'readOnly' => true,
|
'readOnly' => true,
|
||||||
'title' => "userid",
|
'title' => 'userid',
|
||||||
'example' => 1,
|
'example' => 1,
|
||||||
],
|
],
|
||||||
'email' => [
|
'email' => [
|
||||||
@ -206,8 +206,8 @@ class FunctionalTest extends WebTestCase
|
|||||||
'dummies' => [
|
'dummies' => [
|
||||||
'items' => ['$ref' => '#/definitions/DummyType'],
|
'items' => ['$ref' => '#/definitions/DummyType'],
|
||||||
'type' => 'array',
|
'type' => 'array',
|
||||||
'example' => sprintf('[{%s}]', DummyType::class)
|
'example' => sprintf('[{%s}]', DummyType::class),
|
||||||
]
|
],
|
||||||
],
|
],
|
||||||
'required' => ['dummy', 'dummies'],
|
'required' => ['dummy', 'dummies'],
|
||||||
], $this->getModel('UserType')->toArray());
|
], $this->getModel('UserType')->toArray());
|
||||||
@ -223,8 +223,8 @@ class FunctionalTest extends WebTestCase
|
|||||||
'enum' => ['male', 'female'],
|
'enum' => ['male', 'female'],
|
||||||
],
|
],
|
||||||
'baz' => [
|
'baz' => [
|
||||||
'type' => 'boolean'
|
'type' => 'boolean',
|
||||||
]
|
],
|
||||||
],
|
],
|
||||||
'required' => ['foo'],
|
'required' => ['foo'],
|
||||||
], $this->getModel('DummyType')->toArray());
|
], $this->getModel('DummyType')->toArray());
|
||||||
|
@ -20,9 +20,9 @@ class JMSFunctionalTest extends WebTestCase
|
|||||||
'properties' => [
|
'properties' => [
|
||||||
'id' => [
|
'id' => [
|
||||||
'type' => 'integer',
|
'type' => 'integer',
|
||||||
'description' => "User id",
|
'description' => 'User id',
|
||||||
'readOnly' => true,
|
'readOnly' => true,
|
||||||
'title' => "userid",
|
'title' => 'userid',
|
||||||
'example' => 1,
|
'example' => 1,
|
||||||
],
|
],
|
||||||
'email' => [
|
'email' => [
|
||||||
@ -32,7 +32,7 @@ class JMSFunctionalTest extends WebTestCase
|
|||||||
'roles' => [
|
'roles' => [
|
||||||
'type' => 'array',
|
'type' => 'array',
|
||||||
'description' => 'User roles',
|
'description' => 'User roles',
|
||||||
'title' => "roles",
|
'title' => 'roles',
|
||||||
'example' => '["ADMIN","SUPERUSER"]',
|
'example' => '["ADMIN","SUPERUSER"]',
|
||||||
'items' => ['type' => 'string'],
|
'items' => ['type' => 'string'],
|
||||||
],
|
],
|
||||||
@ -61,7 +61,7 @@ class JMSFunctionalTest extends WebTestCase
|
|||||||
'type' => 'integer',
|
'type' => 'integer',
|
||||||
],
|
],
|
||||||
'email' => [
|
'email' => [
|
||||||
'type' => 'string'
|
'type' => 'string',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
], $this->getModel('VirtualProperty')->toArray());
|
], $this->getModel('VirtualProperty')->toArray());
|
||||||
|
@ -22,9 +22,6 @@
|
|||||||
"zircote/swagger-php": "^2.0.9"
|
"zircote/swagger-php": "^2.0.9"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"symfony/yaml": "Temporary: see https://github.com/symfony/symfony/pull/24634/files#r153192689",
|
|
||||||
"symfony/yaml": "^2.8|^3.0|^4.0",
|
|
||||||
|
|
||||||
"symfony/templating": "^2.8|^3.0|^4.0",
|
"symfony/templating": "^2.8|^3.0|^4.0",
|
||||||
"symfony/twig-bundle": "^3.0|^4.0",
|
"symfony/twig-bundle": "^3.0|^4.0",
|
||||||
"symfony/asset": "^2.8|^3.0|^4.0",
|
"symfony/asset": "^2.8|^3.0|^4.0",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user