Browse Source

Merge pull request #16 from lucasmichot/feature/master/long-statement

Shorten a very long statement
Marcel Pociot 9 năm trước cách đây
mục cha
commit
ed7838bcf9
1 tập tin đã thay đổi với 6 bổ sung1 xóa
  1. 6 1
      src/Mpociot/ApiDoc/ApiDocGenerator.php

+ 6 - 1
src/Mpociot/ApiDoc/ApiDocGenerator.php

@@ -24,13 +24,18 @@ class ApiDocGenerator
         $routeAction = $route->getAction();
         $response = $this->getRouteResponse($route);
         $routeDescription = $this->getRouteDescription($routeAction['uses']);
+        if ($response->headers->get('Content-Type') === 'application/json') {
+            $content = json_encode(json_decode($response->getContent()), JSON_PRETTY_PRINT);
+        } else {
+            $content = $response->getContent();
+        }
         $routeData = [
             'title' => $routeDescription['short'],
             'description' => $routeDescription['long'],
             'methods' => $route->getMethods(),
             'uri' => $route->getUri(),
             'parameters' => [],
-            'response' => ($response->headers->get('Content-Type') === 'application/json') ? json_encode(json_decode($response->getContent()), JSON_PRETTY_PRINT) : $response->getContent(),
+            'response' => $content,
         ];
 
         $validator = Validator::make([], $this->getRouteRules($routeAction['uses']));