diff --git a/composer.json b/composer.json index cda381b..b02b413 100644 --- a/composer.json +++ b/composer.json @@ -12,5 +12,8 @@ "psr-4": { "JsonRpc\\": "src/" } + }, + "require-dev": { + "itxq/api-doc-php": "^1.1" } } diff --git a/composer.lock b/composer.lock index b79ca2a..7423d5a 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "20228fdc76a78774b09e7d2ba713c22a", + "content-hash": "2bc6549f9c92876a91cb2530fc974c23", "packages": [ { "name": "doctrine/inflector", @@ -1598,7 +1598,50 @@ "time": "2018-12-06T10:45:32+00:00" } ], - "packages-dev": [], + "packages-dev": [ + { + "name": "itxq/api-doc-php", + "version": "v1.1.1", + "source": { + "type": "git", + "url": "https://github.com/itxq/api-doc-php.git", + "reference": "79ac71cf09da49491cfb92722d6f6e13ad8f6482" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/itxq/api-doc-php/zipball/79ac71cf09da49491cfb92722d6f6e13ad8f6482", + "reference": "79ac71cf09da49491cfb92722d6f6e13ad8f6482", + "shasum": "", + "mirrors": [ + { + "url": "https://dl.laravel-china.org/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "php": ">=5.6.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "itxq\\apidoc\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "IT小强xqitw.cn", + "email": "360237521@qq.com" + } + ], + "description": "api-doc-php", + "time": "2018-06-24T04:20:25+00:00" + } + ], "aliases": [], "minimum-stability": "stable", "stability-flags": [], diff --git a/src/Server/JsonRpcServerDoc.php b/src/Server/JsonRpcServerDoc.php index 2db5e61..ddc3dc8 100644 --- a/src/Server/JsonRpcServerDoc.php +++ b/src/Server/JsonRpcServerDoc.php @@ -2,6 +2,8 @@ namespace JsonRpc\Server; +use itxq\apidoc\BootstrapApiDoc; + class JsonRpcDoc { @@ -18,10 +20,9 @@ class JsonRpcDoc { $methods = []; foreach ($this->map as $key => $item) { - $methods[] = [ - 'method' => $key, - 'desc' => $this->desc($item[0], $item[1]), - ]; + if (!in_array($item[0], $methods)) { + $methods[] = $item[0]; + } } return $methods; } @@ -32,16 +33,13 @@ class JsonRpcDoc /** * @var $view Factory */ - $view = view(); - - dump($this->methods()); - exit; - - $view->share('methods', $this->methods()); - - return $view->exists('doc') ? - $view->make('doc') : - $view->file(__DIR__ . '/../views/doc.blade.php'); + $config = [ + 'class' => $this->methods(), + 'filter_method' => [], + ]; + $api = new BootstrapApiDoc($config); + $doc = $api->getHtml(); + exit($doc); } protected function desc($class, $method)