Is there an existing issue for this?
Describe the bug
In a project I use some nullable structs in my API with XML Documentation to give it a description, but this description is not shown in the openapi specification:
"components": {
"schemas": {
"MyClass": {
"type": "object",
"description": "My class for demonstration purposes."
},
"MyStruct": {
"type": "object"
},
"MyStruct2": {
"type": "object",
"description": "My second struct for demonstration purposes."
}
}
},
Expected Behavior
I expect that the XmlCommentSchemaTransformer ignores the Nullable<> type when trying to find the description:
"components": {
"schemas": {
"MyClass": {
"type": "object",
"description": "My class for demonstration purposes."
},
"MyStruct": {
"type": "object",
"description": "My struct for demonstration purposes."
},
"MyStruct2": {
"type": "object",
"description": "My second struct for demonstration purposes."
}
}
},
Steps To Reproduce
The following Program.cs in a simple webapi project will reproduce this problem:
using Microsoft.AspNetCore.Http.HttpResults;
var builder = WebApplication.CreateSlimBuilder(args);
builder.Services.AddOpenApi();
var app = builder.Build();
app.MapOpenApi();
app.MapGet("/nullable-struct", Ok<MyStruct?> () => TypedResults.Ok<MyStruct?>(null))
.WithName("GetMyStruct");
app.MapGet("/not-nullable-struct", Ok<MyStruct2> () => TypedResults.Ok<MyStruct2>(default))
.WithName("GetMyStruct2");
app.MapGet("/class", Ok<MyClass?> () => TypedResults.Ok<MyClass?>(null))
.WithName("GetMyClass");
app.Run();
/// <summary>
/// My struct for demonstration purposes.
/// </summary>
internal struct MyStruct() { }
/// <summary>
/// My second struct for demonstration purposes.
/// </summary>
internal struct MyStruct2() { }
/// <summary>
/// My class for demonstration purposes.
/// </summary>
internal class MyClass() { }
Exceptions (if any)
No response
.NET Version
10.0.400
Anything else?
After some debugging I found that in the 'XmlCommentGenerator.Emitter.cs' the generated code for DocumentationCommentIdHelper doesn't request the underlying type from a nullable type, therefore it will never generate the correct Id.
Is there an existing issue for this?
Describe the bug
In a project I use some nullable structs in my API with XML Documentation to give it a description, but this description is not shown in the openapi specification:
Expected Behavior
I expect that the
XmlCommentSchemaTransformerignores theNullable<>type when trying to find the description:Steps To Reproduce
The following Program.cs in a simple webapi project will reproduce this problem:
Exceptions (if any)
No response
.NET Version
10.0.400
Anything else?
After some debugging I found that in the 'XmlCommentGenerator.Emitter.cs' the generated code for DocumentationCommentIdHelper doesn't request the underlying type from a nullable type, therefore it will never generate the correct Id.