hskrasek / openapi-schema-to-json-schema
PHP library to convert OpenAPI schema objects to JSON Schema
Installs: 2 291
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 3
Forks: 0
Open Issues: 3
Requires
- php: >=7.1
- league/flysystem: ^1.0
- league/json-reference: dev-master
- league/pipeline: ^0.3.0
- symfony/console: ~3.3 | ^4.0
- symfony/property-access: ^4.0
- symfony/property-info: ^4.0
- symfony/serializer: ^4.0
- symfony/yaml: ^4.0
Requires (Dev)
- phpunit/phpunit: ^6.5
- squizlabs/php_codesniffer: ^2.3
This package is auto-updated.
Last update: 2025-02-25 01:18:19 UTC
README
This is PHP port of the Node package by the same name, so huge props to Github user mikunn for the work he did. This package currently converts from OpenAPI 3.0 to JSON Schema Draft 4.
Features
- converts OpenAPI 3.0 Schema Object to JSON Schema Draft 4
- converts common named data types to
type
andformat
- for example
type: "dateTime"
becomestype: "string"
withformat: "date-time"
- for example
- deletes
nullable
and adds"null"
totype
array ifnullable
istrue
- supports deep structures with nested
allOf
s etc. - removes OpenAPI specific properties such as
discriminator
,deprecated
etc. unless specified otherwise - optionally supports
patternProperties
withx-patternProperties
in the Schema Object
NOTE: $ref
s are not dereferenced. Use a dereferencer such as json-schema-ref-parser prior to using this package.
Install
Via Composer
$ composer require hskrasek/openapi-schema-to-json-schema
Usage
vendor/bin/oas-to-jsonschema convert docs/schemas docs/specs
Change log
Please see CHANGELOG for more information on what has changed recently.
Testing
$ composer test
Contributing
Please see CONTRIBUTING and CODE_OF_CONDUCT for details.
Security
If you discover any security related issues, please email hunterskrasek@me.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.