Skip to content

Releases: wol-soft/php-json-schema-model-generator

0.21.1

07 Oct 10:35
Compare
Choose a tag to compare

Bugfixes: #40 #41 #43

Pattern Properties

08 Jul 14:45
Compare
Choose a tag to compare

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 the AdditionalPropertiesAccessorPostProcessor (docs)

Features

  • Added support for pattern properties (docs)
  • Added a new builtin post processor (PatternPropertiesAccessorPostProcessor) to access pattern 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

10 Feb 11:38
9a25740
Compare
Choose a tag to compare

Backwards incompatible changes

  • Custom post processors must extend the abstract class PHPModelGenerator\SchemaProcessor\PostProcessor\PostProcessor instead of implementing the PHPModelGenerator\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)

28 Jan 15:16
Compare
Choose a tag to compare
0.19.2

Map the result of gettype for const properties to internal types to g…

Fix reference resolving (#25)

17 Dec 15:04
9e8901a
Compare
Choose a tag to compare
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

11 Nov 14:18
2cfe6f6
Compare
Choose a tag to compare

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 the AdditionalPropertiesAccessorPostProcessor doesn't trigger setter hooks
  • Uses for classes from the same namespace
  • Set nullable properties to null via the populate method of the PopulatePostProcessor 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 the AdditionalPropertiesAccessorPostProcessor

Schema Hooks

25 Jul 16:46
ac2ae33
Compare
Choose a tag to compare

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)

Post Processors

16 Jul 11:30
Compare
Choose a tag to compare

Backward incompatible changes

The interfaces for filters have been moved to the production repository to implement a custom filter in a single class. The namespaces have been changed:

  • FilterInterface is now located at PHPModelGenerator\Filter\FilterInterface
  • TransformingFilterInterface is now located at PHPModelGenerator\Filter\TransformingFilterInterface

The output format of schema providers has been changed. Instead of a tuple for each schema a JsonSchema object must be returned. If you have implemented a custom schema provider have a look at the SchemaProviderInterface for more details and change your implementation to match the new interface. Basically instead of a tuple [$fileName, $jsonSchemaStructure] you must now return a JsonSchema object:

new JsonSchema($fileName, $jsonSchemaStructure);

Features

  • Implemented post processors (#16) which can be used to change the generated model (eg. add additional functions to the model) (docs)
    • Builtin post processor: PopulatePostProcessor, adds a populate method to the model which allows updating any subset of the model's properties with validation (docs)
    • Provides an interface to implement custom post processors (docs)
  • Extended the output of a SchemaException to contain the file which caused the exception

Internal

  • Instead of arrays the schemas are passed through the library via JsonSchema objects.
  • Adding serialization methods is now handled via a post processor

Reworked type hints

08 Jul 15:08
Compare
Choose a tag to compare

Backward incompatible changes

Arrays accepted null values implicitly without an option to disable null values. This behaviour has been changed so only non-null values are accepted now. If you require the acceptance of null values add null to the accepted item types of your array:

...
"myArrayProperty": {
	"type": "array",
	"items": {
		"type": ["string", "null"]
	}
}
...

Internal

  • Changed some internal behaviour for a performance increase of the generated models (#12)
  • Changed the generation process of merged properties so no unused code is generated (#13) (docs)

Bugfixes

  • Arrays accept null entries implicitly
  • RecursiveDirectoryIterator with a trailing slash results in a wrong base directory (#14)
  • Wrong type hints for multi type properties and array properties

Bugfix

25 Jun 16:44
Compare
Choose a tag to compare

Bugfixes

  • Fix error importing builtin types for transforming filters leading to fatal errors