2017 © Pedro Peláez
 

library raml-php-parser

A RAML parser built in php

image

raml-org/raml-php-parser

A RAML parser built in php

  • Wednesday, July 25, 2018
  • by martin-georgiev
  • Repository
  • 28 Watchers
  • 187 Stars
  • 8,499 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 73 Forks
  • 9 Open issues
  • 34 Versions
  • 622 % Grown

The README.md

Build Status Coverage Status Latest Stable Version Total Downloads, (*1)

See the RAML specification., (*2)

RAML 0.8 Support

For RAML 0.8 support follow version 2., (*3)

RAML 1.0 Support

For RAML 1.0 support follow version 3 or above. RAML 1.0 support is still work in progress., (*4)

What is done and should work: - Part of RAML 1.0 type expressions - Enums - Union type expression (the "or" | operator) - Array of types - discriminator and discriminatorValue facets - Traits inheritance, (*5)

To be implemented: - Libraries - User defined facets - Full implementation of type expressions - The shorthand array and the union type have been implemented - Bi-dimensional array and the array-union combination have NOT been implemented yet. - Multiple inheritance - Annotations - Overlays and Extensions - Improved Security Schemes, (*6)

Get started

Requires:, (*7)

composer require raml-org/raml-php-parser
$parser = new \Raml\Parser();
$apiDef = $parser->parse($filename, true);

$title = $apiDef->getTitle();

Parsing schemas

The library can convert schemas into an validation object. There is a default list, or they can be configured manually. Each schema parser needs to conform to Raml\Schema\SchemaParserInterface and will return a instance of Raml\Schema\SchemaDefinitionInterface., (*8)

Additional parsers and schema definitions can be created and passed into the Raml\Parser constructor, (*9)

Exporting routes

It is also possible to export the entire RAML file to an array of the full endpoints. For example, considering a basic RAML, this can be returned using:, (*10)

$parser = new \Raml\Parser();
$api = $parser->parse('tests/fixture/simple.raml');

$routes = $api->getResourcesAsUri();

To return:, (*11)

[
    GET /songs => ...
    POST /songs => ...
    GET /songs/{songId} => ...
    DELETE /songs/{songId} => ...
]

$routes = $api->getResourcesAsUri(new \Raml\RouteFormatter\NoRouteFormatter());

Route Formatters

There are two Route Formatters included in the package:, (*12)

  • NoRouteFormatter which does nothing and simply echoes the result
  • SymfonyRouteFormatter which adds the routes to a Symfony RouteCollection

Contributing

composer run-static-analysis
composer check-code-style
composer run-tests

The Versions