Browse Source

[BUGFIXES] Header containing ":" + invalid "showresponse" condition (#242)

* [BUGFIX] Header containing ":" values management

* [CHANGE] To pass styleci.io tests

* [BUGFIX] Invalid condition test to display response
Fabien SOMNIER 7 years ago
parent
commit
4a78f3db0f

+ 4 - 2
src/Mpociot/ApiDoc/Generators/AbstractGenerator.php

@@ -112,9 +112,11 @@ abstract class AbstractGenerator
 
         // Split headers into key - value pairs
         $headers = collect($headers)->map(function ($value) {
-            $split = explode(':', $value);
+            $split = explode(':', $value); // explode to get key + values
+            $key = array_shift($split); // extract the key and keep the values in the array
+            $value = implode(':', $split); // implode values into string again
 
-            return [trim($split[0]) => trim($split[1])];
+            return [trim($key) => trim($value)];
         })->collapse()->toArray();
 
         //Changes url with parameters like /users/{user} to /users/1

+ 1 - 1
src/resources/views/partials/route.blade.php

@@ -38,7 +38,7 @@ $.ajax(settings).done(function (response) {
 });
 ```
 
-@if(in_array('GET',$parsedRoute['methods']) || isset($parsedRoute['showresponse']) && $parsedRoute['showresponse'])
+@if(in_array('GET',$parsedRoute['methods']) || (isset($parsedRoute['showresponse']) && $parsedRoute['showresponse']))
 > Example response:
 
 ```json