Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.NET 9 OpenAPI incorrect schema for array of nullable strings #60803

Open
1 task done
Markz878 opened this issue Mar 7, 2025 · 0 comments
Open
1 task done

.NET 9 OpenAPI incorrect schema for array of nullable strings #60803

Markz878 opened this issue Mar 7, 2025 · 0 comments
Labels
area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc feature-openapi

Comments

@Markz878
Copy link

Markz878 commented Mar 7, 2025

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

When a class has a property of type string?[], the generated OpenApi schema does not allow nulls.

Expected Behavior

The schema object should allow nulls in the array.

Steps To Reproduce

Minimal repro:

WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
builder.Services.AddOpenApi();
WebApplication app = builder.Build();
app.MapOpenApi();
app.MapGet("/weatherforecast", () =>
{
    return Enumerable.Range(1, 5).Select(index => new WeatherForecast(["10", null, "30"])).ToArray();
});
app.Run();
internal record WeatherForecast(string?[] Temperature);

Exceptions (if any)

No response

.NET Version

9.0.2 and 10.0.100-preview.1.25120.13

Anything else?

Any ideas how to fix this with for example a schema transformer?

@martincostello martincostello added feature-openapi area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc and removed area-web-frameworks labels Mar 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc feature-openapi
Projects
None yet
Development

No branches or pull requests

2 participants