hmaus / reynaldo
Parse API Blueprint refract into a iterable PHP data structure for easier access
Installs: 98 577
Dependents: 5
Suggesters: 0
Security: 0
Stars: 6
Watchers: 6
Forks: 8
Open Issues: 1
Requires
- php: >=7.0
Requires (Dev)
- codeclimate/php-test-reporter: ^0.3.2
- hmaus/drafter-installer: ^1.0
- hmaus/drafter-php: ^5.0
- phpunit/phpunit: ^5.0
- symfony/var-dumper: ^3.1
README
Turn API Blueprint Refract Parse Result (Drafter's output) into a traversable PHP data structure.
What is Reynaldo?
It should ease the processing of Drafter refract output.
You read your Drafter parse result, either JSON or YAML, you convert that to a PHP assoc array,
e.g. json_decode($parseresult, true)
in PHP and pass it into \Hmaus\Reynaldo\Parser\RefractParser::parse
.
Out comes an easily traversable object.
You can find a little example in /example
.
// load file and json_decode as assoc array into $apiDescription $parser = new RefractParser(); $parseResult = $parser->parse($apiDescription); $api = $parseResult->getApi(); // try to get the API title `$api->getApiTitle();` // or the document description in markdown `$api->getApiDocumentDescription();` foreach ($parseResult->getApi()->getResourceGroups() as $apiResourceGroup) { foreach ($apiResourceGroup->getResources() as $apiResource) { foreach ($apiResource->getTransitions() as $apiStateTransition) { foreach ($apiStateTransition->getHttpTransactions() as $apiHttpTransaction) { // inspect `$apiHttpTransaction->getHttpRequest()`, `$apiHttpTransaction->getHttpResponse()` } } } }
Requirements
- PHP 7.0 or greater
Installation
The recommended way to install is by using composer:
$ composer require hmaus/reynaldo
This will install the PHP package with your application.
License
Reynaldo is licensed under the MIT License - see the LICENSE file for details.