Re: Resolve virtual path for Swagger UI to work with ending '/'

705 views
Skip to first unread message
Message has been deleted

Ron Ratovsky

unread,
May 10, 2016, 2:07:20 PM5/10/16
to swagger-sw...@googlegroups.com
For Swashbuckle related questions, it’d be better to open a ticket on its github repository.

From: <swagger-sw...@googlegroups.com> on behalf of 7036 Golf Pointe Circle Household <7036golfpo...@gmail.com>
Reply-To: "swagger-sw...@googlegroups.com" <swagger-sw...@googlegroups.com>
Date: Tuesday, 10 May 2016 at 05:46
To: Swagger <swagger-sw...@googlegroups.com>
Subject: Resolve virtual path for Swagger UI to work with ending '/'

We are using Swashbuckle to add Swagger doc to my API, using the Swashbuckle Nuget package. In WebAPI\App_Start\SwaggerConfig.cs changed base url to the following below:




   
GlobalConfiguration.Configuration
           
.EnableSwagger("docs/{apiVersion}/help",c =>
               c
.RootUrl(req => req.RequestUri.GetLeftPart(UriPartial.Authority)+ req.GetRequestContext().VirtualPathRoot.TrimEnd('/'));
             
.....
             
.....
             
})
           
.EnableSwaggerUi("help/{*assetPath}", c =>....



If I keep everything intact, 
when I navigate to **/help** - all works 

 - localhost/WebAPI/docs/v1/help - JSON appears and ok
  
 - localhost/WebAPI/help/index - UI appears and works

when I navigate to **/help/**, 

 - localhost/WebAPI/docs/v1/help/ - JSON appears and ok
 - localhost/WebAPI/help/ - UI redirects to at
   localhost/WebAPI/help/help/index and we get an empty page with error

{"message":"An error has occurred.","exceptionMessage":"Mapping not
found -
help/index"
,"exceptionType":"Swashbuckle.SwaggerUi.AssetNotFound","stackTrace":"
at Swashbuckle.SwaggerUi.EmbeddedAssetProvider.GetAsset(String
rootUrl, String path)\r\n at
Swashbuckle.Application.SwaggerUiHandler.SendAsync(HttpRequestMessage
request, CancellationToken cancellationToken)"}




What needs to be done to Swagger/Swashbuckle to make the path work?
We are not using OWIN. 

BONUS QUESTION: How to change the documentation path from https://[your-url]/help/index to https://[your-url]/help

--
You received this message because you are subscribed to the Google Groups "Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages