Skip to content

sync 2.x #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: 2.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
dist: trusty

language: php

sudo: false
Expand Down
15 changes: 11 additions & 4 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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')
Expand Down
11 changes: 6 additions & 5 deletions Formatter/HtmlFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Nelmio\ApiDocBundle\Formatter;

use Symfony\Component\Templating\EngineInterface;
use Twig\Environment as TwigEnvironment;

class HtmlFormatter extends AbstractFormatter
{
Expand All @@ -31,7 +32,7 @@ class HtmlFormatter extends AbstractFormatter
protected $defaultRequestFormat;

/**
* @var EngineInterface
* @var EngineInterface|TwigEnvironment
*/
protected $engine;

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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,
Expand All @@ -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,
),
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.


Expand Down
2 changes: 1 addition & 1 deletion Resources/config/formatters.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<service id="nelmio_api_doc.formatter.html_formatter" class="%nelmio_api_doc.formatter.html_formatter.class%"
parent="nelmio_api_doc.formatter.abstract_formatter" public="true">
<call method="setTemplatingEngine">
<argument type="service" id="templating" />
<argument type="service" id="twig" />
</call>
<call method="setMotdTemplate">
<argument>%nelmio_api_doc.motd.template%</argument>
Expand Down
2 changes: 1 addition & 1 deletion Resources/doc/configuration-reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Resources/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
14 changes: 7 additions & 7 deletions Resources/doc/swagger-support.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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**::

Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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``
-------------------------------------------
Expand All @@ -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::
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion Resources/views/method.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@
<tr>
<td>{{ name }}</td>
<td>{{ infos.dataType }}</td>
<td>{% include 'NelmioApiDocBundle:Components:version.html.twig' with {'sinceVersion': infos.sinceVersion, 'untilVersion': infos.untilVersion} only %}</td>
<td>{% include '@NelmioApiDoc/Components/version.html.twig' with {'sinceVersion': infos.sinceVersion, 'untilVersion': infos.untilVersion} only %}</td>
<td>{{ infos.description }}</td>
</tr>
{% endfor %}
Expand Down
4 changes: 2 additions & 2 deletions Resources/views/resource.html.twig
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{% extends "NelmioApiDocBundle::layout.html.twig" %}
{% extends "@NelmioApiDoc/layout.html.twig" %}

{% block content %}
<li class="resource">
<ul class="endpoints">
<li class="endpoint">
<ul class="operations">
{% include 'NelmioApiDocBundle::method.html.twig' %}
{% include '@NelmioApiDoc/method.html.twig' %}
</ul>
</li>
</ul>
Expand Down
4 changes: 2 additions & 2 deletions Resources/views/resources.html.twig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends "NelmioApiDocBundle::layout.html.twig" %}
{% extends "@NelmioApiDoc/layout.html.twig" %}

{% block content %}
<div id="summary">
Expand Down Expand Up @@ -33,7 +33,7 @@
<li class="endpoint">
<ul class="operations">
{% for data in methods %}
{% include 'NelmioApiDocBundle::method.html.twig' %}
{% include '@NelmioApiDoc/method.html.twig' %}
{% endfor %}
</ul>
</li>
Expand Down
3 changes: 3 additions & 0 deletions Tests/Formatter/testFormat-result-no-dunglas.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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**
Expand Down
3 changes: 3 additions & 0 deletions Tests/Formatter/testFormat-result.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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**
Expand Down