Advanced filters and Schema Providers
Backward incompatible changes
As the JSON schemas are fetched via a provider now you have to change your model generator script. To get the old behaviour simply add the RecursiveDirectoryProvider
:
Change from:
(new Generator())
->generateModels(__DIR__ . '/schema', __DIR__ . '/result');
to:
(new Generator())
->generateModels(new RecursiveDirectoryProvider(__DIR__ . '/schema'), __DIR__ . '/result');
Features
- Fetch JSON schemas via a provider implementation allowing different sources for object schemas than a folder structure containing the objects as separate .json files
- Added an Open API v3 schema provider which accepts an Open API v3 json file and converts all models located at
#/components/schemas
into PHP models (docs) - Added additional builtin filters
- Advanced filter logic
- Filter may be applied to an array
- Added transforming filter. A transforming filter takes the provided value and transforms the value into another type. The transformed type will be reflected as property type into the generated model (docs). A transforming filter for example may be used to initialize an object with a provided string (eg. date string into DateTime object). Properties with a transforming filter also accept an already transformed value (eg. the property with a DateTime filter also accepts a DateTime object).
- Added filter options. A filter now may accept additional options which define the behaviour of the filter (docs)
Bugfixes
- If multiple filters are applied to a single property they will now be executed in the order of their appearance in the JSON Schema
Internal
- Moved serialization functionality into a trait to reduce code duplication