X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/5c6a6b50a0c4d42fa245fa7aa8c2e7315d56e3ff..refs/pull/3099/head:/app/Api/ApiDocsGenerator.php diff --git a/app/Api/ApiDocsGenerator.php b/app/Api/ApiDocsGenerator.php index d130304de..4cba7900b 100644 --- a/app/Api/ApiDocsGenerator.php +++ b/app/Api/ApiDocsGenerator.php @@ -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;