A set of technologies in the .NET Framework for building web applications and XML web services.
Hi @Tirth Shah ,
Thanks for reaching out.
Property or indexer 'IOpenApiMediaType.Example' cannot be assigned to -- it is read-only
The error occurs because Microsoft.OpenApi 3.x introduced breaking changes, including making certain OpenAPI model properties (such as IOpenApiMediaType.Example) read-only. When upgrading a project to .NET 10, dependency updates may cause the OpenAPI package to move from 2.x (compatible) to 3.x (incompatible).
.NET 10’s OpenAPI generator was built against the 2.x OpenAPI model, so when version 3.x is present, the generator attempts to assign values to properties that are no longer writable - resulting in the build failure you’re seeing.
I have done some research on this behavior, and based on community findings, the issue occurs specifically when Microsoft.OpenApi 3.x is used with .NET 10. Rolling the package back to a 2.x version restores the original property behavior and resolves the build error.
At this time, .NET 10 does not provide full support for Microsoft.OpenApi 3.x, and broader support is expected in a future .NET release.
Recommended solution:
- Downgrade Microsoft.OpenApi to a 2.x version (for example,
2.3.9) to restore compatibility.
For more information, please check this link: https://github.com/dotnet/aspnetcore/issues/64317
Hope this helps! If my answer was helpful - kindly follow the instructions here so others with the same problem can benefit as well.