Download the PHP package reinfi/openapi-models without Composer
On this page you can find all versions of the php package reinfi/openapi-models. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download reinfi/openapi-models
More information about reinfi/openapi-models
Files in reinfi/openapi-models
Package openapi-models
Short Description Generate PHP models from openapi definition
License MIT
Informations about the package openapi-models
OpenAPI Models generated for PHP
This library does not provide any client or server implementation for your open api definition. It just generates models defined in your schemas.
This library may not be feature complete for all openapi definition. If you miss a feature, just file an issue.
Why?
There are some common open api generators like JanePHP or OpenAPI Generator but they create old PHP Syntax due to their backwards compatibility.
- No readonly objects
- No constructor promoted properties
- No typed properties, except PHPDoc
That is the reason why this library exists to simply generate models with new PHP syntax.
Install
Use composer to install it as development dependency.
composer require --dev reinfi/openapi-models
Usage
Default configuration file is openapi-models.php
.
Your configuration file should return an array with the following settings:
Generate
To generate your files just run php vendor/bin/openapi-models generate
.
If you like to store your configuration somewhere else you need to provide the file name to the command.
php vendor/bin/openapi-models generate --config spec/openapi-models.php
Validate
To validate your files, i.e. if the specification matches the generated files, you can run php vendor/bin/openapi-models validate
.
Make sure you use the same configuration file as used for the generate command.
Types
This library does not support mixed
type from open-api specification.
Therefore, you always have to set a type in your specification.
Date or DateTime
The following schema has date/date-time properties.
The default is to generate the fields as string
-type because this would not require
any logic for serialization of the class.
You can change the configuration dateTimeAsObject
to true
and then these fields will be of type DateTimeInterface
.
A serialization function is added to these classes to support native json_encode
. If you do not use native json_encode you
may need to provide an own implementation to fulfill open api specifications.
The default format for a date
is Y-m-d
, for a date-time
-type is Y-m-d\TH:i:sP
(RFC3339), but you can configure it.
This is just for convenience if you do not want to deal with time zones or just need different formats.
All versions of openapi-models with dependencies
nette/php-generator Version ^4.1
symfony/console Version ^6.0 | ^7.0
php-di/php-di Version ^7.0
marcelthole/openapi-merge Version ^2.0
michaelpetri/typed-input Version ^1.3
webmozart/glob Version ^4.6
ocramius/package-versions Version ^2.8
php-openapi/openapi Version ^2.0