From d79be997020193d06b98fdf202552c895a6c5a1b Mon Sep 17 00:00:00 2001 From: shalvah Date: Thu, 24 Jun 2021 23:38:51 +0100 Subject: [PATCH] Theme fixes --- camel/Camel.php | 4 +++- resources/views/components/body-parameters.blade.php | 7 +++---- .../views/partials/example-requests/bash.md.blade.php | 5 +++-- resources/views/themes/default/index.blade.php | 2 +- src/Extracting/ApiDetails.php | 1 - src/Writing/HtmlWriter.php | 5 +++-- 6 files changed, 13 insertions(+), 11 deletions(-) diff --git a/camel/Camel.php b/camel/Camel.php index 96a0d755..e8fd8f67 100644 --- a/camel/Camel.php +++ b/camel/Camel.php @@ -150,7 +150,9 @@ public static function groupEndpoints(array $endpoints, array $endpointGroupInde 'description' => Arr::first($endpointsInGroup, function (ExtractedEndpointData $endpointData) { return !empty($endpointData->metadata->groupDescription); })->metadata->groupDescription ?? '', - 'endpoints' => $sortedEndpoints->map(fn(ExtractedEndpointData $endpointData) => $endpointData->forSerialisation()->toArray())->values()->all(), + 'endpoints' => $sortedEndpoints->map( + fn(ExtractedEndpointData $endpointData) => $endpointData->forSerialisation()->toArray() + )->values()->all(), ]; })->values()->all(); } diff --git a/resources/views/components/body-parameters.blade.php b/resources/views/components/body-parameters.blade.php index 7c77df41..8e64c8c8 100644 --- a/resources/views/components/body-parameters.blade.php +++ b/resources/views/components/body-parameters.blade.php @@ -3,7 +3,8 @@ @if($name === '[]')

Body: {{ $parameter['type'] }} {!! Parsedown::instance()->text($parameter['description'] ?? '') !!} - @foreach($parameter['__fields'] as $subfieldName => $subfield) +

+ @foreach($parameter['__fields'] as $subfieldName => $subfield) @if(!empty($subfield['__fields'])) @component('scribe::components.body-parameters', ['parameters' => [$subfieldName => $subfield], 'endpointId' => $endpointId,]) @endcomponent @@ -22,11 +23,10 @@

@endif @endforeach -

@elseif(!empty($parameter['__fields']))

- + @component('scribe::components.field-details', [ 'name' => $parameter['name'], 'type' => $parameter['type'] ?? 'string', @@ -38,7 +38,6 @@ ]) @endcomponent -
@foreach($parameter['__fields'] as $subfieldName => $subfield) @if(!empty($subfield['__fields'])) @component('scribe::components.body-parameters', ['parameters' => [$subfieldName => $subfield], 'endpointId' => $endpointId,]) diff --git a/resources/views/partials/example-requests/bash.md.blade.php b/resources/views/partials/example-requests/bash.md.blade.php index d9bacdc9..220edbc0 100644 --- a/resources/views/partials/example-requests/bash.md.blade.php +++ b/resources/views/partials/example-requests/bash.md.blade.php @@ -23,6 +23,7 @@ @endforeach @endforeach @elseif(count($endpoint->cleanBodyParameters)) - --data "{!! addslashes(json_encode($endpoint->cleanBodyParameters, JSON_UNESCAPED_UNICODE)) !!}" + --data "{!! addslashes(json_encode($endpoint->cleanBodyParameters, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)) !!}" @endif -``` + +``` \ No newline at end of file diff --git a/resources/views/themes/default/index.blade.php b/resources/views/themes/default/index.blade.php index cfd65ab4..a25c0efe 100644 --- a/resources/views/themes/default/index.blade.php +++ b/resources/views/themes/default/index.blade.php @@ -30,7 +30,7 @@ - + MENU diff --git a/src/Extracting/ApiDetails.php b/src/Extracting/ApiDetails.php index ab4bf50a..51dcadcf 100644 --- a/src/Extracting/ApiDetails.php +++ b/src/Extracting/ApiDetails.php @@ -52,7 +52,6 @@ public function writeMarkdownFiles(): void ConsoleOutputUtils::info('Extracted intro and auth Markdown files to: ' . $this->markdownOutputPath); } - public function writeIntroMarkdownFile(): void { $introMarkdownFile = $this->markdownOutputPath . '/intro.md'; diff --git a/src/Writing/HtmlWriter.php b/src/Writing/HtmlWriter.php index bb71dad7..55c300a0 100644 --- a/src/Writing/HtmlWriter.php +++ b/src/Writing/HtmlWriter.php @@ -94,8 +94,9 @@ protected function transformMarkdownFileToHTML(string $markdownFilePath): string protected function getMetadata(): array { - // NB:These paths are wrong for laravel type but will be set correctly by the Writer class $links = []; + + // NB:These paths are wrong for laravel type but will be set correctly by the Writer class if ($this->config->get('postman.enabled', true)) { $links[] = 'View Postman collection'; } @@ -120,7 +121,7 @@ protected function getMetadata(): array 'last_updated' => date("F j Y"), 'auth' => $auth, 'try_it_out' => $this->config->get('try_it_out'), - 'links' => $links + ['Documentation powered by Scribe ✍'], + 'links' => array_merge($links, ['Documentation powered by Scribe ✍']), ]; } }