Skip to content

Property or indexer 'IOpenApiMediaType.Example' cannot be assigned to -- it is read only in OpenAPI.NET 3.0.0 #2610

@muhammadzandieh8

Description

@muhammadzandieh8

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

Image

To Reproduce

  1. Create a new ASP.NET Core project targeting .NET 10.
  2. Add Microsoft.AspNetCore.OpenApi package.
  3. Add Scalar.AspNetCore package.
  4. Configure services as follows:
builder.Services.AddOpenApi();
// ... other services
app.MapOpenApi(); 
app.MapScalarApiReference(...);
  1. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions