After upgrading a project to .NET 10 and using the built-in Microsoft.AspNetCore.OpenApi package (which seems to support Microsoft.OpenApi 3.0.0 generation), the application fails to start or build correctly. It throws multiple Property or indexer 'IOpenApiMediaType.Example' cannot be assigned to -- it is read only
To Reproduce
- Create a new ASP.NET Core project targeting .NET 10.
- Add Microsoft.AspNetCore.OpenApi package.
- Add Scalar.AspNetCore package.
- Configure services as follows:
builder.Services.AddOpenApi();
// ... other services
app.MapOpenApi();
app.MapScalarApiReference(...);
- Run the application in Development mode.
Workaround
Downgrading the Microsoft.OpenApi package to version 2.3.9 resolved the runtime error.
Environment:
ASP.NET Core Target: .NET 10.0
Microsoft.AspNetCore.OpenApi version: (auto-included in .NET 10, likely pulling a newer Microsoft.OpenApi version)
Microsoft.OpenApi version: 3.0.0 (causes error), 2.3.9 (workaround, resolves error)
Scalar.AspNetCore version: 2.10.3
After upgrading a project to .NET 10 and using the built-in Microsoft.AspNetCore.OpenApi package (which seems to support Microsoft.OpenApi 3.0.0 generation), the application fails to start or build correctly. It throws multiple Property or indexer 'IOpenApiMediaType.Example' cannot be assigned to -- it is read only
To Reproduce
Workaround
Downgrading the Microsoft.OpenApi package to version 2.3.9 resolved the runtime error.
Environment:
ASP.NET Core Target: .NET 10.0
Microsoft.AspNetCore.OpenApi version: (auto-included in .NET 10, likely pulling a newer Microsoft.OpenApi version)
Microsoft.OpenApi version: 3.0.0 (causes error), 2.3.9 (workaround, resolves error)
Scalar.AspNetCore version: 2.10.3