diff --git a/config/scribe.php b/config/scribe.php index 95fea297..a1662723 100644 --- a/config/scribe.php +++ b/config/scribe.php @@ -17,7 +17,8 @@ 'description' => '', /* - * The base URL displayed in the docs. If this is empty, Scribe will use the value of config('app.url'). + * The base URL displayed in the docs. If this is empty, Scribe will use the value of config('app.url') at generation time. + * If you're using `laravel`` type, you can set this to a dynamic string, like '{{ config("app.tenant_url") }}' to get a dynamic base URL. */ 'base_url' => null, @@ -189,7 +190,7 @@ /** * The base URL for the API tester to use (for example, you can set this to your staging URL). - * Leave as null to use the current app URL (config(app.url)). + * Leave as null to use the current app URL when generating (config("app.url")). */ 'base_url' => null, diff --git a/resources/views/partials/example-requests/bash.md.blade.php b/resources/views/partials/example-requests/bash.md.blade.php index 25945ab4..87c67ce1 100644 --- a/resources/views/partials/example-requests/bash.md.blade.php +++ b/resources/views/partials/example-requests/bash.md.blade.php @@ -4,7 +4,7 @@ @endphp ```bash curl --request {{$endpoint->httpMethods[0]}} \ - {{$endpoint->httpMethods[0] == 'GET' ? '--get ' : ''}}"{{ rtrim($baseUrl, '/')}}/{{ ltrim($endpoint->boundUri, '/') }}@if(count($endpoint->cleanQueryParameters))?{!! u::printQueryParamsAsString($endpoint->cleanQueryParameters) !!}@endif"@if(count($endpoint->headers)) \ + {{$endpoint->httpMethods[0] == 'GET' ? '--get ' : ''}}"{!! rtrim($baseUrl, '/') !!}/{{ ltrim($endpoint->boundUri, '/') }}@if(count($endpoint->cleanQueryParameters))?{!! u::printQueryParamsAsString($endpoint->cleanQueryParameters) !!}@endif"@if(count($endpoint->headers)) \ @foreach($endpoint->headers as $header => $value) --header "{{$header}}: {{ addslashes($value) }}"@if(! ($loop->last) || ($loop->last && count($endpoint->bodyParameters))) \ @endif diff --git a/resources/views/partials/example-requests/javascript.md.blade.php b/resources/views/partials/example-requests/javascript.md.blade.php index f0755684..3dc9335b 100644 --- a/resources/views/partials/example-requests/javascript.md.blade.php +++ b/resources/views/partials/example-requests/javascript.md.blade.php @@ -4,7 +4,7 @@ @endphp ```javascript const url = new URL( - "{{ rtrim($baseUrl, '/') }}/{{ ltrim($endpoint->boundUri, '/') }}" + "{!! rtrim($baseUrl, '/') !!}/{{ ltrim($endpoint->boundUri, '/') }}" ); @if(count($endpoint->cleanQueryParameters)) @@ -53,7 +53,7 @@ body, @elseif(count($endpoint->cleanBodyParameters)) @if ($endpoint->headers['Content-Type'] == 'application/x-www-form-urlencoded') - body: body, + body, @else body: JSON.stringify(body), @endif diff --git a/resources/views/partials/example-requests/php.md.blade.php b/resources/views/partials/example-requests/php.md.blade.php index ac9637a3..36db15ff 100644 --- a/resources/views/partials/example-requests/php.md.blade.php +++ b/resources/views/partials/example-requests/php.md.blade.php @@ -4,9 +4,10 @@ @endphp ```php $client = new \GuzzleHttp\Client(); +$url = '{!! rtrim($baseUrl, '/') . '/' . ltrim($endpoint->boundUri, '/') !!}'; @if($endpoint->hasHeadersOrQueryOrBodyParams()) $response = $client->{{ strtolower($endpoint->httpMethods[0]) }}( - '{{ rtrim($baseUrl, '/') . '/' . ltrim($endpoint->boundUri, '/') }}', + $url, [ @if(!empty($endpoint->headers)) 'headers' => {!! u::printPhpValue($endpoint->headers, 8) !!}, @@ -43,7 +44,7 @@ ] ); @else -$response = $client->{{ strtolower($endpoint->httpMethods[0]) }}('{{ rtrim($baseUrl, '/') . '/' . ltrim($endpoint->boundUri, '/') }}'); +$response = $client->{{ strtolower($endpoint->httpMethods[0]) }}($url); @endif $body = $response->getBody(); print_r(json_decode((string) $body)); diff --git a/resources/views/partials/example-requests/python.md.blade.php b/resources/views/partials/example-requests/python.md.blade.php index 49200c20..6ba7bad1 100644 --- a/resources/views/partials/example-requests/python.md.blade.php +++ b/resources/views/partials/example-requests/python.md.blade.php @@ -6,7 +6,7 @@ import requests import json -url = '{{ rtrim($baseUrl, '/') }}/{{ $endpoint->boundUri }}' +url = '{!! rtrim($baseUrl, '/') !!}/{{ $endpoint->boundUri }}' @if($endpoint->hasFiles() || (isset($endpoint->headers['Content-Type']) && $endpoint->headers['Content-Type'] == 'multipart/form-data' && count($endpoint->cleanBodyParameters))) files = { @foreach($endpoint->cleanBodyParameters as $parameter => $value)