فهرست منبع

Merge pull request #368 from vanderbake/master

Add custom logo support
Shalvah A 6 سال پیش
والد
کامیت
92226ed67d
2فایلهای تغییر یافته به همراه19 افزوده شده و 0 حذف شده
  1. 11 0
      config/apidoc.php
  2. 8 0
      src/Commands/GenerateDocumentation.php

+ 11 - 0
config/apidoc.php

@@ -143,4 +143,15 @@ return [
             ],
         ],
     ],
+
+    /*
+     * Custom logo path. Will be copied during generate command. Set this to false to use the default logo.
+     *
+     * Change to an absolute path to use your custom logo. For example:
+     * 'logo' => resource_path('views') . '/api/logo.png'
+     *
+     * If you want to use this, please be aware of the following rules:
+     * - size: 230 x 52
+     */
+    'logo' => false,
 ];

+ 8 - 0
src/Commands/GenerateDocumentation.php

@@ -8,6 +8,7 @@ use Illuminate\Console\Command;
 use Mpociot\Reflection\DocBlock;
 use Illuminate\Support\Collection;
 use Mpociot\ApiDoc\Tools\RouteMatcher;
+use Illuminate\Support\Facades\Storage;
 use Mpociot\ApiDoc\Generators\Generator;
 use Mpociot\Documentarian\Documentarian;
 use Mpociot\ApiDoc\Postman\CollectionWriter;
@@ -169,6 +170,13 @@ class GenerateDocumentation extends Command
 
             file_put_contents($outputPath.DIRECTORY_SEPARATOR.'collection.json', $this->generatePostmanCollection($parsedRoutes));
         }
+
+        if ($logo = config('apidoc.logo')) {
+            Storage::copy(
+                $logo,
+                $outputPath.DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.'logo.png'
+            );
+        }
     }
 
     /**