承接 nostop8/rest-api-doc 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

nostop8/rest-api-doc

Composer 安装命令:

composer require nostop8/rest-api-doc

包简介

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

README 文档

README

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

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://<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.

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.

Extra Tip

While developing API which should be depended on 3-rd party that are not available yet for some reason, it might be useful for you to use an external online API mocking tool - QuickMocker. It is also useful while integrating your application with webhooks to debug requests that arrive from some 3-rd party while you do not host your application remotely.

nostop8/rest-api-doc 适用场景与选型建议

nostop8/rest-api-doc 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 20.2k 次下载、GitHub Stars 达 19, 最近一次更新时间为 2016 年 05 月 02 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「generator」 「documentation」 「rest」 「api」 「yii2」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 nostop8/rest-api-doc 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 nostop8/rest-api-doc 我们能提供哪些服务?
定制开发 / 二次开发

基于 nostop8/rest-api-doc 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 20.2k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 20
  • 点击次数: 8
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 19
  • Watchers: 3
  • Forks: 14
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-05-02