Nelmioapidocbundle: How to specify content requirements?

Created on 3 Jun 2014  路  7Comments  路  Source: nelmio/NelmioApiDocBundle

Hey,

I am wondering how to document the specification of my content.
My API takes an json object from the content. I want to document which requirments to this json object are expected.

Thanks in advance.

Most helpful comment

The phpdoc is parsed and then put into the Description section of the documentation of each endpoint.

You can write whatever you want:

class MyController
{
      /**
       * Get information for a given user.
       *
       * ### Minimal Response (e.g. anonymous) ###
       *
       *     {
       *       "user": {
       *         "id": 999,
       *         "updatedAt": "2012-04-14 21:50:58",
       *         "createdAt": "2012-04-14 21:48:27"
       *       }
       *     }
       *
       *
       * ### Full Response ###
       *
       *     {
       *       "user": {
       *         "updatedAt": "2012-04-14 21:50:58",
       *         "createdAt": "2012-04-14 21:48:27",
       *         "firstName": "XXXXXX",
       *         "lastName": "xxxxxx",
       *         "address": "Xxxxxxxx 99"
       *      }
       *    }
       */
       public function myAction() {}

All 7 comments

I put this information in the phpdoc. It supports markdown.

Can you please provide an example?

And will it be shown in the /api/doc ?

The phpdoc is parsed and then put into the Description section of the documentation of each endpoint.

You can write whatever you want:

class MyController
{
      /**
       * Get information for a given user.
       *
       * ### Minimal Response (e.g. anonymous) ###
       *
       *     {
       *       "user": {
       *         "id": 999,
       *         "updatedAt": "2012-04-14 21:50:58",
       *         "createdAt": "2012-04-14 21:48:27"
       *       }
       *     }
       *
       *
       * ### Full Response ###
       *
       *     {
       *       "user": {
       *         "updatedAt": "2012-04-14 21:50:58",
       *         "createdAt": "2012-04-14 21:48:27",
       *         "firstName": "XXXXXX",
       *         "lastName": "xxxxxx",
       *         "address": "Xxxxxxxx 99"
       *      }
       *    }
       */
       public function myAction() {}

Great! Thanks a lot

mh I tried this but there is no output...

Added the comment just below @ApiDoc

It should be put before annotations.

thanks again

Was this page helpful?
0 / 5 - 0 ratings