ngs-doo / dsl-json

High performance JVM JSON library
https://dsl-platform.com
BSD 3-Clause "New" or "Revised" License
1.01k stars 106 forks source link

Configure for external classes using configuration #272

Open vstoyanov opened 7 months ago

vstoyanov commented 7 months ago

Hello,

Thank you very much for your excellent library. I have a tiny issue with it - there is a case where DTOs are defined in a separate artifact, which we cannot annotate with @JsonCompile as we don't want the dsl-json dependency there.

I attempted several workarounds - external configuration files, adding a bogus DTO which referenced the necessary types just to trigger the automatic creation of converter for dependent types[0]. Currently I found myself forced to work with copies of the contract objects, which is not ideal in the long term.

I was wondering if I could contribute some sort of an external configuration which would mimic the structure configured by the annotations, however, with the possibility of specifying it externally. Do you see any value in such a thing?

Best, Vasil Stoyanov

  1. BTW, there seems to be an issue with Lombok types which have both an empty constructor and a builder. The empty constructor is selected first, but with the builder properties (without set* prefix). I can open another ticket for it and have it fixed.
zapov commented 6 months ago

Hi @vstoyanov Yeah, it would be nice to improve support for declaring external classes for analysis. PR is welcome, some up-front proposal would be nice to have. btw. dsl-json somewhat supports other annotations, so you could maybe use those to avoid dsl-json dependency: https://github.com/ngs-doo/dsl-json/blob/master/library/src/main/java/com/dslplatform/json/processor/CompiledJsonAnnotationProcessor.java#L22

What is the issue with declaring additional DTO to cover for this types? How would that differ from other kind of configuration (eg by allowing to set all configuration properties, not just reference it?).