File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -104,7 +104,15 @@ public class POJO {
104
104
ObjectMapper mapper = new ObjectMapper (new ProtobufFactory ());
105
105
ProtobufSchemaGenerator gen = new ProtobufSchemaGenerator ();
106
106
mapper. acceptJsonFormatVisitor(POJO . class, gen);
107
- ProtobufSchema schemaWrapper = gen. getProtobufSchema();
107
+ ProtobufSchema schemaWrapper = gen. getGeneratedSchema();
108
+ NativeProtobufSchema nativeProtobufSchema = schemaWrapper. getSource();
109
+
110
+ String asProtofile = nativeProtobufSchema. toString();
111
+ ```
112
+ Alternatively same can be achieved with less code:
113
+ ``` java
114
+ ProtobufMapper mapper = new ProtobufMapper ()
115
+ ProtobufSchema schemaWrapper = mapper. generateSchemaFor(POJO . class)
108
116
NativeProtobufSchema nativeProtobufSchema = schemaWrapper. getSource();
109
117
110
118
String asProtofile = nativeProtobufSchema. toString();
You can’t perform that action at this time.
0 commit comments