title: ASP.NET Core 3.1 AWS Lambda Swagger definition not working when deployed
body: <p>Having the below code to configure in Startup.cs</p>
  
  <p>Variables.</p>
  
  <pre><code>private const string SwaggerDocumentVersionName = "v1";
  private static string SwaggerDocumentServiceName =&gt; $"Users API({SwaggerDocumentVersionName})";
  </code></pre>
  
  <p><code>ConfigureServices</code> method.</p>
  
  <pre><code>services.AddSwaggerGen(c =&gt;
  {
     c.SwaggerDoc(
           SwaggerDocumentVersionName, 
                 new OpenApiInfo
                 {
                     Title = SwaggerDocumentServiceName,
                     Version = $"{SwaggerDocumentVersionName}"
                 });
  });
  </code></pre>
  
  <p><code>Configure</code> method.</p>
  
  <pre><code>app.UseSwagger(c =&gt;
  {
      c.RouteTemplate = "/swagger/{documentName}/swagger.json";
  });
  
  app.UseSwaggerUI(c =&gt;
  {
      c.RoutePrefix = "swagger/ui";
      c.SwaggerEndpoint($"/swagger/{SwaggerDocumentVersionName}/swagger.json", SwaggerDocumentServiceName);
  });
  </code></pre>
  
  <p>When running locally (<code>https://localhost:5001/swagger/ui</code> resolved to <code>https://localhost:5001/swagger/ui/index.html</code>) definition is loaded correctly and everything seems fine.</p>
  
  <p>Deploying the service to AWS Lambda as ASP.NET Core REST API and navigating to the URL (<code>https://DNS_URL/API_PREFIX/swagger/ui</code> resolved to <code>https://DNS_URL/API_PREFIX/swagger/ui/index.html</code>)it shows the below error loading the JSON definition.</p>
  
  <p><a href="https://i.stack.imgur.com/yQnQb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yQnQb.png" alt="Swagger JSON Definition Error"></a></p>
  
  <p>The interesting part is that if you navigate to the JSON definition route (<code>https://DNS_URL/API_PREFIX/swagger/v1/swagger.json</code>) it shows the definition. </p>