title: NSwag: Generate C# Client from multiple Versions of an API
body: <p>We are versioning our API and generating the Swagger specification using Swashbuckle in ASP.NET Core 1.1. We can generate two API docs based on those JSON specification files:</p>
  
  <pre><code>&lt;!-- language: c# --&gt;
  services.AddSwaggerGen(setupAction =&gt;
  {
      setupAction.SwaggerDoc("0.1", new Info { Title = "Api", Version = "0.1", Description = "API v0.1" });
      setupAction.SwaggerDoc("0.2", new Info { Title = "Api", Version = "0.2", Description = "API v0.2" });
  
      // more configuration omitted
  }
  </code></pre>
  
  <p>We are including all actions in both spec files, unless it is mapped to a specific version using the <code>[MapToApiVersion]</code> and <code>ApiExplorerSettings(GroupName ="&lt;version&gt;")]</code> attributes. Methods belonging to an older version only are also decorated with the <code>[Obsolete]</code> attribute:</p>
  
  <pre><code>&lt;!-- language: c# --&gt;
  [MapToApiVersion("0.1")]
  [ApiExplorerSettings(GroupName = "0.1")]
  [Obsolete]
  </code></pre>
  
  <p>However, we want to have only one C# Client generated from the Union of both spec files, where all methods are included in the Client, 0.1 as well as 0.2, but all obsolete methods marked, in fact, as obsolete.</p>
  
  <p>I have looked into both NSwag (which we are using for quite some time now) as well as AutoRest. AutoRest seems to <a href="https://github.com/Azure/autorest/blob/master/Samples/1c-multiple-input-swaggers/readme.md" rel="nofollow noreferrer">support a merging scenario</a>, but I could not get it to work because of schema validation errors (and I am more than unsure whether our specific scenario would be actually supported).</p>
  
  <p>My last idea as of now to get this sorted is to somehow JSON-merge the specs into one and then feed it to NSwag.</p>
  
  <p>Do we miss anything here? Is this somehow possible to realize with NSwag?</p>