PHPackages                             byjg/swagger-test - 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. [Testing &amp; Quality](/categories/testing)
4. /
5. byjg/swagger-test

ActiveLibrary[Testing &amp; Quality](/categories/testing)

byjg/swagger-test
=================

A set of tools for testing your REST calls based on the OpenApi specification using PHPUnit. Currently, this library supports the OpenApi specifications 2.0 (formerly swagger) and 3.0.

6.0.0(5mo ago)103397.9k—3.9%35[5 issues](https://github.com/byjg/php-swagger-test/issues)[5 PRs](https://github.com/byjg/php-swagger-test/pulls)3MITPHPPHP &gt;=8.3 &lt;8.6CI passing

Since May 22Pushed 2mo ago4 watchersCompare

[ Source](https://github.com/byjg/php-swagger-test)[ Packagist](https://packagist.org/packages/byjg/swagger-test)[ GitHub Sponsors](https://github.com/byjg)[ RSS](/packages/byjg-swagger-test/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (4)Versions (28)Used By (3)

Swagger Test
============

[](#swagger-test)

[![Sponsor](https://camo.githubusercontent.com/fab14b7f7f475072ada0473f193d6f322561fd4a2958e0cc89910d053347cf27/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53706f6e736f722d2532336561346161613f6c6f676f3d67697468756273706f6e736f7273266c6f676f436f6c6f723d7768697465266c6162656c436f6c6f723d306431313137)](https://github.com/sponsors/byjg)[![Build Status](https://github.com/byjg/php-swagger-test/actions/workflows/phpunit.yml/badge.svg?branch=master)](https://github.com/byjg/php-swagger-test/actions/workflows/phpunit.yml)[![Opensource ByJG](https://camo.githubusercontent.com/425c1bbccc0f292bf4d20569ae74a6b2e384fd648f1af8911bc61de9a8dcfc0b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6f70656e736f757263652d62796a672d737563636573732e737667)](http://opensource.byjg.com)[![GitHub source](https://camo.githubusercontent.com/88e61eb211719144efdd570290a0456b6e13099c2df8d973f1bb43fe33bf0039/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4769746875622d736f757263652d696e666f726d6174696f6e616c3f6c6f676f3d676974687562)](https://github.com/byjg/php-swagger-test/)[![GitHub license](https://camo.githubusercontent.com/7ebb861cab4df16ee54a53dd1d565b33b9b76aa8496a4194afaf3aa1b2f672ea/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f62796a672f7068702d737761676765722d746573742e737667)](https://opensource.byjg.com/opensource/licensing.html)[![GitHub release](https://camo.githubusercontent.com/2fcfb1b5d8e50b98551e969c0a375efb9bf2b901e9c9caa36dd9d8a3075be9f5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f62796a672f7068702d737761676765722d746573742e737667)](https://github.com/byjg/php-swagger-test/releases/)

A set of tools for testing your REST calls based on the OpenApi specification using PHPUnit. Currently, this library supports the OpenApi specifications `2.0` (formerly swagger) and `3.0`.

Some features of the OpenAPI specification are not fully implemented:

- Callbacks (OpenAPI 3.0)
- Links (OpenAPI 3.0)
- References to external documents/objects
- Complex schema validations

For details on the schema classes and their specific features, see [Schema Classes](docs/schema-classes.md).

PHP Swagger Test can help you to test your REST API. You can use this tool both for Unit Tests or Functional Tests.

This tool reads an OpenAPI/Swagger specification in JSON format (not YAML) and enables you to test the request and response. You can use the tool "" for creating the JSON file when you are developing your REST API.

The ApiTestCase's assertion process is based on throwing exceptions if some validation or test failed.

Documentation
-------------

[](#documentation)

- [Functional test cases](docs/functional-tests.md) - Testing your API with HTTP requests
- [Contract test cases](docs/contract-tests.md) - Testing without HTTP using custom requesters
- [Runtime parameters validator](docs/runtime-parameters-validator.md) - Validating requests in production
- [Mocking Requests](docs/mock-requests.md) - Testing with mocked responses
- [Schema classes](docs/schema-classes.md) - Working with OpenAPI 2.0 and 3.0 schemas
- [Using the OpenApiValidation trait](docs/trait-usage.md) - Flexible validation without extending ApiTestCase
- [Advanced usage](docs/advanced-usage.md) - File uploads, custom clients, authentication, and more
- [Exception handling](docs/exceptions.md) - Understanding and handling validation exceptions
- [Migration guide](docs/migration-guide.md) - Upgrading from older versions
- [Troubleshooting](docs/troubleshooting.md) - Common issues and solutions

Who is using this library?
--------------------------

[](#who-is-using-this-library)

- [ByJG PHP Rest Reference Architecture](https://github.com/byjg/php-rest-reference-architecture)
- [Laravel Swagger Test](https://github.com/pionl/laravel-swagger-test)

Install
-------

[](#install)

```
composer require "byjg/swagger-test"
```

Tests
-----

[](#tests)

```
SPEC=swagger php -S 127.0.0.1:8080 tests/rest/app.php &
SPEC=openapi php -S 127.0.0.1:8081 tests/rest/app.php &
vendor/bin/phpunit
```

References
----------

[](#references)

This project uses the [byjg/webrequest](https://github.com/byjg/webrequest) component. It implements the PSR-7 specification, and a HttpClient / MockClient to do the requests. Check it out to get more information.

Questions?
----------

[](#questions)

Please raise your issue on [Github issue](https://github.com/byjg/php-swagger-test/issues).

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

[](#dependencies)

 ```
flowchart TD
    byjg/swagger-test --> byjg/webrequest
```

      Loading ---

[Open source ByJG](http://opensource.byjg.com)

###  Health Score

67

—

FairBetter than 100% of packages

Maintenance78

Regular maintenance activity

Popularity52

Moderate usage in the ecosystem

Community29

Small or concentrated contributor base

Maturity91

Battle-tested with a long release history

 Bus Factor1

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

Recently: every ~155 days

Total

27

Last Release

90d ago

Major Versions

1.2.5 → 2.0.02019-10-21

2.0.1 → 3.0.02020-04-02

3.1.4 → 4.9.02023-05-21

4.9.2 → 5.0.02024-10-27

5.0.x-dev → 6.0.02025-11-25

PHP version history (4 changes)1.2.4PHP &gt;=5.6

4.9.1PHP &gt;=7.4

5.0.0PHP &gt;=8.1 &lt;8.4

6.0.0PHP &gt;=8.3 &lt;8.6

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/981924?v=4)[Joao Gilberto Magalhaes](/maintainers/byjg)[@byjg](https://github.com/byjg)

---

Top Contributors

[![byjg](https://avatars.githubusercontent.com/u/981924?v=4)](https://github.com/byjg "byjg (212 commits)")[![vitormattos](https://avatars.githubusercontent.com/u/1079143?v=4)](https://github.com/vitormattos "vitormattos (14 commits)")[![UlrichEckhardt](https://avatars.githubusercontent.com/u/8566055?v=4)](https://github.com/UlrichEckhardt "UlrichEckhardt (14 commits)")[![malinink](https://avatars.githubusercontent.com/u/5726553?v=4)](https://github.com/malinink "malinink (4 commits)")[![claude](https://avatars.githubusercontent.com/u/81847?v=4)](https://github.com/claude "claude (4 commits)")[![antonio-rylke-vgl](https://avatars.githubusercontent.com/u/28530190?v=4)](https://github.com/antonio-rylke-vgl "antonio-rylke-vgl (3 commits)")[![ODAEL](https://avatars.githubusercontent.com/u/4458995?v=4)](https://github.com/ODAEL "ODAEL (3 commits)")[![Hordev](https://avatars.githubusercontent.com/u/66357476?v=4)](https://github.com/Hordev "Hordev (3 commits)")[![domingojimenez](https://avatars.githubusercontent.com/u/113131435?v=4)](https://github.com/domingojimenez "domingojimenez (2 commits)")[![gustavoporcides](https://avatars.githubusercontent.com/u/48253490?v=4)](https://github.com/gustavoporcides "gustavoporcides (1 commits)")[![artjomsimon](https://avatars.githubusercontent.com/u/2609170?v=4)](https://github.com/artjomsimon "artjomsimon (1 commits)")[![Fantom409](https://avatars.githubusercontent.com/u/14968877?v=4)](https://github.com/Fantom409 "Fantom409 (1 commits)")[![89409](https://avatars.githubusercontent.com/u/84925319?v=4)](https://github.com/89409 "89409 (1 commits)")[![steveplevno](https://avatars.githubusercontent.com/u/57771690?v=4)](https://github.com/steveplevno "steveplevno (1 commits)")[![thePanz](https://avatars.githubusercontent.com/u/226021?v=4)](https://github.com/thePanz "thePanz (1 commits)")

---

Tags

hacktoberfestphpphpunitswagger

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/byjg-swagger-test/health.svg)

```
[![Health](https://phpackages.com/badges/byjg-swagger-test/health.svg)](https://phpackages.com/packages/byjg-swagger-test)
```

###  Alternatives

[phpspec/prophecy

Highly opinionated mocking framework for PHP 5.3+

8.5k551.7M682](/packages/phpspec-prophecy)[brianium/paratest

Parallel testing for PHP

2.5k118.8M754](/packages/brianium-paratest)[beberlei/assert

Thin assertion library for input validation in business models.

2.4k96.9M570](/packages/beberlei-assert)[mikey179/vfsstream

Virtual file system to mock the real file system in unit tests.

1.4k108.0M2.7k](/packages/mikey179-vfsstream)[orchestra/testbench

Laravel Testing Helper for Packages Development

2.2k39.1M32.1k](/packages/orchestra-testbench)[phpspec/phpspec

Specification-oriented BDD framework for PHP 7.1+

1.9k36.7M3.1k](/packages/phpspec-phpspec)

PHPackages © 2026

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