PHPackages                             eleven-labs/api-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. eleven-labs/api-validator

ActiveLibrary

eleven-labs/api-validator
=========================

Validate PSR-7 Requests against an OpenAPI/Swagger2 Schema

0.7.0(5y ago)247.3k↑83.3%6[3 issues](https://github.com/eleven-labs/api-validator/issues)3PHPPHP ^7.4 || ^8.0

Since Aug 4Pushed 2y ago48 watchersCompare

[ Source](https://github.com/eleven-labs/api-validator)[ Packagist](https://packagist.org/packages/eleven-labs/api-validator)[ RSS](/packages/eleven-labs-api-validator/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (10)Versions (19)Used By (3)

API Validator
=============

[](#api-validator)

[![Build Status](https://camo.githubusercontent.com/851a6b05ceedb9152440ae229f920a200d52523ce2943a07d8313b105085e511/68747470733a2f2f7472617669732d63692e6f72672f656c6576656e2d6c6162732f6170692d76616c696461746f722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/eleven-labs/api-validator)[![Code Coverage](https://camo.githubusercontent.com/2efe1a266345e90895cf79885d2beee4e2a78d7f69c17fe1199e3aab57becaaa/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f656c6576656e2d6c6162732f6170692d76616c696461746f722f6261646765732f636f7665726167652e706e67)](https://scrutinizer-ci.com/g/eleven-labs/api-validator/)[![Scrutinizer Quality Score](https://camo.githubusercontent.com/e5804308aee21330715090ba18e064a99e83b9adc547dc35bded3c8ccee1a0b5/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f656c6576656e2d6c6162732f6170692d76616c696461746f722f6261646765732f7175616c6974792d73636f72652e706e67)](https://scrutinizer-ci.com/g/eleven-labs/api-validator/)

This library provides a set of classes suited to describe a WebService based on the HTTP protocol.

It can validate [PSR-7 Requests](http://www.php-fig.org/psr/psr-7/) against a schema.

It's design is heavily inspired by the OpenAPI/Swagger2.0 specifications.

As of now, it only support the OpenAPi/Swagger2.0 specifications but we plan to support [RAML 1.0](https://github.com/raml-org/raml-spec/blob/master/versions/raml-10/raml-10.md/)and [API Elements (API Blueprint)](https://github.com/apiaryio/api-elements) in the future.

Dependencies
------------

[](#dependencies)

We rely on the [justinrainbow/json-schema](https://github.com/justinrainbow/json-schema) library to parse specification files and to validate requests and responses:

- Request's `headers`, `query`, `uri` and `body` parts.
- Response `headers` and `body` parts.

Usage
-----

[](#usage)

### Before you start

[](#before-you-start)

You will need to write a **valid** Swagger 2.0 file in order to use this library. Ensure that this file is valid using the [Swagger Editor](http://editor.swagger.io/).

You can also validate your specifications using the [Swagger 2.0 JSONSchema](https://github.com/OAI/OpenAPI-Specification/blob/master/schemas/v2.0/schema.json).

### Validate a request

[](#validate-a-request)

You can validate any PSR-7:

- Request implementing the `Psr\Http\Message\RequestInterface` interface.
- Response implementing the `Psr\Http\Message\ResponseInterface` interface.

```
