mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-03 08:09:25 +03:00
78664ef9ec
* Initial pass for OA3 upgrade * Fix Util Tests * Fix first batch of Unit Tests. Up to Model * Another batch of fixed tests * Update annotations * Convert Model & Property Describers * Update tests, Fix RouteDescribers, FIx additional bugs * Another batch of updates * Another batch of fixed Functional Tests * Fix FunctionalTest tests * Fix Bazinga Tests * FIx FOS Rest * Fix JMS TEsts & describers * Fix all Tests * Fix few stuff from own CR * CS Fixes * CS Fixes 2 * CS Fixes 3 * CS Fixes 4 * Remove collection bug * Updates after first CRs * CS * Drop support for SF3 * Update the docs * Add an upgrade guide * misc doc fixes * Configurable media types * Code Style Fixes * Don't use ::$ref for @Response and @RequestBody * Fix upgrading guide * Fix OA case Co-authored-by: Filip Benčo <filip.benco@websupport.sk> Co-authored-by: Guilhem Niot <guilhem.niot@gmail.com> Co-authored-by: Mantis Development <mantis@users.noreply.github.com>
59 lines
1.9 KiB
PHP
59 lines
1.9 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 FOS\RestBundle\FOSRestBundle;
|
|
use OpenApi\Annotations as OA;
|
|
|
|
class FOSRestTest extends WebTestCase
|
|
{
|
|
protected function setUp()
|
|
{
|
|
parent::setUp();
|
|
|
|
static::createClient([], ['HTTP_HOST' => 'api.example.com']);
|
|
}
|
|
|
|
public function testFOSRestAction()
|
|
{
|
|
if (!class_exists(FOSRestBundle::class)) {
|
|
$this->markTestSkipped('FOSRestBundle is not installed.');
|
|
}
|
|
|
|
$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(OA\UNDEFINED, $fooParameter->schema->format);
|
|
|
|
$barProperty = $this->getProperty($bodySchema, 'bar');
|
|
$this->assertEquals('\d+', $barProperty->pattern);
|
|
$this->assertEquals(OA\UNDEFINED, $barProperty->format);
|
|
|
|
$bazProperty = $this->getProperty($bodySchema, 'baz');
|
|
$this->assertEquals(OA\UNDEFINED, $bazProperty->pattern);
|
|
$this->assertEquals('IsTrue', $bazProperty->format);
|
|
|
|
// The _format path attribute should be removed
|
|
$this->assertNotHasParameter('_format', 'path', $operation);
|
|
}
|
|
}
|