g4t / swagger
g4t laravel swagger
Installs: 13 865
Dependents: 0
Suggesters: 0
Security: 0
Stars: 117
Watchers: 6
Forks: 15
Open Issues: 1
- dev-main
- 4.0.1.x-dev
- 4.0.1
- 4.0.0.x-dev
- 4.0.0
- 3.2.3.x-dev
- 3.2.3
- 3.2.2.x-dev
- 3.2.2
- 3.2.1.x-dev
- 3.2.1
- 3.2.0
- 3.1.19.x-dev
- 3.1.19
- 3.1.18.x-dev
- 3.1.18
- 3.1.17
- 3.1.16
- 3.1.15
- 3.1.14
- 3.1.13
- 3.1.12
- 3.1.11
- 3.1.10
- 3.1.9
- 3.1.8
- 3.1.7
- 3.1.6
- 3.1.5
- 3.1.4
- 3.1.3
- 3.1.2
- 3.1.1
- 3.1.0
- 3.0.9
- 3.0.8
- 3.0.7.x-dev
- 3.0.7
- 3.0.6.x-dev
- 3.0.6
- 3.0.5.x-dev
- 3.0.5
- 3.0.4.x-dev
- 3.0.4
- 3.0.3.x-dev
- 3.0.3
- 3.0.2.x-dev
- 3.0.2
- 3.0.1.x-dev
- 3.0.1
- 3.0.0.x-dev
- 3.0.0
- 2.0.7
- 2.0.6.x-dev
- 2.0.6
- 2.0.5
- 2.0.4
- 2.0.3.x-dev
- 2.0.3
- 2.0.2.x-dev
- 2.0.2
- 2.0.1.x-dev
- 2.0.1
- 2.0.0.x-dev
- 2.0.0
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3.x-dev
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- dev-dev
This package is auto-updated.
Last update: 2025-03-14 12:41:44 UTC
README
The Swagger Laravel Autogenerate Package is a convenient tool that automatically generates Swagger documentation for your Laravel APIs based on your route definitions. It eliminates the need for manually documenting your API endpoints, saving you time and effort.
Features
- Automatically generates Swagger documentation for Laravel APIs.
- Extracts route information, including URI, HTTP methods, route names, middleware, and more.
- Supports request validations and parameter definitions.
- Generates JSON output conforming to the Swagger/OpenAPI specification.
- Easy integration and configuration within Laravel projects.
Installation
Install the Swagger Laravel Autogenerate Package via Composer:
composer require g4t/swagger
Usage
Click here to watch a video on how to use this package
- After installing the package, publish the configuration file:
php artisan vendor:publish --provider "G4T\Swagger\SwaggerServiceProvider"
-
Configure the package by modifying the
config/swagger.php
file according to your needs. This file allows you to specify various settings for the Swagger documentation generation. -
Access the generated Swagger documentation by visiting the
/swagger/documentation
route in your Laravel application. For example,http://your-app-url/swagger/documentation
. -
The issues history page is now included in config/swagger.php, and the default route is
http://your-app-url/swagger/issues
. -
To add a description in a Swagger route using the ->description() method, you can follow the example you provided and include it in your Laravel application's routes. Here's how you can describe a route using the ->description() method in a Swagger route:
Route::get('user', [UserController::class, 'index'])->description('Get list of users with pagination.');
-
To add a summary in a Swagger route using the ->summary() method, you can follow the example you provided and include it in your Laravel application's routes. Here's how you can describe a route using the ->summary() method in a Swagger route:
Route::get('user', [UserController::class, 'index'])->summary('get users.');
-
To hide endpoint from Swagger documentation using the ->hiddenDoc() method. Here's how you can hide route using the ->hiddenDoc() method:
Route::get('user', [UserController::class, 'index'])->hiddenDoc();
-
To add a Section Description you can use this attribute
#[SwaggerSection('everything about your users')]
in your controller. Here's how you can use this attribute in your controller:<?php namespace App\Http\Controllers; use G4T\Swagger\Attributes\SwaggerSection; #[SwaggerSection('everything about your users')] class UserController extends Controller { // ... // ... // ... }
-
To enable documentation auth, open
config/swagger.php
and edit this"enable_auth" => false, "username" => "admin", "password" => "pass", "sesson_ttl" => 100000,
Suggestions
If you have any suggestions or feature requests, please feel free to add them on our Canny board.
Contributing
Contributions to the Swagger Laravel Autogenerate Package are always welcome! If you find any issues or have suggestions for improvements, please feel free to open an issue or submit a pull request.
License
The Swagger Laravel Autogenerate Package is open-source software licensed under the MIT license.
Credits
The Swagger Laravel Autogenerate Package is developed and maintained by HusseinAlaa.