[GitHub] sijie commented on a change in pull request #2578: [WIP] Add support for schema extraction from a jar
sijie commented on a change in pull request #2578: [WIP] Add support for schema extraction from a jar URL: https://github.com/apache/incubator-pulsar/pull/2578#discussion_r217571498 ## File path: pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/utils/SchemaExtractor.java ## @@ -0,0 +1,29 @@ +package org.apache.pulsar.admin.cli.utils; + +import org.apache.avro.Schema; +import org.apache.avro.reflect.ReflectData; +import org.codehaus.jackson.map.ObjectMapper; +import org.codehaus.jackson.map.SerializationConfig; +import org.codehaus.jackson.schema.JsonSchema; + +import java.io.IOException; + +public class SchemaExtractor { + +public static String getJsonSchema(Class clazz) throws IOException { + +org.codehaus.jackson.map.ObjectMapper mapper = new ObjectMapper(); + mapper.configure(SerializationConfig.Feature.WRITE_ENUMS_USING_TO_STRING, true); + +JsonSchema schema = mapper.generateJsonSchema(clazz); + +return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(schema); +} + +public static String getAvroSchema(Class clazz) { Review comment: use `Schema.AVRO(class).getSchemaInfo()` to get schema This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] sijie commented on a change in pull request #2578: [WIP] Add support for schema extraction from a jar
sijie commented on a change in pull request #2578: [WIP] Add support for schema extraction from a jar URL: https://github.com/apache/incubator-pulsar/pull/2578#discussion_r217571566 ## File path: pulsar-client-tools/pom.xml ## @@ -101,6 +101,18 @@ test + Review comment: I don't think you need to manually add these. just the methods in Schema class to get schema info. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] sijie commented on a change in pull request #2578: [WIP] Add support for schema extraction from a jar
sijie commented on a change in pull request #2578: [WIP] Add support for schema extraction from a jar URL: https://github.com/apache/incubator-pulsar/pull/2578#discussion_r217571451 ## File path: pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/utils/SchemaExtractor.java ## @@ -0,0 +1,29 @@ +package org.apache.pulsar.admin.cli.utils; + +import org.apache.avro.Schema; +import org.apache.avro.reflect.ReflectData; +import org.codehaus.jackson.map.ObjectMapper; +import org.codehaus.jackson.map.SerializationConfig; +import org.codehaus.jackson.schema.JsonSchema; + +import java.io.IOException; + +public class SchemaExtractor { Review comment: use `Schema.JSON(class).getSchemaInfo()` This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services