Skip to content

OpenApi controller endpoint metadata inheritance inconsistent #61801

@ArwynFr

Description

@ArwynFr

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

When using inheritance with controllers, endpoint metadata attributes are not managed consistently.
For instance, OpenApi will use ProducesResponseTypeAttribute inherited from the parent class, but not EndpointSummaryAttribute nor EndpointDescriptionAttribute.

Expected Behavior

No response

Steps To Reproduce

using Microsoft.AspNetCore.Http.HttpResults;
using Microsoft.AspNetCore.Mvc;

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers();
builder.Services.AddOpenApi();

var app = builder.Build();
app.MapOpenApi();

await app.RunAsync();

public abstract class PingControllerBase : ControllerBase
{
    [EndpointSummary("This is base summary.")]
    [EndpointDescription("This is base description.")]
    [ProducesResponseType<ProblemDetails>(StatusCodes.Status404NotFound, "application/problem+json")]
    [HttpGet("/api/base")]
    public abstract Results<Ok, NotFound> ExecuteBase();
}

[ApiController]
public class PingController : PingControllerBase
{
    public override Results<Ok, NotFound> ExecuteBase() => throw new NotImplementedException();

    [EndpointSummary("This is child summary.")]
    [EndpointDescription("This is child description.")]
    [ProducesResponseType<ProblemDetails>(StatusCodes.Status404NotFound, "application/problem+json")]
    [HttpGet("/api/ping")]
    public Results<Ok, NotFound> Execute() => throw new NotImplementedException();
}

v1.json

Exceptions (if any)

No response

.NET Version

9.0.203

Anything else?

Microsoft.AspNetCore.OpenApi v9.0.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    ✔️ Resolution: AnsweredResolved because the question asked by the original author has been answered.Status: Resolvedarea-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