Image by @blackieshoot at Unsplash
Panettone is a CLI tool for extracting PHP types from Open API schemas. Types are generated by interpreting the data model (schema) of Open API documents. Unlike Api Platform's schema generator, it does not determine types using path and operations.
Pre-release 0.2.3 introduces an initial set of functional structures to be used in the future for Open API parsing.
composer require alexanderallen/panettone
vendor/bin/panettone --help
As Panettone is not a CLI tool and not a library, I recommend that you install it to your project's tools
directory, as such:
mkdir -p tools
cd tools
composer require alexanderallen/panettone
cd ..
vendor/bin/panettone --help
vendor/bin/panettone schema/my-saucy-schema.yaml tmp vendor/alexanderallen/panettone/test/schema/settings.ini
In the example above, Panettone will:
schema/my-saucy-schema.yaml
Open Api file;tmp
directory, and;vendor/alexanderallen/panettone/test/schema/settings.ini
to guide the type generation process.vendor/bin/panettone --help
Description:
Generate PHP types from Open API sources.
Usage:
panettone <input> [<output> [<config>]]
Arguments:
input Path to Open Api source file in YAML format
output Destination for generated files
config Path to .ini configuration file [default: "settings.ini"]
Options:
-h, --help Display help for the given command. When no command is given display help for the panettone command
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi|--no-ansi Force (or disable --no-ansi) ANSI output
-n, --no-interaction Do not ask any interactive question
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Help:
Generates PHP types from a Open API source.
Panettone is configured by placing a settings.ini
in the directory from where you are executing Panettone, usually where your composer.json
is.
Below is a list of the currently supported configuration options. Do note that the [file], [class]
segments
are required when using the options listed under them.
; Enable detailed logging during type generation.
debug = true
[file]
; Path where to dump the generated file.
output_path = "tmp"
; Namespace for all generated files.
namespace = "Panettone"
; Comment to apply to every generated file.
comment = "Example file comments are configured in settings.ini."
[class]
nullable = true
default = null
Tests are located in the tests
directory. PHPUnit is installed separately in the tools/phpunit
directory.
To test, first use Composer to install PHPUnit then run the test script.
composer -d tools/phpunit install
. tools/phpunit/test
Coverage details are gathered during testing in Github and pushed to Coveralls.