I have fixed the issue when update packages
from
Microsoft.OpenApi from 2.0.0-preview5 to 1.6.23 and
dotnet add package Microsoft.OpenApi --version 1.6.23
Microsoft.AspNetCore.OpenApi 10.0.0-preview.1.25120.3 to 9.0.2
dotnet add package Microsoft.AspNetCore.OpenApi --version 9.0.2
If there is an error / Warning As Error: Detected package downgrade:
run the below command in terminal
dotnet nuget locals all --clear