Skip to content

Commit

Permalink
documentation update
Browse files Browse the repository at this point in the history
  • Loading branch information
DjordyKoert committed Jan 6, 2024
1 parent 1204c32 commit 6135a63
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 4 deletions.
2 changes: 1 addition & 1 deletion DependencyInjection/NelmioApiDocExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public function load(array $configs, ContainerBuilder $container): void
}

if (PHP_VERSION_ID > 80100) {
// Add autoconfiguration for inline parameter describer
// Add autoconfiguration for route argument describer
$container->registerForAutoconfiguration(RouteArgumentDescriberInterface::class)
->addTag('nelmio_api_doc.route_argument_describer');

Expand Down
2 changes: 1 addition & 1 deletion Processors/MapQueryStringProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

/**
* A processor that adds query parameters to operations that have a MapQueryString attribute.
* A processor is used to ensure that a Model is created.
* A processor is used to ensure that a Model has been created.
*
* @see SymfonyMapQueryStringDescriber
*/
Expand Down
2 changes: 1 addition & 1 deletion Processors/MapRequestPayloadProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

/**
* A processor that adds query parameters to operations that have a MapRequestPayload attribute.
* A processor is used to ensure that a Model is created.
* A processor is used to ensure that a Model has been created.
*
* @see SymfonyMapRequestPayloadDescriber
*/
Expand Down
43 changes: 42 additions & 1 deletion Resources/doc/symfony_attributes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,52 @@ Complete example
}
}
Customization
----------------------

Imagine you want to add, modify, or remove some documentation for a route argument. For that you will have to create your own describer which implements the :class:`RouteArgumentDescriberInterface`_ interface.
Register your route argument describer
~~~~~~~
Before you can use your custom describer you must register it in your route argument describer as a service and tag it with ``nelmio_api_doc.route_argument_describer``.
Services implementing the :class:`RouteArgumentDescriberInterface`_ interface are automatically detected and used by NelmioApiDocBundle.
.. configuration-block::
.. code-block:: yaml
# config/services.yaml
services:
App\Describer\CustomRouteArgumentDescriber:
tags:
- { name: nelmio_api_doc.route_argument_describer }
.. code-block:: xml
<!-- config/services.xml -->
<service id="App\Describer\CustomRouteArgumentDescriber">
<tag name="nelmio_api_doc.route_argument_describer" />

Check failure on line 177 in Resources/doc/symfony_attributes.rst

View workflow job for this annotation

GitHub Actions / Lint (DOCtor-RST)

Please remove space before "/>"
</service>
.. code-block:: php
// config/services.php
use App\Describer\CustomRouteArgumentDescriber;
return function (ContainerConfigurator $container) {
$container->services()
->set(CustomRouteArgumentDescriber::class)
->tag('nelmio_api_doc.route_argument_describer')
;
};
Disclaimer
----------------------
Make sure to use at least php 8 (annotations) to make use of this functionality
Make sure to use at least php 8.1 (attribute support) to make use of this functionality.
.. _`Symfony MapQueryString`: https://symfony.com/doc/current/controller.html#mapping-the-whole-query-string
.. _`Symfony MapQueryParameter`: https://symfony.com/doc/current/controller.html#mapping-query-parameters-individually
.. _`Symfony MapRequestPayload`: https://symfony.com/doc/current/controller.html#mapping-request-payload
.. _`RouteArgumentDescriberInterface`: https://github.com/DjordyKoert/NelmioApiDocBundle/blob/master/RouteDescriber/RouteArgumentDescriber/SymfonyMapQueryParameterDescriber.php

0 comments on commit 6135a63

Please sign in to comment.