PHPackages                             vfunin/laravel-openapi-testing - 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. [Testing &amp; Quality](/categories/testing)
4. /
5. vfunin/laravel-openapi-testing

ActiveLibrary[Testing &amp; Quality](/categories/testing)

vfunin/laravel-openapi-testing
==============================

1.2(2y ago)021MITPHPPHP ^8.2

Since Oct 27Pushed 2y ago1 watchersCompare

[ Source](https://github.com/vfunin/laravel-openapi-testing)[ Packagist](https://packagist.org/packages/vfunin/laravel-openapi-testing)[ RSS](/packages/vfunin-laravel-openapi-testing/feed)WikiDiscussions main Synced yesterday

READMEChangelog (3)Dependencies (7)Versions (7)Used By (0)

Laravel OpenApi Testing
=======================

[](#laravel-openapi-testing)

This packages is based on `osteel/openapi-httpfoundation-testing` and provides `ValidatesAgainstOpenApiSpec` trait

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

[](#installation)

You can install the package via composer:

`composer require mib/laravel-openapi-testing`

Basic usage
-----------

[](#basic-usage)

Let's add validation according to oas3 to our tests. All we need is to `use ValidatesAgainstOpenApiSpec;` and implement `getOpenApiDocumentPath(): string` method like that:

```
class SomeTestCase extends AnotherTestCase
{
    use ValidatesAgainstOpenApiSpec;

    protected function getOpenApiDocumentPath(): string
    {
        return public_path('api-docs/v1/index.yaml');
    }
}
```

The trait overrides `$this->call` method to add the needed validation As a result all http related helper methods (`$this->get()`, `$this->postJson()` and e.t.c) perform the validation too. Both request and response is validated to match some part of the given spec. If validation fails your tests is automatically marked as failed, no need to need any manual assertions.

### Turning validation off

[](#turning-validation-off)

In some cases you may want to turn validation for a specific request. Here is an example how to do it:

```
// Turn off validation for both request
$this->skipNextOpenApiRequestValidation()->getJson(...);

// Turn off validation for both response
$this->skipNextOpenApiResponseValidation()->getJson(...);

// Turn off validation for both request and response
$this->skipNextOpenApiValidation()->getJson(...);
```

### Mapping paths

[](#mapping-paths)

In order to validate request against oas3 the package need to map it to one of the paths described in specification document. We use path from Laravel's route (`$request->route()->uri`) for that purpose. If it does not fully match in your case you can explicitly set OpenApi path for the current request like that:

```
$this->forceOpenApiPath('/pets/{petId}')->getJson(...);
```

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

[](#contributing)

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

### Testing

[](#testing)

1. composer install
2. npm i
3. composer test

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 60% 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 ~44 days

Recently: every ~56 days

Total

6

Last Release

758d ago

PHP version history (2 changes)1.0.0PHP ^8.0

1.1PHP ^8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/74611423?v=4)[Vladislav Funin](/maintainers/vfunin)[@vfunin](https://github.com/vfunin)

---

Top Contributors

[![synacsuser-ship-it](https://avatars.githubusercontent.com/u/288554401?v=4)](https://github.com/synacsuser-ship-it "synacsuser-ship-it (6 commits)")[![vfunin](https://avatars.githubusercontent.com/u/74611423?v=4)](https://github.com/vfunin "vfunin (3 commits)")[![bobanobi4](https://avatars.githubusercontent.com/u/37823768?v=4)](https://github.com/bobanobi4 "bobanobi4 (1 commits)")

---

Tags

laravelfactory

###  Code Quality

TestsPest

Code StylePHP CS Fixer

### Embed Badge

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

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

###  Alternatives

[mpociot/laravel-test-factory-helper

Generate Laravel test factories from your existing models

933639.6k4](/packages/mpociot-laravel-test-factory-helper)[thedoctor0/laravel-factory-generator

Automatically generate Laravel factories for your models.

2151.1M1](/packages/thedoctor0-laravel-factory-generator)[laravel-shift/factory-generator

Generate factories from existing models

49796.0k](/packages/laravel-shift-factory-generator)[laracasts/behat-laravel-extension

Laravel extension for Behat

2621.3M13](/packages/laracasts-behat-laravel-extension)[kunicmarko/graphql-test

GraphQL Test Cases

1359.0k](/packages/kunicmarko-graphql-test)[mnabialek/laravel-quick-migrations

Run Laravel tests quicker

2211.1k](/packages/mnabialek-laravel-quick-migrations)

PHPackages © 2026

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