inveniem / guzzle-description-loader
从各种文件格式加载 Guzzle 服务描述
v1.0.0
2023-05-24 02:58 UTC
Requires
- php: >=7.1.3
- symfony/config: ^4.4 || ^5 || ^6
- symfony/yaml: ^4.4 || ^5 || ^6
Requires (Dev)
- phpunit/phpunit: ^9
Replaces
- gimler/guzzle-description-loader: <=0.0.4
- kezor/guzzle-description-loader: <=0.0.4
README
A stand-alone Service Description loader for Guzzle with compatibility for Symfony 4.x, 5.x, and 6.x.
安装
如果您正在使用 Composer,您应该这样做,只需运行以下命令
composer require "inveniem/guzzle-description-loader"
支持的文件格式
- Yaml
- Php
- Json
使用
use Guzzle\Service\Loader\JsonLoader; use GuzzleHttp\Command\Guzzle\Description; use Symfony\Component\Config\FileLocator; $configDirectories = array(DESCRIPTION_PATH); $this->locator = new FileLocator($configDirectories); $this->jsonLoader = new JsonLoader($this->locator); $description = $this->jsonLoader->load($this->locator->locate('description.json')); $description = new Description($description);
示例
{
"operations": {
"certificates.list": {
"httpMethod": "GET",
"uri": "certificates",
"description": "Lists and returns basic information about all of the management certificates associated with the specified subscription.",
"responseModel": "CertificateList"
}
},
"models": {
"CertificateList": {
"type": "array",
"name": "certificates",
"sentAs": "SubscriptionCertificate",
"location": "xml",
"items": {
"type": "object"
}
}
},
"imports": [
"description_import.json"
]
}