liberty_code / open_api
Library
Requires
- php: ~7 || ~8
- liberty_code/cache: ~1.0.0
- liberty_code/di: ~1.0.0
- liberty_code/library: ~1.0.0
- liberty_code/parser: ~1.0.0
Requires (Dev)
- liberty_code/register: ~1.0.0
- phpunit/phpunit: 8.5.22
This package is not auto-updated.
Last update: 2026-08-19 14:25:43 UTC
README
Description
Library contains Open API components, to handle Open API specifications.
Requirement
- Script language: PHP: version 7 || 8
Installation
Several ways are possible:
Composer
Requirement
It requires composer installation. For more information: https://getcomposer.org
Command: Move in project root path
cd "<project_root_path>"Command: Installation
php composer.phar require liberty_code/open_api ["<version>"]Note
Include vendor
If project uses composer, vendor must be included:
require_once('<project_root_path>/vendor/autoload.php');Configuration
Installation command allows to add, on composer file "/composer.json", following configuration:
{ "require": { "liberty_code/open_api": "<version>" } }
Include
Download
- Download following repository.
- Put it on repository root path.
Include source
require_once('<repository_root_path>/include/Include.php');
Usage
Specification parser
Specification parser allows to get parsed specification data, for specific specification.
Elements
SpecParser
Allows to design specific specification parser, to get parsed specification data, for specific specification.
ParserSpecParser
Extends specification parser features. Allows to get parsed specification data, from specific parser, and specified specification.
SpecParserCollection
Allows to design collection of specification parsers.
SpecParserFactory
Allows to design specification parser factory, to provide new or specified specification parser instance, from specified configuration.
BaseSpecParserFactory
Extends specification parser factory features. Can be consider as base of all specification parser factories.
StandardSpecParserFactory
Extends base specification parser factory features. Provides specification parser instance.
SpecParserBuilder
Uses array of source data to hydrate specification parser collection.
Example
// Get specification parser factory
use liberty_code\open_api\parser\factory\standard\model\StandardSpecParserFactory;
$specParserFactory = new StandardSpecParserFactory($parserFactory);
...
// Get new specification parser, from configuration
$specParser = $specParserFactory->getObjSpecParser(array(...));
...
// Get parsed specification data
var_dump($specParser->getTabSpecData());
...
// Get specification parser collection
use liberty_code\open_api\parser\model\DefaultSpecParserCollection;
$specParserCollection = new DefaultSpecParserCollection();
...
// Get specification parser builder
use liberty_code\open_api\parser\build\model\DefaultSpecParserBuilder;
$specParserBuilder = new DefaultSpecParserBuilder($specParserFactory);
...
// Hydrate specification parser collection
$specParserBuilder->setTabDataSrc(array(...));
$specParserBuilder->hydrateSpecParserCollection($specParserCollection);
...
foreach($specParserCollection->getTabKey() as $key) {
echo($specParserCollection->getObjSpecParser($key)->getStrKey() .'<br />');
}
/**
* Show:
* Specification parser key 1
* ...
* Specification parser key N
*/
...
Utility
Component
Component features.
Operation
Operation features.
Test
Unit test
Unit tests allows to test components features, and to automate their validation.
Requirement
Composer
It requires composer installation. For more information: https://getcomposer.org
Command: Dependencies installation
php composer.phar install
Command: Run unit tests
vendor\bin\phpunitNote
It uses PHPUnit to handle unit tests. For more information: https://phpunit.readthedocs.io