]> BookStack Code Mirror - bookstack/blobdiff - app/Api/ApiDocsGenerator.php
Update verify-totp.blade.php
[bookstack] / app / Api / ApiDocsGenerator.php
index ea77ae45084cd91b8a3db1d13f546372629ce77b..4cba7900b7942adca030e193647b99f0622dc6c5 100644 (file)
@@ -28,7 +28,7 @@ class ApiDocsGenerator
         if (Cache::has($cacheKey) && config('app.env') === 'production') {
             $docs = Cache::get($cacheKey);
         } else {
-            $docs = (new static())->generate();
+            $docs = (new ApiDocsGenerator())->generate();
             Cache::put($cacheKey, $docs, 60 * 24);
         }
 
@@ -55,10 +55,16 @@ class ApiDocsGenerator
     {
         return $routes->map(function (array $route) {
             $exampleTypes = ['request', 'response'];
+            $fileTypes = ['json', 'http'];
             foreach ($exampleTypes as $exampleType) {
-                $exampleFile = base_path("dev/api/{$exampleType}s/{$route['name']}.json");
-                $exampleContent = file_exists($exampleFile) ? file_get_contents($exampleFile) : null;
-                $route["example_{$exampleType}"] = $exampleContent;
+                foreach ($fileTypes as $fileType) {
+                    $exampleFile = base_path("dev/api/{$exampleType}s/{$route['name']}." . $fileType);
+                    if (file_exists($exampleFile)) {
+                        $route["example_{$exampleType}"] = file_get_contents($exampleFile);
+                        continue 2;
+                    }
+                }
+                $route["example_{$exampleType}"] = null;
             }
 
             return $route;