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

ActiveLibrary[API Development](/categories/api)

mikegarde/laravel-openapi-export
================================

Laravel package to export OpenAPI/Swagger documentation from routes

0.0.1(1y ago)05GPL-3.0-onlyPHPPHP ^8.0

Since Jan 25Pushed 1y ago1 watchersCompare

[ Source](https://github.com/MikeGarde/laravel-openapi-export)[ Packagist](https://packagist.org/packages/mikegarde/laravel-openapi-export)[ RSS](/packages/mikegarde-laravel-openapi-export/feed)WikiDiscussions main Synced 1mo ago

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

Laravel OpenAPI Export
======================

[](#laravel-openapi-export)

This package provides a simple way to export your Laravel routes to an OpenAPI 3.0 specification file.

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

[](#installation)

You can install the package via composer:

```
composer require mikegarde/laravel-openapi-export --dev
```

Usage
-----

[](#usage)

To export your routes to an OpenAPI 3.0 specification file, run the following command:

```
php artisan openapi:export
```

This will generate a file called `openapi.yml` in the root of your project. Pop it into your favorite OpenAPI viewer like [editor.swagger.io](https://editor.swagger.io/) and you're 4% closer to having a fully documented API!

### Options

[](#options)

Change the output file path:

```
php artisan openapi:export --output=path/to/docs/file.yml
```

Change the output format:

```
php artisan openapi:export --format=json
```

Raw Output
----------

[](#raw-output)

```
php artisan openapi:export --raw
```

In RESTful API design, route parameters are typically used to identify resources or perform specific actions. They are generally required, as their presence directly impacts the resource being accessed or manipulated. However, Laravel allows for optional route parameters in URLs (e.g., /users/{id?}), which can lead to ambiguity and inconsistencies in how the API behaves or is interpreted by developers and consumers.

By default, this package resolves the ambiguity introduced by optional route parameters by duplicating such routes into two distinct versions:

- A route where the optional parameter is entirely absent.
- A route where the parameter is included but marked as required.

This approach aligns with API best practices, where route parameters in the path are considered mandatory for proper identification of resources. It ensures that:

- Clarity: Consumers of the API know understand the different responses when "optional" parameters are skipped.
- Consistency: The API adheres to conventional REST principles, avoiding unexpected behavior when optional parameters are included in a path.
- Validation: APIs that depend on OpenAPI/Swagger documentation or automated tools can properly validate requests, reducing errors caused by ambiguous routing definitions.

However if you want to keep the optional parameters as optional, you can disable this behavior by setting the `--raw` flag when running the `openapi:export` command.

TODO
----

[](#todo)

- Add support for exporting only specific routes
- Add support for exporting only routes with specific tags
- Add support for exporting only routes with specific methods
- Add support for updating existing OpenAPI files

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance44

Moderate activity, may be stable

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity32

Early-stage or recently created project

 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

Unknown

Total

1

Last Release

469d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/38661d707f6a81eb0c2855c2f16143a3c744b89e8ef63044fc05fceb9b28f46a?d=identicon)[MikeGarde](/maintainers/MikeGarde)

---

Top Contributors

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

---

Tags

laravelswaggeropenapi

### Embed Badge

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

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

###  Alternatives

[darkaonline/l5-swagger

OpenApi or Swagger integration to Laravel

2.9k34.0M111](/packages/darkaonline-l5-swagger)[darkaonline/swagger-lume

OpenApi or Swagger integration to Lumen

3372.3M3](/packages/darkaonline-swagger-lume)[wotz/laravel-swagger-ui

Add Swagger UI to a Laravel application.

277321.8k](/packages/wotz-laravel-swagger-ui)[erasys/openapi-php

Open API 3.0 builder and validation library for PHP that helps you write valid specs.

2080.3k4](/packages/erasys-openapi-php)

PHPackages © 2026

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