Download the PHP package atoum/apiblueprint-extension without Composer
On this page you can find all versions of the php package atoum/apiblueprint-extension. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download atoum/apiblueprint-extension
More information about atoum/apiblueprint-extension
Files in atoum/apiblueprint-extension
Package apiblueprint-extension
Short Description Compile and run tests written in the API Blueprint format (`.apib`) with atoum
License MIT
Homepage http://www.atoum.org
Informations about the package apiblueprint-extension
atoum/apiblueprint-extension
The candidates:
- atoum is a PHP test framework,
- API Blueprint is a high-level HTTP API description language.
The problem: API Blueprint is only a text file. Easy to read for human, but a machine can't do anything with it.
The solution: Compile API Blueprint files into executable tests. It works as any test written with the atoum API, and it works within the atoum ecosystem. Here is an overview of the workflow:
In more details, here is what happens:
- A finder iterates over
.apib
files, - For each file, it is parsed into an intermediate representation,
- The intermediate representation is compiled to target “atoum tests”,
- The fresh tests are pushed in the test queue of atoum,
- atoum executes everything as usual.
The bonus: A very simple script is provided to render many API Blueprint files as a standalone HTML single-page file.
Installation and configuration
With Composer, to include this extension into
your dependencies, you need to
require
atoum/apiblueprint-extension
:
To enable the extension, the .atoum.php
configuration file must be edited to add:
Configure the finder
Assuming the .apib
files are located in the ./apiblueprints
directory, the following code adds this directory to the API Blueprint
finder, compiles everything to tests, and enqueue them:
Configure the location of JSON schemas when defined outside .apib
files
API Blueprint uses JSON Schema to validate HTTP requests and responses when the message aims at being a valid JSON message.
We recommend to define JSON schemas outside the .apib
files for several reasons:
- They can be versionned independently from the
.apib
files, - They can be used inside your application to validate incoming HTTP requests or outgoing HTTP responses,
- They can be used by other tools.
To do so, one must go through these 2 steps:
- Mount a JSON schema directory with the help of the extension's configuration,
- Use
{"$ref": "json-schema://<mount>/schema.json"}
in the Schema section.
Example:
-
In the
.atoum.php
file where the extension is configured: -
In the API Blueprint file:
where
test
is the “mount point name”, and/api-foo/my-schema.json
is a valid JSON schema file located at/path/to/schemas/api-foo/my-schema.json
.
Testing
Before running the test suites, the development dependencies must be installed:
Then, to run all the test suites:
Compliance with the API Blueprint specification
This atoum extension implements the API Blueprint specification.
Language features | Implemented? |
---|---|
Metadata section | yes |
API name & overview section | yes |
Resource group section | yes |
Resource section | yes |
Resource model section | no (ignored) |
Schema section | yes |
Action section | yes |
Request section | yes |
Response section | yes |
URI parameters section | no (ignored) |
Attributes section | no (ignored) |
Headers section | yes |
Body section | yes |
Data Structures section | no (ignored) |
Relation section | no (ignored) |
License
Please, see the LICENSE
file. This project uses the same license than atoum.
All versions of apiblueprint-extension with dependencies
ext-curl Version *
ext-mbstring Version *
atoum/atoum Version ~3.2
hoa/ustring Version ~4.0
justinrainbow/json-schema Version ~5.2
league/commonmark Version ~0.16