Kotlinx.serialization: Is there any kotlin class generator based on .proto file available?

Created on 31 May 2019  路  6Comments  路  Source: Kotlin/kotlinx.serialization

just as title

feature wontfix

Most helpful comment

I am actually interested in having .proto file generated from my @Serializable data class. This is because I was using serialization-protobuf library but then those data class needed to be sent over the wire to a backend in golang and I unfortunately had to redo all my classes the old way instead to make it work (with .proto and protobuf-lite).

Happy to see the generator for the next release!

All 6 comments

There isn't any and we have no plans to add it in the nearest future.

This project has a purpose drastically different from the original Protobuf: Kotlin-first data model that is format-agnostic and can be shared between all the platforms Kotlin supports.
Kotlin classes are the core of the application data model, not the formats or schemas.

Protobuf inverses this principle: .proto file is the core of the data model and every "backend" (language, service, w/e) decides exactly to process it complying the given schema.

What we have in mind is generating .proto files from the given serializable Kotlin class, so it's possible to share (Kotlin-first) schema with other languages if there is need for.

Any idea when we will be able to generate .proto from kotlin files? I'm working on a project that has a front-end (vue), iOS, and we only want to keep one source of truth for proto files, which currently seems like we must use .proto files rather the kotlin data classes.

Probably around 1.1.0, probably the end of this year

Hi, any update about this issue ?

We have a prototype of .proto file generator that is aiming for the next release: #1255

We do not plan to implement .proto -> Kotlin conversion tho, for that purpose, I'd recommend using third-party solutions such as https://github.com/streem/pbandk

I am actually interested in having .proto file generated from my @Serializable data class. This is because I was using serialization-protobuf library but then those data class needed to be sent over the wire to a backend in golang and I unfortunately had to redo all my classes the old way instead to make it work (with .proto and protobuf-lite).

Happy to see the generator for the next release!

Was this page helpful?
0 / 5 - 0 ratings