Skip to content

fix: ensure that @Nullable does not incorrectly affect object schemas#5124

Open
Mattias-Sehlstedt wants to merge 2 commits intoswagger-api:masterfrom
Mattias-Sehlstedt:do-not-set-nullable-on-objects
Open

fix: ensure that @Nullable does not incorrectly affect object schemas#5124
Mattias-Sehlstedt wants to merge 2 commits intoswagger-api:masterfrom
Mattias-Sehlstedt:do-not-set-nullable-on-objects

Conversation

@Mattias-Sehlstedt
Copy link
Copy Markdown
Contributor

@Mattias-Sehlstedt Mattias-Sehlstedt commented Apr 11, 2026

Pull Request

Thank you for contributing to swagger-core!

Please fill out the following information to help us review your PR efficiently.


Description

Changes so that a @Nullable annotation present on a model does not incorrectly set type: null for OAS 3.1 or nullable: true for OAS 3.0. The nullable is instead dropped entirely. This since the resolving currently does not support an easy way of expressing nullable with refs correctly as per:
OAS3.0

{ "nullable": true, "allOf": [{ "$ref": "#/components/schemas/NestedObject" }] }

or
OAS3.1

{ "oneOf": [{ "$ref": "#/components/schemas/NestedObject" }, { "type": "null" }] }

Fixes: #5115

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • ♻️ Refactor (non-breaking change)
  • 🧪 Tests
  • 📝 Documentation
  • 🧹 Chore (build or tooling)

Checklist

  • I have added/updated tests as needed
  • I have added/updated documentation where applicable
  • The PR title is descriptive
  • The code builds and passes tests locally
  • I have linked related issues (if any)

Screenshots / Additional Context

@Mattias-Sehlstedt Mattias-Sehlstedt force-pushed the do-not-set-nullable-on-objects branch from 23de3a0 to 8f9aeb7 Compare April 23, 2026 19:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: @Nullable annotation incorrectly affects object and sets the type to null

2 participants