Download the PHP package mlambley/swagception without Composer
On this page you can find all versions of the php package mlambley/swagception. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mlambley/swagception
More information about mlambley/swagception
Files in mlambley/swagception
Package swagception
Short Description Validate your API against Swagger 2.0 using Codeception
License MIT
Informations about the package swagception
Swagception
Validate your API against Swagger 2.0 using Codeception
How to Install
What is Swagger?
Swagger 2.0 (aka Open API 2.0) defines the structure of your API, including end points and the structure of input and output data. See their website for more information.
What is Swagception?
If you have an existing Swagger 2.0 specification, you can use it to validate your API using this tool. This tool is designed to work with Codeception. Specifically, it automates the generation of acceptance tests for your API. It will not validate your specification itself. It will only validate that your API matches your existing specification.
Why Swagception?
I could not find any API validator which uses Swagger and is designed specifically for Codeception. Also, this library aims to fully take into account the features of the Swagger 2.0 specification.
Acceptance test generation
The paths in your Swagger specification will look something like /api/entity/{entityID}/other/{otherID}
How then do we generate an actual url using real entity ids which will produce a real response?
By default, this library will do this using the enum
and x-example
fields. However, it is more useful to be able to specify your own ids.
You can create a handler for each entity. Use annotations to link them to one or more paths. Then, all you need to do is tell the system where to find them.
Swagception extension
Now that you have some real data at your disposal, it's time to configure your codeception environment for Swagception. You only need to set up one extension. More information about codeception extensions is available here. Put the following in your codeception.yml or suite.yml file:
Cest structure
With the full functionality of Swagception enabled, it's time to link everything together in your Codeception cest. The recommended way is to feed the paths (end points) into a cest data provider. Your terminal will then output a line for each path.
Alternatively, you can loop through them in a single function.
Or, if you already have the json and the schema objects, you can call the validation method directly.
More settings
See more configuration options.
Issues?
Log a github issue. Your assistance is appreciated.
All versions of swagception with dependencies
zeptech/annotations Version ^1.1
justinrainbow/json-schema Version ^5.2
guzzlehttp/guzzle Version ^6.3 || ^7.0
pimple/pimple Version ^3.2
codeception/module-asserts Version ^1.2