diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php
new file mode 100644
index 0000000..149f92f
--- /dev/null
+++ b/DependencyInjection/Configuration.php
@@ -0,0 +1,22 @@
+root('nelmio_api_doc')
+ ->children()
+ ->scalarNode('name')->defaultValue('API documentation')->end()
+ ;
+
+ return $treeBuilder;
+ }
+}
diff --git a/DependencyInjection/NelmioApiDocExtension.php b/DependencyInjection/NelmioApiDocExtension.php
index 1f2da18..b4e8626 100644
--- a/DependencyInjection/NelmioApiDocExtension.php
+++ b/DependencyInjection/NelmioApiDocExtension.php
@@ -5,6 +5,7 @@ namespace Nelmio\ApiDocBundle\DependencyInjection;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\DependencyInjection\ContainerBuilder;
+use Symfony\Component\Config\Definition\Processor;
use Symfony\Component\Config\FileLocator;
class NelmioApiExtension extends Extension
@@ -14,6 +15,12 @@ class NelmioApiExtension extends Extension
*/
public function load(array $configs, ContainerBuilder $container)
{
+ $processor = new Processor();
+ $configuration = new Configuration();
+ $config = $processor->processConfiguration($configuration, $configs);
+
+ $container->setParameter('nelmio_api_doc.api_name', $config['name']);
+
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('formatters.xml');
$loader->load('request_listener.xml');
diff --git a/Formatter/HtmlFormatter.php b/Formatter/HtmlFormatter.php
index 5a76317..925e123 100644
--- a/Formatter/HtmlFormatter.php
+++ b/Formatter/HtmlFormatter.php
@@ -7,6 +7,19 @@ use Symfony\Component\Routing\Route;
class HtmlFormatter extends AbstractFormatter
{
+ /**
+ * @var string
+ */
+ private $apiName;
+
+ /**
+ * @param string $apiName
+ */
+ public function setApiName($apiName)
+ {
+ $this->apiName = $apiName;
+ }
+
/**
* {@inheritdoc}
*/
@@ -69,7 +82,7 @@ class HtmlFormatter extends AbstractFormatter
private function renderWithLayout($content)
{
- extract(array('content' => $content));
+ extract(array('api_name' => $this->apiName, 'content' => $content));
ob_start();
include __DIR__ . '/../Resources/views/formatter_layout.html.php';
diff --git a/README.md b/README.md
index 90e1a12..ce87259 100644
--- a/README.md
+++ b/README.md
@@ -126,6 +126,15 @@ A use case could be to generate a static version of your documentation:
php app/console api:doc:dump --format=html > api.html
+## Configuration ##
+
+You can specify your own API name:
+
+ # app/config/config.yml
+ nelmio_api_doc:
+ name: My API
+
+
## Credits ##
The design is heavily inspired by the [swagger-ui](https://github.com/wordnik/swagger-ui) project.
diff --git a/Resources/config/formatters.xml b/Resources/config/formatters.xml
index d4f7ce4..6207088 100644
--- a/Resources/config/formatters.xml
+++ b/Resources/config/formatters.xml
@@ -23,7 +23,11 @@