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

ActiveLibrary[API Development](/categories/api)

mdwheele/laravel-openapi
========================

0.1.0(6y ago)21982[4 issues](https://github.com/mdwheele/laravel-openapi/issues)MITPHPPHP ^7.3

Since Sep 9Pushed 6y ago2 watchersCompare

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

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

OpenAPI-driven routing and validation for Laravel
=================================================

[](#openapi-driven-routing-and-validation-for-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/c6239a0a44ffddbaa2c7671aabbefda3d34a9693caf659f248e0732001ca684d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f767072652f6d64776865656c652f6c61726176656c2d6f70656e6170692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mdwheele/laravel-openapi)[![PHP from Packagist](https://camo.githubusercontent.com/27ccd228f4ac9be32ce64f7004623aaedc7f0883f4be25b4ef3de54f0395dcb1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6d64776865656c652f6c61726176656c2d6f70656e617069)](https://camo.githubusercontent.com/27ccd228f4ac9be32ce64f7004623aaedc7f0883f4be25b4ef3de54f0395dcb1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6d64776865656c652f6c61726176656c2d6f70656e617069)[![Total Downloads](https://camo.githubusercontent.com/8d768ec4e26f52c6cd82373f9ce01d7adc179b653091ce2d02327c3254f45986/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d64776865656c652f6c61726176656c2d6f70656e6170692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mdwheele/laravel-openapi)[![CircleCI](https://camo.githubusercontent.com/777a4f80f7399d2bcee9d4babfbfcd99d3bdc623253dd66b26bd75ca9ef182b2/68747470733a2f2f636972636c6563692e636f6d2f67682f6d64776865656c652f6c61726176656c2d6f70656e6170692e7376673f7374796c653d737667)](https://circleci.com/gh/mdwheele/laravel-openapi)

This package allows you to create a single specification for your Laravel application that will register routes and validate all requests your API receives as well as all responses that you generate.

The [OpenAPI](https://github.com/OAI/OpenAPI-Specification) development experience in PHP feels disjoint...

- I can update my OpenAPI specification with no impact on the actual implementation, leaving room for drift.
- I can try and glue them together with process and custom tooling, but I feel like I'm gluing 9,001 pieces of the internet together and it's different for each project. I'd prefer if someone else to do that work.
- Documentation generators are **AMAZING**, but if there's nothing to stop implementation from drifting away from documentation, then is it worth it?
- Tooling to validate JSON Schema is great, but the error messages I get back are hard to grok for beginners and aren't always obvious.

This package aims to create a positive developer experience where you truly have a **single source of record**, your OpenAPI specification. From this, the package will automatically register routes with Laravel. Additionally, it will attach a [Middleware](https://laravel.com/docs/master/middleware) to these routes that will validate all incoming requests and outgoing responses. When the package detects a mismatch in implementation and specification, you'll get a **helpful** error message that hints at **what to do next**.

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

[](#installation)

You can install the package through Composer.

```
composer require mdwheele/laravel-openapi
```

Optionally, you can publish the config file of this package with this command:

```
php artisan vendor:public --provider="Mdwheele\OpenApi\OpenApiServiceProvider"
```

The following config file will be published in `config/openapi.php`:

```
