X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/45b5e631e241e7809d8752279d781ec391245423..refs/pull/1973/head:/app/Api/ApiDocsGenerator.php diff --git a/app/Api/ApiDocsGenerator.php b/app/Api/ApiDocsGenerator.php index 41decd23d..a0c45608a 100644 --- a/app/Api/ApiDocsGenerator.php +++ b/app/Api/ApiDocsGenerator.php @@ -31,9 +31,12 @@ class ApiDocsGenerator protected function loadDetailsFromFiles(Collection $routes): Collection { return $routes->map(function (array $route) { - $exampleResponseFile = base_path('dev/api/responses/' . $route['name'] . '.json'); - $exampleResponse = file_exists($exampleResponseFile) ? file_get_contents($exampleResponseFile) : null; - $route['example_response'] = $exampleResponse; + $exampleTypes = ['request', 'response']; + 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; + } return $route; }); }