https://github.com/hms5232/laravel-swagger
Integrate Swagger UI and Editor into Laravel
https://github.com/hms5232/laravel-swagger
laravel-package openapi swagger swagger-editor swagger-ui
Last synced: 3 months ago
JSON representation
Integrate Swagger UI and Editor into Laravel
- Host: GitHub
- URL: https://github.com/hms5232/laravel-swagger
- Owner: hms5232
- License: mit
- Created: 2022-10-26T04:41:38.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2026-01-22T11:52:42.000Z (5 months ago)
- Last Synced: 2026-01-23T02:35:05.691Z (5 months ago)
- Topics: laravel-package, openapi, swagger, swagger-editor, swagger-ui
- Language: PHP
- Homepage: https://packagist.org/packages/hms5232/laravel-swagger
- Size: 55.7 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# laravel-swagger
[](https://packagist.org/packages/hms5232/laravel-swagger)


[](https://packagist.org/packages/hms5232/laravel-swagger)
[](https://github.com/hms5232/laravel-swagger/blob/main/README.md)
[](https://github.com/hms5232/laravel-swagger/actions?query=branch%3Amain)
Render [OpenAPI](https://www.openapis.org/) JSON or YAML with [SwaggerUI](https://swagger.io/tools/swagger-ui/) and/or [Swagger Editor](https://editor.swagger.io/) in Laravel.
## Usage
### Installation
```shell
composer require hms5232/laravel-swagger
```
or you want to install only at development environment:
```shell
composer require hms5232/laravel-swagger --dev
```
### Configure
All configurable items are in `config/swagger.php` after you run publish command:
```shell
php artisan vendor:publish --provider "Hms5232\LaravelSwagger\LaravelSwaggerServiceProvider"
```
If you want to override the exists config file, execute command with `--force` flag.
See the config file for detail information.
### Manually register
Package support auto-discovery. If you want to control when to register, you can do the following steps:
1. Edit `composer.json` make auto discovery ignore laravel-swagger:
```json
"extra": {
"laravel": {
"dont-discover": [
"hms5232/laravel-swagger"
]
}
},
```
2. Re-generate optimized autoload files:
```shell
composer dump-autoload
```
3. Edit `app/Providers/AppServiceProvider.php` define when to register:
```php
use Hms5232\LaravelSwagger\LaravelSwaggerServiceProvider; // add this
class AppServiceProvider extends ServiceProvider
{
public function register()
{
// set condition
// for example, only register when env is "local"
if ($this->app->environment('local')) {
$this->app->register(LaravelSwaggerServiceProvider::class); // register laravel-swagger
}
}
}
```
## Why another package
I just want to write a YAML file directly, and use Swagger UI serve/resolve docs.
But exists projects are either using annotations or only supporting JSON (seems like bug, but does not fix.).
So I develop this package, only have a view modified from [Swagger UI (unpkg)](https://swagger.io/docs/open-source-tools/swagger-ui/usage/installation/#unpkg), two routes to link documents.
> This section was written at version [0.1.0](https://github.com/hms5232/laravel-swagger/releases/tag/v0.1.0) and may be outdated in the future.
## LICENSE
[MIT](LICENSE)