maxbeckers / php-openapi-tools
Tools for transforming OpenAPI documents
Requires
- php: >=8.2
- guzzlehttp/psr7: ^2.13.6
- maxbeckers/php-yaml-parser: ^1.0.4
- softcreatr/jsonpath: ^2.2.1
- symfony/console: ^7.0|^8.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.89
- phpunit/phpunit: ^10.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Standalone CLI tools and PHP APIs for transforming OpenAPI documents.
Features
- Apply supported subsets of OpenAPI Overlay 1.0, 1.1 and 1.2.
- Bundle documents by resolving supported local references.
- Record source locations for bundled content and map bundled pointers back to their original source locations.
- Use the CLI or the PHP API.
Requirements
- PHP
>=8.2 - Composer
>=2.0
Installation
composer require --dev maxbeckers/php-openapi-tools
Quick Start
Apply one or more overlays to an OpenAPI document:
vendor/bin/openapi-tools overlay openapi.yaml overlaid.json --overlay overlay.yaml
Bundle the resulting document, including reachable local reference targets:
vendor/bin/openapi-tools bundle overlaid.json bundle.json
The current implementation supports subsets of Overlay 1.0, 1.1 and 1.2 with
RFC 9535 JSONPath and local JSON Pointer references. This is an offline,
local-file interoperability profile: it does not fetch remote documents or
implement general URI and JSON Schema identity semantics. See the overlay
guide and bundling guide for supported
features and restrictions. Bundles can be consumed by
php-openapi-generator; the embedded-document extension is not necessarily
supported by other tools.
PHP API
For library use, MaxBeckers\OpenApiTools\Document\OverlayApplier applies an
overlay to a document object, and DocumentBundler bundles a file using
JsonDocumentReader. BundleSourceMap maps bundled pointers to recorded
original source locations.
Development
composer install
composer test
composer cs-check
composer cs
License
This project is licensed under the MIT License - see the LICENSE file for details.
Questions or Issues? Please open an issue on GitHub.
Built with ❤️ for PHP developers