2013-11-14 11:43:09 +01:00
|
|
|
NelmioApiDocBundle
|
|
|
|
==================
|
|
|
|
|
|
|
|
The **NelmioApiDocBundle** bundle allows you to generate a decent documentation
|
|
|
|
for your APIs.
|
|
|
|
|
2015-10-27 10:27:13 +01:00
|
|
|
* [Installation](#installation)
|
|
|
|
* [Usage](#usage)
|
|
|
|
- [The `ApiDoc()` Annotation](the-apidoc-annotation.md)
|
|
|
|
- [Multiple API Documentation a.k.a. "Views"](multiple-api-doc.md)
|
|
|
|
- [Other Bundle Annotations](other-bundle-annotations.md)
|
|
|
|
- [Swagger Support](swagger-support.md)
|
|
|
|
- [DunglasApiBundle Support](dunglasapibundle.md)
|
|
|
|
- [Sandbox](sandbox.md)
|
|
|
|
- [Commands](commands.md)
|
|
|
|
* [Configuration In-Depth](configuration-in-depth.md)
|
|
|
|
* [Frequently Asked Questions](faq.md)
|
|
|
|
* [Configuration Reference](configuration-reference.md)
|
|
|
|
|
2013-11-14 11:43:09 +01:00
|
|
|
|
2013-12-05 17:10:38 +01:00
|
|
|
Installation
|
|
|
|
------------
|
2013-11-14 11:43:09 +01:00
|
|
|
|
2015-05-16 12:17:59 +02:00
|
|
|
Require the `nelmio/api-doc-bundle` package in your composer.json and update
|
|
|
|
your dependencies.
|
2013-11-14 11:43:09 +01:00
|
|
|
|
2014-10-21 21:24:58 +01:00
|
|
|
$ composer require nelmio/api-doc-bundle
|
2013-12-05 17:10:38 +01:00
|
|
|
|
2013-11-14 11:43:09 +01:00
|
|
|
Register the bundle in `app/AppKernel.php`:
|
|
|
|
|
2015-04-28 23:29:18 +02:00
|
|
|
```php
|
2014-09-21 05:04:16 +04:00
|
|
|
// app/AppKernel.php
|
|
|
|
public function registerBundles()
|
|
|
|
{
|
|
|
|
return array(
|
|
|
|
// ...
|
|
|
|
new Nelmio\ApiDocBundle\NelmioApiDocBundle(),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
```
|
2013-11-14 11:43:09 +01:00
|
|
|
|
|
|
|
Import the routing definition in `routing.yml`:
|
2015-05-16 12:17:59 +02:00
|
|
|
|
2014-07-31 10:18:25 -07:00
|
|
|
```yaml
|
|
|
|
# app/config/routing.yml
|
|
|
|
NelmioApiDocBundle:
|
|
|
|
resource: "@NelmioApiDocBundle/Resources/config/routing.yml"
|
|
|
|
prefix: /api/doc
|
|
|
|
```
|
2015-05-16 12:17:59 +02:00
|
|
|
|
2013-11-14 11:43:09 +01:00
|
|
|
Enable the bundle's configuration in `app/config/config.yml`:
|
2015-05-16 12:17:59 +02:00
|
|
|
|
2015-04-28 23:29:18 +02:00
|
|
|
```yaml
|
2014-07-31 10:18:25 -07:00
|
|
|
# app/config/config.yml
|
|
|
|
nelmio_api_doc: ~
|
|
|
|
```
|
2013-11-14 11:43:09 +01:00
|
|
|
|
2015-05-16 12:17:59 +02:00
|
|
|
The **NelmioApiDocBundle** requires Twig as a template engine so do not forget
|
|
|
|
to enable it:
|
|
|
|
|
2015-04-30 17:33:10 +02:00
|
|
|
```yaml
|
|
|
|
# app/config/config.yml
|
|
|
|
framework:
|
|
|
|
templating:
|
|
|
|
engines: ['twig']
|
|
|
|
```
|
|
|
|
|
2013-12-05 17:10:38 +01:00
|
|
|
Usage
|
|
|
|
-----
|
2013-11-14 11:43:09 +01:00
|
|
|
|
2015-05-16 12:17:59 +02:00
|
|
|
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
|
2015-10-27 10:27:13 +01:00
|
|
|
really easy to document an API method. The following chapters will help you
|
|
|
|
setup your API documentation:
|
2013-11-14 11:43:09 +01:00
|
|
|
|
2015-10-27 10:27:13 +01:00
|
|
|
* [The `ApiDoc()` Annotation](the-apidoc-annotation.md)
|
|
|
|
* [Multiple API Documentation a.k.a. "Views"](multiple-api-doc.md)
|
|
|
|
* [Other Bundle Annotations](other-bundle-annotations.md)
|
|
|
|
* [Swagger Support](swagger-support.md)
|
|
|
|
* [DunglasApiBundle Support](dunglasapibundle.md)
|
|
|
|
* [Sandbox](sandbox.md)
|
|
|
|
* [Commands](commands.md)
|
2013-12-05 00:05:47 +01:00
|
|
|
|
2014-01-10 11:16:09 +01:00
|
|
|
### 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)
|
2013-12-05 00:05:47 +01:00
|
|
|
|
2013-12-05 17:10:38 +01:00
|
|
|
### On-The-Fly Documentation
|
2013-11-14 11:43:09 +01:00
|
|
|
|
2013-12-05 17:10:38 +01:00
|
|
|
By calling an URL with the parameter `?_doc=1`, you will get the corresponding
|
|
|
|
documentation if available.
|