Giter Club home page Giter Club logo

yii2-rest-doc's People

Contributors

csminb avatar michkarevev avatar pahanini avatar pastuhov avatar pavel-ekt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

yii2-rest-doc's Issues

Strict Warning

PHP Strict Warning 'yii\base\ErrorException' with message 'Declaration of pahanini\restdoc\models\ControllerParser::parse() should be compatible with pahanini\restdoc\models\Parser::parse($doc)'

in /path/to/project/vendor/pahanini/yii2-rest-doc/models/ControllerParser.php:11

"phpunit/phpunit" : "6.*",

Hi,

please remove it from composer require part.

add it to "require-dev": { if you need this specific version.

best Péter

not inherit @restdoc-link

<?php

/**
 * A class.
 *
 * @property int $id ID
 * @property string $name Some name
 */
class A extends \yii\db\ActiveRecord {

  /**
   * @restdoc-link $id
   * @restdoc-link $name
   */
  public function fields() {
    return [
      'id',
      'name',
    ];
  }
}
<?php

/**
 * @inheritdoc
 */
class B extends A {

  /**
   * @inheritdoc
   * @restdoc-field string $created_at Date of create
   */
  public function fields() {
    return [
      'id',
      'name',
      'created_at',
    ];
  }
}

Result fo A class:

Attribute Type Description
id int ID
name string Some name

Result for B class:

Attribute Type Description
id
name
created_at string Date of create

Please Create Better Documentation

I'm not understand about how to use this package, please add example and step by step how to use it, give screenshoot for every step is better

Getting unknown property TestController::modelClass

Why you search modelClass? I can use many models in one controller...

api/TestController.php

/**
 * Test Controller
 *
 * @restdoc-label Test controller
 *
 */
class TestController extends Controller
{
    public function behaviors()
    {
        $behaviors = parent::behaviors();
        $behaviors['authenticator'] = [
            'class' => \yii\filters\auth\CompositeAuth::className(),
            'authMethods' => [
                \yii\filters\auth\HttpBasicAuth::className(),
                \yii\filters\auth\HttpBearerAuth::className(),
                \yii\filters\auth\QueryParamAuth::className(),
            ],
        ];
        return $behaviors;
    }

    /**
     * Gets users profile info
     *
     * @return Profile
     *
     * @throws NotFoundHttpException
     */
    public function actionProfile()
    {
        return $this->findModel(Yii::$app->user->identity->id)->profile;
    }

    /**
     * Creates new entry of [[Network]] for current user
     *
     * << REST API USAGE >>
     *
     * @restdoc-field int $network Type of network from special list of networks
     * @restdoc-field string $access_token Access token received from social network
     * @restdoc-field string $secret_token Secret token received from social network
     * @restdoc-field string $refresh_token Refresh token received from social network
     * @restdoc-field string $token_type Token type received from social network
     * @restdoc-field string $network_user_id Id of user in current network
     * 
     * @return string If success
     */
    public function actionAddNetwork()
    {
        Network::deleteAll([
            'user_id' => Yii::$app->user->identity->id,
            'network' => Yii::$app->request->post('network'),
        ]);

        $social = new Network();
        $social->user_id = Yii::$app->user->identity->id;

        $social->load(Yii::$app->request->getBodyParams(), '');

        if ($social->save()) {
            return ['success' => true];
        }

        return $social;
    }

    public function findModel($id)
    {
        if (($model = User::findOne($id)) !== null) {
            return $model;
        } else {
            throw new NotFoundHttpException("Object not found");
        }
    }
}

php 7 codestyle use

when use aka php7

use common/models{
     Class1, Class2
}; 

fatal error

Parse Error: Syntax error, unexpected '{', expecting T_STRING on line 9
Exception 'yii\base\InvalidParamException' with message 'File /var/www/html/frontend/modules/api/modules/v3/controllers/RecommendationController.php includes more then one class'

Order of controllers

It would be great, if i can specify index of ordering controllers in resulting document

Composer conflicts with phpdocumentor -> phpspecs -> phpunit

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Conclusion: don't install pahanini/yii2-rest-doc dev-master
    - Conclusion: don't install pahanini/yii2-rest-doc 0.0.10
    - Conclusion: don't install pahanini/yii2-rest-doc 0.0.9
    - Conclusion: don't install pahanini/yii2-rest-doc 0.0.8
    - Conclusion: don't install pahanini/yii2-rest-doc 0.0.7
    - Conclusion: don't install pahanini/yii2-rest-doc 0.0.6
    - Conclusion: don't install pahanini/yii2-rest-doc 0.0.5
    - Conclusion: don't install pahanini/yii2-rest-doc 0.0.4
    - Conclusion: don't install pahanini/yii2-rest-doc 0.0.3
    - Conclusion: don't install pahanini/yii2-rest-doc 0.0.2
    - Conclusion: don't install pahanini/yii2-rest-doc 0.0.1
    - Conclusion: remove phpdocumentor/reflection-docblock 4.3.0
    - Installation request for pahanini/yii2-rest-doc * -> satisfiable by pahanini/yii2-rest-doc[0.0.1, 0.0.10, 0.0.2, 0.0.3, 0.0.4, 0.0.5, 0.0.6, 0.0.7, 0.0.8, 0.0.9, dev-analysis-zOPEwa, dev-master].
    - Conclusion: don't install phpdocumentor/reflection-docblock 4.3.0
    - pahanini/yii2-rest-doc dev-analysis-zOPEwa requires phpdocumentor/reflection-docblock ~2.0 -> satisfiable by phpdocumentor/reflection-docblock[2.0.0, 2.0.0a1, 2.0.0a2, 2.0.0a3, 2.0.1, 2.0.2, 2.0.3, 2.0.4, 2.0.5].
    - Can only install one of: phpdocumentor/reflection-docblock[2.0.0, 4.3.0].
    - Can only install one of: phpdocumentor/reflection-docblock[2.0.0a1, 4.3.0].
    - Can only install one of: phpdocumentor/reflection-docblock[2.0.0a2, 4.3.0].
    - Can only install one of: phpdocumentor/reflection-docblock[2.0.0a3, 4.3.0].
    - Can only install one of: phpdocumentor/reflection-docblock[2.0.1, 4.3.0].
    - Can only install one of: phpdocumentor/reflection-docblock[2.0.2, 4.3.0].
    - Can only install one of: phpdocumentor/reflection-docblock[2.0.3, 4.3.0].
    - Can only install one of: phpdocumentor/reflection-docblock[2.0.4, 4.3.0].
    - Can only install one of: phpdocumentor/reflection-docblock[2.0.5, 4.3.0].
    - Installation request for phpdocumentor/reflection-docblock (locked at 4.3.0) -> satisfiable by phpdocumentor/reflection-docblock[4.3.0].


Installation failed, reverting ./composer.json to its original content.

phpdocumentor is a phpspecs dependency that, in turn, is a phpunit dependency.

It seems to be a bug since we can't remove phpunit. Any workarounds?

Thank you.

if field not comprised in the list (method field()) she not comprised in the rest-dock

We have a class:

/**
 * A class.
 * 
 * @property int a `a` field 
 * @property int b `b` field
 * @property int c `c` field
 */
class A extends ActiveRecord {

  /**
   * @restdock-link a
   * @restdock-link b
   */
  public function fields()
  {
    return [
      'a',
      'b',
    ];
  }

  public function rules(){
    return [
      ['a', 'required'],
      ['c', 'required'],
    ];
  }
}

And we get documentation:

Obaining record

Attribute Type Description
a int a field
b int b field

Create record

Attribute Type Description
a int a field

As you can see documentation not contain c attribute in section Create record.

I got an error when I execute "build-rest-doc" with yii console

`$ ./yii build-rest-doc/run
Exception 'yii\base\InvalidCallException' with message 'Setting read-only property: yii\console\Application::view'

Stack trace:
#0 /home/v/sites/yii2adv/vendor/yiisoft/yii2/BaseYii.php(521): yii\base\Component->__set('view', Array)
#1 /home/v/sites/yii2adv/vendor/yiisoft/yii2/base/Object.php(105): yii\BaseYii::configure(Object(yii\console\Application), Array)
#2 /home/v/sites/yii2adv/vendor/yiisoft/yii2/base/Application.php(206): yii\base\Object->__construct(Array)
#3 /home/v/sites/yii2adv/vendor/yiisoft/yii2/console/Application.php(89): yii\base\Application->__construct(Array)
#4 /home/v/sites/yii2adv/yii(26): yii\console\Application->__construct(Array)
#5 {main}

I've already set up twig and installed slate like #8 said. Can you help me to analyze the problem where it is?thank you @pahanini

Can't generate documentation.

When I run the command >php yii build-rest-doc, I do not get any error, but the generated html file is containing has the same content as the template(restdoc.twig).
What could cause this problem ?

Thank you in advance.

Route to resource

Hello. How can i specify url route to resource? Maybe you can add new retsdoc-parameter like restdoc-route to your ControllerDoc?

Read Me is confusing

As a noob in slate, api documentation & twig, the ReadMe doesn't explain how to set this up from scratch. I set up and configured this and it ran successfully, but just gives me some plain 'nice-documentation.html' file. Then what? Where do you put this? What do you do with it? What folder structure should I put this in considering my API is a module?

not implement multiple type

<?php
/**
 * A class.
 */
class A extends \yii\db\ActiveRecord {

  /**
   * @restdoc-field int $id ID
   * @restdoc-field string|null $name Some name
   */
  public function fields() {
    return [
      'id',
      'name',
    ];
  }
}

expected:

Attribute Type Description
id int ID
name string null

actual:

Attribute Type Description
id int ID
name string null

Can't generate HTML

I installed the configured as in the instruction. Then I ran
php yii build-rest-doc/run
The generated html file is exactly as the template(restdoc.twig). How can I use it?

Output file is just twig code

Trying to use this command- ./yii build-rest-doc/run

For some reason it just takes the twig code and puts it into my html file.

Here is my config -

controllerMap' => [
        'build-rest-doc' => [
            'sourceDirs' => [
                '@app/api/controllers',
            ],
            'template' => '//restdoc/restdoc.twig',
            'class' => '\pahanini\restdoc\controllers\BuildController',
            'sortProperty' => 'shortDescription', // <-- default value (how controllers will be sorted)
            'targetFile' => 'api/web/docs/index.html'
        ],
    ],

The command runs without any errors.

index.md for slate

Hi,

do you have maybe an example for creating slate index.md? that would be very useful!

best Péter

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.