encodingSchema

fun encodingSchema(descriptors: List<SerialDescriptor> = emptyList(), typesFromSerializersModule: List<KType> = emptyList(), serializersModule: SerializersModule = EmptySerializersModule(), encodeZeroValues: Boolean = false): EncodingSchema

Creates an EncodingSchema from the parameters:

  • descriptors is a list of SerialDescriptors for all top-level messages that should be supported by the schema. Note that any referenced descriptors are discovered automatically.

  • typesFromSerializersModule is a list of KTypes for all top-level messages to be supported by the schema, which are not already included in descriptors. These types are looked up in the serializersModule.

  • serializersModule is the SerializersModule to use to support contextual serialization and open polymorphism.

  • encodeZeroValues controls whether fields that have their Protobuf default values (zero/empty) are encoded or omitted. This can be useful for compatibility with Protobuf 2 consumers. Note that this only applies to singular fields: values for optional and repeatable fields are always encoded.