Buf Schema Generator
The schema is generated based on provided SerialDescriptor and is compatible with proto2 schema definition. An arbitrary Kotlin class represent much wider object domain than the ProtoBuf specification, thus schema generator has the following list of restrictions:
Serial name of the class and all its fields should be a valid Proto identifier
The name of the type without the package directive uniquely identifies the proto message type and two or more fields with the same serial name are considered to have the same type. Schema generator allows to specify a separate package directive for the pack of classes in order to mitigate this limitation.
Nested collections, e.g.
List<List<Int>>are represented using the artificial wrapper message in order to distinguish repeated fields boundaries.
Default Kotlin values are not representable in proto schema. A special commentary is generated for properties with default values.
Empty nullable collections are not supported by the generated schema and will be prohibited in ProtoBuf as well due to their ambiguous nature.
Contextual data is represented as as
Polymorphic data is represented as a artificial
Other types are mapped according to their specification: primitives as primitives, lists as 'repeated' fields and maps as 'repeated' map entries.
The name of messages and enums is extracted from SerialDescriptor.serialName in SerialDescriptor without the package directive, as substring after the last dot character, the
'?' character is also removed if it is present at the end of the string.
Generate text of protocol buffers schema version 2 for the given serializable descriptors. packageName define common protobuf package for all messages and enum in the schema, it may contain
'z' letters in upper and lower case, decimal digits,
'_' chars, but started only from a letter and not finished by dot.