Thanks to the previous answer which links the github issue I have found the solution.
I had to add the OpenApi version like this,
app.UseSwagger(c => { c.OpenApiVersion = Microsoft.OpenApi.OpenApiSpecVersion.OpenApi2_0; });