mcarleio / konvert

This kotlin compiler plugin is using KSP API and generates kotlin code to map one class to another
https://mcarleio.github.io/konvert/
Apache License 2.0
86 stars 8 forks source link

Allow setting parameters for missing properties #28

Closed MV-GH closed 10 months ago

MV-GH commented 11 months ago

I have a bunch of dtos where I want to pass one of the missing properties through a parameter.

I thought I could achieve this by doing

    @Konvert(mappings=[Mapping(target="auth", constant="auth")])
    fun toV0x18(d: v0x19.datatypes.CreateComment, auth: String): CreateComment

But it throws this error:

[ksp] java.lang.IllegalStateException: Konvert annotated function must have exactly one parameter and must have a return type: toV0x18
at io.mcarle.konvert.processor.konvert.KonverterDataCollector$collectKonvertData$1.invoke(KonverterDataCollector.kt:61)

So I request the ability to specify missing properties through parameters. This probably a bit complex when generating nested mappings. But I only need it for top level mappings. So sublevel mappings can still throw that error. If it deems to complex. To pass the parameters through nested function calls.

mcarleio commented 10 months ago

fixed with 2.4.0