Home > Back-end >  How to set @SWG\Info annotation for only area in Symfony using NelmioApiDocBundle
How to set @SWG\Info annotation for only area in Symfony using NelmioApiDocBundle

Time:09-22

/**
 * @SWG\Swagger(
 *   @SWG\Info(
 *     title="My first swagger documented API",
 *     version="1.0.0"
 *   )
 * )
 */

I tried to write this block in:

my base controller - src/MyProject/ApiBundle/Controller/SiteApi/SiteApiBaseController.php

my bundle file - src/MyProject/ApiBundle/MyProjectApiBundle.php

Generated JSON contains empty "info": {"title": ""}

Symfony 3.4, NelmioApiDocBundle 3.9.1(including zircote/swagger-php 2.0.9)

CodePudding user response:

• For controller try:

 /**
    use FOS\RestBundle\Controller\Annotations as Rest;
    use Swagger\Annotations as SWG;
    ...

     * Add Tva.         
     * @Rest\Post("/tva/add")
     * @SWG\Tag(name="TVA Management")
      ...
      ...
     * @SWG\Response(response=201, description="Tva created successfully.")
      ...
      ...
    */

=> You will get something like this:

You will get something like this

• For api/doc page Title, Description & Version, try to edit this file:

~Your_Project_Path\config\packages\nelmio_api_doc.yaml
  • Related