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

ActiveLibrary[API Development](/categories/api)

fillincode/swagger
==================

Package for generating OpenApi documentation

1.0.4(1y ago)0603MITPHPPHP ^8.0

Since Jan 17Pushed 1y ago2 watchersCompare

[ Source](https://github.com/pulsar88/swagger)[ Packagist](https://packagist.org/packages/fillincode/swagger)[ RSS](/packages/fillincode-swagger/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependencies (2)Versions (6)Used By (0)

Swagger-parser
==============

[](#swagger-parser)

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

[](#installation)

```
composer require fillincode/swagger
```

Публикация конфигурации

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

Config
------

[](#config)

### OpenApi version

[](#openapi-version)

```
'openapi' => '3.0.0',
```

### Block configuration with information about your Api. You can define the title, description, version, terms of use, contact details and license

[](#block-configuration-with-information-about-your-api-you-can-define-the-title-description-version-terms-of-use-contact-details-and-license)

```
'info' => [
    'title' => 'API documentation',
    'description' => 'API documentation',
    'version' => '1.0.0',
    'termsOfService' => 'https://example.com/terms',
    'contact' => [
        'name' => 'example',
        'url' => 'https://example.com',
        'email' => 'example@mail.ru',
    ],
    'license' => [
        'name' => 'CC Attribution-ShareAlike 4.0 (CC BY-SA 4.0)',
        'url' => 'https://openweathermap.org/price',
    ],
],
```

### Ready-made authorization schemes

[](#ready-made-authorization-schemes)

```
'securitySchemes' => [
    'passport' => [
        'type' => 'http',
        'in' => 'header',
        'name' => 'Authorization',
        'scheme' => 'Bearer',
        'description' => 'To authorize, use the key ',
    ],
    'sanctum' => [
        'type' => 'http',
        'in' => 'header',
        'name' => 'Authorization',
        'scheme' => 'Bearer',
        'description' => 'To authorize, use the key ',
    ],
],
```

### Information on the server to which requests will be sent

[](#information-on-the-server-to-which-requests-will-be-sent)

```
'servers' => [
    [
        'url' => env('APP_URL'),
        'description' => 'Server for testing',
    ],
```

### Server authorization configuration

[](#server-authorization-configuration)

1. It is necessary to determine whether there are requests that require authorization
2. Middleware, which checks authorization
3. Select the desired authorization scheme
4. You need to define a function or Invokable class that will return the authorization token(s). You can return an array with a description of the token and its value or just a string token

An example of such a class

```
    public function __invoke(): string|array
    {
        $user = User::whereEmail('user@mail.ru')->first();

        return $user?->createToken('user-token')->accessToken;
    }

    ````

    public function __invoke(): string|array
    {
        $user = User::whereEmail('user@mail.ru')->first();
        $admin = User::whereEmail('admin@mail.ru')->first();

        return [
            'user' => $user?->createToken('user-token')->accessToken,
            'admin' => $admin?->createToken('admin-token')->accessToken
        ];
    }
```

### Authorization configuration

[](#authorization-configuration)

```
'auth' => [
    'has_auth' => true,
    'middleware' => 'auth.api',
    'security_schema' => 'passport',
    'make_token' => [
        'action' => 'makeTokenFunction',
    ],
],
```

### Configuration for storing temporary files with test results. Driver and path can be determined

[](#configuration-for-storing-temporary-files-with-test-results-driver-and-path-can-be-determined)

```
'storage' => [
    'driver' => 'local',
    'path' => 'data',
],
```

### Configuration for resource keys

[](#configuration-for-resource-keys)

```
'pre_key' => 'data',

'resources_keys' => [
    'has_pre_key' => false,
    'use_wrap' => true,
],
```

Examples of resource key configuration settings

For example, if there is an additional key that does not belong to a resource, the resources have keys, but they are not set via wrap

Response

```
'data' => [
    'user' => [
        'id' => 12,
        'name' => 'user_name'
    ]
]
```

Resource

```
    class UserResource extends JsonResource

    public function toArray(Request $request)
    {
        return [
            'user' => [
                'id' => $this->id,
                'name' => $this->name
            ]
        ]
    }
```

Configuration

```
'pre_key' => 'data',

'resources_keys' => [
    'has_pre_key' => true,
    'use_wrap' => false,
],
```

If there is no additional key in the response, and the resource uses the wrap property as a key

Response

```
'user' => [
    'id' => 12,
    'name' => 'user_name'
]
```

Resource

```
    class UserResource extends JsonResource

    public static $wrap = 'user';

    public function toArray(Request $request)
    {
        return [
            'id' => $this->id,
            'name' => $this->name
        ]
    }
```

Configuration

```
'pre_key' => '',

'resources_keys' => [
    'has_pre_key' => true,
    'use_wrap' => true,
],
```

If the response contains just data without any keys

Response

```
[
    'id' => 12,
    'name' => 'user_name'
]
```

Resource

```
    class UserResource extends JsonResource

    public function toArray(Request $request)
    {
        return [
            'id' => $this->id,
            'name' => $this->name
        ]
    }

    public function boot(): void
    {
        JsonResource::withoutWrapping();
    }
```

Configuration

```
'pre_key' => '',

'resources_keys' => [
    'has_pre_key' => false,
    'use_wrap' => false,
],
```

### Ready description of response codes. You can add your own response descriptions to this array

[](#ready-description-of-response-codes-you-can-add-your-own-response-descriptions-to-this-array)

```
'codes' => [
    200 => 'Request completed successfully',
    201 => 'Object created successfully',
    204 => 'Not content',
    401 => 'Not authentication',
    403 => 'Not authorization',
    404 => 'Not found',
    422 => 'Data validation error',
    500 => 'Server error',
],
```

Commands
--------

[](#commands)

Clears the directory with test results

```
php artisan swagger:destroy
```

Generates a documentation file from all files with test results

```
php artisan swagger:parse
```

Runs tests, generates new documentation and deletes temporary files

```
php artisan swagger:generate
```

Attributes
----------

[](#attributes)

### Group

[](#group)

The attribute is used to group routes

Applicable:

1. Controller method

The parameter accepts:

1. Group name (string). **Required**

Example:

```
    use Fillincode\Swagger\Attributes\Group;

    #[Group('group_name')]
    public function example_method()
    {
        //
    }
```

### Summary

[](#summary)

Brief description of the route

Applicable:

1. Controller method

The parameter accepts:

1. Summary (string). **Required**

Example:

```
    use Fillincode\Swagger\Attributes\Summary;

    #[Summary('summary')]
    public function example_method()
    {
        //
    }
```

### Description

[](#description)

Detailed description of the route

Applicable:

1. Controller method

The parameter accepts:

1. Description (string). **Required**

Example:

```
    use Fillincode\Swagger\Attributes\Description;

    #[Description('description')]
    public function example_method()
    {
        //
    }
```

### Code

[](#code)

The attribute is needed for a custom code description

Applicable:

1. Controller method

The parameter accepts:

1. Code (integer). **Required**
2. Description code (string). **Required**

Example:

```
    use Fillincode\Swagger\Attributes\Code;

    #[Code(201, 'Object update')]
    public function example_method()
    {
        //
    }
```

### PathParameter

[](#pathparameter)

The attribute is needed to describe the parameters that are passed in the address bar

Applicable:

1. Controller method

The parameter accepts:

1. Parameter name (string). **Required**
2. Type (string). **Required**
3. Description (string)
4. Available values (string|array). The parameter is only needed for the enum type
5. Required (boolean). Is the parameter required. By default, true

Example:

```
    use Fillincode\Swagger\Attributes\PathParameter;

    #[PathParameter('parameter_name', 'enum', 'description parameter', ['string_1', 'string_2', 12], false)]
    public function example_method()
    {
        //
    }
```

### QueryParameter

[](#queryparameter)

The attribute is needed to describe the parameters that are passed in the GET parameter

Applicable:

1. Controller method

The parameter accepts:

1. Parameter name (string). **Required**
2. Type (string). **Required**
3. Example (string/integer/boolean). **Required**
4. Description (string)
5. Available values (string|array). The parameter is only needed for the enum type
6. Required (boolean). Is the parameter required. By default, true

Example:

```
    use Fillincode\Swagger\Attributes\QueryParameter;

    #[QueryParameter('parameter_name', 'string', 'example_string', 'description parameter')]
    public function example_method()
    {
        //
    }
```

### Resource

[](#resource)

The attribute is used to indicate the resource that is returned in the response. This resource will collect information based on the response data. To describe nested resources, you must define this attribute on the parent resource

Applicable:

1. Controller method
2. Resource class

The parameter accepts:

1. Class (string). **Required**
2. Name (string|null). This parameter is only needed if the resource object has a key, and it is different from the resource's wrap property.
3. use\_wrap (boolean|null). If a resource uses wrap as a key, then you need to pass true (Can be activated for all resources in the configuration)
4. has\_key (boolean|null). If the resource has a key, then you need to pass true (Can be configured for all resources in the configuration)

Example:

```
    use Fillincode\Swagger\Attributes\Resource;

    #[Resource(ProjectResource::class)]
    public function example_method()
    {
        //
    }

    ````

    #[Resource(CategoryResource::class, 'categories')]
    class ExampleResource extends JsonResource
    {
        //
    }
```

### FormRequest

[](#formrequest)

The attribute is needed to indicate the FormRequest class by which data will be collected to describe the parameters passed in the request

Applicable:

1. Controller method

The parameter accepts:

1. Class (string). **Required**

Example:

```
    use Fillincode\Swagger\Attributes\FormRequest;

    #[FormRequest(FormRequest::class)]
    public function example_method()
    {
        //
    }
```

### Property

[](#property)

The attribute describes the parameter that is passed in the request or returned in the response

Applicable:

1. FormRequest class
2. Resource class

The parameter accepts:

1. Name (string). **Required**
2. Type (string). **Required**
3. Description (string).
4. In (string|array). Available values, parameter needed only for enum type
5. is\_required (bool). Default true

Example:

```
    use Fillincode\Swagger\Attributes\Property;

    #[Property('age', 'integer', 'student age')]
    class ProjectRequest extends FormRequest
    {
        //
    }

    ````
    #[Property('age', 'integer', 'student age')]
    class ProjectResource extends JsonResource
    {
        //
    }
```

Additionally
------------

[](#additionally)

An example when a resource has an array whose keys need to be documented

```
    use Fillincode\Swagger\Attributes\Property;

    #[Property('id', 'string', 'user id')]
    #[Property('data.info_1', 'string', 'user info 1')]
    #[Property('data.info_2', 'string', 'user info 2')]
    class UserResource extends JsonResource
    {
        public function toArray(Request $request)
        {
            return [
                'id' => $this->id,
                'data' => [
                    'info_1' => $this->data['info_1'],
                    'info_2' => $this->data['info_2'],
                ]
            ]
        }
    }
```

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~86 days

Total

5

Last Release

545d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3817489?v=4)[pulsar88](/maintainers/pulsar88)[@pulsar88](https://github.com/pulsar88)

---

Top Contributors

[![KoryaginDmitry](https://avatars.githubusercontent.com/u/81314264?v=4)](https://github.com/KoryaginDmitry "KoryaginDmitry (4 commits)")

### Embed Badge

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

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

###  Alternatives

[statamic/cms

The Statamic CMS Core Package

4.8k3.5M916](/packages/statamic-cms)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k5.8M712](/packages/sylius-sylius)[darkaonline/l5-swagger

OpenApi or Swagger integration to Laravel

2.9k36.4M126](/packages/darkaonline-l5-swagger)[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

1155.2k](/packages/rcsofttech-audit-trail-bundle)[icawebdesign/hibp-php

PHP library for accessing the Have I Been Pwned API.

2548.8k2](/packages/icawebdesign-hibp-php)[2lenet/crudit-bundle

The easy like Crud'it Bundle.

1615.6k12](/packages/2lenet-crudit-bundle)

PHPackages © 2026

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