PHPackages                             macpaw/behat-openapi-psr7-validator - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. macpaw/behat-openapi-psr7-validator

ActiveSymfony-bundle[HTTP &amp; Networking](/categories/http)

macpaw/behat-openapi-psr7-validator
===================================

Behat extension for automatic OpenAPI validation of HTTP requests/responses using league/openapi-psr7-validator

v1.1.0(3mo ago)11.2k1[1 PRs](https://github.com/MacPaw/behat-openapi-psr7-validator/pulls)MITPHPPHP &gt;=8.2CI passing

Since Jan 30Pushed 3mo agoCompare

[ Source](https://github.com/MacPaw/behat-openapi-psr7-validator)[ Packagist](https://packagist.org/packages/macpaw/behat-openapi-psr7-validator)[ Docs](https://github.com/macpaw/behat-openapi-psr7-validator)[ RSS](/packages/macpaw-behat-openapi-psr7-validator/feed)WikiDiscussions develop Synced today

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

Behat OpenAPI PSR-7 Validator
=============================

[](#behat-openapi-psr-7-validator)

Symfony Behat extension for automatic OpenAPI validation of HTTP requests/responses using [league/openapi-psr7-validator](https://github.com/thephpleague/openapi-psr7-validator).

VersionBuild StatusCode CoverageLatest Release`main`[![CI](https://github.com/MacPaw/behat-openapi-psr7-validator/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/MacPaw/behat-openapi-psr7-validator/actions/workflows/ci.yml?query=branch%3Amain)[![Coverage Status](https://camo.githubusercontent.com/4ee8f1e07fb57b5344f6e1573d98f1dfb24ba79261b72e268971f9c2c5e67302/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f6d61637061772f62656861742d6f70656e6170692d707372372d76616c696461746f722f6d61696e3f6c6f676f3d636f6465636f76)](https://codecov.io/gh/macpaw/behat-openapi-psr7-validator/branch/main)[![Latest Release](https://camo.githubusercontent.com/166724ba3a389c67300045968f54d00832d6fbe9eb469353cd0b632e2b41be36/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f6d61637061772f62656861742d6f70656e6170692d707372372d76616c696461746f72)](https://camo.githubusercontent.com/166724ba3a389c67300045968f54d00832d6fbe9eb469353cd0b632e2b41be36/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f6d61637061772f62656861742d6f70656e6170692d707372372d76616c696461746f72)`develop`[![CI](https://github.com/MacPaw/behat-openapi-psr7-validator/actions/workflows/ci.yml/badge.svg?branch=develop)](https://github.com/MacPaw/behat-openapi-psr7-validator/actions/workflows/ci.yml?query=branch%3Adevelop)[![Coverage Status](https://camo.githubusercontent.com/9e4e802069d8a378722a38d32f2ae19e61ce42449e478abf82229d4d1c6b0e22/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f6d61637061772f62656861742d6f70656e6170692d707372372d76616c696461746f722f646576656c6f703f6c6f676f3d636f6465636f76)](https://codecov.io/gh/macpaw/behat-openapi-psr7-validator/branch/develop)----

Features
--------

[](#features)

- Automatic request/response validation against OpenAPI schemas
- Scan local directories for OpenAPI YAML files
- Fetch OpenAPI specs from remote GitHub repositories (with token support for private repos)
- Separate control for request and response validation skipping
- Auto-skip request validation for 4xx responses (configurable)
- Tag-based and step-based validation control

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

[](#installation)

```
composer require --dev macpaw/behat-openapi-psr7-validator
```

### HTTP Client Requirement (Optional)

[](#http-client-requirement-optional)

GitHub schema loading requires a PSR-18 HTTP client registered as `Psr\Http\Client\ClientInterface`. The GitHub loader only activates when both conditions are met:

- `github_sources` is configured
- HTTP client service is available

If using only `local_paths`, no HTTP client is needed.

```
# Install if using github_sources
composer require symfony/http-client
```

Configuration
-------------

[](#configuration)

### 1. Register the bundle

[](#1-register-the-bundle)

```
// config/bundles.php
return [
    // ... other bundles
    BehatOpenApiValidator\BehatOpenApiValidatorBundle::class => ['test' => true],
];
```

### 2. Configure the package and register event subscriber

[](#2-configure-the-package-and-register-event-subscriber)

```
# config/packages/behat_openapi_validator.yaml
when@test:
    behat_openapi_validator:
        is_enabled: true
        should_request_on_4xx_be_skipped: true
        local_paths:
            - '%kernel.project_dir%/docs/openapi'
        github_sources:
            - url: 'https://github.com/Owner/Repo/tree/main/docs/openapi'
              token_env: 'GITHUB_TOKEN'

    services:
      BehatOpenApiValidator\EventListener\ApiContextListener:
        tags: ['kernel.event_subscriber']
```

### 3. Add context to behat.yml

[](#3-add-context-to-behatyml)

```
default:
    suites:
        default:
            contexts:
                - BehatOpenApiValidator\Context\OpenApiValidatorContext
```

Usage
-----

[](#usage)

### Automatic Validation

[](#automatic-validation)

Once configured, the package automatically validates:

- **Requests**: Validated against OpenAPI schema before response
- **Responses**: Validated against OpenAPI schema after response

### Skip Validation

[](#skip-validation)

#### Using Tags

[](#using-tags)

```
@skipOpenApiValidation
Scenario: Skip all validation
    When I send "GET" request to "some_route" route

@skipOpenApiRequestValidation
Scenario: Skip only request validation
    When I send "POST" request to "invalid_request_route" route

@skipOpenApiResponseValidation
Scenario: Skip only response validation
    When I send "GET" request to "route_with_custom_response" route
```

#### Using Steps

[](#using-steps)

```
Scenario: Disable validation via step
    Given OpenAPI validation is disabled
    When I send "GET" request to "some_route" route

Scenario: Disable only request validation
    Given OpenAPI request validation is disabled
    When I send "POST" request to "some_route" route

Scenario: Disable only response validation
    Given OpenAPI response validation is disabled
    When I send "GET" request to "some_route" route
```

### 4xx Response Handling

[](#4xx-response-handling)

By default, request validation is skipped for 4xx responses (the request is intentionally invalid to trigger the error). Response validation still runs to ensure error responses match the OpenAPI error schema.

Configure via `should_request_on_4xx_be_skipped: false` to always validate requests.

License
-------

[](#license)

MIT

---

###  Health Score

45

—

FairBetter than 91% of packages

Maintenance81

Actively maintained with recent releases

Popularity22

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

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

Recently: every ~13 days

Total

8

Last Release

100d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1935412?v=4)[MacPaw Inc.](/maintainers/macpaw)[@MacPaw](https://github.com/MacPaw)

---

Top Contributors

[![zakhar-huzenko](https://avatars.githubusercontent.com/u/26282904?v=4)](https://github.com/zakhar-huzenko "zakhar-huzenko (26 commits)")[![cursoragent](https://avatars.githubusercontent.com/u/199161495?v=4)](https://github.com/cursoragent "cursoragent (3 commits)")[![crossplanegithub[bot]](https://avatars.githubusercontent.com/u/1935412?v=4)](https://github.com/crossplanegithub[bot] "crossplanegithub[bot] (1 commits)")

---

Tags

apibackendbddbehatmacpawopenapipsr-7symfony-bundlevalidatorpsr-7apisymfonyvalidatoropenapiBDDBehatMacPaw

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/macpaw-behat-openapi-psr7-validator/health.svg)

```
[![Health](https://phpackages.com/badges/macpaw-behat-openapi-psr7-validator/health.svg)](https://phpackages.com/packages/macpaw-behat-openapi-psr7-validator)
```

###  Alternatives

[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.6M574](/packages/shopware-core)[shopware/platform

The Shopware e-commerce core

3.4k1.5M3](/packages/shopware-platform)[drupal/core-recommended

Locked core dependencies; require this project INSTEAD OF drupal/core.

6942.5M421](/packages/drupal-core-recommended)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.1k17.8k](/packages/prestashop-prestashop)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.4M203](/packages/sulu-sulu)[aeliot/todo-registrar

Register TODOs from source code in issue tracker

153.0k](/packages/aeliot-todo-registrar)

PHPackages © 2026

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