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

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

ensi/laravel-openapi-testing
============================

laravel openapi testing

0.4.3(1y ago)269.5k↓25%5MITPHPPHP ^8.1CI passing

Since Aug 24Pushed 9mo ago2 watchersCompare

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

READMEChangelog (10)Dependencies (8)Versions (13)Used By (0)

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

[](#laravel-openapi-testing)

[![Latest Version on Packagist](https://camo.githubusercontent.com/ac3efdefea8b169d0cee2f6f87d2dd4280aeda47f583c591776ab509e9c612b4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f656e73692f6c61726176656c2d6f70656e6170692d74657374696e672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ensi/laravel-openapi-testing)[![Tests](https://github.com/ensi-platform/laravel-openapi-testing/actions/workflows/run-tests.yml/badge.svg?branch=master)](https://github.com/ensi-platform/laravel-openapi-testing/actions/workflows/run-tests.yml)[![Total Downloads](https://camo.githubusercontent.com/847a74e970bb498b5283bb8f5f3c200e4400be3d2e33a417be67e3e11226421e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f656e73692f6c61726176656c2d6f70656e6170692d74657374696e672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ensi/laravel-openapi-testing)

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

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

[](#installation)

You can install the package via composer:

```
composer require ensi/laravel-openapi-testing --dev
```

Version Compatibility
---------------------

[](#version-compatibility)

Laravel OpenApi TestingPHP^0.1.0^8.0^0.2.0^8.0^0.3.0^8.0^0.4.0^8.1Basic 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. composer test

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](.github/SECURITY.md) on how to report security vulnerabilities.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance52

Moderate activity, may be stable

Popularity36

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~121 days

Recently: every ~87 days

Total

12

Last Release

393d ago

PHP version history (2 changes)0.1.0PHP ^8.0

0.4.0PHP ^8.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/8089373?v=4)[Наталия](/maintainers/MsNatali)[@MsNatali](https://github.com/MsNatali)

![](https://avatars.githubusercontent.com/u/7352966?v=4)[Andrey](/maintainers/dimionx)[@DimionX](https://github.com/DimionX)

---

Top Contributors

[![MsNatali](https://avatars.githubusercontent.com/u/8089373?v=4)](https://github.com/MsNatali "MsNatali (17 commits)")[![arrilot](https://avatars.githubusercontent.com/u/2826480?v=4)](https://github.com/arrilot "arrilot (9 commits)")[![DimionX](https://avatars.githubusercontent.com/u/7352966?v=4)](https://github.com/DimionX "DimionX (7 commits)")[![C0rTeZ13](https://avatars.githubusercontent.com/u/120840631?v=4)](https://github.com/C0rTeZ13 "C0rTeZ13 (2 commits)")[![valerialukinykh](https://avatars.githubusercontent.com/u/123940772?v=4)](https://github.com/valerialukinykh "valerialukinykh (2 commits)")[![koopaTro0pa](https://avatars.githubusercontent.com/u/60116849?v=4)](https://github.com/koopaTro0pa "koopaTro0pa (1 commits)")

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[phpspec/prophecy

Highly opinionated mocking framework for PHP 5.3+

8.5k551.7M682](/packages/phpspec-prophecy)[brianium/paratest

Parallel testing for PHP

2.5k118.8M754](/packages/brianium-paratest)[beberlei/assert

Thin assertion library for input validation in business models.

2.4k96.9M570](/packages/beberlei-assert)[mikey179/vfsstream

Virtual file system to mock the real file system in unit tests.

1.4k108.0M2.7k](/packages/mikey179-vfsstream)[orchestra/testbench

Laravel Testing Helper for Packages Development

2.2k39.1M32.1k](/packages/orchestra-testbench)[phpspec/phpspec

Specification-oriented BDD framework for PHP 7.1+

1.9k36.7M3.1k](/packages/phpspec-phpspec)

PHPackages © 2026

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