mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-02 23:59:26 +03:00
14383f4ee5
* add zircore/swagger-php v4 to composer.json * fix incompatibilities * add compatibility with 3.2 * Apply fixes from StyleCI * mark SetsContextTrait as internal * Bump php version Co-authored-by: Alexey <alshenestky@icloud.com> Co-authored-by: Alexey Alshenetsky <alshenetsky@users.noreply.github.com> Co-authored-by: Guilhem Niot <guilhem@gniot.fr>
70 lines
2.5 KiB
PHP
70 lines
2.5 KiB
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;
|
|
|
|
use OpenApi\Annotations as OA;
|
|
use OpenApi\Generator;
|
|
|
|
class FOSRestTest extends WebTestCase
|
|
{
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
static::createClient([], ['HTTP_HOST' => 'api.example.com']);
|
|
}
|
|
|
|
public function testFOSRestAction()
|
|
{
|
|
$operation = $this->getOperation('/api/fosrest', 'post');
|
|
|
|
$this->assertHasParameter('foo', 'query', $operation);
|
|
$this->assertInstanceOf(OA\RequestBody::class, $operation->requestBody);
|
|
|
|
$bodySchema = $operation->requestBody->content['application/json']->schema;
|
|
|
|
$this->assertHasProperty('bar', $bodySchema);
|
|
$this->assertHasProperty('baz', $bodySchema);
|
|
|
|
$fooParameter = $this->getParameter($operation, 'foo', 'query');
|
|
$this->assertInstanceOf(OA\Schema::class, $fooParameter->schema);
|
|
$this->assertEquals('\d+', $fooParameter->schema->pattern);
|
|
$this->assertEquals(Generator::UNDEFINED, $fooParameter->schema->format);
|
|
|
|
$mappedParameter = $this->getParameter($operation, 'mapped[]', 'query');
|
|
$this->assertTrue($mappedParameter->explode);
|
|
|
|
$barProperty = $this->getProperty($bodySchema, 'bar');
|
|
$this->assertEquals('\d+', $barProperty->pattern);
|
|
$this->assertEquals(Generator::UNDEFINED, $barProperty->format);
|
|
|
|
$bazProperty = $this->getProperty($bodySchema, 'baz');
|
|
$this->assertEquals(Generator::UNDEFINED, $bazProperty->pattern);
|
|
$this->assertEquals('IsTrue', $bazProperty->format);
|
|
|
|
$dateTimeProperty = $this->getProperty($bodySchema, 'datetime');
|
|
$this->assertEquals('date-time', $dateTimeProperty->format);
|
|
|
|
$dateTimeAltProperty = $this->getProperty($bodySchema, 'datetimeAlt');
|
|
$this->assertEquals('date-time', $dateTimeAltProperty->format);
|
|
|
|
$dateTimeNoFormatProperty = $this->getProperty($bodySchema, 'datetimeNoFormat');
|
|
$this->assertEquals(Generator::UNDEFINED, $dateTimeNoFormatProperty->format);
|
|
|
|
$dateProperty = $this->getProperty($bodySchema, 'date');
|
|
$this->assertEquals('date', $dateProperty->format);
|
|
|
|
// The _format path attribute should be removed
|
|
$this->assertNotHasParameter('_format', 'path', $operation);
|
|
}
|
|
}
|