定制 religisaci/codeception-api-validator 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

religisaci/codeception-api-validator

最新稳定版本:1.0.0

Composer 安装命令:

composer require religisaci/codeception-api-validator

包简介

Validate API Requests and Responses against Swagger / OpenAPI definitions. This package is modified awuttig/codeception-api-validator package for PHP 7.4

README 文档

README

Validate API Requests and Responses against Swagger / OpenAPI definitions

Note: this is based on awuttig/codeception-api-validator and modified for PHP 7.4

Installation

You need to add the repository into your composer.json file

    composer require --dev religisaci/codeception-api-validator

Usage

You can use this module as any other Codeception module, by adding 'ApiValidator' to the enabled modules in your Codeception suite configurations.

Enable module and setup the configuration variables

  • The schema could be set in config file directly and via $I->haveOpenApiSchema or $I->haveSwaggerSchema
modules:
    enabled:
        - \Religisaci\ApiValidator:
            depends: [REST, PhpBrowser]
            schema: '/tests/_data/swagger.yaml'
            

Update Codeception build

  codecept build

Implement the cept / cest

  $I->wantToTest('Validate request and response against OpenAPI Specification.');
  
  $I->sendGET('api/foo/bar');
  
  $I->seeRequestIsValid();
  $I->seeResponseIsValid(); 

Methods

seeRequestIsValid()

Validates the current request against the current schema definiton.

  $I->seeRequestIsValid();
  

seeResponseIsValid()

Validates the current response against the current schema definiton.

  $I->seeRequestIsValid();
  

seeRequestAndResponseAreValid()

Validates the current request and response against the current schema definiton.

  $I->seeRequestAndResponseAreValid();
  

haveOpenAPISchema()

Set the path to the OpenAPI Schema Specification

  $schema = 'file://' . codecept_root_dir('../../web/api/documentation/swagger.yaml');
  $I->haveOpenAPISchema($schema);
  

haveSwaggerSchema()

Set the path to the Swagger Schema Specification

  $schema = 'file://' . codecept_root_dir('../../web/api/documentation/swagger.yaml');
  $I->haveSwaggerSchema($schema);
  

Authors

  • André Wuttig - Concept, Initial work - aWuttig
  • Tomáš Hojgr - Modification for PHP 7.4 - Religisaci

See also the list of contributors who participated in this project.

统计信息

  • 总下载量: 999
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2023-02-28

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固