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

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.9.2
    • Fix Version/s: 1.10.0
    • Component/s: java
    • Labels:
      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

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

                Dates

                • Created:
                  Updated:
                  Resolved: