vojtechhabarta / typescript-generator

Generates TypeScript from Java - JSON declarations, REST service client
MIT License
1.14k stars 237 forks source link

org.springframework.lang.Nullable not supported #1040

Open klaus7 opened 10 months ago

klaus7 commented 10 months ago

Hello,

some external dependency I use (and inherit from) uses the org.springframework.lang.Nullable annotation. When I add this to my list of nullable annotations like:

            val gen = TypeScriptGenerator(Settings().apply {
                // ...
                nullableAnnotations = listOf(
                    org.springframework.lang.Nullable::class.java,
                    javax.annotation.Nullable::class.java,
                    jakarta.annotation.Nullable::class.java,
                )

... it will fail with the following error:

Exception in thread "main" java.lang.RuntimeException: 'org.springframework.lang.Nullable' annotation cannot be used as nullable annotation because it doesn't have 'TYPE_PARAMETER' or 'TYPE_USE' target.
    at cz.habarta.typescript.generator.Settings.validate(Settings.java:410)
    at cz.habarta.typescript.generator.TypeScriptGenerator.<init>(TypeScriptGenerator.java:59)

This is in the spring framework, so I can't really change anything in the annotation, but I guess the annotation provided by spring should be supported as it is?

weberhofer commented 5 months ago

That would really be a nice enhancement. At least with Java 21 org.checkerframework.checker.nullness.qual.Nullable seems to be the only working annotation for Nullable.