PHPackages                             freedomcore/laravel-openapi - 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. freedomcore/laravel-openapi

ActiveLibrary[API Development](/categories/api)

freedomcore/laravel-openapi
===========================

OpenAPI documentation generator for Laravel

1.0.2(5y ago)030MITPHPPHP ^8.0

Since Dec 18Pushed 5y ago1 watchersCompare

[ Source](https://github.com/darki73/laravel-openapi)[ Packagist](https://packagist.org/packages/freedomcore/laravel-openapi)[ RSS](/packages/freedomcore-laravel-openapi/feed)WikiDiscussions main Synced today

READMEChangelog (3)Dependencies (1)Versions (4)Used By (0)

Laravel OpenAPI
===============

[](#laravel-openapi)

Simple to use OpenAPI 3 compatible documentation generator.
Also includes OpenAPI UI.
[![Total Downloads](https://camo.githubusercontent.com/8bdf4c4b33c2a738b370342605fd605c8cfd85639004af484b4e37d80a543002/68747470733a2f2f706f7365722e707567782e6f72672f66726565646f6d636f72652f6c61726176656c2d6f70656e6170692f646f776e6c6f6164732e737667)](https://packagist.org/packages/freedomcore/laravel-openapi)[![GuitHub Sponsor](https://camo.githubusercontent.com/4d74f563ddcfffd1950ad775f9cc4724a53f22bd5debaf25d73868778e05e471/68747470733a2f2f696d672e736869656c64732e696f2f7374617469632f76313f6c6162656c3d53706f6e736f7225323066726565646f6d636f72652f6c61726176656c2d6f70656e617069266d6573736167653d254532253944254134266c6f676f3d476974487562266c696e6b3d68747470733a2f2f6769746875622e636f6d2f73706f6e736f72732f6461726b693733)](https://img.shields.io/static/v1?label=Sponsor%20freedomcore/laravel-openapi&message=%E2%9D%A4&logo=GitHub&link=https://github.com/sponsors/darki73)

About
-----

[](#about)

1. OAS3 support
2. Automatic generation (assuming relevant configuration option is turned on)
3. Includes of OpenAPI UI
4. Uses PHP 8 Attributes

Requirements
------------

[](#requirements)

This package developed on `Laravel 8.19.0`, but it might work on the previous releases.
All other requirements are inherited from the `Laravel 8`.
\###PHP 8 is required for this package to work

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

[](#installation)

#### Install package through composer

[](#install-package-through-composer)

```
composer require freedomcore/laravel-openapi
```

#### Publish configuration files and views

[](#publish-configuration-files-and-views)

```
php artisan vendor:publish --provider "FreedomCore\OpenAPI\OpenAPIServiceProvider"
```

#### Edit the `openapi.php` configuration file for your liking

[](#edit-the-openapiphp-configuration-file-for-your-liking)

What is included
----------------

[](#what-is-included)

Out of the box this package can work with `FormRequest`, it is also able to generate valid code for the method parameters when they are included in `query | path`, so there will be no duplicates and `in: ****` will also be assigned correctly.

Usage
-----

[](#usage)

### FreedomCore\\OpenAPI\\Attributes\\Controller

[](#freedomcoreopenapiattributescontroller)

Controller attribute allows you to mark class as a Controller.
This will help generator to recognize classes and create appropriate tags for routes.

```
/**
 * Class User
 * @package App\Http\Controllers\User
 */
#[FreedomCore\OpenAPI\Attributes\Controller(
    name: 'User',
    description: 'User related endpoints'
)]
class User extends Controller {

}
```

### FreedomCore\\OpenAPI\\Attributes\\Request\\\*

[](#freedomcoreopenapiattributesrequest)

There are total of 5 types of requests currently supported by this package.

- **FreedomCore\\OpenAPI\\Attributes\\Request\\Delete**

```
/**
 * Delete constructor.
 * @param string $description
 * @param bool $deprecated
 */
public function __construct(string $description = '', bool $deprecated = false) {
    parent::__construct('DELETE', $description, $deprecated);
}
```

- **FreedomCore\\OpenAPI\\Attributes\\Request\\Get**

```
/**
 * Get constructor.
 * @param string $description
 * @param bool $deprecated
 */
public function __construct(string $description = '', bool $deprecated = false) {
    parent::__construct('GET', $description, $deprecated);
}
```

- **FreedomCore\\OpenAPI\\Attributes\\Request\\Patch**

```
/**
 * Patch constructor.
 * @param string $description
 * @param bool $deprecated
 */
public function __construct(string $description = '', bool $deprecated = false) {
    parent::__construct('PATCH', $description, $deprecated);
}
```

- **FreedomCore\\OpenAPI\\Attributes\\Request\\Post**

```
/**
 * Post constructor.
 * @param string $description
 * @param bool $deprecated
 */
public function __construct(string $description = '', bool $deprecated = false) {
    parent::__construct('POST', $description, $deprecated);
}
```

- **FreedomCore\\OpenAPI\\Attributes\\Request\\Put**

```
/**
 * Put constructor.
 * @param string $description
 * @param bool $deprecated
 */
public function __construct(string $description = '', bool $deprecated = false) {
    parent::__construct('PUT', $description, $deprecated);
}
```

You dont have to use these Attributes unless you want to add description to the resource, possible request types will be inferred from Laravel routing system.

### FreedomCore\\OpenAPI\\Attributes\\Response\\\*

[](#freedomcoreopenapiattributesresponse)

There are total of 18 types of responses currently supported by this package.
They do come with the correct response codes attached to them, so the only thing you have to do (or not) is add description.

This is the base class:

```
