diff --git a/.travis.yml b/.travis.yml index 37fdc8553..3f69eaac2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,5 @@ +dist: trusty + language: php sudo: false diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 2baac26ed..a2cecf6a1 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -18,9 +18,16 @@ class Configuration implements ConfigurationInterface { public function getConfigTreeBuilder() { - $treeBuilder = new TreeBuilder(); - $treeBuilder - ->root('nelmio_api_doc') + $treeBuilder = new TreeBuilder('nelmio_api_doc'); + + if (method_exists($treeBuilder, 'getRootNode')) { + $rootNode = $treeBuilder->getRootNode(); + } else { + // symfony < 4.2 support + $rootNode = $treeBuilder->root('nelmio_api_doc'); + } + + $rootNode ->children() ->scalarNode('name')->defaultValue('API documentation')->end() ->arrayNode('exclude_sections') @@ -31,7 +38,7 @@ public function getConfigTreeBuilder() ->arrayNode('motd') ->addDefaultsIfNotSet() ->children() - ->scalarNode('template')->defaultValue('NelmioApiDocBundle::Components/motd.html.twig')->end() + ->scalarNode('template')->defaultValue('@NelmioApiDoc/Components/motd.html.twig')->end() ->end() ->end() ->arrayNode('request_listener') diff --git a/Formatter/HtmlFormatter.php b/Formatter/HtmlFormatter.php index 94ab16f47..ec2c90c97 100644 --- a/Formatter/HtmlFormatter.php +++ b/Formatter/HtmlFormatter.php @@ -12,6 +12,7 @@ namespace Nelmio\ApiDocBundle\Formatter; use Symfony\Component\Templating\EngineInterface; +use Twig\Environment as TwigEnvironment; class HtmlFormatter extends AbstractFormatter { @@ -31,7 +32,7 @@ class HtmlFormatter extends AbstractFormatter protected $defaultRequestFormat; /** - * @var EngineInterface + * @var EngineInterface|TwigEnvironment */ protected $engine; @@ -113,9 +114,9 @@ public function setEnableSandbox($enableSandbox) } /** - * @param EngineInterface $engine + * @param EngineInterface|TwigEnvironment $engine */ - public function setTemplatingEngine(EngineInterface $engine) + public function setTemplatingEngine($engine) { $this->engine = $engine; } @@ -197,7 +198,7 @@ public function setDefaultSectionsOpened($defaultSectionsOpened) */ protected function renderOne(array $data) { - return $this->engine->render('NelmioApiDocBundle::resource.html.twig', array_merge( + return $this->engine->render('@NelmioApiDoc/resource.html.twig', array_merge( array( 'data' => $data, 'displayContent' => true, @@ -211,7 +212,7 @@ protected function renderOne(array $data) */ protected function render(array $collection) { - return $this->engine->render('NelmioApiDocBundle::resources.html.twig', array_merge( + return $this->engine->render('@NelmioApiDoc/resources.html.twig', array_merge( array( 'resources' => $collection, ), diff --git a/README.md b/README.md index a9da1b193..49a5c530c 100644 --- a/README.md +++ b/README.md @@ -13,14 +13,14 @@ for your APIs. Documentation ------------- -[Read the documentation on symfony.com](https://symfony.com/doc/current/bundles/NelmioApiDocBundle/index.html) +[Read the documentation on symfony.com](https://symfony.com/doc/2.x/bundles/NelmioApiDocBundle/index.html) Contributing ------------ See -[CONTRIBUTING](https://github.com/nelmio/NelmioApiDocBundle/blob/master/CONTRIBUTING.md) +[CONTRIBUTING](https://github.com/nelmio/NelmioApiDocBundle/blob/2.x/CONTRIBUTING.md) file. diff --git a/Resources/config/formatters.xml b/Resources/config/formatters.xml index 9d55d2158..54f5eb58f 100644 --- a/Resources/config/formatters.xml +++ b/Resources/config/formatters.xml @@ -21,7 +21,7 @@ - + %nelmio_api_doc.motd.template% diff --git a/Resources/doc/configuration-reference.rst b/Resources/doc/configuration-reference.rst index a4cbddb0a..d72ba35a4 100644 --- a/Resources/doc/configuration-reference.rst +++ b/Resources/doc/configuration-reference.rst @@ -8,7 +8,7 @@ Configuration Reference exclude_sections: [] default_sections_opened: true motd: - template: 'NelmioApiDocBundle::Components/motd.html.twig' + template: '@NelmioApiDoc/Components/motd.html.twig' request_listener: enabled: true parameter: _doc diff --git a/Resources/doc/index.rst b/Resources/doc/index.rst index 360404a08..1c1033999 100644 --- a/Resources/doc/index.rst +++ b/Resources/doc/index.rst @@ -15,7 +15,7 @@ following command to download the latest stable version of this bundle: .. code-block:: bash - $ composer require nelmio/api-doc-bundle + $ composer require nelmio/api-doc-bundle:^2.0 This command requires you to have Composer installed globally, as explained in the `installation chapter`_ of the Composer documentation. diff --git a/Resources/doc/swagger-support.rst b/Resources/doc/swagger-support.rst index a4b23b95b..fd09295e3 100644 --- a/Resources/doc/swagger-support.rst +++ b/Resources/doc/swagger-support.rst @@ -8,7 +8,7 @@ based on ``@ApiDoc`` annotations, which can be used for consumption by Annotation options ------------------ -A couple of properties has been added to ``@ApiDoc``: +Several properties have been added to ``@ApiDoc`` to provide this feature: To define a **resource description**:: @@ -49,9 +49,9 @@ Multiple response models ------------------------ Swagger provides you the ability to specify alternate output models for -different status codes. Example, ``200`` would return your default resource object -in JSON form, but ``400`` may return a custom validation error list object. This -can be specified through the ``responseMap`` property:: +different status codes. For example: ``200`` would return your default resource object +in JSON form, while ``400`` may return a custom validation error list object. This +can be specified using the ``responseMap`` property:: /** * @ApiDoc( @@ -79,7 +79,7 @@ when this endpoint returns a ``400 Validation failed.`` HTTP response. .. note:: You can omit the ``200`` entry in the ``responseMap`` property and specify - the default ``output`` property instead. That will result on the same thing. + the default ``output`` property instead. That will result in the same response. Integration with ``swagger-api/swagger-ui`` ------------------------------------------- @@ -93,7 +93,7 @@ You could import the routes for use with `swagger-ui`_. resource: "@NelmioApiDocBundle/Resources/config/swagger_routing.yml" prefix: /api-docs -Et voila!, simply specify http://yourdomain.com/api-docs in your ``swagger-ui`` +Et voila! Simply specify http://yourdomain.com/api-docs in your ``swagger-ui`` instance and you are good to go. .. note:: @@ -118,7 +118,7 @@ To dump just the resource list: $ php app/console api:swagger:dump --list-only -To dump just the API definition the ``users`` resource: +To dump just the API definition of the ``users`` resource: .. code-block:: bash diff --git a/Resources/views/method.html.twig b/Resources/views/method.html.twig index efd6f6079..774cf9ff5 100644 --- a/Resources/views/method.html.twig +++ b/Resources/views/method.html.twig @@ -189,7 +189,7 @@ {{ name }} {{ infos.dataType }} - {% include 'NelmioApiDocBundle:Components:version.html.twig' with {'sinceVersion': infos.sinceVersion, 'untilVersion': infos.untilVersion} only %} + {% include '@NelmioApiDoc/Components/version.html.twig' with {'sinceVersion': infos.sinceVersion, 'untilVersion': infos.untilVersion} only %} {{ infos.description }} {% endfor %} diff --git a/Resources/views/resource.html.twig b/Resources/views/resource.html.twig index 1a51099f4..07230e2cd 100644 --- a/Resources/views/resource.html.twig +++ b/Resources/views/resource.html.twig @@ -1,11 +1,11 @@ -{% extends "NelmioApiDocBundle::layout.html.twig" %} +{% extends "@NelmioApiDoc/layout.html.twig" %} {% block content %}
      • - {% include 'NelmioApiDocBundle::method.html.twig' %} + {% include '@NelmioApiDoc/method.html.twig' %}
    diff --git a/Resources/views/resources.html.twig b/Resources/views/resources.html.twig index 997153dba..a6d2ca78a 100644 --- a/Resources/views/resources.html.twig +++ b/Resources/views/resources.html.twig @@ -1,4 +1,4 @@ -{% extends "NelmioApiDocBundle::layout.html.twig" %} +{% extends "@NelmioApiDoc/layout.html.twig" %} {% block content %}
    @@ -33,7 +33,7 @@
    • {% for data in methods %} - {% include 'NelmioApiDocBundle::method.html.twig' %} + {% include '@NelmioApiDoc/method.html.twig' %} {% endfor %}
  • diff --git a/Tests/Formatter/testFormat-result-no-dunglas.markdown b/Tests/Formatter/testFormat-result-no-dunglas.markdown index c22632cba..3baba524e 100644 --- a/Tests/Formatter/testFormat-result-no-dunglas.markdown +++ b/Tests/Formatter/testFormat-result-no-dunglas.markdown @@ -622,6 +622,9 @@ dependency_type[a]: _This method is useful to test if the getDocComment works._ +This method is useful to test if the getDocComment works. +And, it supports multilines until the first '@' char. + #### Requirements #### **id** diff --git a/Tests/Formatter/testFormat-result.markdown b/Tests/Formatter/testFormat-result.markdown index 068d0f21d..deb85f286 100644 --- a/Tests/Formatter/testFormat-result.markdown +++ b/Tests/Formatter/testFormat-result.markdown @@ -706,6 +706,9 @@ dependency_type[a]: _This method is useful to test if the getDocComment works._ +This method is useful to test if the getDocComment works. +And, it supports multilines until the first '@' char. + #### Requirements #### **id**