PHPackages                             james.rus52/laravel-swagger-ui - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. james.rus52/laravel-swagger-ui

ActiveLibrary[API Development](/categories/api)

james.rus52/laravel-swagger-ui
==============================

Add Swagger UI to a Laravel application.

1.0.5(1y ago)068MITPHPPHP ^7.4|^8.0

Since Oct 16Pushed 1y agoCompare

[ Source](https://github.com/jamesRUS52/laravel-swagger-ui)[ Packagist](https://packagist.org/packages/james.rus52/laravel-swagger-ui)[ Docs](https://github.com/jamesRUS52/laravel-swagger-ui)[ RSS](/packages/jamesrus52-laravel-swagger-ui/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (4)Versions (10)Used By (0)

Laravel Swagger UI
==================

[](#laravel-swagger-ui)

[![Latest Version on Packagist](https://camo.githubusercontent.com/e1e92b80771b99587ab3c5fc13197003cd11a11dfd9bbb8139f8a3d6af783da5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a616d65732e72757335322f6c61726176656c2d737761676765722d75692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/james.rus52/laravel-swagger-ui)[![GitHub 'Run Tests' Workflow Status](https://camo.githubusercontent.com/a92c2cbabad061be821cb1ec6f583d3760dc10aacddc0c9fcc86b80ba538603c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f6a616d65732e72757335322f6c61726176656c2d737761676765722d75692f72756e2d74657374733f6c6162656c3d7465737473267374796c653d666c61742d737175617265266c6f676f3d676974687562)](https://github.com/jamesRUS52/laravel-swagger-ui/actions?query=workflow%3Arun-tests)[![Total Downloads](https://camo.githubusercontent.com/e9e13039df9d24e4eb9c12e5b1ddaf68b6edef1f1e34578edc4f178a5d4c0d16/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6a616d65732e72757335322f6c61726176656c2d737761676765722d75692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/james.rus52/laravel-swagger-ui)

This package makes it easy to make your project's Swagger (OpenAPI v3 JSON) file accessible in a Swagger UI right in your Laravel application.

The Swagger UI will automatically use your current project environment. It will set your api's base url to the active base url. Possible oauth2 configuration, such as urls and client-id/client-secret, can also be injected in Swagger UI via the configuration file.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require james.rus52/laravel-swagger-ui
```

After installing Laravel Swagger UI, publish its service provider and configuration file using the `swagger-ui:install` Artisan command.

```
php artisan swagger-ui:install
```

Usage
-----

[](#usage)

The Swagger UI is exposed at `/swagger`. By default, you will only be able to access it in the local environment. Within your `app/Providers/SwaggerUiServiceProvider.php` file, there is a `gate` method. This authorization gate controls access to Swagger UI in non-local environments. You can modify this gate as needed to restrict access to your Swagger UI and Swagger (OpenAPI v3) file:

```
/**
 * Register the Swagger UI gate.
 *
 * This gate determines who can access Swagger UI in non-local environments.
 *
 * @return void
 */
protected function gate()
{
    Gate::define('viewSwaggerUI', function ($user = null) {
        return in_array(optional($user)->email, [
            //
        ]);
    });
}
```

In the published `config/swagger-ui.php` file, you edit the path to the Swagger UI and the location of the Swagger (OpenAPI v3) file. By default, the package expects to find the OpenAPI json file in 'resources/swagger' directory.

```
// in config/swagger-ui.php

return [
    // ...

    'path' => 'swagger',

    'file' => resource_path('swagger/openapi.json'),

    // ...
];
```

You also have the option to customize the oauth setup. By default, the oauth paths are configured based on Laravel Passport. You can also set a client ID and client secret. These values will be automatically prefilled in the authentication view in Swagger UI.

```
// in config/swagger-ui.php

return [
    // ...

    'oauth' => [
        'token_path' => 'oauth/token',
        'refresh_path' => 'oauth/token',
        'authorization_path' => 'oauth/authorize',

        'client_id' => env('SWAGGER_UI_OAUTH_CLIENT_ID'),
        'client_secret' => env('SWAGGER_UI_OAUTH_CLIENT_SECRET'),
    ];

    // ...
];
```

### Testing

[](#testing)

```
composer test
```

Linting
-------

[](#linting)

```
composer lint
```

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Anton V. Davydov](https://github.com/jamesRUS52)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance31

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 64.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~186 days

Recently: every ~283 days

Total

8

Last Release

727d ago

Major Versions

0.2.0 → 1.0.02021-04-08

PHP version history (2 changes)0.1.0PHP ^7.4

0.2.0PHP ^7.4|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/a64ca777106023ca0997b82cf8bce53932d67b442b16154d859bbd15fe9f2171?d=identicon)[jamesRUS52](/maintainers/jamesRUS52)

---

Top Contributors

[![gdebrauwer](https://avatars.githubusercontent.com/u/22586858?v=4)](https://github.com/gdebrauwer "gdebrauwer (25 commits)")[![jamesRUS52](https://avatars.githubusercontent.com/u/39707635?v=4)](https://github.com/jamesRUS52 "jamesRUS52 (12 commits)")[![jan-claeys](https://avatars.githubusercontent.com/u/32668993?v=4)](https://github.com/jan-claeys "jan-claeys (2 commits)")

---

Tags

laravelswaggeropenapiswagger-uijames.rus52

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/jamesrus52-laravel-swagger-ui/health.svg)

```
[![Health](https://phpackages.com/badges/jamesrus52-laravel-swagger-ui/health.svg)](https://phpackages.com/packages/jamesrus52-laravel-swagger-ui)
```

###  Alternatives

[darkaonline/l5-swagger

OpenApi or Swagger integration to Laravel

2.9k34.0M112](/packages/darkaonline-l5-swagger)[wotz/laravel-swagger-ui

Add Swagger UI to a Laravel application.

277321.8k](/packages/wotz-laravel-swagger-ui)[harmbandstra/swagger-ui-bundle

Exposes swagger UI inside your Symfony project through a route (eg. /docs)

42867.3k](/packages/harmbandstra-swagger-ui-bundle)[scalar/laravel

Render your OpenAPI-based API reference

6183.9k2](/packages/scalar-laravel)[johnylemon/laravel-apidocs

Laravel API documentation generating tool

472.8k](/packages/johnylemon-laravel-apidocs)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
