Update areas.rst (#1983)

* Update areas.rst

'with_annotations' option is not mentioned in actual documentation

* Slight changes

* Rephrase
This commit is contained in:
Valentin Salmeron 2022-04-21 23:18:01 +02:00 committed by GitHub
parent f8c030d096
commit 35ea6f2759
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -32,6 +32,7 @@ You can define areas which will each generates a different documentation:
store:
# Includes routes with names containing 'store'
name_patterns: [ store ]
Your main documentation is under the ``default`` area. It's the one shown when accessing ``/api/doc``.
@ -52,3 +53,38 @@ Then update your routing to be able to access your different documentations:
# defaults: { _controller: nelmio_api_doc.controller.swagger }
That's all! You can now access ``/api/doc/internal``, ``/api/doc/commercial`` and ``/api/doc/store``.
Use annotations to filter documented routes in each area
--------------------------------------------------------
You can use the `@Areas` annotation inside your controllers to define your routes' areas.
First, you need to define which areas will use the`@Areas` annotations to filter
the routes that should be documented:
.. code-block:: yaml
nelmio_api_doc:
areas:
default:
path_patterns: [ ^/api ]
internal:
with_annotations: true
Then add the annotation before your controller or action::
use Nelmio\Annotations as Nelmio;
/**
* @Nelmio\Areas({"internal"}) => All actions in this controller are documented under the 'internal' area
*/
class MyController
{
/**
* @Nelmio\Areas({"internal"}) => This action is documented under the 'internal' area
*/
public function index()
{
...
}
}