title: RESTful api versioning and grouping in doc from Swagger with multiple endpoints
body: <p>I am trying to implement the version options on a MVC dotnet Core app that has API endpoint on it.  </p>
  
  <p>The set up i am after is like this</p>
  
  <pre><code> --AiM api
     |_v1
     |_v2
   --RMS api
     |_v1
  </code></pre>
  
  <p>I have it mostly working but the items on v1 are not showing up on v2.  The output is like so</p>
  
  <p><a href="https://i.stack.imgur.com/QB9hv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QB9hv.png" alt="enter image description here"></a>
  <a href="https://i.stack.imgur.com/8FlzE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8FlzE.png" alt="enter image description here"></a></p>
  
  <p>But when we get to the version 2 on the <code>AiM v2</code> endpoint I only the one item 
  <a href="https://i.stack.imgur.com/bPzah.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bPzah.png" alt="enter image description here"></a></p>
  
  <p>Which is not what i was expecting</p>
  
  <p>I have made a test to get each one showing on its different pages in swagger like this</p>
  
  <p>In <strong>controller</strong></p>
  
  <pre><code>[ApiVersion("2.0")]
  [ApiVersion("1.0")]
  [ApiExplorerSettings(GroupName = "aim_v1")]
  [Route("aim/v{version:apiVersion}/write/")]
  public class aimWriter_v1Controller : Controller
  {
  
      [SwaggerOperation(Tags = new[] { "AiM Departments" })]
      [HttpPost("departments/delete/{id}")]
      public IActionResult departments(string foo)
      {
          return Json(new
          {
              results = "edited"
          });
      }
  
      [SwaggerOperation(Tags = new[] { "AiM Contacts" })]
      [HttpPost("contacts/delete/{id}")]
      public IActionResult contact_delete(string foo)
      {
          return Json(new
          {
              results = "edited"
          });
      }
  
      [SwaggerOperation(Tags = new[] { "AiM Contacts" })]
      [HttpPost("contacts/activate/{id}")]
      public IActionResult contact_activate(string foo)
      {
          return Json(new
          {
              results = "edited"
          });
      }
  }
  
  
  [ApiVersion("2.0")]
  [ApiExplorerSettings(GroupName = "aim_v2")]
  [Route("aim/v{version:apiVersion}/write/")]
  public class aimWriter_v2Controller : Controller
  {
  
      [SwaggerOperation(Tags = new[] { "AiM Contacts" })]
      [HttpPost("contacts/delete/{id}")]
      public IActionResult contact_delete(string foo)
      {
          return Json(new
          {
              results = "edited"
          });
      }
  
  
  }
  
  
  [ApiVersion("2.0")]
  [ApiVersion("1.0")]
  [ApiExplorerSettings(GroupName = "aim_v1")]
  [Route("aim/v{version:apiVersion}/")]
  public class aim_v1Controller : Controller
  {
  
      [SwaggerOperation(Tags = new[] { "AiM Rooms" })]
      [HttpPost("rooms")]
      public IActionResult rooms(string foo)
      {
          return Json(new
          {
              results = "foo"
          });
      }
  
      [SwaggerOperation(Tags = new[] { "AiM Buildings" })]
      [HttpPost("buildings/rooms/{id}")]
      public IActionResult building_rooms(string foo)
      {
          return Json(new
          {
              results = "foo"
          });
      }
  
      [SwaggerOperation(Tags = new[] { "AiM Rooms" })]
      [HttpPost("rooms/{id}")]
      public IActionResult room(string foo)
      {
          return Json(new
          {
              results = "foo"
          });
      }
  }
  
  // set up as just a new endpoint (NOTE: in different controller)
  [ApiVersion("1.0")]
  [ApiExplorerSettings(GroupName = "rms_v1")]
  [Route("rms/v{version:apiVersion}/")]
  public class rms_v1Controller : Controller
  {
      [SwaggerOperation(Tags = new[] { "RMS Orders" })]
      [HttpPost("set_order/{id}")]
      public IActionResult set_order(string foo)
      {
          return Json(new
          {
              results = "foo"
          });
      }
  
  }
  </code></pre>
  
  <p>And in the <strong>Startup.cs</strong></p>
  
  <pre><code>    public void ConfigureServices(IServiceCollection services)
      {
          services.AddRouting(options =&gt; options.LowercaseUrls = true);
          services.AddMvc();
  
          services.AddApiVersioning(options =&gt; {
              options.AssumeDefaultVersionWhenUnspecified = true ;
              options.DefaultApiVersion = new ApiVersion(new DateTime(2016, 7, 1));
          });
          services.AddSwaggerGen(c =&gt;
          {
  
  
              c.SwaggerDoc("aim_v1", new Info
              {
                  Version = "aim/v1",
                  Title = "WSU HTTP API"
              });
              c.SwaggerDoc("aim_v2", new Info
              {
                  Version = "aim/v2",
                  Title = "WSU HTTP API v2"
              });
              c.SwaggerDoc("rms_v1", new Info
              {
                  Version = "rms/v1",
                  Title = "WSU HTTP API"
              });
  
  
  
  
              //Set the comments path for the swagger json and ui.
              var basePath = PlatformServices.Default.Application.ApplicationBasePath;
              var xmlPath = Path.Combine(basePath, "project.in.bin.def.xml");
              c.IncludeXmlComments(xmlPath);
          });
  
      }
      public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
      {
  
          // Enable middleware to serve generated Swagger as a JSON endpoint.
          app.UseSwagger(o =&gt;
          {
              o.PreSerializeFilters.Add((swaggerDoc, httpReq) =&gt; swaggerDoc.Host = httpReq.Host.Value);
              o.RouteTemplate = "doc/{documentName}/scheme.json";
          });
  
          // Enable middleware to serve swagger-ui (HTML, JS, CSS etc.), specifying the Swagger JSON endpoint.
          app.UseSwaggerUI(c =&gt;
          {
              c.RoutePrefix = "docs";
              c.SwaggerEndpoint("/doc/aim_v1/scheme.json", "AiM v1.0.0");
              c.SwaggerEndpoint("/doc/rms_v1/scheme.json", "Rms v1.0.0");
              c.SwaggerEndpoint("/doc/aim_v2/scheme.json", "AiM v2.0.0");
          });
      }
  </code></pre>
  
  <p>And in the <strong>index.html</strong> for the swagger ui doc template file has</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      window.JSConfig = JSON.parse('{"SwaggerEndpoints":[{"Url":"/doc/aim_v1/scheme.json","Description":"AiM v1.0.0"},{"Url":"/doc/aim_v2/scheme.json","Description":"AiM v2.0.0"},{"Url":"/doc/rms_v1/scheme.json","Description":"RMS v1.0.0"}],"BooleanValues":["false","true"],"DocExpansion":"list","SupportedSubmitMethods":["get","post","put","delete","patch"],"OnCompleteScripts":[],"OnFailureScripts":[],"ShowRequestHeaders":false,"JsonEditor":false,"OAuth2ClientId":"your-client-id","OAuth2ClientSecret":"your-client-secret-if-required","OAuth2Realm":"your-realms","OAuth2AppName":"your-app-name","OAuth2ScopeSeparator":" ","OAuth2AdditionalQueryStringParams":{}}');
  
  $(function () {
  
    hljs.configure({
      highlightSizeThreshold: 5000
    });
  
    // Pre load translate...
    if(window.SwaggerTranslator) {
      window.SwaggerTranslator.translate();
    }
    window.swaggerUi = new SwaggerUi({
        url: "/doc/aim_v1/scheme.json",
      dom_id: "swagger-ui-container",
      supportedSubmitMethods: ['get', 'post'],
      onComplete: function(swaggerApi, swaggerUi){
        if(typeof initOAuth == "function") {
          initOAuth({
              clientId: "ffff==",
              clientSecret: "bbbb",
              realm: "wsu-api",
              appName: "wsu-api-broker",
              scopeSeparator: " ",
              additionalQueryStringParams: {}
          });
        }
  
        if(window.SwaggerTranslator) {
          window.SwaggerTranslator.translate();
        }
        _.each(JSConfig.OnCompleteScripts, function (script) {
            $.getScript(script);
        });
  
      },
      onFailure: function(data) {
        log("Unable to Load SwaggerUI");
      },
      docExpansion: false,
      jsonEditor: false,
      defaultModelRendering: 'schema',
      showRequestHeaders: false
    });
  
    window.swaggerUi.load();
  
    function log() {
      if ('console' in window) {
        console.log.apply(console, arguments);
      }
    }
  </code></pre>
  
  <p>});
      </p>
  
  <p>In order to get the items on the different endpoints I used the <code>[ApiExplorerSettings(GroupName = "aim_v1")]</code> on the classes and matched them up in the <strong>Startup.cs</strong> and <strong>index.html</strong> files.  At this point I am unsure where to make my edit to get all of the <code>[ApiVersion("1.0")]</code> items show on the <code>[ApiVersion("2.0")]</code> as I think the <strong>ApiExplorerSettings</strong> <strong><em>GroupName</em></strong> is what it locking this up.  </p>