exsyst/swagger

A php library to manipulate Swagger specifications

Maintainers

👁 EXSyst

Package info

github.com/GuilhemN/swagger

pkg:composer/exsyst/swagger

Statistics

Installs: 16 404 539

Dependents: 8

Suggesters: 0

Stars: 358

Open Issues: 2

v0.4.2 2020-11-19 17:14 UTC

Requires

  • php: ^7.0|^8.0

Requires (Dev)

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT 5d4ad40fe816b7783adc090b64fba6c392be64bc

  • Guilhem Niot <guilhem.woop@gniot.fr>

This package is auto-updated.

Last update: 2026-06-28 04:16:18 UTC


README

👁 Build Status
👁 Scrutinizer Code Quality
👁 Code Coverage

A php library to manipulate Swagger/Open API specifications.

Installation

composer require EXSyst/Swagger

Usage

Read an api.json file:

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

// or

$swagger = new Swagger($array);

Collections

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
	$paths->add($a);
	
	// retrieving
	if ($paths->has('/user') || $paths->contains($p)) {
		$path = $paths->get('/user');
	}
	
	// removing
	$paths->remove('/user');
}

Models

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.

Contributing

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