From 73dee2ba792a852c8681c9504139fb51e116a5ac Mon Sep 17 00:00:00 2001 From: shalvah Date: Thu, 11 Oct 2018 15:13:32 +0100 Subject: [PATCH] Add custom headers to generated doc --- phpunit.xml | 2 +- resources/views/partials/route.blade.php | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/phpunit.xml b/phpunit.xml index a006d680..8875a97f 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -7,7 +7,7 @@ convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" - stopOnFailure="false"> + stopOnFailure="true"> tests/ diff --git a/resources/views/partials/route.blade.php b/resources/views/partials/route.blade.php index 02e340a6..b2367d1e 100644 --- a/resources/views/partials/route.blade.php +++ b/resources/views/partials/route.blade.php @@ -11,7 +11,13 @@ ```bash curl -X {{$parsedRoute['methods'][0]}} {{$parsedRoute['methods'][0] == 'GET' ? '-G ' : ''}}"{{ trim(config('app.docs_url') ?: config('app.url'), '/')}}/{{ ltrim($parsedRoute['uri'], '/') }}" \ - -H "Accept: application/json"@if(count($parsedRoute['parameters'])) \ + -H "Accept: application/json"@if(count($parsedRoute['headers'])) \ +@foreach($parsedRoute['headers'] as $header => $value) + -H "{{$header}}"="{{$value}}" @if(! ($loop->last))\ + @endif +@endforeach +@endif +@if(count($parsedRoute['parameters'])) \ @foreach($parsedRoute['parameters'] as $attribute => $parameter) -d "{{$attribute}}"="{{$parameter['value']}}" @if(! ($loop->last))\ @endif @@ -30,7 +36,10 @@ "data": {!! str_replace("\n}","\n }", str_replace(' ',' ',json_encode(array_combine(array_keys($parsedRoute['parameters']), array_map(function($param){ return $param['value']; },$parsedRoute['parameters'])), JSON_PRETTY_PRINT))) !!}, @endif "headers": { - "accept": "application/json" + "accept": "application/json", +@foreach($parsedRoute['headers'] as $header => $value) + "{{$header}}": "{{$value}}", +@endforeach } }