Skip to content

OpenApi: Support UseAllOfToExtendReferenceSchemas #61632

@lindeberg

Description

@lindeberg

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe the problem.

The problem is that nullable references are created like this:

"NullableOfChocolateChip": {
  "type": "integer",
  "nullable": true
}

"result": {
  "$ref": "#/components/schemas/NullableOfChocolateChip"
}

Describe the solution you'd like

I want OpenAPI references to be created using allOf so that I can make the reference nullable. For example:

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

Additional context

With SwashBuckle, this works by:

// https://github.com/domaindrivendev/Swashbuckle.AspNetCore/issues/2378#issuecomment-1072977332
// https://github.com/OAI/OpenAPI-Specification/issues/1368
options.UseAllOfToExtendReferenceSchemas();
options.SupportNonNullableReferenceTypes();

Metadata

Metadata

Assignees

No one assigned

    Labels

    ✔️ Resolution: FixedThe bug or enhancement requested in this issue has been checked-in!area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-openapi

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions