jsonschema-generator icon indicating copy to clipboard operation
jsonschema-generator copied to clipboard

Support dynamic addition of properties

Open CarstenEnglert opened this issue 6 years ago • 1 comments

GH-45 aims at considering the Jackson @JsonSubTypes annotation for looking-up per-property subtypes. In that context, Jackson also has a @JsonTypeInfo annotation which may describe an identifier (e.g. a "type" property) how the subtypes may be differentiated.

In some cases, this additional identifier may not already be declared as such but could potentially be added automatically during serialization to JSON.

The Schema Generator should cater for this kind of identifier (property) being added without having a declared field/method as reference for it.

Additionally, the jackson module could be enhanced to consider the @JsonTypeInfo annotation accordingly: (1) adding this kind of identifier property as per the @JsonTypeInfo annotation and (2) ideally setting its "const" value as per the @JsonSubTypes annotation.

CarstenEnglert avatar Mar 14 '20 12:03 CarstenEnglert

As of release v4.8.0, the subtype resolution by the jackson module is now available, which includes at least a very simple form of adding additional properties (via allOf and custom definitions).

Closing this now, as it doesn't seem worth the extra effort at this stage – at least until someone has a similar requirement that cannot be properly achieved with the existing configuration options.

CarstenEnglert avatar Mar 30 '20 12:03 CarstenEnglert