PHPackages                             chstudio/raven - 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. [API Development](/categories/api)
4. /
5. chstudio/raven

ActiveLibrary[API Development](/categories/api)

chstudio/raven
==============

Testing your code through OpenAPI documentation easily.

v0.5.0(2mo ago)367892[10 issues](https://github.com/CHStudio/Raven/issues)[1 PRs](https://github.com/CHStudio/Raven/pulls)Apache-2.0PHPPHP ^8.2.0CI passing

Since Oct 4Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/CHStudio/Raven)[ Packagist](https://packagist.org/packages/chstudio/raven)[ RSS](/packages/chstudio-raven/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (21)Versions (10)Used By (0)

Raven - How to test your API documentation and behavior.
========================================================

[](#raven---how-to-test-your-api-documentation-and-behavior)

[![Scrutinizer Code Quality](https://camo.githubusercontent.com/c76ce8526b79dcf484c514a738b9f7d83a032c52476c88a9e75cd5051fc657cd/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f434853747564696f2f526176656e2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d61696e)](https://scrutinizer-ci.com/g/CHStudio/Raven/?branch=main)[![Code Coverage](https://camo.githubusercontent.com/493df9cf9b552a139500b08d90fddfb1eb9ac37c1d5b6b723eb605e3ef2beb4d/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f434853747564696f2f526176656e2f6261646765732f636f7665726167652e706e673f623d6d61696e)](https://scrutinizer-ci.com/g/CHStudio/Raven/?branch=main)

[![Latest Stable Version](https://camo.githubusercontent.com/60aa69495eeb22afe79c3e09c2dc0e0a47dae69796f3ead0185bdb689ba014f8/68747470733a2f2f706f7365722e707567782e6f72672f636873747564696f2f726176656e2f762f737461626c65)](https://packagist.org/packages/chstudio/raven)[![License](https://camo.githubusercontent.com/77b15c4c30784139f2bcb2e654fc529a2d7f1e8e40eb4ecebccaf109020bf373/68747470733a2f2f706f7365722e707567782e6f72672f636873747564696f2f726176656e2f6c6963656e7365)](https://packagist.org/packages/chstudio/raven)

This library was written to allow testing OpenAPI documentation easily. It also allows verifying that your code implementation is compatible with that documentation.

Why creating such tool ?
------------------------

[](#why-creating-such-tool-)

We work a lot on API related projects. Sometimes we create API, sometimes we consume them. The OpenAPI description format is now well known and used in a lot of different contexts.

Our concern is that it's hard to ensure that the written documentation is representing the current API behavior. We wanted to track the implementation difference between the doc and the code.

We searched the ecosystem and found that it exists different tools to mock APIs or to perform requests to them. However we can't find a tool that allows performing HTTP requests that use fixtures and are able to perform specific validation on the responses.

So we started working on `Raven`!

It relies on PSRs to be easily integrated in any project and is composed of two different parts:

- An HTTP request factory to define the input,
- An executor that'll be responsible to actually validate Requests and Responses.

### Raven, isn't it a bird ?

[](#raven-isnt-it-a-bird-)

Nope, we use here [the human name of the X-Men character Mystique](https://en.wikipedia.org/wiki/Mystique_(character)). She's able to transform and adapt to any situation which is that tool goal. We need to adapt to any API to trigger valid requests and analyze responses.

Install it
----------

[](#install-it)

Using Composer:

```
composer require chstudio/raven
```

To use Raven you might need to also install:

- [an HTTP message factory compatible with PSR-17](https://packagist.org/providers/psr/http-factory-implementation),
- [an HTTP client compatible with PSR-18](https://packagist.org/providers/psr/http-client-implementation).

Of course you can also write your own. The only constraint is to be compatible with PSRs interfaces.

Usage
-----

[](#usage)

### Execute Request / Response validation

[](#execute-request--response-validation)

This library defines its own interfaces for request validation. It comes with an adapter to the [league/openapi-psr7-validator](https://packagist.org/packages/league/openapi-psr7-validator)package which define a complete validation logic.

```
