Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://gitlab.com/vuphuong87/symfony-openapi-schema-validator
The OpenAPI schema validator wrapper for Symfony HTTP Request / Response object
https://gitlab.com/vuphuong87/symfony-openapi-schema-validator
openapi symfony validator
Last synced: 3 months ago
JSON representation
The OpenAPI schema validator wrapper for Symfony HTTP Request / Response object
- Host: gitlab.com
- URL: https://gitlab.com/vuphuong87/symfony-openapi-schema-validator
- Owner: vuphuong87
- Created: 2020-09-25T04:50:15.989Z (over 4 years ago)
- Default Branch: master
- Last Synced: 2024-09-27T14:03:51.400Z (4 months ago)
- Topics: openapi, symfony, validator
- Stars: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Symfony OpenAPI Schema Validator
[![coverage report](https://gitlab.com/vuphuong87/symfony-openapi-schema-validator/badges/master/coverage.svg)](https://gitlab.com/vuphuong87/symfony-openapi-schema-validator/-/commits/master)
The OpenAPI schema validator wrapper for Symfony HTTP Request / Response object.
This package use `league/openapi-psr7-validator` package to validate OpenAPI schema on a PSR7 Request / Response object.
The Symfony HTTP Request / Response object will be converted to PSR7 objects thanks to `symfony/psr-http-message-bridge` package.## Install
``` bash
$ composer require vuphuong87/symfony-openapi-schema-validator
```## Usage
### Validate a Request
``` php
$schemaValidator = new SchemaValidator($apispec);
$schemaValidator->isValidRequest($request)
```### Validate a Response
``` php
$path = '/v1/posts'; // uri path defined in schema
$schemaValidator = new SchemaValidator($apispec);
$schemaValidator->isValidResponse($response, $path, 'GET');
```### Get validation errors
``` php
$schemaValidator->getErrors();
```