A php library to manipulate Swagger specifications

Installs: 3 163 044

Dependents: 12

Suggesters: 0

Security: 0

Stars: 282

Watchers: 2

Forks: 18

Open Issues: 1

v0.4.1 2018-07-27 06:40 UTC

This package is auto-updated.

Last update: 2020-02-17 12:25:50 UTC


Build Status Scrutinizer Code Quality Code Coverage

A php library to manipulate Swagger/Open API specifications.


composer require EXSyst/Swagger


Read an api.json file:

$swagger = Swagger::fromFile('api.json');

// or

$swagger = new Swagger($array);


There are two major collections: Paths and Definitions. The API is similar for both:

$paths = $swagger->getPaths();
$p = new Path('/user');

foreach ($paths as $path) {
	// adding
	// retrieving
	if ($paths->has('/user') || $paths->contains($p)) {
		$path = $paths->get('/user');
	// removing


There are a lot of models, e.g. the mentioned Path above. The API is well written, so it works with the auto-completion of your IDE. It is straight forward and uses the same naming scheme as the OpenAPI specification.


Feel free to fork and submit a pull request (don't forget the tests) and I am happy to merge.