@php use Knuckles\Scribe\Tools\Utils as u; /** @var Knuckles\Camel\Output\OutputEndpointData $endpoint */ @endphp

{{ $endpoint->name() }}

@component('scribe::components.badges.auth', ['authenticated' => $endpoint->isAuthed()]) @endcomponent

{!! Parsedown::instance()->text($endpoint->metadata->description ?: '') !!}
{{ u::trans("scribe::endpoint.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)

{{ u::trans("scribe::endpoint.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, "<>"))
{!! u::trans("scribe::endpoint.responses.binary") !!} - {{ htmlentities(str_replace("<>", "", $response->content)) }}
@elseif($response->status == 204)
{!! u::trans("scribe::endpoint.responses.empty") !!}
@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

{{ u::trans("scribe::endpoint.request") }}    @if($metadata['try_it_out']['enabled'] ?? false)    @endif

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

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

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

{{ u::trans("scribe::endpoint.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))

{{ u::trans("scribe::endpoint.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, 'example' => $parameter->example ?? '', 'enumValues' => $parameter->enumValues, 'endpointId' => $endpoint->endpointId(), 'component' => 'url', 'isInput' => true, ]) @endcomponent
@endforeach @endif @if(count($endpoint->queryParameters))

{{ u::trans("scribe::endpoint.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, 'example' => $parameter->example ?? '', 'enumValues' => $parameter->enumValues, 'endpointId' => $endpoint->endpointId(), 'component' => 'query', 'isInput' => true, 'html' => $htmlOptions, ]) @endcomponent
@endforeach @endif @if(count($endpoint->nestedBodyParameters))

{{ u::trans("scribe::endpoint.body_parameters") }}

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

{{ u::trans("scribe::endpoint.response") }}

{{ u::trans("scribe::endpoint.response_fields") }}

@endif