From c17ca0f5b168913fcb14e71a492efd2659f33eb8 Mon Sep 17 00:00:00 2001 From: hms5232 Date: Thu, 15 Aug 2024 19:41:18 +0800 Subject: [PATCH] fix: no tittle when not set custom html title This is why I use null coalescing. --- resources/views/editor.blade.php | 2 +- resources/views/ui.blade.php | 2 +- tests/SwaggerEditorTest.php | 8 ++++++++ tests/SwaggerUiTest.php | 8 ++++++++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/resources/views/editor.blade.php b/resources/views/editor.blade.php index d7a176c..09bea22 100644 --- a/resources/views/editor.blade.php +++ b/resources/views/editor.blade.php @@ -9,7 +9,7 @@ @php $ver = config('swagger.editor.ver') ?? '4.5.0'; - $title = config('swagger.editor.title', config('app.name') . ' - Swagger Editor'); + $title = config('swagger.editor.title') ?? config('app.name') . ' - SwaggerEditor'; @endphp diff --git a/resources/views/ui.blade.php b/resources/views/ui.blade.php index 9db627c..71f57ed 100644 --- a/resources/views/ui.blade.php +++ b/resources/views/ui.blade.php @@ -9,7 +9,7 @@ @php $ver = config('swagger.ui.ver') ?? '4.5.0'; - $title = config('swagger.ui.title', config('app.name') . ' - SwaggerUI'); + $title = config('swagger.ui.title') ?? config('app.name') . ' - SwaggerUI'; @endphp diff --git a/tests/SwaggerEditorTest.php b/tests/SwaggerEditorTest.php index 5fa4d08..cc037c5 100644 --- a/tests/SwaggerEditorTest.php +++ b/tests/SwaggerEditorTest.php @@ -158,4 +158,12 @@ public function testCustomTitle() $res->assertDontSee(' - Swagger Editor'); $res->assertSee('Custom Swagger Editor'); } + + #[Test] + #[DefineEnvironment('swaggerCustomTitle')] + public function testDefaultTitle() + { + $res = $this->get('/swagger-editor'); + $res->assertSee(' - Swagger Editor'); + } } diff --git a/tests/SwaggerUiTest.php b/tests/SwaggerUiTest.php index d610c9b..e3657fa 100644 --- a/tests/SwaggerUiTest.php +++ b/tests/SwaggerUiTest.php @@ -155,4 +155,12 @@ public function testCustomTitle() $res->assertDontSee(' - SwaggerUI'); // Default title $res->assertSee('My Swagger UI'); } + + #[Test] + #[DefineEnvironment('enableLS')] + public function testDefaultTitle() + { + $res = $this->get('/swagger'); + $res->assertSee(' - SwaggerUI'); // Default title + } }