SQL::Translator::Parser::OpenAPI - convert OpenAPI schema to SQL::Translator schema
OS | Build status |
---|---|
Linux |
use SQL::Translator;
use SQL::Translator::Parser::OpenAPI;
my $translator = SQL::Translator->new;
$translator->parser("OpenAPI");
$translator->producer("YAML");
$translator->translate($file);
# or...
$ sqlt -f OpenAPI -t MySQL <my-openapi.json >my-mysqlschema.sql
This module implements a SQL::Translator::Parser to convert a JSON::Validator::OpenAPI specification to a SQL::Translator::Schema.
It uses, from the given API spec, the given "definitions" to generate tables in an RDBMS with suitable columns and types.
To try to make the data model represent the "real" data, it applies heuristics:
- to remove object definitions that only have one property
- to find object definitions that have all the same properties as another, and remove all but the shortest-named one
- to remove object definitions whose properties are a strict subset of another
None at present.
Standard as per SQL::Translator::Parser. The input $data is a scalar that can be understood as a JSON::Validator specification.
To debug, set environment variable SQLTP_OPENAPI_DEBUG
to a true value.
Ed J, <etj at cpan.org>
Copyright (C) Ed J
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.