mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-02 15:51:48 +03:00
Merge remote-tracking branch 'origin/3.x' into HEAD
This commit is contained in:
commit
d167685f42
@ -8,6 +8,7 @@ CHANGELOG
|
||||
3.7.0
|
||||
-----
|
||||
|
||||
* remove pattern added from the Expression Violation message.
|
||||
* Added `@SerializedName` annotation support and name converters when using Symfony >= 4.2.
|
||||
|
||||
3.3.0
|
||||
|
@ -69,7 +69,7 @@ final class OpenApiPhpDescriber
|
||||
return $v instanceof OA\AbstractAnnotation;
|
||||
});
|
||||
|
||||
if (0 === count($annotations)) {
|
||||
if (0 === count($annotations) && 0 === count($classAnnotations[$declaringClass->getName()])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -69,8 +69,6 @@ class SymfonyConstraintAnnotationReader
|
||||
} elseif ($annotation instanceof Assert\Choice) {
|
||||
$values = $annotation->callback ? call_user_func(is_array($annotation->callback) ? $annotation->callback : [$reflectionProperty->class, $annotation->callback]) : $annotation->choices;
|
||||
$property->enum = array_values($values);
|
||||
} elseif ($annotation instanceof Assert\Expression) {
|
||||
$this->appendPattern($property, $annotation->message);
|
||||
} elseif ($annotation instanceof Assert\Range) {
|
||||
$property->minimum = (int) $annotation->min;
|
||||
$property->maximum = (int) $annotation->max;
|
||||
|
@ -61,9 +61,9 @@ class ObjectModelDescriber implements ModelDescriberInterface, ModelRegistryAwar
|
||||
$class = $model->getType()->getClassName();
|
||||
$schema->_context->class = $class;
|
||||
|
||||
$context = [];
|
||||
$context = ['serializer_groups' => null];
|
||||
if (null !== $model->getGroups()) {
|
||||
$context = ['serializer_groups' => array_filter($model->getGroups(), 'is_string')];
|
||||
$context['serializer_groups'] = array_filter($model->getGroups(), 'is_string');
|
||||
}
|
||||
|
||||
$annotationsReader = new AnnotationsReader($this->doctrineReader, $this->modelRegistry, $this->mediaTypes);
|
||||
|
31
Tests/Functional/Controller/InvokableController.php
Normal file
31
Tests/Functional/Controller/InvokableController.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?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\Controller;
|
||||
|
||||
use OpenApi\Annotations as OA;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
|
||||
/**
|
||||
* Prevents a regression (see https://github.com/nelmio/NelmioApiDocBundle/issues/1559).
|
||||
*
|
||||
* @Route("/api/invoke", host="api.example.com", name="invokable", methods={"GET"})
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="Invokable!"
|
||||
* )
|
||||
*/
|
||||
class InvokableController
|
||||
{
|
||||
public function __invoke()
|
||||
{
|
||||
}
|
||||
}
|
@ -374,7 +374,6 @@ class FunctionalTest extends WebTestCase
|
||||
],
|
||||
'propertyExpression' => [
|
||||
'type' => 'integer',
|
||||
'pattern' => 'If this is a tech post, the category should be either php or symfony!',
|
||||
],
|
||||
'propertyRange' => [
|
||||
'type' => 'integer',
|
||||
@ -449,4 +448,10 @@ class FunctionalTest extends WebTestCase
|
||||
$this->assertSame('array', $property->oneOf[1]->type);
|
||||
$this->assertSame('#/components/schemas/CompoundEntity', $property->oneOf[1]->items->ref);
|
||||
}
|
||||
|
||||
public function testInvokableController()
|
||||
{
|
||||
$operation = $this->getOperation('/api/invoke', 'get');
|
||||
$this->assertSame('Invokable!', $this->getOperationResponse($operation, 200)->description);
|
||||
}
|
||||
}
|
||||
|
@ -81,6 +81,7 @@ class TestKernel extends Kernel
|
||||
$routes->import(__DIR__.'/Controller/ApiController.php', '/', 'annotation');
|
||||
$routes->import(__DIR__.'/Controller/ClassApiController.php', '/', 'annotation');
|
||||
$routes->import(__DIR__.'/Controller/UndocumentedController.php', '/', 'annotation');
|
||||
$routes->import(__DIR__.'/Controller/InvokableController.php', '/', 'annotation');
|
||||
$routes->import('', '/api', 'api_platform');
|
||||
$routes->add('/docs/{area}', 'nelmio_api_doc.controller.swagger_ui')->setDefault('area', 'default');
|
||||
$routes->add('/docs.json', 'nelmio_api_doc.controller.swagger');
|
||||
|
Loading…
x
Reference in New Issue
Block a user