Skip to content

jSpecify (java nullability annotations) - respect annotations when generating openapi schema #2329

@mapuci

Description

@mapuci

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? 😅

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions