NelmioApiDocBundle/Resources/doc/alternative_names.rst
Filip Benčo 78664ef9ec
OpenApi 3 Support (#1623)
* Initial pass for OA3 upgrade

* Fix Util Tests

* Fix first batch of Unit Tests. Up to Model

* Another batch of fixed tests

* Update annotations

* Convert Model & Property Describers

* Update tests, Fix RouteDescribers, FIx additional bugs

* Another batch of updates

* Another batch of fixed Functional Tests

* Fix FunctionalTest tests

* Fix Bazinga Tests

* FIx FOS Rest

* Fix JMS TEsts & describers

* Fix all Tests

* Fix few stuff from own CR

* CS Fixes

* CS Fixes 2

* CS Fixes 3

* CS Fixes 4

* Remove collection bug

* Updates after first CRs

* CS

* Drop support for SF3

* Update the docs

* Add an upgrade guide

* misc doc fixes

* Configurable media types

* Code Style Fixes

* Don't use ::$ref for @Response and @RequestBody

* Fix upgrading guide

* Fix OA case

Co-authored-by: Filip Benčo <filip.benco@websupport.sk>
Co-authored-by: Guilhem Niot <guilhem.niot@gmail.com>
Co-authored-by: Mantis Development <mantis@users.noreply.github.com>
2020-05-28 13:19:11 +02:00

52 lines
1.7 KiB
ReStructuredText

Alternative Names
=================
NelmioApiDoc automatically generates the model names but the ``nelmio_api_doc.models.names`` option allows to
customize the names for some models.
Configuration
-------------
You can define alternative names for each group and area combinations: when conflicts arises, the last matching rule will be used:
.. code-block:: yaml
nelmio_api_doc:
models:
names:
- { alias: MainUser, type: App\Entity\User}
- { alias: MainUser_light, type: App\Entity\User, groups: [light] }
- { alias: MainUser_secret, type: App\Entity\User, areas: [private] }
- { alias: MainUser, type: App\Entity\User, groups: [standard], areas: [private] }
In this case the class ``App\Entity\User`` will be aliased into:
- ``MainUser`` when no more detailed rules are specified
- ``MainUser_light`` when the group is equal to ``light``
- ``MainUser_secret`` for the ``private`` area
- ``MainUser`` for the ``private`` area when the group is equal to ``standard``
.. tip::
This allows to use normal references instead of ``@Model``. Notably, you can specify
the groups used for a model once in config and then refer to its alternative name:
.. code-block:: yaml
nelmio_api_doc:
models:
names: [ { alias: MyModel, type: App\MyModel, groups: [light] }]
.. code-block:: php
class HomeController
{
/**
* @OA\Response(response=200, @OA\JsonContent(@OA\Schema(ref="#/components/schemas/MyModel")))
*/
public function indexAction()
{
}
}