Comments (13)
this would allow use of Kotlin serialization in conjunction with GRPC which requires the .proto
files. https://grpc.io/
from kotlinx.serialization.
@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.
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.
@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.
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.
from kotlinx.serialization.
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.
@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.
Ah ok, thank you!
from kotlinx.serialization.
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.
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.
@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.
from kotlinx.serialization.
Related Issues (20)
- Streaming performance: kotlinx-io & Okio integrations
- kotlinx.serialization.json deserialize error HOT 1
- Quoted booleans are being allowed even with `isLenient = false` HOT 6
- very strange serialization HOT 2
- The built-in String type (JsonPrimitive/JsonLiteral) puts double quotes around the string value HOT 8
- Don't check kind if needn't type discriminator for enum and primitive HOT 5
- 2.0.20 with generatedSerializer and reference to interface: SealedClassSerializer init: subclassSerializers contains null HOT 2
- [protobuf] How to encode/decode map with null value?
- Option to serialize enums as lowercase/snake_case HOT 4
- hande single quotes when `isLenient=true` HOT 3
- Support for `serializer<@Contextual T>` HOT 3
- Not a Bug But missing step in the Documentation when working with KMP HOT 1
- "Serializer for class List is not found" on Native. HOT 2
- [FEATURE] Allow defining a sealed class as a subclass of an open polymorphic class HOT 2
- @file:UseContextualSerialization doesn't work on Kotlin 2.0.20-RC2 HOT 1
- CBOR/COSE: support sorting of keys
- Deserializing, Transitient field use default value instead of the values from subclass constructor
- Implement additional extension serializers for frequently utilized data types in web requests. HOT 1
- Provide a way to introspect `NothingSerialDescriptor` HOT 1
- Optimize JsonElement HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kotlinx.serialization.