Hi! I just released KReplica, a code generation to...
# feed
r
Hi! I just released KReplica, a code generation tool that seeks to make it easier to manage multiple DTO variants from a single interface: a base DTO, a create request DTO, and a patch request DTO. It can also optionally automatically create value classes and versioned schemas. That said, I think the most useful feature of KReplica is how it generates sealed interfaces. Allowing you to use exhaustive
when
statements to filter through all schema types, filtering by a specific schema version, or filtering by a specific schema variant (e.g. base DTOs). There's a Readme with more info. I hope someone could comment if the project seems interesting and/or if the README is understandable. There's a lot of examples, but just the first two examples are important to understanding it. https://github.com/AvaileDev/KReplica
K 1
m
idea is very great. if possible convert IDE plugin
r
Thank you! What do you mean by that? It is already a Gradle plugin?
m
IDE plugin like gui plugin like json to kotlin class plugin similar plugin available something like that
r
Do you mean like take any JSON schema and convert it to KReplica codegen? Well it's not super far fetched, since the Kotlin Poet part of KReplica already accepts JSON due to a potential design flaw early on (I didn't realize you could run Kotlin Poet and KSP in the same module). But currently it cannot parse arbitrary JSON. What would be interesting would be to given the option to replace the KSP phase with a parser that can parse (arbitrary) JSON. I would be happy to explore the idea if there's interest for it from a few more people.
_ The other thing under consideration is that KReplica currently cleans the build folder at the start of each run to prevent stale data... this would not be ideal with raw JSON input probably. It wouldn't be too much of an issue to clean up, but how would that be handled? Would the build folder simply not be automatically cleaned? Or would the user just manually copy paste the generated files to their designated folder?
m
i not prefer build folder dto generate code some time it need change some field or value
one more think many developer use official library and most trust library or plugin add in project. your idea is very nice and great. i just suggestion create IDE plugin much better
r
I'll look into it. But just a quick question: You want to copy paste a JSON schema and convert it into KReplica generated code right? That can feasibly be made into an IDE plugin (I think).
m
Yes
👍 1