Skip to content

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

0.21.4

13 Oct 13:31
Compare
Choose a tag to compare
Fix missing required check for required referenced property inside a …

0.21.3

12 Oct 12:32
Compare
Choose a tag to compare

Fix fatal errors during model generation

Fix validation of required properties not defined in the properties section of a schema

08 Oct 09:55
Compare
Choose a tag to compare

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

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)