PHP code example of scrumworks / openapi-schema
1. Go to this page and download the library: Download scrumworks/openapi-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/ */
scrumworks / openapi-schema example snippets
class User
{
public string $name;
public string $surname;
}
class Test
{
/**
* @var integer
*/
public int $test;
public ?string $name;
/**
* @var User[]
*/
public array $users;
}
$di = new \ScrumWorks\OpenApiSchema\DiContainer();
$schemaParser = $di->getSchemaParser();
$schema = $schemaParser->getEntitySchema('Test');
// Now you can get informations about entity schema
assert($schema->getPropertySchema('test') instanceof \ScrumWorks\OpenApiSchema\ValueSchema\IntegerSchema);
// Getting OpenAPI entity schema (result is PHP array)
$openApiTranslator = $di->getOpenApiTranslator();
$openApiValueSchema = $openApiTranslator->translateValueSchema($schema);