8

We're using avro for (de)serialization of messages that flow through a message broker. For the purpose of storing the avro files a schema registry (apicurio) is used. This provides two benefits - schema validation and compatibility validation. However, I'm wondering if there is a way to go around the schema registry and achieve the same locally, using a script/plugin. Validating if an avro file is syntactically/semantically valid should be possible. The same applies for compatibility validation, as checking if a new schema version is backward/forward compatible against a list of other schemas (the previous versions) also sounds doable locally.

Is there a library that does that? Ideally a gradle plugin, but a java/python library would do as well, as it can easily be called from a gradle task.

Milan Milanov
  • 412
  • 1
  • 8
  • 27

2 Answers2

3

I believe this is confluent's Java class for checking schema compatibility within its schema registry:

You can use it to validate schemas locally.

Expedia has used it as a basis to create their own compatibility tool:

dominicst
  • 64
  • 1
  • 6
1

I could not find a plugin doing just that what you ask for. Plugins seem to aim for generating classes from the schema files (i.e. https://github.com/davidmc24/gradle-avro-plugin). Without getting into why you want to do this, I think you could use this simple approach (How do I call a static Java method from Gradle) to hook you custom code into Gradle and checking for schema validity and compatibility.

Refer to following Avro Java API:

Also checking this particular class can be helpful for executing validation against the schema:

sol25
  • 139
  • 1
  • 8