awuttig / codeception-api-validator
此包的最新版本(2.0.1)没有可用的许可证信息。
根据 Swagger / OpenAPI 定义验证 API 请求和响应
2.0.1
2022-10-26 08:55 UTC
Requires
- codeception/codeception: ^5.0.0
- codeception/module-phpbrowser: ^3.0.0
- codeception/module-rest: ^3.0.0
- eleven-labs/api-validator: ~0.7.0
- symfony/serializer: ^3.4
Requires (Dev)
- phpstan/phpstan: ^1.8
- phpunit/phpunit: ~9.5
- squizlabs/php_codesniffer: ~3.0.2
README
根据 Swagger / OpenAPI 定义验证 API 请求和响应
安装
您需要将存储库添加到您的 composer.json 文件中
composer require --dev awuttig/codeception-api-validator
用法
您可以将此模块用作其他任何 Codeception 模块,通过将 'ApiValidator' 添加到您的 Codeception 套件配置中启用的模块。
启用模块并设置配置变量
schema
可以直接在配置文件中设置,也可以通过$I->haveOpenApiSchema
或$I->haveSwaggerSchema
设置
modules: enabled: - ApiValidator: depends: REST schema: '/tests/_data/swagger.yaml'
更新 Codeception 构建
codecept build
实现 cept / cest
$I->wantToTest('Validate request and response against OpenAPI Specification.'); $I->sendGET('api/foo/bar'); $I->seeRequestIsValid(); $I->seeResponseIsValid();
方法
seeRequestIsValid()
验证当前请求是否与当前架构定义一致。
$I->seeRequestIsValid();
seeResponseIsValid()
验证当前响应是否与当前架构定义一致。
$I->seeRequestIsValid();
seeRequestAndResponseAreValid()
验证当前请求和响应是否与当前架构定义一致。
$I->seeRequestAndResponseAreValid();
haveOpenAPISchema()
设置 OpenAPI 架构规范路径
$schema = 'file://' . codecept_root_dir('../../web/api/documentation/swagger.yaml'); $I->haveOpenAPISchema($schema);
haveSwaggerSchema()
设置 Swagger 架构规范路径
$schema = 'file://' . codecept_root_dir('../../web/api/documentation/swagger.yaml'); $I->haveSwaggerSchema($schema);
作者
- André Wuttig - 概念,初始工作 - aWuttig
请参阅参与此项目的贡献者列表。