raml-org / raml-php-parser
A RAML parser built in php
Installs: 304 418
Dependents: 4
Suggesters: 0
Security: 0
Stars: 197
Watchers: 24
Forks: 78
Open Issues: 7
Requires
- php: ^7.3|^8.0
- ext-dom: *
- ext-json: *
- ext-pcre: *
- justinrainbow/json-schema: ^5.0
- oodle/inflect: ^0.2
- psr/http-message: ^1.0
- symfony/routing: ^3.0|^4.0|^5.0|^v6.0
- symfony/yaml: ^3.0|^4.0|^5.0
- willdurand/negotiation: ^2.2.1|^3
Requires (Dev)
- friendsofphp/php-cs-fixer: *
- php-coveralls/php-coveralls: ^2.1
- phpstan/phpstan: ^0.12
- phpstan/phpstan-phpunit: ^0.12.16
- phpunit/phpunit: ^9.0
- slam/phpstan-extensions: ^5.0
Replaces
- dev-master
- v4.8.1
- v4.8.0
- v4.7.0
- v4.6.1
- v4.6.0
- v4.5.1
- v4.5.0
- v4.4.0
- v4.3.2
- v4.3.1
- v4.3.0
- 4.2.0
- 4.1.0
- 4.0.0
- 3.0.1
- 3.0.0
- v2.x-dev
- v2.3.5
- v2.3.4
- v2.3.3
- v2.3.2
- v2.3.1
- v2.3.0
- 2.2.1
- 2.2.0
- 2.1.1
- 2.1.0
- 2.0.2
- 2.0.1
- 2.0.0
- 1.1.1
- 1.1.0
- 1.0.0
- 0.6.3
- 0.6.2
- 0.6.1
- 0.6.0
- 0.5.3
- 0.5.2
- 0.5.1
- 0.5.0
- 0.4.1
- 0.4.0
- 0.3.2
- 0.3.1
- 0.3.0
- 0.2.3
- 0.2.2
- 0.2.1
- 0.2.0
- 0.1.0
This package is not auto-updated.
Last update: 2023-03-15 10:54:21 UTC
README
See the RAML specification.
RAML 0.8 Support
For RAML 0.8 support follow version 2.
RAML 1.0 Support
For RAML 1.0 support follow version 3 or above. RAML 1.0 support is still work in progress.
What is done and should work:
- Part of RAML 1.0 type expressions
- Enums
- Union type expression (the "or"
|
operator) - Array of types
discriminator
anddiscriminatorValue
facets- Traits inheritance
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
Get started
Requires:
- composer (see https://getcomposer.org)
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
.
Additional parsers and schema definitions can be created and passed into the Raml\Parser
constructor
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:
$parser = new \Raml\Parser(); $api = $parser->parse('tests/fixture/simple.raml'); $routes = $api->getResourcesAsUri();
To return:
[ 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:
NoRouteFormatter
which does nothing and simply echoes the resultSymfonyRouteFormatter
which adds the routes to a SymfonyRouteCollection
Contributing
composer run-static-analysis composer check-code-style composer run-tests