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(1y ago)021MITPHPPHP ^8.2

Since Oct 27Pushed 1y 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 1mo ago

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

28

—

LowBetter than 54% of packages

Maintenance31

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 75% 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

710d ago

PHP version history (2 changes)1.0.0PHP ^8.0

1.1PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/1a6d95b26fae4c4c707d38dcfe304d47866f24355c6ecf8b3fd2016ee7b0cfb8?d=identicon)[vfunin](/maintainers/vfunin)

---

Top Contributors

[![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

933635.2k2](/packages/mpociot-laravel-test-factory-helper)[thedoctor0/laravel-factory-generator

Automatically generate Laravel factories for your models.

214997.4k1](/packages/thedoctor0-laravel-factory-generator)[laravel-shift/factory-generator

Generate factories from existing models

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

Laravel extension for Behat

2611.3M12](/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

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

PHPackages © 2026

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