{{-- Copyright (c) ppy Pty Ltd . Licensed under the GNU Affero General Public License v3.0. See the LICENCE file in the repository root for full licence text. --}} @php /** @var Knuckles\Camel\Output\OutputEndpointData $endpoint */ use App\Libraries\ApidocRouteHelper; $uri = $endpoint->uri; $methods = $endpoint->httpMethods; $descriptions = explode("\n---\n", $endpoint->metadata->description ?? ''); $topDescription = $descriptions[0]; $bottomDescription = $descriptions[1] ?? ''; $isApiUri = substr($uri, 0, 6) === 'api/v2'; // either remove api/v2 prefix or add full url $displayUri = $isApiUri ? substr($uri, 6) : $GLOBALS['cfg']['app']['url'].$uri; $helper = ApidocRouteHelper::instance(); @endphp @if ($showEndpointTitle ?? true)

{{ $endpoint->name() }}

@endif @if ($isApiUri)

@if ($helper->getAuth($methods, $uri)) requires user @endif @foreach($helper->getScopeTags($methods, $uri) as $scope) {{ ApidocRouteHelper::scopeBadge($scope) }} @endforeach

@endif {!! Parsedown::instance()->text($topDescription) !!}
Example request:
@foreach($metadata['example_languages'] as $language)
@include("scribe::partials.example-requests.$language")
@endforeach
@if($endpoint->isGet() || $endpoint->hasResponses()) @foreach($endpoint->responses as $response)

Example response ({{ $response->fullDescription() }}):

@if(count($response->headers))
Show headers
@foreach($response->headers as $header => $value)
{{ $header }}: {{ is_array($value) ? implode('; ', $value) : $value }}
@endforeach 
@endif
@if(is_string($response->content) && Str::startsWith($response->content, "<>"))
[Binary data] - {{ htmlentities(str_replace("<>", "", $response->content)) }}
@elseif($response->status == 204)
[Empty response]
@else
@php($parsed = json_decode($response->content))
{{-- If response is a JSON string, prettify it. Otherwise, just print it --}}
{!! htmlentities($parsed != null ? json_encode($parsed, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) : $response->content) !!}
@endif 
@endforeach @endif
@if ($showRequestTitle ?? true)

Request

@endif @foreach($endpoint->httpMethods as $method)

@component('scribe::components.badges.http-method', ['method' => $method])@endcomponent {{ $displayUri }}

@endforeach
@if(count($endpoint->headers))

Headers

@foreach($endpoint->headers as $name => $example) isAuthed() && $metadata['auth']['location'] == 'header' && $metadata['auth']['name'] == $name) { $htmlOptions = [ 'class' => 'auth-value', ]; } ?>
@component('scribe::components.field-details', [ 'name' => $name, 'type' => null, 'required' => true, 'description' => null, 'example' => $example, 'endpointId' => $endpoint->endpointId(), 'component' => 'header', 'isInput' => true, 'html' => $htmlOptions, ]) @endcomponent
@endforeach @endif @if(count($endpoint->urlParameters))

URL Parameters

@foreach($endpoint->urlParameters as $attribute => $parameter)
@component('scribe::components.field-details', [ 'name' => $parameter->name, 'type' => $parameter->type ?? 'string', 'required' => $parameter->required, 'description' => $parameter->description, // TODO: show correct example (from $parameter->example) 'example' => '', 'endpointId' => $endpoint->endpointId(), 'component' => 'url', 'isInput' => true, ]) @endcomponent
@endforeach @endif @if(count($endpoint->queryParameters))

Query Parameters

@foreach($endpoint->queryParameters as $attribute => $parameter) isAuthed() && $metadata['auth']['location'] == 'query' && $metadata['auth']['name'] == $attribute) { $htmlOptions = [ 'class' => 'auth-value', ]; } ?>
@component('scribe::components.field-details', [ 'name' => $parameter->name, 'type' => $parameter->type, 'required' => $parameter->required, 'description' => $parameter->description, // TODO: show correct example (from $parameter->example) 'example' => '', 'endpointId' => $endpoint->endpointId(), 'component' => 'query', 'isInput' => true, 'html' => $htmlOptions, ]) @endcomponent
@endforeach @endif @if(count($endpoint->nestedBodyParameters))

Body Parameters

@endif @if(count($endpoint->responseFields))

Response

Response Fields

@endif {!! Parsedown::instance()->text($bottomDescription) !!}