The order in which you configure Swagger UI in Startup.cs - Configure method determines the dropdown list order. By default, the UI displays the specifications corresponding to the first option in the dropdown.
We can change the order of versions as shown below, but I am not sure if there is any property to override default version while retaining the dropdown order of versions in UI.
In the below example, it will open v1.1 by default.
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1.1/swagger.json", "V1.1");
c.SwaggerEndpoint("/swagger/v1.0/swagger.json", "V1.0");
c.SwaggerEndpoint("/swagger/v1.2/swagger.json", "V1.2");
}
Howerver, there's a workaround: You can pass the value of querystring parameter urls.primaryName so that it loads that version by default.
https://localhost:5001/swagger/index.html?urls.primaryName=v1.1
(Or)
You can try customizing the Swagger UI by injecting custom javascript as follows:
app.UseSwaggerUI(
....
c => c.InjectJavascript(***pass custom javascript here***) )
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…