paveljanda/php-openapi-specificaion-expander

Script that recursively expands references in OpenAPI specification

v3.0.1 2019-11-27 15:05 UTC

This package is auto-updated.

Last update: 2024-10-28 03:10:33 UTC


README

Build Status Scrutinizer Code Quality Latest Stable Version License Total Downloads

paveljanda/php-openapi-specificaion-expander

This tool let's you expand recursively definitions in open api specifiation (JSON/YAML)

Installation

composer require paveljanda/php-openapi-specificaion-expander

Example - YAML

require __DIR__ . '/vendor/autoload.php';

use PavelJanda\OpenAPIExpander\OpenAPIExpander;
use Symfony\Component\Yaml\Yaml;

$specData = Yaml::parseFile(__DIR__ . '/openapiv3.yaml');

$expandedData = (new OpenAPIExpander)->expand($specData);

echo Yaml::dump($expandedData, 100, 2);

Example - JSON

require __DIR__ . '/vendor/autoload.php';

use PavelJanda\OpenAPIExpander\OpenAPIExpander;

$specData = json_decode(file_get_contents(__DIR__ . '/openapiv3.json'));

$expandedData = (new OpenAPIExpander)->expand($specData);

echo json_encode($expandedData, JSON_PRETTY_PRINT);