2017 © Pedro Peláez
 

yii2-extension rest-api-doc

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

image

fijas/rest-api-doc

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

  • Wednesday, January 17, 2018
  • by fijas
  • Repository
  • 1 Watchers
  • 1 Stars
  • 51 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 5 Forks
  • 0 Open issues
  • 10 Versions
  • 31 % Grown

The README.md

yii2-rest-api-doc

Simple documentation generator for Yii2 REST applications based on defined API endpoints and actions annotations. Forked from the excellent nostop8/yii2-rest-api-doc., (*1)

Installation

  • Run composer require fijas/rest-api-doc;

Alternatively add into require section of your composer.json following string "nostop8/rest-api-doc": "1.0" and run composer update - In your application config file inside modules section add, (*2)

'modules' => [
  ...
  'documentation' => [
    'class' => fijas\yii2\rest_api_doc\Module',
    //options (not required):
    'layout' => 'default',
    'title' => 'REST API Documentation
  ]
  ...
],
  • 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., (*3)

  • Now run your application at http://<yourappdomain>/documentation and if you did everything correct, you shoul see something like this: alt tag

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: http://www.yiiframework.com/doc-2.0/guide-rest-routing.html
  • 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 - http://www.yiiframework.com/doc-2.0/yii-rest-urlrule.html 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., (*4)

  • The documentation is rendered inside a default layout which can be altered to your liking by specifying the layout module option., (*5)

Example of annotations

<?php

namespace app\controllers;

class ExampleController extends \yii\rest\ActiveController
{

    /**
     * Rest Description: Your endpoint description.
     * Rest Fields: ['field1', 'field2'].
     * Rest Filters: ['filter1', 'filter2'].
     * Rest Expand: ['expandRelation1', 'expandRelation2'].
     */
    public function actionTest()
    {
        return ['field1', 'field2'];
    }
}

As you may see from this example, every annotation starts with its name and collon (:) and ends with a dot (.). Also the body of every annotation type might consist of PHP array. You must follow this rules in order to define properly documentation description and service testing functionality., (*6)

The Versions

17/01 2018

dev-master

9999999-dev

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

  Sources   Download

MIT

The Requires

 

by Volodymyr Dovbenko
by Fijas Pocker

api rest yii2 generator documentation docs

17/01 2018

1.3.2

1.3.2.0

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

  Sources   Download

MIT

The Requires

 

by Volodymyr Dovbenko
by Fijas Pocker

api rest yii2 generator documentation docs

11/11 2017

1.3.1

1.3.1.0

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

  Sources   Download

MIT

The Requires

 

by Volodymyr Dovbenko
by Fijas Pocker

api rest yii2 generator documentation docs

11/11 2017

1.3.0

1.3.0.0

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

  Sources   Download

MIT

The Requires

 

by Volodymyr Dovbenko
by Fijas Pocker

api rest yii2 generator documentation docs

10/11 2017

v1.1.0

1.1.0.0

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

  Sources   Download

MIT

The Requires

 

by Volodymyr Dovbenko
by Fijas Pocker

api rest yii2 generator documentation docs

23/06 2017

1.022

1.022.0.0

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

  Sources   Download

MIT

The Requires

 

by Volodymyr Dovbenko

api rest yii2 generator documentation

07/04 2017

1.021

1.021.0.0

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

  Sources   Download

MIT

The Requires

 

by Volodymyr Dovbenko

api rest yii2 generator documentation

25/03 2017

1.02

1.02.0.0

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

  Sources   Download

MIT

The Requires

 

by Volodymyr Dovbenko

api rest yii2 generator documentation

16/11 2016

1.01

1.01.0.0

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

  Sources   Download

MIT

The Requires

 

by Volodymyr Dovbenko

api rest yii2 generator documentation

22/08 2016

1.0

1.0.0.0

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

  Sources   Download

MIT

The Requires

 

by Volodymyr Dovbenko

api rest yii2 generator documentation