Swashbuckle.WebApi icon indicating copy to clipboard operation
Swashbuckle.WebApi copied to clipboard

Base URL is not populating in Swashbuckle 5.0

Open BabakGoshtasbi opened this issue 10 years ago • 21 comments

The Base URL is not showing even after setting up c.RootUrl(req => GetRootUrlFromAppConfig());

Could you please advise ?

BabakGoshtasbi avatar Jun 17 '15 14:06 BabakGoshtasbi

I have the same problem even without changing the c.RootUrl(). The application is running from the root of the website.

dstarosta avatar Jul 23 '15 18:07 dstarosta

Can you elaborate or maybe provide a screenshot? @dstarosta if you're app is running from the root of the website, then there is no base URL

domaindrivendev avatar Jul 27 '15 08:07 domaindrivendev

Closing due to inactivity. Please go ahead and re-open if you can provide some more information

domaindrivendev avatar Aug 13 '15 16:08 domaindrivendev

Still in 5.2.2 config.EnableSwagger("api-docs/{apiVersion}/swagger", c => { c.RootUrl(req => ApiConfig.GetRootUrl()); c.Schemes(new[] { "http" }); c.BasicAuth("Basic"); c.SingleApiVersion(ApiConfig.GetCurrentVersion(), "Gateway REST API documentation") .Description("Active documentation of Gateway system API"); c.IncludeXmlComments(ApiConfig.GetXmlCommentsPath()); }).EnableSwaggerUi( ApiConfig.GetApiDocumentationUrl() + "/{*assetPath}" ); swagger_0 0 1

Regards

Krikroff77 avatar Nov 02 '15 23:11 Krikroff77

I have the same problem, any ideas?

Jcomper avatar Jul 13 '16 06:07 Jcomper

Same problem here.

eavonius avatar Jul 18 '16 23:07 eavonius

Same problem in 5.3.2

deepumi avatar Jul 27 '16 16:07 deepumi

Seeing the same behavior.

BeerDiet avatar Aug 01 '16 15:08 BeerDiet

In the example above -

http://localhost:9000/api-docs/v1/swagger

Is the application actually hosted in an IIS Virtual Directory (or self-hosted equivalent) called "api-docs" ? The "BASE URL" that shows up on Swagger is mapped to the "basePath" property of the swagger document, which in turn is set up like this:

            var swaggerDoc = new SwaggerDocument
            {
               ...
                basePath = (rootUri.AbsolutePath != "/") ? rootUri.AbsolutePath : null,
              ...
            };

If it isn't hosted in a Virtual Directory that resides within the application root, then that AbsolutePath property is going to be null - hence the Base URL that you see is also going to be empty. Might be worth taking a look at..

EDIT: typo.

shashinh avatar Aug 01 '16 16:08 shashinh

Still seeing this in 5.4.0, my application is hosted in IIS I have this in my EnableSwagger section of SwaggerConfig c.RootUrl(j=> System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/MyApi") .AppSettings.Settings["baseUrl"].Value);

ChrisBDFA avatar Sep 12 '16 16:09 ChrisBDFA

Hello :) Same problem in 5.4.0

rafastellato avatar Oct 31 '16 14:10 rafastellato

@domaindrivendev Can I ping you to take a look at this? This thing was pre-installed with a Visual Studio template. I hit F5 and I see a blank URL on IIS. Same thing when published to Azure. It looks like the screenshot posted by @Krikroff77.

chadwackerman avatar Nov 29 '16 03:11 chadwackerman

I also am encountering this issue.

Workaround CSS?

div.footer { display:none; }

jsblock78 avatar Dec 29 '16 15:12 jsblock78

@domaindrivendev Same issue here, running from an Owin server in a desktop application.

jv42 avatar Mar 08 '17 16:03 jv42

Has this been resolved yet? I am having same issue, ideally it should be version specific so it shows different urls when selecting different version.

utsxumiao avatar Jun 13 '17 04:06 utsxumiao

Not for me . :-(

BabakGoshtasbi avatar Jun 13 '17 18:06 BabakGoshtasbi

Also having this same issue.

zerosnap avatar Sep 13 '17 19:09 zerosnap

My RootUrl is working as expected, however the URL shown in the "Curl" and "Request URL" areas does not contain the base.

jpdillingham avatar Sep 19 '17 23:09 jpdillingham

If I add: using System.Net.Http; in top of Swaggerconfig.cs and replace: c.RootUrl(req => GetRootUrlFromAppConfig()); with: c.RootUrl(req => req.RequestUri.GetLeftPart(UriPartial.Authority).TrimEnd('/') + req.GetRequestContext().VirtualPathRoot.TrimStart('/')); it works with Swashbuckle v.5.6.0.

Roesler avatar Oct 04 '17 14:10 Roesler

Having the same issue on v5.6.0. My application is hosted in IIS.

nilaybhima avatar Mar 11 '18 22:03 nilaybhima

I'm having the same issue. Swashbuckle v5.6.0. App is hosted in IIS. Nothing too fancy.

Specifying c.RootUrl(req => GetRootUrlFromAppConfig()); has no effect.

syntax-e avatar Feb 11 '19 22:02 syntax-e

app.UseSwagger(c => { c.PreSerializeFilters.Add((swaggerDoc, httpReq) => { swaggerDoc.Host = httpReq.Host.Value; swaggerDoc.Schemes = new List() { httpReq.Scheme }; swaggerDoc.BasePath = httpReq.PathBase; }); });

If any one using Dot Net Core

kambleaa007 avatar Aug 29 '19 13:08 kambleaa007