
Swagger 2.0 supports specifying both host, scheme and base path directly in the swagger document. By default SwashBuckle does not set any values for these properties in the swagger document.
The following snippet will dynamically add the properties taken from the request to the swagger document:
app.UseSwagger(c => { c.PreSerializeFilters.Add((swaggerDoc, httpReq) => { swaggerDoc.Host = httpReq.Host.Value; swaggerDoc.Schemes = new List<string>() { httpReq.Scheme }; swaggerDoc.BasePath = httpReq.PathBase; }); });