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

ActiveLibrary[API Development](/categories/api)

ronappleton/laravel-swagger
===========================

Auto generates the swagger documentation for a laravel project

v0.6.3(6y ago)033MITPHP

Since Mar 27Pushed 6y agoCompare

[ Source](https://github.com/ronappleton/laravel-swagger)[ Packagist](https://packagist.org/packages/ronappleton/laravel-swagger)[ RSS](/packages/ronappleton-laravel-swagger/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (4)Versions (17)Used By (0)

Laravel Swagger
===============

[](#laravel-swagger)

Laravel Swagger scans your Laravel project's endpoints and auto generates a Swagger 2.0 documentation for you.

[![Build Status](https://camo.githubusercontent.com/34d265d2f6871983e1ae8ca0cddb7464eeaf27e9decd0c1649f0edabc11c759c/68747470733a2f2f7472617669732d63692e6f72672f6d7472616a616e6f2f6c61726176656c2d737761676765722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/mtrajano/laravel-swagger)[![Latest Stable Version](https://camo.githubusercontent.com/693433b858c7d1f6585fc08bac0994d021f7ef726b81e69a2558065366586816/68747470733a2f2f706f7365722e707567782e6f72672f6d7472616a616e6f2f6c61726176656c2d737761676765722f762f737461626c65)](https://packagist.org/packages/mtrajano/laravel-swagger)[![License](https://camo.githubusercontent.com/b0a7957227e0b94d3a8ebe1841599f7aa6ef3c19cc9a4b0dbd86b174c92985ba/68747470733a2f2f706f7365722e707567782e6f72672f6d7472616a616e6f2f6c61726176656c2d737761676765722f6c6963656e7365)](https://packagist.org/packages/mtrajano/laravel-swagger)

Laravel Versions
----------------

[](#laravel-versions)

This fork has so far been tested with the following Laravel versions:

- 6.16.0

About
-----

[](#about)

Laravel Swagger works based on recommended practices by Laravel. It will parse your routes and generate a path object for each one. If you inject Form Request classes in your controller's actions as request validation, it will also generate the parameters for each request that has them. For the parameters, it will take into account wether the request is a GET/HEAD/DELETE or a POST/PUT/PATCH request and make its best guess as to the type of parameter object it should generate. It will also generate the path parameters if your route contains them. Finally, this package will also scan any documentation you have in your action methods and add it as summary and description to that path, along with any appropriate annotations such as @deprecated.

One thing to note is this library leans on being explicit. It will choose to include keys even if they have a default. For example it chooses to say a route has a deprecated value of false rather than leaving it out. I believe this makes reading the documentation easier by not leaving important information out. The file can be easily cleaned up afterwards if the user chooses to leave out the defaults.

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

[](#installation)

The package can easily be installed by running `composer require mtrajano/laravel-swagger` in your project's root folder.

If you are running a version of Laravel &lt; 5.5 also make sure you add `Mtrajano\LaravelSwagger\SwaggerServiceProvider::class` to the `providers` array in `config/app.php`.

This will register the artisan command that will be available to you.

You can also override the default config provided by the application by running `php artisan vendor:publish --provider "Mtrajano\LaravelSwagger\SwaggerServiceProvider"` in your projects root and change the configuration in the new `config/laravel-swagger.php` file created.

Usage
-----

[](#usage)

Generating the swagger documentation is easy, simply run `php artisan laravel-swagger:generate` in your project root. Keep in mind the command will simply print out the output in your console. If you want the docs saved in a file you can reroute the output like so: `php artisan laravel-swagger:generate > swagger.json`

If you wish to generate docs for a subset of your routes, you can pass a filter using `--filter`, for example: `php artisan laravel-swagger:generate --filter="/api"`

By default, laravel-swagger prints out the documentation in json format, if you want it in YAML format you can override the format using the `--format` flag. Make sure to have the yaml extension installed if you choose to do so.

Format options are:
`json`
`yaml`

Example
-------

[](#example)

Say you have a route `/api/users/{id}` that maps to `UserController@show`

Your sample controller might look like this:

```
/**
 * Return all the details of a user
 *
 * Returns the user's first name, last name and address
 * Please see the documentation [here](https://example.com/users) for more information
 *
 * @deprecated
 */
class UserController extends Controller
{
    public function show(UserShowRequest $request, $id)
    {
        return User::find($id);
    }
}
```

And the FormRequest class might look like this:

```
class UserShowRequest extends FormRequest
{
    public function rules()
    {
        return [
            'fields' => 'array'
            'show_relationships' => 'boolean|required'
        ];
    }
}
```

Running `php artisan laravel-swagger:generate > swagger.json` will generate the following file:

```
{
    "swagger": "2.0",
    "info": {
        "title": "Laravel",
        "description": "Test",
        "version": "1.0.1"
    },
    "host": "http:\/\/localhost",
    "basePath": "\/",
    "paths": {
        "\/api\/user\/{id}": {
            "get": {
                "summary": "Return all the details of a user",
                "description": "Returns the user's first name, last name and address
 Please see the documentation [here](https://example.com/users) for more information",
                "deprecated": true
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                },
                "parameters": [
                    {
                        "in": "path",
                        "name": "id",
                        "type": "integer",
                        "required": true,
                        "description": ""
                    },
                    {
                        "in": "query",
                        "name": "fields",
                        "type": "array",
                        "required": false,
                        "description": ""
                    },
                    {
                        "in": "query",
                        "name": "show_relationships",
                        "type": "boolean",
                        "required": true,
                        "description": ""
                    }
                ]
            },
            ...
        }
    }
}
```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 68.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 ~53 days

Recently: every ~18 days

Total

14

Last Release

2273d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6e2afdd94a6f21a4ec2c5df569b80c1d47d6f5d0428f866f55c4bc117856b58b?d=identicon)[Ron Appleton](/maintainers/Ron%20Appleton)

---

Top Contributors

[![mtrajano](https://avatars.githubusercontent.com/u/4333381?v=4)](https://github.com/mtrajano "mtrajano (49 commits)")[![ronappleton](https://avatars.githubusercontent.com/u/3792420?v=4)](https://github.com/ronappleton "ronappleton (15 commits)")[![overint](https://avatars.githubusercontent.com/u/16414140?v=4)](https://github.com/overint "overint (4 commits)")[![hugef666](https://avatars.githubusercontent.com/u/54015484?v=4)](https://github.com/hugef666 "hugef666 (2 commits)")[![bav55](https://avatars.githubusercontent.com/u/2253306?v=4)](https://github.com/bav55 "bav55 (1 commits)")[![pleaz](https://avatars.githubusercontent.com/u/2572689?v=4)](https://github.com/pleaz "pleaz (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[phpdocumentor/phpdocumentor

Documentation Generator for PHP

4.4k3.1M874](/packages/phpdocumentor-phpdocumentor)[googleads/googleads-php-lib

Google Ad Manager SOAP API Client Library for PHP

67410.3M25](/packages/googleads-googleads-php-lib)[thecodingmachine/graphqlite

Write your GraphQL queries in simple to write controllers (using webonyx/graphql-php).

5723.1M30](/packages/thecodingmachine-graphqlite)[felixfbecker/advanced-json-rpc

A more advanced JSONRPC implementation

25578.7M6](/packages/felixfbecker-advanced-json-rpc)[overblog/graphql-bundle

This bundle provides tools to build a GraphQL server in your Symfony App.

8027.9M28](/packages/overblog-graphql-bundle)[api-platform/api-pack

A pack for API Platform

5236.7M40](/packages/api-platform-api-pack)

PHPackages © 2026

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