Skip to content

Commit e3fa887

Browse files
chore: support URL segment prefix in Swagger URL
1 parent 7706483 commit e3fa887

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

Doppler.HelloMicroservice/Startup.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ public void ConfigureServices(IServiceCollection services)
3030
services.AddSwaggerGen(c =>
3131
{
3232
c.SwaggerDoc("v1", new OpenApiInfo { Title = "Doppler.HelloMicroservice", Version = "v1" });
33+
34+
var baseUrl = Configuration.GetValue<string>("BaseURL");
35+
if (!string.IsNullOrEmpty(baseUrl))
36+
{
37+
c.AddServer(new OpenApiServer() { Url = baseUrl });
38+
};
3339
});
3440
}
3541

@@ -42,7 +48,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
4248
}
4349

4450
app.UseSwagger();
45-
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "Doppler.HelloMicroservice v1"));
51+
app.UseSwaggerUI(c => c.SwaggerEndpoint("v1/swagger.json", "Doppler.HelloMicroservice v1"));
4652

4753
app.UseStaticFiles();
4854

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,5 @@ If you prefer to run these commands without docker, you can read [Dockerfile](./
5353
* Exposing only HTTP (not HTTPS) because that is the responsibility of our reverse proxy.
5454

5555
* Allow overriding project settings based on our Doppler conventions.
56+
57+
* Expose Swagger (with support for segment prefix)

0 commit comments

Comments
 (0)