PHPackages                             specdocular/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. [HTTP &amp; Networking](/categories/http)
4. /
5. specdocular/laravel-openapi

ActiveLibrary[HTTP &amp; Networking](/categories/http)

specdocular/laravel-openapi
===========================

Generate OpenAPI Specification for Laravel Applications

v0.7.1(3w ago)0444↓93.3%MITPHPPHP ^8.2CI failing

Since Feb 13Pushed 3w agoCompare

[ Source](https://github.com/specdocular/laravel-openapi)[ Packagist](https://packagist.org/packages/specdocular/laravel-openapi)[ Docs](https://github.com/specdocular/laravel-openapi)[ RSS](/packages/specdocular-laravel-openapi/feed)WikiDiscussions main Synced 2w ago

READMEChangelogDependencies (48)Versions (9)Used By (0)

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

[](#laravel-openapi)

[![Latest Version on Packagist](https://camo.githubusercontent.com/fe7c8d5633a28ea1b36badda6aa8aeebddf9e34adf7a548fa9dcee3325e92586/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73706563646f63756c61722f6c61726176656c2d6f70656e6170692e737667)](https://packagist.org/packages/specdocular/laravel-openapi)[![PHP Version](https://camo.githubusercontent.com/6b0d9586168f674fbd1f481946ac6f01910443360c80f5226bbf030f9b428346/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f73706563646f63756c61722f6c61726176656c2d6f70656e6170692e737667)](https://packagist.org/packages/specdocular/laravel-openapi)[![Tests](https://github.com/specdocular/laravel-openapi/actions/workflows/tests.yml/badge.svg)](https://github.com/specdocular/laravel-openapi/actions/workflows/tests.yml)[![codecov](https://camo.githubusercontent.com/586e754cabe1aabf5eedda8b834248b084c422d75f206c05ec96020bf23819c8/68747470733a2f2f636f6465636f762e696f2f67682f73706563646f63756c61722f6c61726176656c2d6f70656e6170692f67726170682f62616467652e737667)](https://codecov.io/gh/specdocular/laravel-openapi)[![Code Style](https://github.com/specdocular/laravel-openapi/actions/workflows/php-cs-fixer.yml/badge.svg)](https://github.com/specdocular/laravel-openapi/actions/workflows/php-cs-fixer.yml)

Generate [OpenAPI 3.1.x](https://spec.openapis.org/oas/v3.1.1.html) specifications for Laravel applications using a factory-based, "Laravel way" approach.

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

[](#requirements)

- PHP 8.2 or higher
- Laravel 10, 11, or 12

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

[](#installation)

```
composer require specdocular/laravel-openapi
```

The service provider is auto-discovered by Laravel. Publish the config:

```
php artisan vendor:publish --tag=openapi-config
```

Usage
-----

[](#usage)

### 1. Create an OpenAPI Factory

[](#1-create-an-openapi-factory)

```
use Specdocular\LaravelOpenAPI\Factories\OpenAPIFactory;
use Specdocular\OpenAPI\Schema\Objects\OpenAPI\OpenAPI;
use Specdocular\OpenAPI\Schema\Objects\Info\Info;

class MyAPIFactory extends OpenAPIFactory
{
    public function instance(): OpenAPI
    {
        return OpenAPI::v311(
            Info::create('My API', '1.0.0')
                ->description('API documentation'),
        );
    }
}
```

#### Targeting an OpenAPI version

[](#targeting-an-openapi-version)

The target OAS version is a construction detail of the document, declared by the factory you call — not a config key. `OpenAPI::v311(...)` emits OpenAPI 3.1.1 (the default). To emit **OpenAPI 3.2.0**, call `OpenAPI::v320(...)` instead:

```
    public function instance(): OpenAPI
    {
        return OpenAPI::v320(
            Info::create('My API', '1.0.0')
                ->description('API documentation'),
        );
    }
```

Both factories take the same `Info` and are otherwise interchangeable; the version lives with the document because it co-varies with how the document is built.

### 2. Configure Documents

[](#2-configure-documents)

In `config/openapi.php`:

```
'documents' => [
    'default' => [
        'openapi' => MyAPIFactory::class,
        'directories' => [
            app_path('OpenAPI'),
        ],
    ],
],
```

### 3. Create Component Factories

[](#3-create-component-factories)

Define reusable request bodies, responses, schemas, and parameters as factory classes. Place them in your configured directories and they will be auto-discovered.

### 4. Generate the Spec

[](#4-generate-the-spec)

```
$openApi = app(\Specdocular\LaravelOpenAPI\Generator::class)
    ->generate('default');

$json = json_encode($openApi, JSON_PRETTY_PRINT);
```

Features
--------

[](#features)

- Factory-based component system (schemas, responses, request bodies, parameters)
- Auto-discovery of factories from configured directories
- Multi-document support for separate API versions or modules
- Route-based generation using Laravel route attributes
- Built on [specdocular/php-openapi](https://github.com/specdocular/php-openapi) for the OpenAPI object model

Related Packages
----------------

[](#related-packages)

PackageDescription[specdocular/php-json-schema](https://github.com/specdocular/php-json-schema)JSON Schema Draft 2020-12 builder[specdocular/php-openapi](https://github.com/specdocular/php-openapi)Object-oriented OpenAPI builder (foundation)[specdocular/laravel-rules-to-schema](https://github.com/specdocular/laravel-rules-to-schema)Convert Laravel validation rules to JSON SchemaContributing
------------

[](#contributing)

Contributions are welcome. See [CONTRIBUTING.md](CONTRIBUTING.md) for setup, the required checks, and versioning.

Security
--------

[](#security)

If you discover a security vulnerability, please follow the process in [SECURITY.md](SECURITY.md) rather than opening a public issue.

License
-------

[](#license)

MIT. See [LICENSE](LICENSE) for details.

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance95

Actively maintained with recent releases

Popularity15

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity43

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 ~23 days

Recently: every ~0 days

Total

8

Last Release

24d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e05ce3549156452319c5fdfc014b5eb441e3a6148f1f4957fb863026ecc6f8a0?d=identicon)[mohammad-alavi](/maintainers/mohammad-alavi)

---

Top Contributors

[![Mohammad-Alavi](https://avatars.githubusercontent.com/u/24431504?v=4)](https://github.com/Mohammad-Alavi "Mohammad-Alavi (23 commits)")

---

Tags

apilaravelrestdocumentationswaggeropenapidocs

###  Code Quality

TestsPest

Static AnalysisPHPStan, Psalm, Rector

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/specdocular-laravel-openapi/health.svg)

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

###  Alternatives

[vyuldashev/laravel-openapi

Generate OpenAPI Specification for Laravel Applications

4611.3M](/packages/vyuldashev-laravel-openapi)[darkaonline/l5-swagger

OpenApi or Swagger integration to Laravel

2.9k38.9M150](/packages/darkaonline-l5-swagger)[api-platform/laravel

API Platform support for Laravel

58190.1k21](/packages/api-platform-laravel)[tartanlegrand/laravel-openapi

Generate OpenAPI Specification for Laravel Applications

38222.3k2](/packages/tartanlegrand-laravel-openapi)[lomkit/laravel-rest-api

A package to build quick and robust rest api for the Laravel framework.

60067.0k](/packages/lomkit-laravel-rest-api)[noitran/opendox

OpenApi(Swagger) 3.0 package for Lumen 5.5+ and Laravel 5.5+ with REDOC UI and SwaggerUI 3

2214.6k](/packages/noitran-opendox)

PHPackages © 2026

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