-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Closed
Labels
✔️ Resolution: AnsweredResolved because the question asked by the original author has been answered.Resolved because the question asked by the original author has been answered.Status: Resolvedarea-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesfeature-openapi
Description
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();
}
Exceptions (if any)
No response
.NET Version
9.0.203
Anything else?
Microsoft.AspNetCore.OpenApi v9.0.4
Metadata
Metadata
Assignees
Labels
✔️ Resolution: AnsweredResolved because the question asked by the original author has been answered.Resolved because the question asked by the original author has been answered.Status: Resolvedarea-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesfeature-openapi