awuttig/codeception-api-validator

There is no license information available for the latest version (2.0.1) of this package.

Validate API Requests and Responses against Swagger / OpenAPI definitions

Maintainers

👁 aWuttig

Package info

github.com/aWuttig/codeception-api-validator

pkg:composer/awuttig/codeception-api-validator

Statistics

Installs: 835

Dependents: 0

Suggesters: 0

Stars: 18

Open Issues: 2

2.0.1 2022-10-26 08:55 UTC

Requires (Dev)

Suggests

None

Provides

None

Conflicts

None

Replaces

None

Unknown License f4fcef5deb0cb5a0e34d9ac7792b9e8297693cef

  • André Wuttig <wuttig.woop@mailbox.org>

This package is auto-updated.

Last update: 2026-06-26 16:43:21 UTC


README

Validate API Requests and Responses against Swagger / OpenAPI definitions

Installation

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

 composer require --dev awuttig/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:
 - ApiValidator:
 depends: REST
 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

👁 Image

  • André Wuttig - Concept, Initial work - aWuttig

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