diff --git a/config/swagger-ui.php b/config/swagger-ui.php index d830fc6..56eaa35 100644 --- a/config/swagger-ui.php +++ b/config/swagger-ui.php @@ -46,12 +46,12 @@ 'client_id' => env('SWAGGER_UI_OAUTH_CLIENT_ID'), 'client_secret' => env('SWAGGER_UI_OAUTH_CLIENT_SECRET'), ], + + /* + * Path to a custom stylesheet file if you want to customize the look and feel of swagger-ui. + * The content of the file will be read and added into a style-tag on the swagger-ui page. + */ + 'stylesheet' => null, ], ], - - /** - * Path to a custom stylesheet file if you want to customize the look and feel of swagger-ui. - * The content of the file will be read and added into a style-tag on the swagger-ui page. - */ - 'stylesheet' => null, ]; diff --git a/resources/views/index.blade.php b/resources/views/index.blade.php index 4ed985a..3d7a2f0 100644 --- a/resources/views/index.blade.php +++ b/resources/views/index.blade.php @@ -23,10 +23,8 @@ } - @if (config('swagger-ui.stylesheet')) - + @if (! empty($data['stylesheet'])) + @endif diff --git a/tests/SwaggerUiRouteTest.php b/tests/SwaggerUiRouteTest.php index c8cbdcb..412f8ac 100644 --- a/tests/SwaggerUiRouteTest.php +++ b/tests/SwaggerUiRouteTest.php @@ -66,4 +66,19 @@ public function it_applies_middleware_from_config() $this->assertRouteUsesMiddleware('swagger-with-versions.index', ['web']); } + + /** @test */ + public function it_includes_content_of_custom_stylesheet() + { + file_put_contents( + $path = resource_path('custom-swagger-ui-styling.css'), + $content = '.foo .bar { background-color: red; }' + ); + + config()->set('swagger-ui.files.0.stylesheet', $path); + + $this->get('swagger') + ->assertStatus(200) + ->assertSee("", false); + } }