Skip to content

Commit c9fc4cd

Browse files
authored
Merge pull request #26 from holub/patch-1
update/extend code snippets
2 parents 8520938 + 737fa76 commit c9fc4cd

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

protobuf/README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,15 @@ public class POJO {
104104
ObjectMapper mapper = new ObjectMapper(new ProtobufFactory());
105105
ProtobufSchemaGenerator gen = new ProtobufSchemaGenerator();
106106
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)
108116
NativeProtobufSchema nativeProtobufSchema = schemaWrapper.getSource();
109117

110118
String asProtofile = nativeProtobufSchema.toString();

0 commit comments

Comments
 (0)