Skip to content

fix: do not process a nullable annotation for container items#5079

Open
Mattias-Sehlstedt wants to merge 1 commit intoswagger-api:masterfrom
Mattias-Sehlstedt:do-not-process-nullable-annotation-for-containers
Open

fix: do not process a nullable annotation for container items#5079
Mattias-Sehlstedt wants to merge 1 commit intoswagger-api:masterfrom
Mattias-Sehlstedt:do-not-process-nullable-annotation-for-containers

Conversation

@Mattias-Sehlstedt
Copy link
Contributor

Pull Request

Thank you for contributing to swagger-core!

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


Description

Fixes part of the issue reported in #5077 where the items within a List (container) are affected by a @Nullable annotation. I.e.,

@Nullable
List<String> listOfStrings

This should only mark the list itself as nullable, while the items would be controller either by an explicit @ArraySchema annotation or something similar to

List<@Nullable String> listOfStrings

*Although @Nullable does not apply to a Type field)

This change is achieved by making sure that @Nullable is dropped when annotations are forwarded for a container type field.

The second part of issue #5077 is not handled, where #ref:s are not correctly marked as nullable.

I have intentionally not handled that in this PR since that is a much larger task, since the issue is that there does not seem to exist any framework to support expressing that. I.e., either having

schema:
  allOf:
    - $ref: '#/components/schemas/User'
  nullable: true

for OAS 3.0 or

schema:
  oneOf:
    - $ref: '#/components/schemas/User'
    - type: 'null'

or

schema:
  type: [object, "null"]
  $ref: '#/components/schemas/User'

for OAS 3.1.

Fixes:

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-process-nullable-annotation-for-containers branch from 3df311a to 6f53431 Compare March 6, 2026 16:43
@Mattias-Sehlstedt Mattias-Sehlstedt force-pushed the do-not-process-nullable-annotation-for-containers branch from 6f53431 to 1ff6e43 Compare March 13, 2026 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants