From 0d1834264f0c8d33d667dac780206492c73a5c0d Mon Sep 17 00:00:00 2001 From: Robb Schiefer Date: Wed, 14 Nov 2018 10:11:23 -0600 Subject: [PATCH] Added note for working with virtual directories (#9128) I spent a day or more researching this so that I could use Swagger-UI in my ASP.NET Core API which is used with a reverse-proxy and virtual directory. In the end found Swagger-UI requires relative URLs to start with a period. Related to https://github.com/swagger-api/swagger-ui/issues/4107 Hoping this documentation note will help others. When creating a new PR, please do the following and delete this template text: * Reference the issue number if there is one: Fixes #Issue_Number > The "Fixes #nnn" syntax in the PR description causes > GitHub to automatically close the issue when this PR is merged. --- aspnetcore/tutorials/getting-started-with-swashbuckle.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/aspnetcore/tutorials/getting-started-with-swashbuckle.md b/aspnetcore/tutorials/getting-started-with-swashbuckle.md index 8f3c7a1b6e..dc1006fe58 100644 --- a/aspnetcore/tutorials/getting-started-with-swashbuckle.md +++ b/aspnetcore/tutorials/getting-started-with-swashbuckle.md @@ -4,7 +4,7 @@ author: zuckerthoben description: Learn how to add Swashbuckle to your ASP.NET Core web API project to integrate the Swagger UI. ms.author: scaddie ms.custom: mvc -ms.date: 11/05/2018 +ms.date: 11/14/2018 uid: tutorials/get-started-with-swashbuckle --- # Get started with Swashbuckle and ASP.NET Core @@ -102,6 +102,8 @@ The Swagger UI can be found at `http://localhost:/swagger`. Explore the AP > > [!code-csharp[](../tutorials/web-api-help-pages-using-swagger/samples/2.0/TodoApi.Swashbuckle/Startup3.cs?name=snippet_UseSwaggerUI&highlight=4)] +If using virtual directories (with IIS or a reverse proxy, for example), set the Swagger endpoint to a relative path using the `./` prefix. For example, `./swagger/v1/swagger.json`. Using `/swagger/v1/swagger.json` instructs the app to look for the JSON file at the true root of the URL (plus the route prefix, if used). For example, `http://localhost://swagger/v1/swagger.json` instead of `http://localhost:///swagger/v1/swagger.json`. + ## Customize and extend Swagger provides options for documenting the object model and customizing the UI to match your theme.