Skip to content

OpenAPI: nullability is dropped for collection elements whose type is componentized #68322

Description

@snemeckayova

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

When a collection's element type is a nullable value type that gets componentized into #/components/schemas/*, the generated document loses the element's nullability. The items schema is emitted as a bare $ref to the non-nullable component:

"listOfNullableEnums": {
  "type": "array",
  "items": { "$ref": "#/components/schemas/TestEnum" }
}

Affected shapes include, at minimum:
• Properties typed List<TEnum?> on request or response models.
• Response bodies typed TEnum?[].

The similar query-parameter scenario, TEnum?[] nullableValues, was addressed separately in PR #68250.

Expected Behavior

Nullable collection elements should keep their nullability:

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

Steps To Reproduce

No response

Exceptions (if any)

No response

.NET Version

No response

Anything else?

No response

Activity

  1. added theissue type on Aug 10, 2026
  2. added
    area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etc
    on Aug 10, 2026
  3. Youssef1313 commented on Aug 10, 2026

    @Youssef1313
    Member

    We should verify this for both value and reference types.

  4. self-assigned this
    on Aug 26, 2026
  5. added a commit that references this issue on Sep 3, 2026
  6. added this to the .NET 12 Planning milestone on Sep 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-openapi

Type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions