drunomics / xtrf-rest-client
基于 Guzzle 的 XTRF REST 客户端库
1.0.0
2016-12-14 15:30 UTC
Requires
- php: >=5.5
- guzzlehttp/guzzle: ~6.2.1
- symfony/property-access: ~2.3|~3.0.0
- symfony/serializer: ~2.8
Requires (Dev)
- fr3d/swagger-assertions: ^0.4.0
- jane/open-api: 1.*
- phpunit/phpunit: ~4.8
This package is auto-updated.
Last update: 2024-09-26 12:51:00 UTC
README
基于 Guzzle 的 REST 客户端库。
客户端提供了使用模型类的优秀 API,这些模型基于 Swagger REST 服务规范生成。请参阅 https://swagger.org.cn/。
规范(swagger.json)可以使用 Swagger 的在线编辑器进行编辑:http://editor.swagger.io
使用说明
$config = [
'base_uri' => 'http://example.com',
'username' => 'test',
'password' => 'test',
];
$client = \drunomics\XtrfClient\XtrfClient::create($config);
$quote = $client->getQuote($quote_id);
//...
// More examples like quote creation can be found at the tests, see https://github.com/drunomics/xtrf-rest-client/blob/master/tests/XtrfApiIntegrationTest.php#L145.
关于使用 swagger-UI 的注意事项
请参阅 https://github.com/swagger-api/swagger-ui
Swagger-ui 可以用于提供良好的概述和用于测试的 curl 命令。以下说明如何轻松运行 swagger-ui
-
通过 "composer swagger-ui" 命令运行 swagger-ui。
-
从认证调用开始。其结果需要复制到顶部的 api-key 字段中。
-
Swagger 中的 cookie 认证不起作用。但生成的 curl 命令可以。如果您有 SSL 验证问题,可以预接 curl 选项
curl -3 --insecure OTHER OPTIONS
基于 Swagger 规范生成模型
- 在库目录中运行
composer install
- 运行
composer generate
- 就这么简单。