Skip to content

Version 2.8.0+ does not handle @Schema(nullable = true) fields correctly #2920

@slovelo

Description

@slovelo

Describe the bug

  • From springdoc 2.8.0 and newer, fields that are marked as nullable via @Schema(nullable = true) no longer show as nullable: true in the generated OpenAPI and swagger UI.
  • This issue was introduced after 2.7.0. Tested with 2.8.5 and 2.8.0 which both exhibit the same bug.

To Reproduce
Steps to reproduce the behavior:

  • Java 21, spring-boot 3.4.3
  • springdoc-openapi-starter-webflux-ui 2.8.5
  • Create a class and annotate all fields with @Schema(nullable = true)
  • Expose this class via a get endpoint
  • Inspect OpenAPI JSON or YAML. No fields will be nullable in OpenAPI spec

Sample OpenAPI YAML from 2.8.0 and 2.8.5

components:
  schemas:
    MyType:
      properties:
        id:
          format: int32
          type: integer

Expected behavior
Sample OpenAPI YAML from 2.7.0

components:
  schemas:
    MyType:
      properties:
        id:
          format: int32
          nullable: true
          type: integer

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