Open schubertf opened 3 years ago
@schubertf , thanks for the reproduction. It seems the JsonSchemaInject
of additionalProperties
does not play nicely with json.oneof.for.nullables=true
due to an issue with the underlying JSON schema library.
I've committed https://github.com/confluentinc/schema-registry/pull/2016, but that only allows you to toggle additionalProperties
for all objects, not customize it for each object.
Thanks for your reply @rayokota. As I mentioned, we need to be able to customise additionalProperties for each object. We can currently do this by setting json.oneof.for.nullables to false, but would like to be able to do this and use oneOf for nullable properties.
Serialisation of JSON with schema fails when additionalProperties is set to false.
We have a data model that requires additionalProperties to be set to either true or false at various points in the hierarchy, i.e. some beans will have additionalProperties set to true and others will have it set to false. We are using com.kjetland.jackson.jsonSchema.annotations.JsonSchemaInject to achieve this.
On doing so the schema seems to be generated correctly with additionalProperties set to either true or false as required, however when producing a message (with the configuration property json.oneof.for.nullables set to the default of true) the serialisation fails with an error similar to the following...
If we override the default and set the configuration property json.oneof.for.nullables to false the message is serialised correctly, albeit with a slightly different schema as expected. See attached Maven project to reproduce. json.schema.oneof.additional.properties.zip The serialisation of the JSON payload should work regardless of the value of the json.oneof.for.nullables configuration property.