Description
I need a method to reconstruct the original schema string before referenced schemas were resolved and inlined by the Parser.
There is already logic to do this for a schema in the context of a protocol, but not after a schema (and its referenced schemas) are submitted to the parse() method of Schema.Parser.
The method would be the following on Schema:
public String toString(Collection<Schema> referencedSchemas, boolean pretty) { try { StringWriter writer = new StringWriter(); JsonGenerator gen = FACTORY.createGenerator(writer); if (pretty) { gen.useDefaultPrettyPrinter(); } Schema.Names names = new Schema.Names(); if (referencedSchemas != null) { for (Schema s : referencedSchemas) { names.add(s); } } toJson(names, gen); gen.flush(); return writer.toString(); } catch (IOException e) { throw new AvroRuntimeException(e); } }
Attachments
Issue Links
- relates to
-
AVRO-2832 [Java] Create a configurable Formatter for Schemas
- Open
- links to