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

ActiveLibrary[API Development](/categories/api)

brocc/laravel-openapi
=====================

Write OpenApi Specification for Laravel Applications

v1.0.3(2mo ago)210.1k↓38.9%3[1 issues](https://github.com/brocc-ab/laravel-openapi/issues)MITPHPPHP ^7.3|^8.0|^8.2

Since Feb 25Pushed 2mo ago3 watchersCompare

[ Source](https://github.com/brocc-ab/laravel-openapi)[ Packagist](https://packagist.org/packages/brocc/laravel-openapi)[ RSS](/packages/brocc-laravel-openapi/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (8)Versions (7)Used By (0)

Write OpenAPI Specifications for Laravel Applications
=====================================================

[](#write-openapi-specifications-for-laravel-applications)

[![Latest Version](https://camo.githubusercontent.com/c206770eda91c046ae1dae4026e8819006bc9b5bfb0f82ce4da913406f6f4189/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f62726f63632d61622f6c61726176656c2d6f70656e6170692e7376673f7374796c653d666c61742d737175617265)](https://github.com/brocc-ab/laravel-openapi/releases)[![Build Status](https://camo.githubusercontent.com/db43a524fa92720fa8d3916c4876e7cee3ddaf80949d17f6a7fe64bfcbe9b165/68747470733a2f2f7472617669732d63692e636f6d2f62726f63632d61622f6c61726176656c2d6f70656e6170692e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/brocc-ab/laravel-openapi)[![StyleCI](https://camo.githubusercontent.com/da686c22ca5d79827be5f141787691c0380ab27c01467b444026bc3ee907d451/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3334313937363934362f736869656c643f6272616e63683d6d6173746572)](https://github.styleci.io/repos/341976946?branch=master)[![License](https://camo.githubusercontent.com/a335c00c4ebc27fffce5f69dc37898de512c8affa7a724b3c4152c3567e1cd24/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f62726f63632f6c61726176656c2d6f70656e617069)](https://packagist.org/packages/brocc/laravel-openapi)

This packages simplifies writing and structuring of OpenAPI Specifications in YAML or JSON.

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

[](#introduction)

OpenAPI Specifications generated from annotations or auto-generated from code is great, especially when working with smaller API's. But when an API grows and gets more complex, using annotations can easily become a mess, ending up in more annotations than actual code.

This package helps writing and structuring [OpenAPI Specifications](https://swagger.io/specification/) written in YAML or JSON. Specifications with referenced parts are merged into a single specification file. This package also comes with [ReDoc](https://github.com/Redocly/redoc) as an UI for your documentation.

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

[](#installation)

To get started, install Laravel OpenAPI via composer:

```
composer require brocc/laravel-openapi

```

You can optionally publish the config file and views with:

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

```

By default this package will check for an OpenAPI Specification file located in `base_path('/api-docs/openapi.yaml')`, this can easily be changes in the config file.

To generate a specification run the following command:

```
php artisan openapi:generate

```

Multiple Specifications
-----------------------

[](#multiple-specifications)

You might have multiple specifications, eg. a public API and an internal API, or even multiple API versions that you wish to separate into different specifications.

### Example of multi-version config.

[](#example-of-multi-version-config)

You can easily generate multiple specifications by adding additional documentations in `config/openapi.php`:

```
'documentations'  => [
    'default' => [
        'title' => 'Docs - latest',

        // Absolute path to the main OpenAPI specification.
        'spec'  => base_path('api-docs/v2/openapi.yaml'),

        'routes' => [
            // Route for accessing documentation UI.
            'ui'         => '/docs',

            // Route to OpenAPI specification file, can be json or yaml.
            'openapi'    => '/openapi/v2/openapi.json',

            // Middleware to be applied on the ui and docs, eg. api, auth, trusted_proxies etc.
            'middleware' => [
                'ui'      => [],
                'openapi' => [],
            ],
        ],
    ],
    'v1' => [
        'title' => 'Docs - v1',

        'spec'  => base_path('api-docs/v1/openapi.yaml'),

        'routes' => [
            'ui'         => '/docs/v1',

            'openapi'    => '/openapi/v1/openapi.json',

            'middleware' => [
                'ui'      => [],
                'openapi' => [],
            ],
        ],
    ],
],
```

This will generate two documentations accessible at `/docs` and `/docs/v1` in your browser, with the specifications accessible at `/openapi/v2/openapi.json` and `/openapi/v1/openapi.json`.

You can easily chose to publish only one specification by specifying the documentation in the `openapi:generate` command:

```
php artisan openapi:generate v1

```

Development
-----------

[](#development)

During development you might want to see the updated docs every time a specification has changed. This can be done by setting `generate_always` to be `true`. It is recommended to keep it set to `false` in production.

Contributing
------------

[](#contributing)

Any contributions are welcome!

We accept contributions via Pull Requests on Github.

###  Health Score

51

—

FairBetter than 96% of packages

Maintenance77

Regular maintenance activity

Popularity30

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 69.2% 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 ~461 days

Total

5

Last Release

62d ago

Major Versions

v0.1.0 → v1.0.02021-02-25

PHP version history (3 changes)v0.1.0PHP ^7.2|^8.0

v1.0.0PHP ^7.3|^8.0

v1.0.3PHP ^7.3|^8.0|^8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/6029843?v=4)[Sami Wiktorin](/maintainers/sayme)[@sayme](https://github.com/sayme)

---

Top Contributors

[![sayme](https://avatars.githubusercontent.com/u/6029843?v=4)](https://github.com/sayme "sayme (9 commits)")[![Gustafsson-Martin](https://avatars.githubusercontent.com/u/51970823?v=4)](https://github.com/Gustafsson-Martin "Gustafsson-Martin (3 commits)")[![teddywafula](https://avatars.githubusercontent.com/u/8319659?v=4)](https://github.com/teddywafula "teddywafula (1 commits)")

---

Tags

laravelopenapidocs

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[darkaonline/l5-swagger

OpenApi or Swagger integration to Laravel

2.9k34.0M112](/packages/darkaonline-l5-swagger)[wotz/laravel-swagger-ui

Add Swagger UI to a Laravel application.

277321.8k](/packages/wotz-laravel-swagger-ui)[m165437/laravel-blueprint-docs

API Blueprint Renderer for Laravel

22779.0k](/packages/m165437-laravel-blueprint-docs)[johnylemon/laravel-apidocs

Laravel API documentation generating tool

472.8k](/packages/johnylemon-laravel-apidocs)

PHPackages © 2026

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