OAS-PHP: PHP Implementation of the OpenAPI Spec.
This library is an implementation of the OpenAPI v3 specification.
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);
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;
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.