hskrasek/openapi-schema-to-json-schema

PHP library to convert OpenAPI schema objects to JSON Schema

0.2.0 2018-02-07 19:03 UTC

This package is auto-updated.

Last update: 2024-04-24 23:25:43 UTC


README

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads

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 and format
    • for example type: "dateTime" becomes type: "string" with format: "date-time"
  • deletes nullable and adds "null" to type array if nullable is true
  • supports deep structures with nested allOfs etc.
  • removes OpenAPI specific properties such as discriminator, deprecated etc. unless specified otherwise
  • optionally supports patternProperties with x-patternProperties in the Schema Object

NOTE: $refs 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.