Giter Club home page Giter Club logo

Comments (13)

apatrida avatar apatrida commented on August 25, 2024 9

this would allow use of Kotlin serialization in conjunction with GRPC which requires the .proto files. https://grpc.io/

from kotlinx.serialization.

elizarov avatar elizarov commented on August 25, 2024 7

@cgruber The idea with @Schema("foo.proto") is quite hard to align with format-agnostic nature of kotlin serialization. The validation has to happen at compile time, but serialization compiler plugin is not format-specific. It does not know and should not know anything about protobuf in particular. Protobuf support is runtime-only.

However, we can build a separate generation/validation tool that takes proto file and generates a Kotlin stub classes based on that, and, in addition to that, as proto file is being updated, performs compile-time validation of the correspondence between proto files and Kotlin files, if you plug the corresponding plugin into the build process.

from kotlinx.serialization.

cgruber avatar cgruber commented on August 25, 2024 2

An alternative (or companion idea) would be to accept @Schema("foo.proto") (handwave about whether that should be a path, a uri, or what). This could allow for (a) schema validation so that you know that your type is wire-compatible with the proto definition, (b) possibly omitting some annotations on fields if it can unambiguously attribute proto fields to properties, and (c) make this useable (and safe) in the context where the source of truth is a .proto, not the .kt file.

from kotlinx.serialization.

elizarov avatar elizarov commented on August 25, 2024 1

@cgruber Thank. Those comments definitely belong to this issue. We do a need a two way (generation/validation) tool and being able to traverse Kotlin serialization schema is a key enabler for that.

from kotlinx.serialization.

pdvrieze avatar pdvrieze commented on August 25, 2024 1

The infrastructure needed to do this is also required for more complex serializers. The actual information is actually embedded in the generated loaders/savers. It is possible to get almost all information (except for optionality) by emulating a loader but manually probing each field.

from kotlinx.serialization.

cgruber avatar cgruber commented on August 25, 2024

from kotlinx.serialization.

leearmstrong avatar leearmstrong commented on August 25, 2024

Did anything ever happen in this?

I am just getting started with using Kotlin. At the moment I have a proto2 file I want to use and decode a payload but curious if I can generate the Kotlin code for the serialization?

from kotlinx.serialization.

sandwwraith avatar sandwwraith commented on August 25, 2024

@leearmstrong This ticket is about the inverse process: generate proto2 files from Kotlin definitions. Unfortunately, as far as I know, there is no automated tool for your case.

from kotlinx.serialization.

leearmstrong avatar leearmstrong commented on August 25, 2024

Ah ok, thank you!

from kotlinx.serialization.

IgorKey avatar IgorKey commented on August 25, 2024

Hi there!
Are there any updates? It was moved to 1.0. as i understand we are so close to 1.0...

from kotlinx.serialization.

qwwdfsad avatar qwwdfsad commented on August 25, 2024

Hi, unfortunately, it is not going to be fixed I'm 1.0.0, but it is something we are looking for after 1.0

from kotlinx.serialization.

RdeWilde avatar RdeWilde commented on August 25, 2024

@shanshin Did you actually manage to get this working?

@elizarov your last reply was from 2017. I guess this is no longer on the roadmap?

from kotlinx.serialization.

sandwwraith avatar sandwwraith commented on August 25, 2024

@RdeWilde See #477 (comment)

from kotlinx.serialization.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.