NelmioApiDocBundle/Tests/Functional/JMSFunctionalTest.php
Christian Schiffler 8da1ac0296 Pass real property to swagger annotation reader
The type invariation (changing from the real property to the sub items
definition) causes the swagger annotations to end up on the created
`Items` entry.
This changes the behaviour to update the real property entry with the
swagger annotation.

Additionally this ensures that "description", "title" and "example" are
only updated on `Schema` instances.
2017-12-15 17:39:18 +01:00

75 lines
2.1 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;
class JMSFunctionalTest extends WebTestCase
{
public function testModelDocumentation()
{
$this->assertEquals([
'type' => 'object',
'properties' => [
'id' => [
'type' => 'integer',
'description' => "User id",
'readOnly' => true,
'title' => "userid",
'example' => 1,
],
'email' => [
'type' => 'string',
'readOnly' => false,
],
'roles' => [
'type' => 'array',
'description' => 'User roles',
'title' => "roles",
'example' => '["ADMIN","SUPERUSER"]',
'items' => ['type' => 'string'],
],
'friendsNumber' => [
'type' => 'string',
],
'friends' => [
'type' => 'array',
'items' => [
'$ref' => '#/definitions/User',
],
],
'best_friend' => [
'$ref' => '#/definitions/User',
],
],
], $this->getModel('JMSUser')->toArray());
}
public function testYamlConfig()
{
$this->assertEquals([
'type' => 'object',
'properties' => [
'id' => [
'type' => 'integer',
],
'email' => [
'type' => 'string'
],
],
], $this->getModel('VirtualProperty')->toArray());
}
protected static function createKernel(array $options = array())
{
return new TestKernel(true);
}
}