[Doc] Some minor fixes in index.rst

This commit is contained in:
Javier Eguiluz 2021-03-23 20:13:05 +01:00 committed by GitHub
parent 5e6140cd65
commit 051fca9070
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -72,7 +72,7 @@ Open a command console, enter your project directory and execute the following c
defaults: { _controller: nelmio_api_doc.controller.swagger } defaults: { _controller: nelmio_api_doc.controller.swagger }
As you just installed the bundle, you'll likely see routes you don't want in As you just installed the bundle, you'll likely see routes you don't want in
your documentation such as `/_profiler/`. To fix this, you can filter the your documentation such as ``/_profiler/``. To fix this, you can filter the
routes that are documented by configuring the bundle: routes that are documented by configuring the bundle:
.. code-block:: yaml .. code-block:: yaml
@ -140,8 +140,8 @@ To document your routes, you can use the SwaggerPHP annotations and the
class UserController class UserController
{ {
      /** /**
        * List the rewards of the specified user. * List the rewards of the specified user.
* *
* This call takes into account all confirmed awards, but not pending or refused awards. * This call takes into account all confirmed awards, but not pending or refused awards.
* *
@ -179,48 +179,49 @@ Use it instead of a definition reference and the bundle will deduce your model p
.. note:: .. note::
   A model can be a Symfony form type, a Doctrine ORM entity or a general PHP object. A model can be a Symfony form type, a Doctrine ORM entity or a general PHP object.
This annotation has two options: This annotation has two options:
* ``type`` to specify your model's type:: * ``type`` to specify your model's type::
/** /**
    * @SWG\Response( * @SWG\Response(
    * response=200, * response=200,
    *     @Model(type=User::class) * @Model(type=User::class)
    * ) * )
    */ */
* ``groups`` to specify the serialization groups used to (de)serialize your model:: * ``groups`` to specify the serialization groups used to (de)serialize your model::
  /** /**
    * @SWG\Response( * @SWG\Response(
    * response=200, * response=200,
    *     @Model(type=User::class, groups={"non_sensitive_data"}) * @Model(type=User::class, groups={"non_sensitive_data"})
    * ) * )
    */ */
.. tip:: .. tip::
When used at the root of ``@SWG\Response`` and ``@SWG\Parameter``, ``@Model`` is automatically nested When used at the root of ``@SWG\Response`` and ``@SWG\Parameter``, ``@Model``
in a ``@SWG\Schema``. is automatically nested in a ``@SWG\Schema``.
To use ``@Model`` directly within a ``@SWG\Schema``, ``@SWG\Items`` or ``@SWG\Property``, you have to use the ``$ref`` field:: To use ``@Model`` directly within a ``@SWG\Schema``, ``@SWG\Items`` or
``@SWG\Property``, you have to use the ``$ref`` field::
/** /**
* @SWG\Response( * @SWG\Response(
* @SWG\Schema(ref=@Model(type=User::class)) * @SWG\Schema(ref=@Model(type=User::class))
* ) * )
* *
* or * or
* *
* @SWG\Response( * @SWG\Response(
* @SWG\Schema(type="object", * @SWG\Schema(type="object",
* @SWG\Property(property="foo", ref=@Model(type=FooClass::class)) * @SWG\Property(property="foo", ref=@Model(type=FooClass::class))
* ) * )
* ) * )
*/ */
Symfony Form types Symfony Form types
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~