23/05
2016
Wallogit.com
2017 © Pedro Peláez
An MSON parser for PHP
Oasis MSON Parser is a PHP wrapper for the Drafter library., (*1)
API Blueprint is Web API documentation language. You can find API Blueprint documentation on the API Blueprint site., (*2)
The best way to install this is via Composer., (*3)
$ composer require brianseitel/oasis-mson-parser
NOTE: Oasis MSON Parser depends on the Drafter library. Please see that repo for build instructions., (*4)
function parse(string $data, $format = 'json')
<?php
require 'vendor/autoload.php';
$results = Oasis\Parser::parse('# My API', 'json');
Parsing this blueprint:, (*5)
# GET /1 + response
will produce the following object (result variable):, (*6)
{
"element": "parseResult",
"content": [
{
"element": "category",
"meta": {
"classes": [
"api"
],
"title": ""
},
"content": [
{
"element": "category",
"meta": {
"classes": [
"resourceGroup"
],
"title": ""
},
"content": [
{
"element": "resource",
"meta": {
"title": ""
},
"attributes": {
"href": "/1"
},
"content": [
{
"element": "transition",
"meta": {
"title": ""
},
"content": [
{
"element": "httpTransaction",
"content": [
{
"element": "httpRequest",
"attributes": {
"method": "GET"
},
"content": []
},
{
"element": "httpResponse",
"attributes": {
"statusCode": "200"
},
"content": []
}
]
}
]
}
]
}
]
}
]
}
]
}
Fork & Pull Request., (*7)
MIT License. See the LICENSE file., (*8)