title: Why aren't Swagger services added to DI container conditionally (only in development)?
body: <p>The default template of ASP.NET Core Web API is given as follows.</p>
  <pre class="lang-cs prettyprint-override"><code>var builder = WebApplication.CreateBuilder(args);
  
  builder.Services.AddControllers();
  
  // Why are the following two statements not enabled only in development?
  builder.Services.AddEndpointsApiExplorer();
  builder.Services.AddSwaggerGen();
  
  var app = builder.Build();
  
  if (app.Environment.IsDevelopment())
  {
      app.UseSwagger();
      app.UseSwaggerUI();
  }
  
  // Others are removed for the sake of simplicity.
  
  app.Run();
  </code></pre>
  <p>As you can see, <code>UseSwagger()</code> and <code>UseSwaggerUI()</code> are activated only in development.</p>
  <h1>Question</h1>
  <p>I am curious why <code>AddEndpointsApiExplorer()</code> and <code>AddSwaggerGen()</code> are not activated only in development as well.</p>