PHPackages                             paddlehq/openapi-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. paddlehq/openapi-validator

AbandonedArchivedPackage[HTTP &amp; Networking](/categories/http)

paddlehq/openapi-validator
==========================

Validate Responses against an OpenApi v3 schema

1.0.2(7y ago)1056.5k4[4 issues](https://github.com/PaddleHQ/openapi-validator/issues)[1 PRs](https://github.com/PaddleHQ/openapi-validator/pulls)Apache-2.0PHPPHP ^7.1

Since Aug 7Pushed 7y agoCompare

[ Source](https://github.com/PaddleHQ/openapi-validator)[ Packagist](https://packagist.org/packages/paddlehq/openapi-validator)[ Docs](https://github.com/PaddleHQ/open-api-validator)[ RSS](/packages/paddlehq-openapi-validator/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (6)Versions (6)Used By (0)

OpenApi Validator
=================

[](#openapi-validator)

[![Latest Stable Version](https://camo.githubusercontent.com/5b6ce0aaf01f3d6b8b20300792aaf1348314864f39c3016153133f2787b58126/68747470733a2f2f706f7365722e707567782e6f72672f706164646c6568712f6f70656e6170692d76616c696461746f722f762f737461626c65)](https://packagist.org/packages/paddlehq/openapi-validator) [![Total Downloads](https://camo.githubusercontent.com/d2253674236b0fb0e88fe44a87b7ea053e9687cd6773e6bc8606b8428460b466/68747470733a2f2f706f7365722e707567782e6f72672f706164646c6568712f6f70656e6170692d76616c696461746f722f646f776e6c6f616473)](https://packagist.org/packages/paddlehq/openapi-validator) [![Latest Unstable Version](https://camo.githubusercontent.com/d3fe08d704164f96a98a6ca677ee18e91c88623ed6bc6be56e0735772ac48b22/68747470733a2f2f706f7365722e707567782e6f72672f706164646c6568712f6f70656e6170692d76616c696461746f722f762f756e737461626c65)](https://packagist.org/packages/paddlehq/openapi-validator) [![License](https://camo.githubusercontent.com/e69b4ce7ec841303702a5dc1f882444ca908126e7db42a4b37bbb133982feef7/68747470733a2f2f706f7365722e707567782e6f72672f706164646c6568712f6f70656e6170692d76616c696461746f722f6c6963656e7365)](https://packagist.org/packages/paddlehq/openapi-validator) [![Daily Downloads](https://camo.githubusercontent.com/dde35f42ec23171bb098a95df64047dee58f00fd94ac2ab07363cbe69a5769b5/68747470733a2f2f706f7365722e707567782e6f72672f706164646c6568712f6f70656e6170692d76616c696461746f722f642f6461696c79)](https://packagist.org/packages/paddlehq/openapi-validator)

This package takes an [OpenApi 3](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md) schema file, converts it to a [JSON Schema (draft 4)](http://json-schema.org/specification-links.html#draft-4) so it can be used for validation.

This is the used to validate a response that implements the `Psr\Http\Message\ResponseInterface.` interface against a given response in the OpenApi schema.

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

[](#installation)

### Library

[](#library)

```
git clone https://github.com/PaddleHQ/openapi-validator.git
```

### Composer

[](#composer)

[Install PHP Composer](https://getcomposer.org/doc/00-intro.md)

```
composer require paddlehq/openapi-validator
```

Usage
-----

[](#usage)

```
use PaddleHq\OpenApiValidator\OpenApiValidatorFactory;

$validatorFactory = new OpenApiValidatorFactory();

$schemaFilePath = __DIR__.'/schema.json'; // See below for example contents of this file
$validator = $validatorFactory->v3Validator($schemaFilePath);

$response = new Psr7Response();
$pathName = '/check/health';
$method = 'GET';
$responseCode = 200;
$contentType = 'application/json';

$validator->validateResponse(
    $response,
    $pathName,
    $method,
    $responseCode,
    $contentType
);
```

### Example OpenApi v3 Schema file

[](#example-openapi-v3-schema-file)

```
{
  "openapi": "3.0.0",
  "info": {
    "title": "Schema Test",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "http://example.com",
      "description": "Test Schema"
    }
  ],
  "paths": {
    "/check/health": {
      "get": {
        "tags": [
          "Checks"
        ],
        "summary": "Health Check.",
        "description": "Returns an OK",
        "operationId": "api.check.user",
        "responses": {
          "200": {
            "description": "Success response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HealthCheck"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "HealthCheck": {
        "description": "Default response from API server to check health",
        "properties": {
          "health": {
            "description": "expect an OK response",
            "type": "string"
          }
        },
        "required": ["health"],
        "type": "object"
      }
    }
  }
}
```

`$validator->validateResponse` throws a `PaddleHq\OpenApiValidator\Exception\InvalidResponseException` when the response does not pass the validation.

Credits
-------

[](#credits)

This package largely relies on [justinrainbow/json-schema](https://github.com/justinrainbow/json-schema).

The code that handles conversion from OpenApi V3 to Json Schema has been taken from [hskrasek/openapi-schema-to-jsonschema](https://github.com/hskrasek/openapi-schema-to-jsonschema)

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance12

Infrequent updates — may be unmaintained

Popularity34

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 66.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 ~21 days

Total

3

Last Release

2844d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7043ccbfe9de8c76b2e70256dedb21c68508cd5440098feaa9bef4a6bfe5e442?d=identicon)[Paddle](/maintainers/Paddle)

---

Top Contributors

[![StuMason](https://avatars.githubusercontent.com/u/21249318?v=4)](https://github.com/StuMason "StuMason (2 commits)")[![danielfosbery](https://avatars.githubusercontent.com/u/1961881?v=4)](https://github.com/danielfosbery "danielfosbery (1 commits)")

---

Tags

psr-7json-schemaswaggeropenapi

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/paddlehq-openapi-validator/health.svg)

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

###  Alternatives

[guzzlehttp/psr7

PSR-7 message implementation that also provides common utility methods

8.0k1.1B4.0k](/packages/guzzlehttp-psr7)[symfony/psr-http-message-bridge

PSR HTTP message bridge

1.3k320.9M983](/packages/symfony-psr-http-message-bridge)[sunrise/http-router

A powerful solution as the foundation of your project.

17451.6k10](/packages/sunrise-http-router)[oat-sa/tao-core

TAO core extension

66143.7k122](/packages/oat-sa-tao-core)[mezzio/mezzio

PSR-15 Middleware Microframework

3923.8M125](/packages/mezzio-mezzio)[api-platform/json-schema

Generate a JSON Schema from a PHP class

324.8M72](/packages/api-platform-json-schema)

PHPackages © 2026

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