Search by

miladev / lara-swagger

miladev95

Swagger model generator based on Laravel migrations

Package info

github.com/miladev95/lara-swagger

pkg:composer/miladev/lara-swagger

Statistics

Installs: 9

Dependents: 0

Suggesters: 0

Stars: 1

Open Issues: 0

v2.0.0 2026-09-01 05:51 UTC

This package is auto-updated.

Last update: 2026-09-01 05:54:57 UTC


README

Latest Stable Version License Total Downloads CI & Release

A Swagger model generator based on migrations

if you bored to create swagger models from your laravel application this package can help you.

Installation

You can install the package via composer:

composer require miladev/lara-swagger

Usage

php artisan lswagger:generate

This command will create a swagger_models.json file in the current working directory containing all models of your Laravel application.

Enum columns

$table->enum('col', ['a', 'b', 'c']) columns are emitted as an OpenAPI-style enum:

{
  "col": {
    "type": "string",
    "enum": ["a", "b", "c"]
  }
}

Foreign-key columns ($table->foreign(...)) are skipped.

Testing

This package uses PHPUnit and Orchestra Testbench.

  • Prerequisites: PHP 8.2+ and Composer
  • Install dev dependencies:
composer install

If you do not have a global Composer installed, you can use a local PHAR inside the project:

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php composer-setup.php --install-dir=. --filename=composer.phar
php -r "unlink('composer-setup.php');"
php composer.phar install
  • Run the tests:
composer test
# or
vendor/bin/phpunit
# or a specific test file
vendor/bin/phpunit tests/Feature/CreateSwaggerCommandTest.php

If you run tests from an IDE, ensure the working directory is the project root so the generated swagger_models.json can be found.

Roadmap

  • Support all kind of migrations (Rename, Delete, ...)

If you want to contribute, open a pull request by following Laravel contribution guide.

License

The MIT License (MIT). Please see License File for more information.