Download the PHP package gpht/openapi-symfony-validator without Composer
On this page you can find all versions of the php package gpht/openapi-symfony-validator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download gpht/openapi-symfony-validator
More information about gpht/openapi-symfony-validator
Files in gpht/openapi-symfony-validator
Package openapi-symfony-validator
Short Description OpenAPI validation library for Symfony applications with PHPUnit integration
License MIT
Informations about the package openapi-symfony-validator
OpenAPI Symfony Validator
A PHP library for validating Symfony application requests and responses against OpenAPI specifications. This library provides PHPUnit integration through traits and automatic test case generation.
Features
- π Easy PHPUnit Integration: Use the
OpenApiValidationTraitin your test classes - π Automatic Test Generation: Generate test cases from OpenAPI specifications
- π― Request/Response Validation: Validate both HTTP requests and responses
- πΊοΈ Path Mapping: Map OpenAPI paths to your actual application routes
- π§ͺ Symfony Integration: Works seamlessly with Symfony's test client
Installation
Install via Composer:
Requirements
- PHP ^8.4
- Symfony ^6.0|^7.0
- PHPUnit ^10.0|^11.0
Usage
Basic Usage with Trait
The easiest way to use this library is with the OpenApiValidationTrait:
The trait will automatically:
- Generate test cases from your OpenAPI specification
- Create PHPUnit data providers
- Execute tests for each endpoint with the configured client
- Validate both requests and responses against the OpenAPI schema
OpenAPI Parameter Requirements
Important: All parameters in your OpenAPI specification must have either an example or default value. The library uses these values to generate test requests.
Path Mapping
The apiMap() method maps OpenAPI paths to your actual application routes:
- Key: The path as defined in your OpenAPI specification
- Value: The actual route path in your Symfony application
Direct Usage (Advanced)
For complex validation scenarios, you can use the OpenApiValidator class directly or fall back to the underlying league/openapi-psr7-validator library:
Development
Code Quality Tools
This project uses Mago for code formatting and linting, plus Psalm for static analysis:
Testing
Run the test suite:
GitHub Actions
The project includes a comprehensive CI pipeline that runs:
- Mago formatting checks
- Mago linting
- Psalm static analysis
- PHPUnit tests
License
MIT
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Run the code quality checks:
composer format-check && composer lint && composer psalm - Run tests:
composer test - Submit a pull request
Requirements for OpenAPI Specifications
- All parameters must have
exampleordefaultvalues - Path parameters are automatically replaced in both OpenAPI and actual paths
- Query parameters without values will be excluded from minimal test cases
- The library supports all standard HTTP methods (GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS)
All versions of openapi-symfony-validator with dependencies
gpht/openapi-psr7-validator Version ^0.23
nyholm/psr7 Version ^1.8
symfony/psr-http-message-bridge Version ^6.0|^7.0
symfony/yaml Version ^6.0|^7.0
symfony/framework-bundle Version ^6.0|^7.0
symfony/browser-kit Version ^6.0|^7.0