-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Closed
Description
Describe the bug
Invalid schema has been generated in cases where a type has a nullable property of a custom struct.
Version 6.2.2 behaves in the expected way.
Expected behavior
A valid schema should be generated.
Actual behavior
An invalid (and recursive) schema has been generated.

Steps to reproduce
public class Program
{
public static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseAuthorization();
app.MapControllers();
app.Run();
}
}
[ApiController]
[Route("[controller]/[action]")]
public class TestController : ControllerBase
{
[HttpGet]
public TestResponse Get()
{
return new()
{
Foo = new(1, 2),
};
}
}
public record TestResponse
{
public TestStruct? Foo { get; init; }
}
public record struct TestStruct(int A, int B);
Exception(s) (if any)
No response
Swashbuckle.AspNetCore version
6.7.0
.NET Version
net8.0
Anything else?
No response
shihabmridha