diff --git a/resources/views/partials/example-requests/python.blade.php b/resources/views/partials/example-requests/python.blade.php index 55bded8c..155414f8 100644 --- a/resources/views/partials/example-requests/python.blade.php +++ b/resources/views/partials/example-requests/python.blade.php @@ -3,6 +3,15 @@ import json url = '{{ rtrim($baseUrl, '/') }}/{{ ltrim($route['boundUri'], '/') }}' +@if(count($route['fileParameters'])) +files = { +@foreach($route['fileParameters'] as $name => $file) + '{!! $name !!}': open('{!! $file->path() !!}', 'rb')@if(!($loop->last)), +@endif +@endforeach + +} +@endif @if(count($route['cleanBodyParameters'])) payload = {!! json_encode($route['cleanBodyParameters'], JSON_PRETTY_PRINT) !!} @endif @@ -17,7 +26,16 @@ @endforeach } + @endif -response = requests.request('{{$route['methods'][0]}}', url{{ count($route['headers']) ?', headers=headers' : '' }}{{ count($route['cleanBodyParameters']) ? ', json=payload' : '' }}{{ count($route['cleanQueryParameters']) ? ', params=params' : ''}}) +@php +$optionalArguments = []; +if (count($route['headers'])) $optionalArguments[] = "headers=headers"; +if (count($route['fileParameters'])) $optionalArguments[] = "files=files"; +if (count($route['cleanBodyParameters'])) $optionalArguments[] = (count($route['fileParameters']) ? "data=payload" : "json=payload"); +if (count($route['cleanQueryParameters'])) $optionalArguments[] = "params=params"; +$optionalArguments = implode(', ',$optionalArguments); +@endphp +response = requests.request('{{$route['methods'][0]}}', url, {{ $optionalArguments }}) response.json() ``` diff --git a/todo.md b/todo.md index 36f799de..45908ae6 100644 --- a/todo.md +++ b/todo.md @@ -1,12 +1,3 @@ -# Documentation tasks -- Rewritten docs. Some things to document: - - plugin api: responses - description, $stage property, scribe:strategy - - fileParams - # Release blocker - Port recent changes from old repo -# Features -- Possible feature: https://github.com/mpociot/laravel-apidoc-generator/issues/731 -- file input python -