Skip to content

Commit

Permalink
Fix null title/description configuration (#1563 followup)
Browse files Browse the repository at this point in the history
  • Loading branch information
abluchet committed Dec 20, 2017
1 parent 26be83a commit c1568e1
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Bridge/Symfony/Bundle/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,19 @@ public function getConfigTreeBuilder()
->children()
->scalarNode('title')
->info('The title of the API.')
->cannotBeEmpty()
->defaultValue('')
->beforeNormalization()
->ifNull()
->then(function ($v) { return ''; })
->end()
->end()
->scalarNode('description')
->info('The description of the API.')
->cannotBeEmpty()
->defaultValue('')
->beforeNormalization()
->ifNull()
->then(function ($v) { return ''; })
->end()
->end()
->scalarNode('version')
->info('The version of the API.')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,4 +234,40 @@ public function testApiKeysConfig()
$this->assertTrue(isset($config['swagger']['api_keys']));
$this->assertSame($exampleConfig, $config['swagger']['api_keys'][0]);
}

/**
* Test config for empty title and description.
*/
public function testEmptyTitleDescriptionConfig()
{
$testConfig = [
'title' => '',
'description' => '',
];

$config = $this->processor->processConfiguration($this->configuration, [
'api_platform' => $testConfig,
]);

$this->assertSame($config['title'], '');
$this->assertSame($config['description'], '');
}

/**
* Test config for null title and description.
*/
public function testNullTitleDescriptionConfig()
{
$testConfig = [
'title' => null,
'description' => null,
];

$config = $this->processor->processConfiguration($this->configuration, [
'api_platform' => $testConfig,
]);

$this->assertSame($config['title'], '');
$this->assertSame($config['description'], '');
}
}

0 comments on commit c1568e1

Please sign in to comment.