Skip to content

Issues with OpenAPI generation and XML comments compatibility in .NET 10 preview 4 controller APIs #62103

Open
@itbencn

Description

@itbencn

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I have been testing the OpenAPI document generation in the .NET 10 Preview 4 version of the aspnetcore project for controller-based APIs (mini APIs are not tested or discussed here).

Expected Behavior

I encountered several issues related to how XML comments interact with OpenAPI generation:

  1. XML <response> comments on controller action methods:
    The official documentation mentions support for XML <response> tags, but these do not seem to be translated into OpenAPI paths.responses. That is, the responses described in XML are missing from the generated OpenAPI YAML/JSON under the paths section.

  2. XML comments on controller classes:

    • The class-level <summary> element is not converted into OpenAPI tags.name.
    • The class-level <remarks> element is not converted into OpenAPI tags.description.

    For comparison, applying [Tags("tagName")] attribute on the controller works fine and the tag name shows up correctly.
    Applying [Description("desc")] attribute on the controller does not translate into the tag's description, either.

  3. Enum support in OpenAPI schema:

    • The current OpenAPI document generation does not correctly support enums.
    • Enum options are missing from the generated OpenAPI schema, even though they are present in the XML documentation.
    • According to OpenAPI specification, enums can be declared with enum: ["name1", "name2"] or enum: [1, 2].
    • It appears this feature is not properly supported or implemented yet in the .NET 10 preview 4 version.

Finally, a question for discussion:

  • What is the recommended practice or approach to include enum member (individual enum value) documentation/comments into the OpenAPI documentation? For example, how to make each enum member's XML <summary> or other annotations appear in the OpenAPI schema description or extensions?

Would appreciate any guidance or roadmap clarification on these points.

Thanks!

Steps To Reproduce

No response

Exceptions (if any)

No response

.NET Version

10.0.100-preview.4.25258.110

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesfeature-openapi

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions