PHPackages                             autoxloo/rest-api-doc - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. autoxloo/rest-api-doc

ActiveYii2-extension[HTTP &amp; Networking](/categories/http)

autoxloo/rest-api-doc
=====================

Forked from https://github.com/nostop8/yii2-rest-api-doc

0.0.7(7y ago)0901MITPHP

Since Apr 17Pushed 4y ago2 watchersCompare

[ Source](https://github.com/autoxloo/yii2-rest-api-doc)[ Packagist](https://packagist.org/packages/autoxloo/rest-api-doc)[ RSS](/packages/autoxloo-rest-api-doc/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (1)

yii2-rest-api-doc
=================

[](#yii2-rest-api-doc)

Simple documentation generator for Yii2 REST applications based on defined API endpoints and actions annotations.

Installation
------------

[](#installation)

- Run `composer require autoxloo/rest-api-doc`;

Alternatively add into `require` section of your `composer.json` following string `"autoxloo/rest-api-doc": "1.0"` and run `composer update`

- In your application config file inside `modules` section add

```
'modules' => [
  ...
  'documentation' => 'autoxloo\yii2\rest_api_doc\Module',
  ...
],

```

- In your application config file inside `bootstrap` section add:

```
'bootstrap' => [
  ...
  'documentation'
  ...
],

```

Please, note. You may change `documentation` into any other word, which would be better to call documentation for your REST API.

- Now run your application at `http:///documentation` and if you did everything correct, you shoul see something like this: [![alt tag](https://camo.githubusercontent.com/1ee4385125a0593aaea5a1e76ed25e1031a62c62bc9e484e29760db8dbd576ae/687474703a2f2f692e696d6775722e636f6d2f757739316552362e706e67)](https://camo.githubusercontent.com/1ee4385125a0593aaea5a1e76ed25e1031a62c62bc9e484e29760db8dbd576ae/687474703a2f2f692e696d6775722e636f6d2f757739316552362e706e67)

Usage
-----

[](#usage)

- First of all you should know that this documentation generator will work only in case you define your REST API endpoints using following principles:
- Currently you can define for you endpoints following annotations types, which will be later displayed/provided by API documentation generator:

1. Rest Description: Your endpoint description.
2. Rest Fields: \['field1', 'field2'\] or \['field3', 'field4'\]. (Please, note: `or` and array after it is extra and might be skipped if your service accepts only one type of body)
3. Rest Filters: \['filter1', 'filter2'\].
4. Rest Expand: \['expandRelation1', 'expandRelation2'\].

- In case you are using CRUD services, which does not require endpoints to be defined (because they are already predefined inside `yii\rest\UrlRule` -  and implemented inside `\yii\rest\ActiveController`) and you still want to add some description, define in your controller empty methods with the same names (e.g. actionCreate, actionUpdate etc.) and add annotations to them as you would do for other actions implemented by you.

Example of annotations
----------------------

[](#example-of-annotations)

```
