jSpecify (java nullability annotations) - respect annotations when generating openapi schema
As mentioned in IntelliJ IDEA’s 2025.2 release: https://www.jetbrains.com/idea/whatsnew/#page__content-jspecify-support--a-major-step-toward-safer-code IntelliJ, Kotlin, and other tools already recognize and respect these annotations.
As far as I know (I'm using Quarkus), currently only jakarta.validation annotations are considered when generating the OpenAPI document — including for nullability, constraints, etc.
However, jakarta.validation annotations are intended for validating method input parameters:
They are suitable for annotating POST/PUT request payloads.
They are not suitable for annotating return types — for example, the return type of a REST endpoint.
It would be helpful if SmallRye OpenAPI could support JSpecify-style nullability annotations (@Nullable, @NonNull, @NullMarked, @NullUnmarked) for better schema generation and more accurate documentation of REST APIs.
Or should I use kotlin instead? 😅
This does seem like something that probably should be supported. This might take some care, with the scoping/enclosure functionality of the @NullMarked and @NullUnmarked annotations. I don't believe we have anything like that currently.
JSpecify Spec: https://jspecify.dev/docs/spec/