PHP code example of benmorel / openapi-schema-to-json-schema
1. Go to this page and download the library: Download benmorel/openapi-schema-to-json-schema library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
benmorel / openapi-schema-to-json-schema example snippets
use BenMorel\OpenApiSchemaToJsonSchema\Convert;
$schema = json_decode(<<<'JSON'
{
"type": "string",
"format": "date-time",
"nullable": true
}
JSON
);
$convertedSchema = Convert::openapiSchemaToJsonSchema($schema);
echo json_encode($convertedSchema, JSON_PRETTY_PRINT);
use BenMorel\OpenApiSchemaToJsonSchema\Convert;
$param = json_decode(<<<'JSON'
{
"name": "parameter name",
"in": "query",
"schema": {
"type": "string",
"format": "date"
}
}
JSON
);
$convertedSchema = Convert::openapiParameterToJsonSchema($param);
echo json_encode($convertedSchema, JSON_PRETTY_PRINT);