How to validate format of an Avro schema file to see if it conforms to Apache Avro specification

Viewed 2209

Our system must process Avro schemas. Before sending Avro schema file to the server, I want to validate the format of the submitted schema file, to see if it conforms to the Apache Avro specification.

The Avro schema is a Json file, so to do basic validation against the Avro specification, I need a Json schema for the Avro schema file (I know that sounds confusing). Unfortunately, the Apache Avro specification does not provide any definition file for the Avro schema which I could run through a validator.

Does anybody know where I can find a Json Schema defining the structure of the Avro schema file according to the Apache Avro specification?

1 Answers

If you have an Avro file, that file contains the schema itself, and therefore would already be "valid". If the file cannot be created with the schema you've given, then you should get an exception (or, at least, any invalid property would be ignored)

You can get that schema via

java -jar avro-tools.jar getschema file.avro

I'm not aware of a way to use a different schema to get a file without going through the Avro client library reader methods

Related