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

{{ $endpoint->name() }}

@foreach($endpoint->httpMethods as $method)
{{ $method }}
@endforeach
{{ rtrim($baseUrl, '/') }}
/{{ ltrim($endpoint->uri, '/') }}
@if($endpoint->metadata->authenticated)
requires authentication
@endif
{!! Parsedown::instance()->text($endpoint->metadata->description ?: '') !!}
@if(count($endpoint->headers))

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

@foreach($endpoint->headers as $header => $value) @component('scribe::themes.elements.components.field-details', [ 'name' => $header, 'type' => null, 'required' => false, 'description' => null, 'example' => $value, 'endpointId' => $endpoint->endpointId(), 'component' => 'header', 'isInput' => true, ]) @endcomponent @endforeach
@endif @if(count($endpoint->urlParameters))

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

@foreach($endpoint->urlParameters as $attribute => $parameter) @component('scribe::themes.elements.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) @component('scribe::themes.elements.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, ]) @endcomponent @endforeach
@endif @if(count($endpoint->nestedBodyParameters))

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

@component('scribe::themes.elements.components.nested-fields', [ 'fields' => $endpoint->nestedBodyParameters, 'endpointId' => $endpoint->endpointId(), ]) @endcomponent
@endif @if(count($endpoint->responseFields))

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

@component('scribe::themes.elements.components.nested-fields', [ 'fields' => $endpoint->nestedResponseFields, 'endpointId' => $endpoint->endpointId(), 'isInput' => false, ]) @endcomponent
@endif
@if($metadata['try_it_out']['enabled'] ?? false) @include("scribe::themes.elements.try_it_out") @endif @if($metadata['example_languages'])
{{ u::trans("scribe::endpoint.example_request") }}:
@foreach($metadata['example_languages'] as $index => $language)
@include("scribe::partials.example-requests.$language")
@endforeach
@endif @if($endpoint->isGet() || $endpoint->hasResponses())
{{ u::trans("scribe::endpoint.example_response") }}:
@foreach($endpoint->responses as $index => $response)
@if(count($response->headers))
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