PHPackages                             nostop8/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. nostop8/rest-api-doc

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

nostop8/rest-api-doc
====================

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

1.1.2(5y ago)1919.9k↓73.6%14[1 PRs](https://github.com/nostop8/yii2-rest-api-doc/pulls)MITPHP

Since Aug 22Pushed 5y ago3 watchersCompare

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

READMEChangelogDependencies (2)Versions (5)Used By (0)

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 nostop8/rest-api-doc`;

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

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

```
'modules' => [
  ...
  'documentation' => 'nostop8\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)

```
