therealgambo / php-raml-parser
基于php的RAML解析器
2.2.0
2016-11-22 07:52 UTC
Requires
- php: >=5.5.9
- justinrainbow/json-schema: ~1.5
- oodle/inflect: ~0.2
- psr/http-message: ^1.0
- symfony/routing: ~3.0
- symfony/yaml: ~3.0
Requires (Dev)
- phpunit/phpunit: 4.*
- satooshi/php-coveralls: ~0.6
- squizlabs/php_codesniffer: @dev
README
!!注意!! 这是对RAML 1.0规范的正在进行中的工作,对于RAML 0.8,请查看master分支
仍然待办
原始文档
将RAML文件解析为PHP对象。
在此处查看RAML规范:https://github.com/raml-org/raml-spec
开始使用
需求
- composer (见 https://getcomposer.org.cn)
composer require alecsammon/php-raml-parser --dev
$parser = new \Raml\Parser(); $apiDef = $parser->parse($filename, true); $title = $apiDef->getTitle();
解析模式
该库可以将模式转换为验证对象。有一个默认列表,或者可以手动配置。每个模式解析器都需要符合 \Raml\Schema\SchemaParserInterface
并返回一个 \Raml\Schema\SchemaDefinitionInterface
实例。
可以创建额外的解析器和模式定义,并将它们传递给 \Raml\Parser
构造函数
导出路由
还可以将整个RAML文件导出为一个完整端点的数组。例如,考虑一个基本RAML,可以使用以下方式返回
$parser = new Raml\Parser(); $api = $parser->parse('test/fixture/simple.raml'); $routes = $api->getResourcesAsUri();
返回
[ GET /songs => ... POST /songs => ... GET /songs/{songId} => ... DELETE /songs/{songId} => ... ] $routes = $api->getResourcesAsUri(new Raml\RouteFormatter\NoRouteFormatter());
路由格式化程序
此包包含两个路由格式化程序
NoRouteFormatter
,它什么都不做,只是简单地输出结果SymfonyRouteFormatter
,它将路由添加到SymfonyRouteCollection
贡献
./vendor/bin/phpunit ./vendor/bin/phpunit --coverage-text ./vendor/bin/phpcs --standard=PSR1,PSR2 src
待办
- 文档/Markdown解析器
- 日期表示法?
- 在提供的URL上解析RAML
支持(我相信)
- 包括
- .yml/.yaml
- .raml/.rml
- .json(使用json-schema解析)
- 显示名称
- 特质
- 资源类型