PHPackages                             g4t/swagger - 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. g4t/swagger

ActiveLibrary[API Development](/categories/api)

g4t/swagger
===========

g4t laravel swagger

4.0.2(1mo ago)12342.0k↓10.9%16[2 issues](https://github.com/hussein4alaa/laravel-g4t-swagger-auto-generate/issues)MITPHP

Since Jun 7Pushed 1mo ago4 watchersCompare

[ Source](https://github.com/hussein4alaa/laravel-g4t-swagger-auto-generate)[ Packagist](https://packagist.org/packages/g4t/swagger)[ RSS](/packages/g4t-swagger/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)DependenciesVersions (77)Used By (0)

Swagger Laravel Autogenerate Package
====================================

[](#swagger-laravel-autogenerate-package)

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.

[![Swagger Laravel Autogenerate Package](https://camo.githubusercontent.com/79878fab167965d878bf0b110755039853a36b599f0dcd37d8b1a8ca7e45f7fd/68747470733a2f2f7777772e73636f7474627261647939312e636f6d2f696d672f6c6f676f732f737761676765722d62616e6e65722e706e67)](https://camo.githubusercontent.com/79878fab167965d878bf0b110755039853a36b599f0dcd37d8b1a8ca7e45f7fd/68747470733a2f2f7777772e73636f7474627261647939312e636f6d2f696d672f6c6f676f732f737761676765722d62616e6e65722e706e67)

Features
--------

[](#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
------------

[](#installation)

Install the Swagger Laravel Autogenerate Package via Composer:

```
composer require g4t/swagger

```

Usage
-----

[](#usage)

#### Click here to watch a video on how to use this package

[](#click-here-to-watch-a-video-on-how-to-use-this-package)

[![Explanatory video on how to use](https://camo.githubusercontent.com/a385df1b6ebb74c30ac21be57f782b195e687358c83868aa40c9f15db7d98112/68747470733a2f2f696d672e796f75747562652e636f6d2f76692f6249314259397441774f772f302e6a7067)](https://www.youtube.com/watch?v=bI1BY9tAwOw)

1. After installing the package, publish the configuration file:

```
php artisan vendor:publish --provider "G4T\Swagger\SwaggerServiceProvider"

```

2. 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.
3. Access the generated Swagger documentation by visiting the `/swagger/documentation` route in your Laravel application. For example, `http://your-app-url/swagger/documentation`.
4. The issues history page is now included in config/swagger.php, and the default route is `http://your-app-url/swagger/issues`.
5. To add a description in a Swagger route using the -&gt;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 -&gt;description() method in a Swagger route:

    ```
     Route::get('user', [UserController::class, 'index'])->description('Get list of users with pagination.');
    ```
6. To add a summary in a Swagger route using the -&gt;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 -&gt;summary() method in a Swagger route:

    ```
     Route::get('user', [UserController::class, 'index'])->summary('get users.');
    ```
7. To hide endpoint from Swagger documentation using the -&gt;hiddenDoc() method. Here's how you can hide route using the -&gt;hiddenDoc() method:

    ```
     Route::get('user', [UserController::class, 'index'])->hiddenDoc();
    ```
8. 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:

    ```
