VS generates the following code in Startup.cs:
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseSwagger();
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "project name v1"));
}
So, it seems that the whole point of using the thing called Swagger is for testing the API during debugging. Then, why are the parameters field disabled by default and I have to click "Try it out" each time? Shouldn't the input fields be enabled by default? How should I modify the generated Startup.cs to enabling the parameters fields by default without pressing the Try button each time?
CodePudding user response:
You can use this method - EnableTryItOutByDefault
app.UseSwaggerUI(c =>
{
c.EnableTryItOutByDefault();
});
There won't be any Try Out button and parameters fields will be enabled by default.