elama / php-raml-parser
A RAML parser built in php
Requires
- php: >=5.6
- justinrainbow/json-schema: 5.1.*
- oodle/inflect: ~0.2
- psr/http-message: ^1.0
- symfony/routing: ^3.0|^4.0|^5.0|^5.1
- symfony/yaml: ^3.0|^4.0|^5.0|^5.1
- willdurand/negotiation: ^2.2
Requires (Dev)
- php-coveralls/php-coveralls: 2.1.*
- phpunit/phpunit: 5.7.*
- squizlabs/php_codesniffer: 3.3.*
- dev-master
- v3.1.30
- v3.1.29
- v3.1.28
- v3.1.25
- V3.1.24
- v3.1.23
- v3.1.22
- v3.1.21
- V3.1.20
- v3.1.19
- 3.1.18
- 3.1.17
- 3.1.16
- 3.1.15
- v3.1.14
- v3.1.13
- v3.1.12
- v3.1.11
- v3.1.10
- v3.1.9
- v3.1.8
- v3.1.7
- v3.1.6
- v3.1.5
- v3.1.4
- v3.1.3
- v3.1.2
- v3.1.1
- v3.1.0
- v3.0.0
- 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.x-dev
- 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
- dev-securitySchemes
This package is auto-updated.
Last update: 2021-07-29 01:29:17 UTC
README
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
Still TODO:
- 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
Original documentation
Parses a RAML file into a PHP object.
See the RAML spec here: https://github.com/raml-org/raml-spec
Get started
Requires:
- composer (see https://getcomposer.org)
composer require elama/php-raml-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('test/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 this package:
NoRouteFormatter
which does nothing and simply echoes the resultSymfonyRouteFormatter
which adds the routes to a SymfonyRouteCollection
Contributing
./vendor/bin/phpunit ./vendor/bin/phpunit --coverage-text ./vendor/bin/phpcs --standard=PSR1,PSR2 src
TODO
- Documentation/Markdown parser
- Date Representations?
- Parse RAML at provided URL
Supported (I Believe)
- Includes
- .yml/.yaml
- .raml/.rml
- .json (parsed using json-schema)
- Display Name
- Traits
- Resource Types