Skip to content

phpowermove/swagger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

swagger

License Latest Stable Version Total Downloads
HHVM Status Build Status Scrutinizer Code Quality Code Coverage

A php library to manipulate swagger/Open API specifications.

Installation

composer require gossi/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');

// adding
$paths->add($p);

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

// removing
$paths->remove('/user');

// iterating
foreach ($paths as $path) {
	// do sth with $path
}

Other collections are: Headers, Parameters, Responses and SecurityDefinitions.

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.

About

A php library to manipulate swagger specifications

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages