Browse Source

Merge remote-tracking branch 'remotes/origin/master' into v4

shalvah 5 năm trước cách đây
mục cha
commit
a7023db077

+ 6 - 0
CHANGELOG.md

@@ -13,6 +13,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 ### Removed
 
+## [3.17.1] - Thursday, 12 September 2019
+### Fixed
+- ResponseCalls: Call Lumen application correctly since it does not use HttpKernel (https://github.com/mpociot/laravel-apidoc-generator/pull/585)
+- Update usage of `clean*Parameters` in python template (https://github.com/mpociot/laravel-apidoc-generator/commit/02fb719d0d6c25e6ce72f30dc8b9604449061156)
+- Bugfix: *really* exclude parameters from examples, not just send empty strings (https://github.com/mpociot/laravel-apidoc-generator/commit/762e2e1003d389d6e785d31144eca89c40515926, https://github.com/mpociot/laravel-apidoc-generator/commit/e54b474578b53f97f4737664a63131b315aaf82d)
+
 ## [3.17.0] - Saturday, 7 September 2019
 ### Added
 - Switched to a plugin architecture that allows support for external strategies (https://github.com/mpociot/laravel-apidoc-generator/pull/570)

+ 15 - 9
resources/views/partials/example-requests/python.blade.php

@@ -5,22 +5,28 @@ import json
 url = '{{ rtrim($baseUrl, '/') }}/{{ ltrim($route['boundUri'], '/') }}'
 @if(count($route['cleanBodyParameters']))
 payload = {
-	@foreach($route['cleanBodyParameters'] as $attribute => $parameter)
-	    '{{ $attribute }}': '{{ $parameter['value'] }}'@if(!($loop->last)),@endif  {{ !$parameter['required'] ? '# optional' : '' }}
-	@endforeach
+@foreach($route['cleanBodyParameters'] as $parameter => $value)
+    '{{ $parameter }}': '{{ $value }}'@if(!($loop->last)),
+@endif
+@endforeach
+
 }
 @endif
 @if(count($route['cleanQueryParameters']))
 params = {
-	@foreach($route['cleanQueryParameters'] as $attribute => $parameter)
-	    '{{ $attribute }}': '{{ $parameter['value'] }}'@if(!($loop->last)),@endif  {{ !$parameter['required'] ? '# optional' : '' }}
-	@endforeach
+@foreach($route['cleanQueryParameters'] as $parameter => $value)
+	'{{ $parameter }}': '{{ $value }}'@if(!($loop->last)),
+@endif
+@endforeach
+
 }
 @endif
 headers = {
-	@foreach($route['headers'] as $header => $value)
-	    '{{$header}}': '{{$value}}'@if(!($loop->last)),@endif
-	@endforeach
+@foreach($route['headers'] as $header => $value)
+	'{{$header}}': '{{$value}}'@if(!($loop->last)),
+@endif
+@endforeach
+
 }
 response = requests.request('{{$route['methods'][0]}}', url, headers=headers{{ count($route['cleanBodyParameters']) ? ', json=payload' : '' }}{{ count($route['cleanQueryParameters']) ? ', params=params' : ''}})
 response.json()

+ 10 - 3
src/Strategies/Responses/ResponseCalls.php

@@ -286,9 +286,16 @@ class ResponseCalls extends Strategy
      */
     protected function callLaravelRoute(Request $request): \Symfony\Component\HttpFoundation\Response
     {
-        $kernel = app(\Illuminate\Contracts\Http\Kernel::class);
-        $response = $kernel->handle($request);
-        $kernel->terminate($request, $response);
+        // Confirm we're running in Laravel, not Lumen
+        if (app()->bound(\Illuminate\Contracts\Http\Kernel::class)) {
+            $kernel = app(\Illuminate\Contracts\Http\Kernel::class);
+            $response = $kernel->handle($request);
+            $kernel->terminate($request, $response);
+        } else {
+            // Handle the request using the Lumen application.
+            $kernel = app();
+            $response = $kernel->handle($request);
+        }
 
         return $response;
     }

+ 1 - 1
src/Tools/Traits/DocBlockParamHelpers.php

@@ -33,7 +33,7 @@ trait DocBlockParamHelpers
     protected function parseParamDescription(string $description, string $type)
     {
         $example = null;
-        if (preg_match('/(.*)\s+Example:\s*(.*)\s*/', $description, $content)) {
+        if (preg_match('/(.*)\s+Example:\s*(.+)\s*/', $description, $content)) {
             $description = $content[1];
 
             // examples are parsed as strings by default, we need to cast them properly