在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:hendrikmaus/drafter-php开源软件地址:https://github.com/hendrikmaus/drafter-php开源编程语言:PHP 100.0%开源软件介绍:Drafter PHP WrapperPHP wrapper for Drafter API Blueprint Parser harness. What is Drafter-php?Drafter-php allows you to use use the drafter API Blueprint Parser harness with your PHP application. In a nutshell: you can convert API Blueprint files to parse result. API Blueprint is a webservice documentation language built on top of Markdown. Requirements
What Is WhatDrafter is a C++ tool to parse API Blueprint. InstallationThe recommended way to install Drafter-php is by using composer: $ composer require hmaus/drafter-php This will install the PHP package with your application. Install Drafter Command Line Tool using ComposerHead over to hmaus/drafter-installer. Usage of Drafter-php
Input / Output Examples
Given this api blueprint source: # GET /message
+ Response 200 (text/plain)
Hello World! The result will look similar (json refract): {
"element": "parseResult",
"content": [
{
"element": "category",
"meta": {
"classes": [
"api"
],
"title": ""
},
"content": [
{
"element": "category",
"meta": {
"classes": [
"resourceGroup"
],
"title": ""
},
"content": [
{
"element": "resource",
"meta": {
"title": ""
},
"attributes": {
"href": "/message"
},
"content": [
{
"element": "transition",
"meta": {
"title": ""
},
"content": [
{
"element": "httpTransaction",
"content": [
{
"element": "httpRequest",
"attributes": {
"method": "GET"
},
"content": []
},
{
"element": "httpResponse",
"attributes": {
"statusCode": "200",
"headers": {
"element": "httpHeaders",
"content": [
{
"element": "member",
"content": {
"key": {
"element": "string",
"content": "Content-Type"
},
"value": {
"element": "string",
"content": "text/plain"
}
}
}
]
}
},
"content": [
{
"element": "asset",
"meta": {
"classes": [
"messageBody"
]
},
"attributes": {
"contentType": "text/plain"
},
"content": "Hello World!\n"
}
]
}
]
}
]
}
]
}
]
}
]
}
]
} Code Examples
Make sure it worksTo make sure it works, we'll ask Drafter for the current version. $version = $drafter
->version()
->run();
// Reset options on the command
$drafter->resetOptions();
Parse your-service.apib into your-service.refract.jsonMake sure your input path is correct and readable, and your output path is writable. $drafter
->input('your-service.apib')
->format('json')
->type('refract')
->output('your-service.refract.json')
->run(); Parse your-service.apib into your-service.ast.jsonMake sure your input path is correct and readable, and your output path is writable. $drafter
->input('your-service.apib')
->format('json')
->output('your-service.ast.json')
->run(); Parse your-service.apib into a PHP data structure$refract = $drafter
->input('your-service.apib')
->format('json')
->run();
$phpObj = json_decode($refract);
$phpArr = json_decode($refract, true); Parse your-service.apib into YAML format$drafter
->input('your-service.apib')
->format('yaml') // optional as yaml is the default
->output('your-service.ast.yml')
->run(); Get Process before it is run$process = $drafter
->input('your-service.apib')
->format('json')
->output('your-service.refract.json')
->build();
// do stuff with the process
$drafter
->run($process); Feature RoadmapDo not hesitate to contribute.
LicenseDrafter-php is licensed under the MIT License - see the LICENSE file for details |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论