NelmioApiDocBundle ================== [![Build Status](https://secure.travis-ci.org/nelmio/NelmioApiDocBundle.png?branch=1.0.x)](http://travis-ci.org/nelmio/NelmioApiDocBundle) The **NelmioApiDocBundle** bundle allows you to generate a decent documentation for your APIs. ## Installation ## This bundle uses [KnpMarkdownBundle](https://github.com/KnpLabs/KnpMarkdownBundle). Register the namespace in `app/autoload.php`: // app/autoload.php $loader->registerNamespaces(array( // ... 'Nelmio' => __DIR__.'/../vendor/bundles', 'Knp' => __DIR__.'/../vendor/bundles', )); Register the bundles in `app/AppKernel.php`: // app/AppKernel.php public function registerBundles() { return array( // ... new Nelmio\ApiDocBundle\NelmioApiDocBundle(), new Knp\Bundle\MarkdownBundle\KnpMarkdownBundle(), ); } Import the routing definition in `routing.yml`: # app/config/routing.yml NelmioApiDocBundle: resource: "@NelmioApiDocBundle/Resources/config/routing.yml" prefix: /api/doc Enable the bundle's configuration in `app/config/config.yml`: # app/config/config.yml nelmio_api_doc: ~ ## Usage ## The main problem with documentation is to keep it up to date. That's why the **NelmioApiDocBundle** uses introspection a lot. Thanks to an annotation, it's really easy to document an API method. ### The ApiDoc() annotation ### The bundle provides an `ApiDoc()` annotation for your controllers: ``` php add('note', null, array( 'description' => 'this is a note', )); // ... } } ``` The bundle will also get information from the routing definition (`requirements`, `pattern`, etc), so to get the best out of it you should define strict _method requirements etc. ### Documentation on-the-fly ### By calling an URL with the parameter `?_doc=1`, you will get the corresponding documentation if available. ### Web Interface ### You can browse the whole documentation at: `http://example.org/api/doc`. ![](https://github.com/nelmio/NelmioApiDocBundle/raw/master/Resources/doc/webview.png) ![](https://github.com/nelmio/NelmioApiDocBundle/raw/master/Resources/doc/webview2.png) ### Command ### A command is provided in order to dump the documentation in `json`, `markdown`, or `html`. php app/console api:doc:dump [--format="..."] The `--format` option allows to choose the format (default is: `markdown`). For example to generate a static version of your documentation you can use: php app/console api:doc:dump --format=html > api.html ## Configuration ## You can specify your own API name: # app/config/config.yml nelmio_api_doc: name: My API ## Credits ## The design is heavily inspired by the [swagger-ui](https://github.com/wordnik/swagger-ui) project.