Skip to content

Commit

Permalink
prettier README
Browse files Browse the repository at this point in the history
  • Loading branch information
osteel committed Jan 12, 2024
1 parent 978cfc7 commit 4431bcf
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ Validate HttpFoundation requests and responses against OpenAPI (3+) definitions.

See [this post](https://tech.osteel.me/posts/openapi-backed-api-testing-in-php-projects-a-laravel-example "OpenAPI-backed API testing in PHP projects – a Laravel example") for more details and [this repository](https://github.com/osteel/openapi-httpfoundation-testing-laravel-example) for an example use in a Laravel project.

> **Note**
> While you can safely use this package for your projects, as long as version `1.0` has not been released "minor" version patches can contain breaking changes. Make sure to check the [release section](../../releases) before you upgrade.
> 💡 While you can safely use this package for your projects, as long as version `1.0` has not been released "minor" version patches can contain breaking changes. Make sure to check the [release section](../../releases) before you upgrade.
## Why?

Expand All @@ -28,8 +27,7 @@ It converts HttpFoundation request and response objects to PSR-7 messages using

## Installation

> **Note**
> This package is mostly intended to be used as part of an API test suite.
> 💡 This package is mostly intended to be used as part of an API test suite.
Via Composer:

Expand Down Expand Up @@ -64,17 +62,15 @@ $validator = ValidatorBuilder::fromYaml($yamlFileOrString)->getValidator();
$validator = ValidatorBuilder::fromJson($jsonFileOrString)->getValidator();
```

> **Note**
> You can also use a dependency injection container to bind the `ValidatorBuilder` class to the [`ValidatorBuilderInterface`](/src/ValidatorBuilderInterface.php) interface it implements and inject the interface instead, which would also be useful for testing and mocking.
> 💡 You can also use a dependency injection container to bind the `ValidatorBuilder` class to the [`ValidatorBuilderInterface`](/src/ValidatorBuilderInterface.php) interface it implements and inject the interface instead, which would also be useful for testing and mocking.
You can now validate `\Symfony\Component\HttpFoundation\Request` and `\Symfony\Component\HttpFoundation\Response` objects for a given [path](https://swagger.io/specification/#paths-object) and method:

```php
$validator->validate($response, '/users', 'post');
```

> **Note**
> For convenience, objects implementing `\Psr\Http\Message\ServerRequestInterface` or `\Psr\Http\Message\ResponseInterface` are also accepted.
> 💡 For convenience, objects implementing `\Psr\Http\Message\ServerRequestInterface` or `\Psr\Http\Message\ResponseInterface` are also accepted.
In the example above, we check that the response matches the OpenAPI definition for a `POST` request on the `/users` path.

Expand Down

0 comments on commit 4431bcf

Please sign in to comment.