title: Configuring ApiVersionDescriptions in .NetCore 3.0 without using build service provider in startup
body: <p>I have the following code in my Startup.cs file to grab and process each of my API version descriptions and add them to my Swagger.</p>
  
  <pre><code>var apiVersionDescriptionProvider = services.BuildServiceProvider().GetService&lt;IApiVersionDescriptionProvider&gt;();
  
          // Register the Swagger generator, defining 1 or more Swagger documents
          services.AddSwaggerGen(setup =&gt;
          {
              foreach (var description in apiVersionDescriptionProvider.ApiVersionDescriptions)
              {
                  setup.SwaggerDoc(
                      $"MyAPISpecification{description.GroupName}",
                      new OpenApiInfo() 
                      { 
                          Title = "My API Specification",
                          Version = description.ApiVersion.ToString(), 
                      });
              }
  </code></pre>
  
  <p>My understanding is that I should dependency inject the implementation of the IApiVersionDescriptionProvider instead of using the BuildServiceProvider inside the ConfigureServices method of my startup class as this would prevent and additional copy of a singleton being created.</p>
  
  <p>How would I go about this in this specific example as this is the method in which services are configured so I do not have an instance built by this point that the service can use wthout using the build service provider.</p>
  
  <p>I read somewhere else on StackOverflow about using options but I could not see how that example would apply in this scenario. Any help would be greatly appreciated as this Swagger configuration was based off of a Pluralsight video posted late 2019 that I would have expected to have been correct.</p>
  
  <p>Thanks in advance.</p>