Skip to content

Commit

Permalink
Merge pull request #33 from nextapps-be/feature/set-page-title
Browse files Browse the repository at this point in the history
Add option to set page title
  • Loading branch information
gdebrauwer authored Jul 25, 2024
2 parents ca531ac + b6dcc1b commit f64fbbf
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
5 changes: 5 additions & 0 deletions config/swagger-ui.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
*/
'path' => 'swagger',

/*
* The title of the page where the swagger file is served.
*/
'title' => env('APP_NAME') . ' - Swagger',

/*
* The versions of the swagger file. The key is the version name and the value is the path to the file.
*/
Expand Down
2 changes: 1 addition & 1 deletion resources/views/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">

<title>{{ config('app.name') }} - {{ __('Swagger') }}</title>
<title>{{ $data['title'] ?? (config('app.name') . ' - ' . __('Swagger')) }}</title>

<link rel="stylesheet" href="https://unpkg.com/swagger-ui-dist@latest/swagger-ui.css">

Expand Down
10 changes: 10 additions & 0 deletions tests/SwaggerUiRouteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,14 @@ public function it_includes_content_of_custom_stylesheet()
->assertStatus(200)
->assertSee("<style>{$content}</style>", false);
}

/** @test */
public function it_sets_page_title()
{
config()->set('swagger-ui.files.0.title', $title = $this->faker->sentence());

$this->get('swagger')
->assertStatus(200)
->assertSee("<title>{$title}</title>", false);
}
}
4 changes: 3 additions & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

namespace NextApps\SwaggerUi\Tests;

use Illuminate\Foundation\Testing\WithFaker;
use JMac\Testing\Traits\AdditionalAssertions;
use Orchestra\Testbench\TestCase as BaseTestCase;

abstract class TestCase extends BaseTestCase
{
use AdditionalAssertions;
use AdditionalAssertions,
WithFaker;

protected function defineEnvironment($app)
{
Expand Down

0 comments on commit f64fbbf

Please sign in to comment.