-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Open
Labels
area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-openapi
Milestone
Description
I think there is a gap in how metadata for parameters defined in an AsParameters
class is captured for OpenAPI document generation.
For example, the following code
app.MapGet("/bar", GetBar).WithName("GetBar");
partial class Program
{
/// <summary>
/// Get a bar
/// </summary>
/// <param name="barParams">Parameters for Bar</param>
public static Ok<string> GetBar([AsParameters] BarBaz barParams)
{
return TypedResults.Ok(barParams.Bar);
}
}
public class BarBaz
{
/// <summary>This is a bar</summary>
public string? Bar { get; set; }
/// <summary>This is a baz</summary>
public string? Baz { get; set; }
}
I would expect that the XML doc comments on Bar
and Baz
would be captured and would appear as the description
for these parameters in the generated OpenAPI document. But this is not currently working.
"summary": "Get a bar",
"operationId": "GetBar",
"parameters": [
{
"name": "Bar",
"in": "query",
"schema": {
"type": "string"
}
},
{
"name": "Baz",
"in": "query",
"schema": {
"type": "string"
}
}
],
I looked into whether Swashbuckle handled this case in the way I expected, and discovered this issue, which references this PR in ASP.NET Core that purports to fix the problem for Swashbuckle.
I created a minimal repro for this in the xmldoc-for-asparameters directory of this repo:
Metadata
Metadata
Assignees
Labels
area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-openapi