NelmioApiDocBundle/Resources/doc/multiple-api-doc.rst

60 lines
1.4 KiB
ReStructuredText
Raw Normal View History

2015-10-27 10:27:13 +01:00
Multiple API Documentation ("Views")
2016-03-05 19:46:43 +01:00
====================================
2015-10-27 10:27:13 +01:00
2016-03-05 19:46:43 +01:00
With the ``views`` tag in the ``@ApiDoc`` annotation, it is possible to create
2015-10-27 10:27:13 +01:00
different views of your API documentation. Without the tag, all methods are
2016-03-05 19:46:43 +01:00
located in the ``default`` view, and can be found under the normal API
2015-10-27 10:27:13 +01:00
documentation url.
2016-08-10 10:37:07 +02:00
You can specify one or more *view* names under which the method will be
2015-10-27 10:27:13 +01:00
visible.
2016-03-05 19:46:43 +01:00
An example::
2015-10-27 10:27:13 +01:00
/**
* A resource
*
* @ApiDoc(
* resource=true,
* description="This is a description of your API method",
* views = { "default", "premium" }
* )
*/
public function getAction()
{
}
/**
* Another resource
*
* @ApiDoc(
* resource=true,
* description="This is a description of another API method",
* views = { "premium" }
* )
*/
public function getAnotherAction()
{
}
In this case, only the first resource will be available under the default view,
2016-03-05 19:46:43 +01:00
while both methods will be available under the ``premium`` view.
2015-10-27 10:27:13 +01:00
2016-03-05 19:46:43 +01:00
Accessing Specific API Views
----------------------------
2015-10-27 10:27:13 +01:00
2016-03-05 19:46:43 +01:00
The ``default`` view can be found at the normal location. Other views can be
found at ``http://your.documentation/<view name>``.
2015-10-27 10:27:13 +01:00
For instance, if your documentation is located at:
2016-03-05 19:46:43 +01:00
.. code-block:: text
2015-10-27 10:27:13 +01:00
2016-03-05 19:46:43 +01:00
http://example.org/doc/api/v1/
2015-10-27 10:27:13 +01:00
2016-03-05 19:46:43 +01:00
then the ``premium`` view will be located at:
2015-10-27 10:27:13 +01:00
2016-03-05 19:46:43 +01:00
.. code-block:: text
2015-10-27 10:27:13 +01:00
2016-03-05 19:46:43 +01:00
http://example.org/doc/api/v1/premium