title: Swagger: Failed to load API definition
body: <p>I've a versioned API, when I select V1 on swagger it works fine, when I change to V2 option I get this message:  </p>
  
  <p><a href="https://i.stack.imgur.com/10d7O.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/10d7O.png" alt="enter image description here"></a></p>
  
  <p>Here is my Startup.cs</p>
  
  <p>ConfigureServices:</p>
  
  <pre><code>services.AddApiVersioning(
              options =&gt;
              {
                  // reporting api versions will return the headers "api-supported-versions" and "api-deprecated-versions"
                  options.ReportApiVersions = true;
              } );
          services.AddVersionedApiExplorer(
              options =&gt;
              {
                  // add the versioned api explorer, which also adds IApiVersionDescriptionProvider service
                  // note: the specified format code will format the version as "'v'major[.minor][-status]"
                  options.GroupNameFormat = "'v'VVV";
  
                  // note: this option is only necessary when versioning by url segment. the SubstitutionFormat
                  // can also be used to control the format of the API version in route templates
                  options.SubstituteApiVersionInUrl = true;
              } );
  </code></pre>
  
  <p>Configure:</p>
  
  <pre><code>app.UseSwagger();
          app.UseSwaggerUI(
              options =&gt;
              {
                  // build a swagger endpoint for each discovered API version
                  foreach ( var description in provider.ApiVersionDescriptions )
                  {
                      options.SwaggerEndpoint( $"/swagger/{description.GroupName}/swagger.json", description.GroupName.ToUpperInvariant() );
                  }
                  options.RoutePrefix = string.Empty;
              } );
  </code></pre>
  
  <p>Here is the source code: <a href="https://github.com/felipexmitz/api-dotnet-core-basics" rel="nofollow noreferrer">https://github.com/felipexmitz/api-dotnet-core-basics</a></p>