PHPackages                             mlambley/swagvalidator - 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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. mlambley/swagvalidator

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

mlambley/swagvalidator
======================

Validates data against a Swagger schema

1.0.0(5y ago)068MITPHPPHP &gt;=5.6

Since Nov 25Pushed 5y ago1 watchersCompare

[ Source](https://github.com/mlambley/swagvalidator)[ Packagist](https://packagist.org/packages/mlambley/swagvalidator)[ RSS](/packages/mlambley-swagvalidator/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (5)Versions (2)Used By (0)

Swagvalidator
=============

[](#swagvalidator)

Validates data against a Swagger schema

How to Install
--------------

[](#how-to-install)

```
composer require --dev mlambley/swagvalidator

```

What is Swagger?
----------------

[](#what-is-swagger)

Swagger 2.0 (aka Open API 2.0) defines the structure of your API, including end points and the structure of input and output data. See [their website](https://swagger.io/) for more information.

What is Swagvalidator?
----------------------

[](#what-is-swagvalidator)

If you have an existing Swagger 2.0 specification, you can use it to validate data coming in or out of your API using this tool. This library fully takes into account the features of the [Swagger 2.0 specification](https://swagger.io/docs/specification/2-0/basic-structure/).

Requirements
------------

[](#requirements)

None. This is a pure PHP tool with no dependencies and will work with PHP 5.6 onwards.

Usage
-----

[](#usage)

```
use Mlambley\Swagvalidator\Validator\Validator;
use Mlambley\Swagvalidator\Exception\ValidationException;

$response = $this->getApi("your/path");
$json = (string)$response->getBody();
$data = json_decode($json);
$schema = json_decode(file_get_contents(__DIR__ . '/swagger.json'));

try {
    (new Validator())
        ->validate($schema->paths->{"your/path"}->get->responses->{"200"}->schema, $data);
} catch (ValidationException $e) {
    //dd($e->getMessage());
}
```

Issues?
-------

[](#issues)

Log a [github issue](https://github.com/mlambley/swagvalidator/issues). Your assistance is appreciated.

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

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

Unknown

Total

1

Last Release

1993d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a42dca105f2bbfaa580a01156becfe7214b1b1a4f1f49cdbf4d2a6113029c24a?d=identicon)[mlambley](/maintainers/mlambley)

###  Code Quality

TestsCodeception

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/mlambley-swagvalidator/health.svg)

```
[![Health](https://phpackages.com/badges/mlambley-swagvalidator/health.svg)](https://phpackages.com/packages/mlambley-swagvalidator)
```

###  Alternatives

[webmozart/assert

Assertions to validate method input/output with nice error messages.

7.6k894.0M1.2k](/packages/webmozart-assert)[bensampo/laravel-enum

Simple, extensible and powerful enumeration implementation for Laravel.

2.0k15.9M104](/packages/bensampo-laravel-enum)[nette/forms

📝 Nette Forms: generating, validating and processing secure forms in PHP. Handy API, fully customizable, server &amp; client side validation and mature design.

54013.2M450](/packages/nette-forms)[swaggest/json-schema

High definition PHP structures with JSON-schema based validation

48612.5M73](/packages/swaggest-json-schema)[stevebauman/purify

An HTML Purifier / Sanitizer for Laravel

5325.6M19](/packages/stevebauman-purify)[ashallendesign/laravel-config-validator

A package for validating your Laravel app's config.

217905.3k5](/packages/ashallendesign-laravel-config-validator)

PHPackages © 2026

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