Releases: wol-soft/php-json-schema-model-generator
Releases · wol-soft/php-json-schema-model-generator
0.21.4
0.21.3
Fix validation of required properties not defined in the properties section of a schema
Previously to this release a schema like the following won't validate the property bar
:
{
"type": "object",
"properties": {
"foo": {
"type": "string"
},
"required": [
"foo",
"bar"
]
}
Now the property will be validated and added to the interface of the generated class. Generated interface:
getFoo(): string;
setFoo(string $value): self;
getBar(): mixed;
setBar(mixed $value): self;
0.21.1
Pattern Properties
Backwards incompatible changes
- The schema hook interfaces SetterBeforeValidationHookInterface and SetterAfterValidationHookInterface have been changed with an additional parameter to determine wether it's an update of a single property or a batch update (eg. via the PopulatePostProcessor). The function signature of the getCode implementation must be updated to match the interface.
- Drop support for the
setPrettyPrint
option (#37) - If a schema defines
additionalProperties
the additional properties will be included in a serialized object by default without the requirement to use theAdditionalPropertiesAccessorPostProcessor
(docs)
Features
- Added support for
pattern properties
(docs) - Added a new builtin post processor (
PatternPropertiesAccessorPostProcessor
) to accesspattern properties
(docs) - Added new hook to hook into seerialization by adding a schema hook implementing the SerializationHookInterface (docs)
- Added code coverage ignore annotations to generated code
Bugfixes
- Adding AdditionalPropertiesAccessorPostProcessor to a mutable object without an additional property definition breaks the rendering
- Invalid pattern provided for a string property now throws an exception while generating the model classes
- Rollback of additional properties and pattern properties in populate in case a later validation fails
- setAdditionalProperty must not check if the provided property key matches an internal property
Internal
- Moved CI from travis.ci to GitHub Actions
Conditional compositions and format validations
Backwards incompatible changes
- Custom post processors must extend the abstract class
PHPModelGenerator\SchemaProcessor\PostProcessor\PostProcessor
instead of implementing thePHPModelGenerator\SchemaProcessor\PostProcessor\PostProcessorInterface
(docs) - A schema with an empty enum will throw a
SchemaException
during the generation process
Features
- Post processors now support pre- and post-execution hooks to execute code before and after the processor is applied to each generated schema (docs)
- Support for conditional compositions (docs)
- Added an option to default arrays to an empty array (#32) (docs)
- Added an option to restrict additional properties by default (#31) (docs)
- If a single filter with options is applied to a property it must no longer be wrapped in a list (#27) (docs)
- Added support for string format validators (docs)
Bugfixes
Fix invalid code generated for const properties (#29)
0.19.2 Map the result of gettype for const properties to internal types to g…
Fix reference resolving (#25)
Merge pull request #26 from wol-soft/RefactorPropertyLateBinding Resolve properties during rendering instead of processing for correct usage of the PropertyProxy
Composition validation of mutable objects
Backwards incompatible changes
- Removed dependency to
symplify/easy-coding-standard
. If you want to use the pretty printing mechanism of the library you need to add the library manually:
composer require --dev symplify/easy-coding-standard
Features
- PHP8 Compatibility
- Optimized duplicate class detection by using only relevant fields for calculating the class signature
- Include object description in class DocBlock
Bugfixes
- The
OpenAPIv3Provider
doesn't resolve internal references - The method
setAdditionalProperty
added by theAdditionalPropertiesAccessorPostProcessor
doesn't trigger setter hooks - Uses for classes from the same namespace
- Set nullable properties to null via the
populate
method of thePopulatePostProcessor
keeps the old value - Property validation of mutable objects which use composition after instantiation (#6)
Internal
- Don't use
array_unique
any longer for unique validations (compare https://bugs.php.net/bug.php?id=65208) as it's not type safe - Properties added to a schema object (eg. in a post processor) can now be marked as internal properties. Internal properties will be private and rendered without getter and setter methods
- Setter logic is not executed if the provided value is identical to the already stored value (Value will not be validated, no schema hooks will be called)
- Also applies to the
PopulatePostProcessor
- Also applies to additional properties added via the
setAdditionalProperty
added by theAdditionalPropertiesAccessorPostProcessor
- Also applies to the
Schema Hooks
Backward incompatible changes
- Sensitive data (file and line) is stripped from serialized exceptions by default. Set the added parameter
$stripSensitiveData
to false to include sensitive data - The exception structure for models with nested objects has changed (see #20 for more details regarding the change)
- When instantiating a nested object manually with invalid data an exception will be thrown
Features
- Added a new builtin post processor:
AdditionalPropertyAccessorPostProcessor
, adds methods to handle the additional properties of a model (#17) (docs) - Optimized exception structure and messages for nested objects to avoid ambiguous error messages (#20)
- Added schema hooks to the generator which allows post processors to inject code snippets into specified places inside the model by implementing defined interfaces (docs)
Bugfixes
- Nested objects instantiated manually don't throw exceptions
- Fix rollback in PopulatePostProcessor with error collection disabled if a validation error is thrown
- Fix setters don't update the values returned by
getRawModelDataInput
(docs)