Skip to content

uuf6429/oas-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OAS-PHP

Minimum PHP Version License Packagist

OAS-PHP: PHP Implementation of the OpenAPI Spec.

This library is an implementation of the OpenAPI v3 specification.

Usage

This library is just a bunch of value objects. The main entry point, (as is the case with the specification), is the Document class:

$document = new \uuf6429\OpenAPI\Spec\Document();
$path = new \uuf6429\OpenAPI\Path();
$document->paths->set('/resource', $path);

Rendering

Ideally, it should be render with a YAML serializer (such as symfony's). Since YAML is a superset of JSON, one can also do:

$document = new Document();
$json = json_encode($document, JSON_THROW_ON_ERROR | JSON_PRETTY_PRINT);

// save to file
file_put_contents('openapi.yaml', $json);

// or serve it out
header('Content-Type: application/x-yaml');
echo $json;

Why?

This library isn't better than the multitude of generators and whatnot out there. The idea is that existing and new PHP-based tools that handle OpenAPI could/should use this implementation instead of having their own version of OpenAPI spec.

About

OpenAPI Spec - PHP Implementation

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages