Uploaded image for project: 'Apache Avro'
  1. Apache Avro
  2. AVRO-2822

Need a method to reconstruct the original schema string before referenced schemas were resolved and inlined by the Parser

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.9.2
    • 1.10.0
    • java
    • None

    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

          Activity

            People

              rayokota Robert Yokota
              rayokota Robert Yokota
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: