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

ActiveLibrary[API Development](/categories/api)

imetal/lumen-swagger
====================

Provided middleware for generating of swagger-documentation file by run testing of restful API.

08051PHP

Since May 17Pushed 2y agoCompare

[ Source](https://github.com/iMetal-NL/lumen-swagger)[ Packagist](https://packagist.org/packages/imetal/lumen-swagger)[ RSS](/packages/imetal-lumen-swagger/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Lumen Swagger plugin
====================

[](#lumen-swagger-plugin)

[![License](https://camo.githubusercontent.com/d02ffd695fef91c41ef4bf81a341dfd4b31f570dc2a714677bd15fb91cd20ac3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f726f6e617369742f6c61726176656c2d73776167676572)](https://packagist.org/packages/ronasit/laravel-swagger)

Introduction
------------

[](#introduction)

This plugin is designed to generate documentation for your REST API during the passing PHPUnit tests.

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

[](#installation)

1. Install the package using the following command: `composer require imetal/lumen-swagger`

    > ***Note***
    >
    > For Laravel 5.5 or later the package will be auto-discovered. For older versions add the `AutoDocServiceProvider` to the providers array in `config/app.php` as follow:
    >
    > ```
    > 'providers' => [
    >    // ...
    >    RonasIT\Support\AutoDoc\AutoDocServiceProvider::class,
    > ],
    > ```
2. Run `php artisan vendor:publish`
3. Add `\RonasIT\Support\AutoDoc\Http\Middleware\AutoDocMiddleware::class` middleware to the global HTTP middleware stack in `Http/Kernel.php`.
4. Add `\RonasIT\Support\AutoDoc\Tests\AutoDocTestCaseTrait` trait to `tests/TestCase.php`
5. Configure documentation saving using one of the next ways:

- Add `SwaggerExtension` to the `` block of your `phpunit.xml`. **Please note that this way will be removed after updating****PHPUnit up to 10 version ([sebastianbergmann/phpunit#4676](https://github.com/sebastianbergmann/phpunit/issues/4676))**```

            ./tests/Feature

    ```
- Call `php artisan swagger:push-documentation` console command after the `tests` stage in your CI/CD configuration

Usage
-----

[](#usage)

### Basic usage

[](#basic-usage)

1. Create test for API endpoint:

    ```
    public function testUpdate()
    {
        $response = $this->json('put', '/users/1', [
            'name': 'Updated User',
            'is_active': true,
            'age': 22
        ]);

        $response->assertStatus(Response::HTTP_NO_CONTENT);
    }
    ```
2. Create request class:

    ```
