{"id":286,"date":"2022-05-29T17:54:04","date_gmt":"2022-05-29T09:54:04","guid":{"rendered":"https:\/\/www.osvlabs.com\/blog\/?p=286"},"modified":"2022-05-29T17:54:04","modified_gmt":"2022-05-29T09:54:04","slug":"laravel-%e6%8e%a5%e5%8f%a3%e6%96%87%e6%a1%a3%e7%94%9f%e6%88%90%e5%ba%93-laravel-apidoc-generator-3-0-%e4%bb%8b%e7%bb%8d","status":"publish","type":"post","link":"https:\/\/blog.osvlabs.com\/?p=286","title":{"rendered":"Laravel \u63a5\u53e3\u6587\u6863\u751f\u6210\u5e93 laravel-apidoc-generator 3.0 \u4ecb\u7ecd"},"content":{"rendered":"<p><a href=\"https:\/\/github.com\/mpociot\/laravel-apidoc-generator\">laravel-apidoc-generator<\/a>\u662f\u4e00\u4e2a\u751f\u6210 <code>laravel\/lumen<\/code>\u63a5\u53e3\u6587\u6863\u5e76\u652f\u6301\u5feb\u6377\u5bfc\u5165<code>postman<\/code>\u7684\u5e93\uff0c\u5728\u7248\u672c<code>3.0.2<\/code>\u4e2d\u4f7f\u7528\u5982\u4e0b:<\/p>\n<blockquote>\n<p>\u5b89\u88c5\u4f7f\u7528\u6839\u636egithub\u4f7f\u7528\u8bf4\u660e\u30023.0\u9700\u8981 PHP &gt; 7, Laravel &gt;= 5.5<\/p>\n<\/blockquote>\n<ol>\n<li>\u82e5\u4f7f\u7528 <code>php artisan vendor:publish --provider=Mpociot\\ApiDoc\\ApiDocGeneratorServiceProvider --tag=config<\/code> \u547d\u4ee4\u5e76\u6ca1\u6709\u5728<code>config<\/code>\u76ee\u5f55\u4e0b\u751f\u6210 <code>apidoc.php<\/code> \u6587\u4ef6\uff0c\u53ef\u4ee5\u4f7f\u7528 <code>php artisan vendor:publish<\/code> \u624b\u52a8\u9009\u62e9 apidoc.<\/li>\n<li>\u5728 <code>apidoc.php<\/code> \u91cc\u53ef\u4ee5\u914d\u7f6e\u6587\u6863\u5c5e\u6027\uff0c\u6bd4\u5982\u5728:\n<pre><code>&#039;apply&#039; =&gt; [\n            \/*\n             * Specify headers to be added to the example requests\n             *\/\n            &#039;headers&#039; =&gt; [\n                 &#039;Authorization&#039; =&gt; &#039;Bearer: {token}&#039;,\n                \/\/ &#039;Api-Version&#039; =&gt; &#039;v2&#039;,\n            ],<\/code><\/pre>\n<p>\u53ef\u4ee5\u914d\u7f6e\u8bf7\u6c42\u7684 <code>headers<\/code>\u4fe1\u606f<\/p>\n<\/li>\n<li>\u6ce8\u610f\u5728<\/li>\n<\/ol>\n<pre><code>   &#039;response_calls&#039; =&gt; [\n                    \/*\n                     * API calls will be made only for routes in this group matching these HTTP methods (GET, POST, etc).\n                     * List the methods here or use &#039;*&#039; to mean all methods. Leave empty to disable API calls.\n                     *\/\n                    &#039;methods&#039; =&gt; [],<\/code><\/pre>\n<p><code>methods<\/code>\u9700\u8981\u6539\u4e3a<code>[]<\/code>,\u9ed8\u8ba4\u662f <code>get<\/code>,\u5982\u679c\u662f<code>get<\/code>\u7684\u8bdd\u5982\u679c\u6709 <code>get<\/code>\u8bf7\u6c42\u7684\u63a5\u53e3\uff0c\u6587\u6863\u7684\u5bfc\u5165\u5230<code>postman<\/code>\u94fe\u63a5\u4f1a\u5931\u6548\u3002<\/p>\n<ol start=\"4\">\n<li>\u751f\u6210\u6587\u6863\u65f6\u8df3\u8fc7\u67d0\u63a5\u53e3:<\/li>\n<\/ol>\n<pre><code>\u5728\u63a5\u53e3\u7684\u65b9\u6cd5\u91cc:\n\/**\n *@hideFromAPIDocumentation\n*\/<\/code><\/pre>\n<ol start=\"5\">\n<li>api\u53c2\u6570:\n<pre><code>\/**\n *  upload_callback\n *  \u4e0a\u4f20\u6210\u529f\u56de\u8c03\n *\n * @bodyParam path string required \u4e0a\u4f20\u8def\u5f84\n * @bodyParam device_no string required \u8bbe\u5907ID\n * @bodyParam record_time int \u89c6\u9891\u5f55\u5236\u65f6\u95f4\n * @bodyParam upload_by int required \u4e0a\u4f20\u8005\n * @bodyParam project_id int required \u5f53\u524d\u9879\u76eeID\n * @bodyParam hash string required \u6587\u4ef6\u7684hash\n * @bodyParam upload_type int required 1-&gt;\u89c6\u9891, 2-&gt;\u68c0\u6d4b\u6587\u4ef6, 3-&gt;\u8eab\u4efd\u8ba4\u8bc1, 4-&gt;\u73af\u5883\u8ba4\u8bc1\n *\n * @param UploadCallbackRequest $request\n *\n * @return \\Illuminate\\Http\\JsonResponse\n *\/<\/code><\/pre>\n<\/li>\n<\/ol>\n<p><img src=\"https:\/\/raw.githubusercontent.com\/Attiv\/tubed\/master\/20220529174557.png\" alt=\"\" \/><\/p>\n<ol start=\"6\">\n<li>\u5bfc\u5165\u5230postman:<br \/>\n\u5728\u8fd0\u884c <code>php artisan apidoc:generate<\/code> \u4e4b\u540e\u751f\u6210\u7684api\u6587\u6863\u7f51\u9875\u9ed8\u8ba4\u5728 <code>public\/doc<\/code>\u76ee\u5f55\u4e0b<br \/>\n\u6253\u5f00\u7f51\u9875\uff0c\u70b9\u51fb\u5982\u679c\u6240\u793a<br \/>\n<img src=\"https:\/\/raw.githubusercontent.com\/Attiv\/tubed\/master\/20220529164733.png\" alt=\"\" \/><br \/>\n\u590d\u5236\u7f51\u9875\u91cc\u7684\u5185\u5bb9\uff0c\u6253\u5f00 <code>postman<\/code> , \u70b9\u51fb <code>import<\/code><br \/>\n<img src=\"https:\/\/raw.githubusercontent.com\/Attiv\/tubed\/master\/20220529174705.png\" alt=\"\" \/><br \/>\n\u7c98\u8d34\uff0c\u70b9\u51fb <code>import<\/code><br \/>\n<img src=\"https:\/\/raw.githubusercontent.com\/Attiv\/tubed\/master\/20220529174811.png\" alt=\"\" \/><br \/>\n\u5728 <code>collections<\/code>\u91cc\u9762\u5c31\u4f1a\u6709\u521a\u5bfc\u5165\u7684\u63a5\u53e3\uff0c\u5df2\u7ecf\u81ea\u52a8\u586b\u5145\u4e86\u63a5\u53e3\u6240\u9700\u53c2\u6570\u540d<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>laravel-apidoc-generator\u662f\u4e00\u4e2a\u751f\u6210 laravel\/lumen\u63a5\u53e3\u6587\u6863\u5e76\u652f\u6301\u5feb\u6377\u5bfc\u5165postman\u7684\u5e93\uff0c\u5728\u7248\u672c3.0.2\u4e2d\u4f7f\u7528\u5982\u4e0b: \u5b89\u88c5\u4f7f\u7528\u6839\u636egithub\u4f7f\u7528\u8bf4\u660e\u30023.0\u9700\u2026<\/p>\n","protected":false},"author":4,"featured_media":288,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[],"blocksy_meta":{"styles_descriptor":{"styles":{"desktop":"","tablet":"","mobile":""},"google_fonts":[],"version":5}},"_links":{"self":[{"href":"https:\/\/blog.osvlabs.com\/index.php?rest_route=\/wp\/v2\/posts\/286"}],"collection":[{"href":"https:\/\/blog.osvlabs.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.osvlabs.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.osvlabs.com\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.osvlabs.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=286"}],"version-history":[{"count":1,"href":"https:\/\/blog.osvlabs.com\/index.php?rest_route=\/wp\/v2\/posts\/286\/revisions"}],"predecessor-version":[{"id":287,"href":"https:\/\/blog.osvlabs.com\/index.php?rest_route=\/wp\/v2\/posts\/286\/revisions\/287"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.osvlabs.com\/index.php?rest_route=\/wp\/v2\/media\/288"}],"wp:attachment":[{"href":"https:\/\/blog.osvlabs.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=286"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.osvlabs.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=286"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.osvlabs.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=286"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}