fiasco/tabular-openapi
Composer 安装命令:
composer require fiasco/tabular-openapi
包简介
Convert OpenAPI Schema into a relational table structure
README 文档
README
Store OpenApi schema objects in tabular data structures.
This library allows you to map OpenApi schemas into tables that could be further converted into CSV, SQL or data lake storage (e.g. Domo).
Install
This library depends on cebe/php-openapi and can be installed with composer:
composer require fiasco/tabular-openapi
Usage
Load the schema
use Fiasco\TabularOpenapi\Schema; $schema = new Schema('https://path/to/openapi-spec.json');
Get an OpenApi schema component to insert data into.
$table = $schema->getTable('Report');
Insert your OpenApi compliant schema object into the table:
$table->addRow($report);
Loop over the schema tables to discover data in the tables. Tabular OpenApi has a dev dependency on Symfony Console so you can output tablular data to console during testing:
use Symfony\Component\Console\Input\ArgvInput; use Symfony\Component\Console\Output\ConsoleOutput; use Symfony\Component\Console\Style\SymfonyStyle; $io = new SymfonyStyle(new ArgvInput(), new ConsoleOutput()); foreach ($schema->getTables() as $name => $table) { $io->title($name.': '.$table->getRowsTotal() . ' ('.$table->uuid.')'); $rows = []; foreach ($table->fetchAll() as $row) { $rows[] = $row; } $headers = array_keys(reset($rows) ?: []); $io->table($headers, $rows); $io->text('----'); }
统计信息
- 总下载量: 3.92k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-03-16