title: NSwag .NET Core API Versioning configuration
body: <p>I'd like to prepare my <strong>.NET Core Web API</strong> project so that multiple versions of the API can be managed and documented, according to the REST services standards.</p>
  
  <p>I'm using <strong>.NET Core 2.1</strong> with <strong>NSwag (v11.18.2)</strong>. I also installed the <strong>Microsoft.AspNetCore.Mvc.Versioning</strong> NuGet package.</p>
  
  <p>I already searched with Google for some configuration examples, but the only useful link I found is <a href="https://github.com/RSuter/NSwag/issues/1393" rel="noreferrer" title="Failed to generate documentation for multiple API versions using ApiVersioning and ApiExplorer">this</a>.</p>
  
  <p>I'm now able to get Swagger pages for both API versions but with some problems:</p>
  
  <ol>
  <li>Please note that none of the last <code>config</code> settings (<code>Title</code>, <code>Description</code>, etc.) takes effect on any of the 2 routes. It only works if I add them on each of the individual configuration. So I'd also like to know if it possible to avoid that, since the general configuration of the API can be version indipendent (title, description and so on...).</li>
  <li>Since the issue with NSwag and Microsoft API Versioning package discussed in the above link, was opened 2-3 months (and NSwag versions too) ago, I'd like to know if it is now truly fixed and in this case, which is the right configuration to set.</li>
  <li>Although the version is explicit in the configuration of the controllers, it is still required as a mandatory input parameter of the controller methods and of course I don't want that! See image:</li>
  </ol>
  
  <p><a href="https://i.stack.imgur.com/GSCr5.png" rel="noreferrer"><img src="https://i.stack.imgur.com/GSCr5.png" alt="Swagger UI tests requiring version as input parameter for methods"></a></p>
  
  <p>So, my actual configuration, by following that example, is looking like this:</p>
  
  <pre><code>public void ConfigureServices(IServiceCollection services)
  {
      services.AddMvc();
      services.AddApiVersioning(options =&gt;
          {
              options.AssumeDefaultVersionWhenUnspecified = true;
              options.DefaultApiVersion = new ApiVersion(1, 0);
              options.ReportApiVersions = true;
          });
  }
  
  public void Configure(IApplicationBuilder app, IHostingEnvironment env)
  {
      app.UseSwaggerWithApiExplorer(config =&gt;
      {
          config.GeneratorSettings.OperationProcessors.TryGet&lt;ApiVersionProcessor&gt;().IncludedVersions = new[] { "1.0" };
          config.SwaggerRoute = "v1.0.json";
      });
  
      app.UseSwaggerWithApiExplorer(config =&gt;
      {
          config.GeneratorSettings.OperationProcessors.TryGet&lt;ApiVersionProcessor&gt;().IncludedVersions = new[] { "2.0" };
          config.SwaggerRoute = "v2.0.json";
      });
  
      app.UseSwaggerUi3(typeof(Startup).GetTypeInfo().Assembly, config =&gt;
      {
          config.SwaggerRoutes.Add(new SwaggerUi3Route("v1.0", "/v1.0.json"));
          config.SwaggerRoutes.Add(new SwaggerUi3Route("v2.0", "/v2.0.json"));
  
          config.GeneratorSettings.Title = "My API";
          config.GeneratorSettings.Description = "API functionalities.";
          config.GeneratorSettings.DefaultUrlTemplate = "{v:apiVersion}/{controller}/{action}/{id?}";
          config.GeneratorSettings.DefaultPropertyNameHandling = PropertyNameHandling.CamelCase
      });
  }
  </code></pre>
  
  <p>And these are my actual controllers:</p>
  
  <pre><code>[ApiController]
  [ApiVersion("1.0")]
  [Route("api/v{version:apiVersion}/[controller]/[action]")]
  [SwaggerTag("Test1", Description = "Core operations on machines (v1.0).")]
  public class MachinesController : Controller
  {
      [HttpGet("{id}")]
      [ProducesResponseType((int)HttpStatusCode.OK)]
      public async Task&lt;ActionResult&lt;Machine&gt;&gt; Get(int id)
      {
          return await ...
      }
  }
  
  [ApiController]
  [ApiVersion("2.0")]
  [Route("api/v{version:apiVersion}/[controller]/[action]")]
  [SwaggerTag("Test2", Description = "Core operations on machines (v2.0).")]
  public class MachinesController : Controller
  {
      [HttpGet("{id}")]
      [ProducesResponseType((int)HttpStatusCode.OK)]
      public async Task&lt;ActionResult&lt;Machine&gt;&gt; Get(int id)
      {
          return await ...
      }
  }
  </code></pre>